Commit Graph

3588 Commits

Author SHA1 Message Date
Andrew Kaster
62a8c26b73 LibWeb: Remove unecessary dependence on Window from Geometry classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct Geometry classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
f0c5f77f99 LibWeb: Remove unecessary dependence on Window from HTML classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct HTML classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
a2ccb00e1d LibWeb: Remove unecessary dependence on Window from CSS classes
These classes only needed Window to get at its realm. Pass a realm
directly to construct CSS classes.
2022-10-01 21:05:32 +01:00
Andrew Kaster
8de7e49a56 LibWeb: Remove unecessary dependence on Window from DOM and WebIDL
These classes only needed Window to get at its realm. Pass a realm
directly to construct DOM and WebIDL classes.

This change importantly removes the guarantee that a Document will
always have a non-null Window object. Only Documents created by a
BrowsingContext will have a non-null Window object. Documents created by
for example, DocumentFragment, will not have a Window (soon).

This incremental commit leaves some workarounds in place to keep other
parts of the code building.
2022-10-01 21:05:32 +01:00
Andrew Kaster
c61a4f35dc LibWeb: Move Web prototypes and constructors to new Intrinsics object
This Intrinsics object hangs off of a new HostDefined struct that takes
the place of EnvironmentSettingsObject as the true [[HostDefined]] slot
on JS::Realm objects created by LibWeb.

This gets the intrinsics off of the GlobalObject, Window, similar to the
previous refactor of LibJS to move the intrinsics into the Realm's
[[Intrinics]] internal slot.

A side effect of this change is that we cannot fully initialize a Window
object until the [[HostDefined]] slot has been installed into the realm,
which happens with the creation of the WindowEnvironmentSettingsObject.

As such, any Window usage that has not been funned through a WindowESO
will not have any cached Web prototyped or constructors, and will not
have Window APIs available to javascript code. Currently this seems
limited to usage of Window in the CSS parser, but a subsequent commit
will clean those up to take Realm as well. However, this commit compiles
so let's cut it off here :^).
2022-10-01 21:05:32 +01:00
MacDue
240fb93cf1 LibWeb: Remove FIXME for double-position linear-gradient() color stops
I added these in #14977, but forgot to remove this FIXME.
2022-10-01 14:08:01 +02:00
Luke Wilde
dbe12662b8 LibWeb: Implement matrix3d transform function from css-transforms-2 2022-10-01 14:07:47 +02:00
Luke Wilde
0fdd924db2 LibWeb: Implement rotation transform functions from css-transforms-2 2022-10-01 14:07:47 +02:00
Luke Wilde
540c307009 LibWeb: Implement Element.insertAdjacentText 2022-10-01 14:06:40 +02:00
Luke Wilde
d540e2ec98 LibWeb: Implement Element.insertAdjacentElement 2022-10-01 14:06:40 +02:00
Luke Wilde
9662eec388 LibWeb: Apply :enabled pseudo class to only certain elements
I thought the spec listing out the elements again was an oversight, but
it isn't, as simply inverting "is_actually_disabled" makes :enabled
apply to every element.
2022-09-30 21:46:53 +02:00
Luke Wilde
2133b7d58a LibWeb: Implement :enabled and :disabled pseudo classes to spec
Previously we only considered an element disabled if it was an <input>
element with the disabled attribute, but there's way more elements that
apply with more nuanced disabled/enabled rules.
2022-09-30 18:05:48 +02:00
Luke Wilde
c85fcd442f LibWeb: Check all <fieldset> ancestors in FormAssociatedElement::enabled
A form associated element is disabled if _any_ <fieldset> ancestor in
the ancestor chain has the disabled attribute, not just the first one.
2022-09-30 18:05:48 +02:00
Andreas Kling
a0f3e2c9a2 LibWeb: Never claim that flex containers create a BFC
If a flex item is itself a flex container, we were previously lying when
asked if the item created a BFC. It creates an FFC, so stop lying about
this in FormattingContext::creates_block_formatting_context().
2022-09-29 20:10:12 +02:00
Andreas Kling
7c6e42c2d4 LibWeb: Fix bogus comparison when measuring if a float can fit
We were using `>=` instead of `>` when checking if a float with a given
width could fit in the available space. If the width was an exact match,
we rejected it! Oops :^)
2022-09-29 20:10:07 +02:00
Andreas Kling
b7f9387f69 LibWeb: Don't draw only-translated stacking contexts via bitmap
If the 2D transform in effect is just a simple translation, we don't
need to draw into a temporary bitmap and then transform it. We can
just translate the painter. :^)
2022-09-29 20:10:02 +02:00
Andreas Kling
e8a5233b94 LibWeb: Don't round fragment widths while accumulating in LineBuilder
By rounding the fragment widths, we sometimes inserted line breaks
prematurely, even though the fragment *would* fit.
2022-09-29 20:09:56 +02:00
Andreas Kling
d64a8c3d2a LibWeb: Resolve cross-axis flex item margins in the common case 2022-09-29 20:09:52 +02:00
Andreas Kling
9e4226f353 LibWeb: Create flex items for empty generated boxes
I couldn't find anything in the specs about this, but GMail uses
empty generated boxes (`::before` and `::after` with `content: ""`)
inside a flexbox container in order to vertically center things.

The flexbox spec tells us to not generate flex items for empty
*anonymous* boxes, so we continue not doing that, but generated boxes
(any pseudo-element box) now always produce a flex item. This probably
isn't perfect either, and we'll have to revisit it for stuff like
`::first-letter`.
2022-09-29 20:09:49 +02:00
Andreas Kling
7abb512a86 LibWeb: Make PercentageOr<T>::contains_percentage() handle more cases 2022-09-29 20:09:44 +02:00
Andreas Kling
df416bb822 LibWeb: Add AvailableSpace.cpp to CMakeLists.txt 2022-09-29 20:05:28 +02:00
Andreas Kling
e6eb8a9f06 LibWeb: Fix crash in get_response_mime_type()
We were creating a ref-counted HeaderList object on the stack,
which then crashed in ~RefCounted() on scope exit, since nobody had
adopted it.
2022-09-29 18:33:53 +02:00
Andreas Kling
8fa459f2d6 LibWeb: Add missing null checks in Layout::Node::set_needs_display()
Let's not assume the containing block has a paintable box just because
someone is calling set_needs_display(). It can just be a no-op in that
case, and nobody gets hurt.
2022-09-29 18:33:41 +02:00
Andreas Kling
385657a4bf LibWeb: Add a helper for calculating the stretch-fit width of a box 2022-09-29 18:33:41 +02:00
Andreas Kling
fce1c673c7 LibWeb: Add CSS::Size::to_string() and an AK::Formatter for it 2022-09-29 18:33:41 +02:00
Andreas Kling
fdc9dc5729 LibWeb: Don't force layout when scrolling to non-existent anchor
If we're asked to scroll to an anchor element that's not actually in the
document, we don't need to perform a layout.
2022-09-29 18:33:41 +02:00
Andreas Kling
f161e20e57 LibWeb: Make FormattingContext::run() take available space as input
Instead of formatting contexts flailing around to figure out from the
"inside" how much space is available on the "outside", we should
provide the amount of available space in both axes as an input to run().

This basically means that when something creates a nested formatting
context, the parent context is responsible for telling the nested context
how much space is available for layout. This information is provided
immediately when invoking run().

Note that this commit doesn't pass accurate values in all cases yet.
This first step just makes it build, and passes available values in some
cases where getting them was trivial.
2022-09-29 18:33:41 +02:00
Andreas Kling
6b2ce2ccc3 LibWeb: Add CSS::Size::make_px(float) convenience helper 2022-09-29 18:33:41 +02:00
networkException
9d1336a1c9 LibWeb: Rename an origin's protocol to origin scheme
This patch updates the naming of an origin's protocol to be called
scheme according to the specification.

See https://html.spec.whatwg.org/multipage/origin.html#concept-origin-scheme
2022-09-29 09:39:04 +01:00
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Sam Atkins
36c5dd78b1 LibWeb: Make Markdown images shrink-to-fit by default
This inserts some CSS and JS to make images in Markdown documents which
are wider than the viewport, become shrink-to-fit. Clicking on these
toggles them between shrink-to-fit and full size.

Anyone who displays Markdown documents using LibWeb gets this
functionality for free! That's Browser, Help, and Welcome's README
display.
2022-09-28 23:58:26 +01:00
Sam Atkins
28a591ce7b LibWeb: Use zoom cursor for CSS zoom-in/zoom-out cursors
Ideally we'd use a different one for each, but this is fine.
2022-09-28 23:58:26 +01:00
Sam Atkins
54be317fa9 LibWeb: Use TokenStreams when expanding unresolved CSS values
This fixes a bug where any whitespace inside the `var()` or `attr()`
functions would make the StyleComputer fail to resolve them.
2022-09-27 19:36:31 +02:00
Sam Atkins
ae64cffd3a LibWeb: Expose token counts from CSS TokenStream 2022-09-27 19:36:31 +02:00
Sam Atkins
8ce38fddd9 LibWeb: Move CSS TokenStream to its own file
This lets us use TokenStream in StyleComputer without every user of
StyleComputer pulling in the entire CSS Parser.
2022-09-27 19:36:31 +02:00
Nico Weber
bf6d5fce18 LibWeb: In MimeType serialization, put just one \ in front of each " 2022-09-27 15:47:54 +01:00
Linus Groh
0b52b883af LibWeb: Implement '5.5. Response class' from the Fetch API :^) 2022-09-27 14:56:17 +01:00
Linus Groh
9fb672e981 LibWeb: Implement '5.4. Request class' from the Fetch API :^) 2022-09-27 14:56:17 +01:00
Linus Groh
5ad6283331 LibWeb: Implement '5.3. Body mixin' from the Fetch API :^)
This will be used to share functionality between Request and Response.
2022-09-27 14:56:17 +01:00
Linus Groh
afe2563e2b LibWeb: Make HeaderList ref-counted
This is needed to eventually share a header list between a Request or
Response object's internal infra request/response and the object's
exposed Header object.
2022-09-27 14:56:17 +01:00
Linus Groh
2d57d47132 LibWeb: Make Fetch::Infrastructure::Request::m_method default to "GET"
ByteBuffer has an inline capacity of 32 bytes, so this isn't fallible
and can be done inline.
2022-09-27 14:56:17 +01:00
Linus Groh
924d7721f0 LibWeb: Stub out Fetch::Infrastructure::Body::fully_read_as_promise() 2022-09-27 14:56:17 +01:00
Linus Groh
a7164f2674 LibWeb: Stub out Fetch::Infrastructure::Body::clone() 2022-09-27 14:56:17 +01:00
Linus Groh
ef5e2eb794 LibWeb: Implement Fetch::Infrastructure::Response::clone() 2022-09-27 14:56:17 +01:00
Linus Groh
b5e8e9b30b LibWeb: Support ReadonlyBytes as argument for extract_body()
This now matches the spec's requirement of "a byte sequence or BodyInit
object object".
2022-09-27 14:56:17 +01:00
Linus Groh
426e32e5c0 LibWeb: Add WebIDL::ExceptionOr constructor for wrapped ValueType
This is copied from JS::ThrowCompletionOr and will allow using them
interchangeably with types wrapped by JS::Value such as JS::Object*.
2022-09-27 14:56:17 +01:00
Linus Groh
4461234898 LibWeb: Support plain (throw) JS::Completion in WebIDL::ExceptionOr
This makes it possible to propagate exceptions from a function that
returns JS::ThrowCompletionOr via TRY() in another function that returns
WebIDL::ExceptionOr.
2022-09-27 14:56:17 +01:00
Linus Groh
fd52119ca3 LibWeb: Add getters and setters for Fetch::Header's members 2022-09-27 14:56:17 +01:00
Linus Groh
dc6fb43d26 LibWeb: Add referrer policy to Fetch::Infrastructure::Request
The enum is in its own directory and namespace as there's a standalone
spec for it, that will later also house AOs.

- https://w3c.github.io/webappsec-referrer-policy/
- https://www.w3.org/TR/referrer-policy/
2022-09-27 14:56:17 +01:00
Linus Groh
a602a4c780 LibWeb: Heap-allocate returned Fetch::Infrastructure::{Request,Response}
A Request/Response instance should always be heap-allocated and have
clear ownership, so let's also wrap it in a NonnullOwnPtr instead of
putting them on the stack.
2022-09-27 14:56:17 +01:00