Commit graph

5856 commits

Author SHA1 Message Date
Callum Law
b262902b02 LibWeb: Add Angle::from_style_value
This method takes a `AngleStyleValue`, `PercentageStyleValue` or
fully-simplified `CalculatedStyleValue` with a numeric type of angle, as
well as a percentage basis and produces the equivalent `Angle` value.

This saves us having to reimplement this logic in multiple places
2025-11-23 09:43:24 +01:00
Callum Law
2f0cd9f739 LibWeb: Add Time::from_style_value
This method takes a `TimeStyleValue`, `PercentageStyleValue` or
fully-simplified `CalculatedStyleValue` with a numeric type of time, as
well as a percentage basis and produces the equivalent `Time` value.

This saves us having to reimplement this logic in multiple places
2025-11-23 09:43:24 +01:00
Jelle Raaijmakers
b3c186ce64 LibWeb: Add spec steps to prescan a byte stream algorithm
Fix up the implementation as we go. Also change `ByteBuffer const&` into
`ReadonlyBytes` everywhere, so we don't accidentally copy bytes.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
f52632d48a LibWeb: Skip right amount of characters during encoding detection
When detecting an element's opening tag, the spec asks us to skip ahead
to the first whitespace or end chevron character before trying to read
attributes. Instead, we were always skipping 2 positions ahead and then
ignoring all whitespace characters and slashes, which was clearly wrong.

Theoretically this could have caused some weird behaviors if part of the
opening tag matched an expected attribute name, but it's very unlikely
to see that in the wild.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
4bcf988e46 LibWeb: Use FlyString attribute name comparisons in encoding detection
Prevent some unnecessary work by performing pointer comparisons.
2025-11-21 17:43:08 +01:00
Jelle Raaijmakers
4ebbbdfef1 LibWeb: Advance position at attribute end quote in encoding detection
This did not cause any immediate issues except generating instances of
`Attr` with useless values which caused some unnecessary work during
encoding detection.
2025-11-21 17:43:08 +01:00
Sam Atkins
e691f0e10f LibWeb/DOM: Stop adding duplicates to the agent's signal_slots
We use a Vector for this, but its spec definition is an ordered set.
That means we need to ensure we don't add duplicates. This fixes issues
where we would send slotchange events multiple times to the same
HTMLSlotElement.
2025-11-21 16:19:57 +01:00
Sam Atkins
6e17503423 LibWeb: Add and remove MutationObservers at specified times
In the current spec, MutationObservers are explicitly added to the
pending mutation observers list, and they are removed when that list is
cleared in the "notify mutation observers" microtask.

This solves some issues with slotchange events.

As noted, we delay actually emptying the list of pending mutation
observers until after we're finished with the "clone", because we can't
actually copy or move the intrusive list. As far as I am aware, this
should not affect behaviour because only one microtask can run at once.
2025-11-21 16:19:57 +01:00
Psychpsyo
2db3796fd3 LibWeb: Implement CSS perspective-origin 2025-11-21 11:14:28 +00:00
Psychpsyo
27e4793c5d LibWeb: Make ObjectPosition more reusable 2025-11-21 11:14:28 +00:00
Psychpsyo
ada3810779 LibWeb: Rename transform_box_rect() to transform_reference_box()
This is closer to its name in the spec.
2025-11-21 11:14:28 +00:00
Sam Atkins
9a1352fc17 LibWeb/CSS: Support calculated angles in conic-gradient() 2025-11-21 11:36:28 +01:00
Estefania
8f15565967 LibWeb: Add stub implementation for Navigator.getBattery()
Adds a stub that returns a cached rejected promise with a
not yet implemented error. This converts
battery-status/battery-promise-window.https.html from timeout
to pass. Full implementation still needed.
2025-11-21 10:53:01 +01:00
Callum Law
408bbead31 LibWeb: Don't mangle inherited properties when updating animated style 2025-11-21 09:24:53 +01:00
Aliaksandr Kalenik
2a18b6b802 LibWeb: Prevent default on pointerdown/mousedown should skip focus steps
Fixes a bug in the ChatGPT model dropdown where clicking it immediately
closes the menu because focus is being stolen.
2025-11-21 08:30:32 +01:00
Jelle Raaijmakers
2c5beeabe3 LibWeb: Improve support for SVG text positioning attributes
Previously, we only supported very basic numbers and a single level of
text positioning support in the `x`, `y`, `dx` and `dy` attributes in
`<text>` and `<tspan>` SVG elements.

This improves our support for them in the following ways:

  * Any `length-percentage` or `number` type value is accepted;
  * Nested `<text>` and `<tspan>` use the 'current text position'
    concept to determine where the next text run should go;
  * We expose the attributes' values through the API.

Though we still do not support:

  * Applying the `rotate` attribute;
  * Applying transformations on a per-character basis.
  * Proper horizontal and vertical glyph advancing (we just use the path
    bounding box for now).
2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
527a293047 LibWeb: Implement SVGAnimatedLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
797e6dd4eb LibWeb: Implement SVGLengthList 2025-11-20 23:15:24 +01:00
Jelle Raaijmakers
832e953c67 LibWeb: Use is_ascii_digit() in SVG attribute parsing 2025-11-20 23:15:24 +01:00
Hendiadyoin1
bcd01da91d AK: Use Deducing this for OptionalBase
This is taken from and akin to
https://github.com/SerenityOS/serenity/pull/25894
2025-11-20 16:27:07 +01:00
Sam Atkins
fd4888e800 LibWeb/Layout: Honor hanging and each-line in text-indent 2025-11-20 16:02:40 +01:00
Sam Atkins
c4b9e7eadf LibWeb: Parse and propagate extended text-indent property values
CSS Text 3 gives `text-indent` a couple of optional keywords to control
which lines are affected. This commit parses them, but doesn't yet do
anything with them.
2025-11-20 16:02:40 +01:00
Aliaksandr Kalenik
0eb28a1a54 LibWeb: Delete unused BufferPolicy from fetch Request
This is no longer needed since all requests are unbuffered.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
16b0f1e6c2 LibWeb: Delete unused ResourceLoader::load()
...and rename `load_unbuffered()` to `load()`.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
3058274386 LibWeb: Use unbuffered network requests for all Fetch requests
Previously, unbuffered requests were only available as a special mode
for EventSource. With this change, they are enabled by default, which
means chunks can be read from the stream as soon as they arrive.

This unlocks some interesting possibilities, such as starting to parse
HTML documents before the entire response has been received (that, in
turn, allows us to initiate subresource fetches earlier or begin
executing scripts sooner), or start rendering videos before they are
fully downloaded.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
f942fef39b LibWeb: Allow microtasks to run if document has been destroyed
187f8c54 made `HTML::Task` runnable for destroyed documents, and this
change aligns microtask behavior with that. This is required for an
upcoming change that switches Fetch to be unbuffered by default. During
navigation, fetching the new document is initiated by the previous
document, which means we need to allow microtasks created in the
previous document's realm to run even after that document has been
destroyed.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
cce5197f90 LibWeb: Implement :resource support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
1f4b53d9fc LibWeb: Implement :about protocol support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
2fd7b70784 LibWeb: Implement file: protocol support for load_unbuffered()
Preparation work before enabling unbuffered fetching by default.
2025-11-20 06:29:13 -05:00
Aliaksandr Kalenik
fa46efae48 LibWeb: Exit process_stylesheet_resource if document isn't fully active
This change is required to fix crashing in `link-re-enable-crash.html`
that is going to be introduced by switching to unbuffered fetching.
2025-11-20 06:29:13 -05:00
Sam Atkins
29666e1d83 LibWeb/DOM: Invalidate children with relative font-weight/font-size
`font-weight` and `font-size` both can have keywords that are relative
to their inherited value, and so need recomputing when that changes.

Fixes all but one subtest in font-weight-computed.html, because that
remaining one uses container-query units. No font-size tests seem to be
affected: font-size-computed.html doesn't update the parent element's
`font-size` so this invalidation bug didn't apply.
2025-11-20 12:22:03 +01:00
Timothy Flynn
813986237e LibWeb: Add some tests that exercise the HTTP disk cache
Our HTTP disk cache is currently manually tested against various sites.
This patch adds some tests to cover various scenarios, including non-
cacheable responses, expired responses, and revalidation.

In order to ensure we hit the disk cache in RequestServer, we must
disable the in-memory cache in WebContent.
2025-11-20 09:33:49 +01:00
Sam Atkins
44326c4d7f LibWeb/CSS: Define value ranges for grid properties
Grid track sizes cannot be negative.
2025-11-19 23:45:52 +00:00
Sam Atkins
7de17dce9d LibWeb/CSS: Absolutize grid-related StyleValues 2025-11-19 23:45:52 +00:00
Aliaksandr Kalenik
597fe8288c LibWeb: Apply own clip rect for background phase only when clip used
Fixes a bug where we would clip `box-shadow` when `overflow: hidden`
was set, which is not supposed to happen since `overflow` only affects
clipping of an element's content.
2025-11-19 18:17:42 +01:00
Aliaksandr Kalenik
e816a92dfe LibWeb: Move clip_frames from public to private in ViewportPaintable 2025-11-19 18:17:42 +01:00
Luke Wilde
47b512ec56 LibWeb/WebAudio: Fire complete event with OfflineAudioCompletionEvent 2025-11-19 17:26:09 +01:00
Psychpsyo
556699d601 LibWeb: Prevent view transition crashes due to lack of execution context 2025-11-19 10:58:29 -05:00
Jelle Raaijmakers
674e1a5c47 LibWeb: Support transitions between 3D and non-derivative 2D functions
If either of the two transform functions during interpolation is a 3D
function, both of them get coerced to a 3D function before deciding what
to do next. However, we only supported converting 2D functions to 3D if
they had a 2D primitive they could be converted to first.

Change our behavior to default to converting to matrix3d() if there is
no explicit conversion path. Fixes a crash in
`css/css-transforms/animation/transform-interpolation-004.html`.
2025-11-19 10:08:11 +01:00
Sam Atkins
7d2f631d4c LibWeb/CSS: Handle whitespace better in font-language-override strings
The rules for strings here are:
- 4 ASCII characters long
- Shorter ones are right-padded with spaces before use
- Trailing whitespace is always removed when serializing

We previously always padded them during parsing, which was incorrect.
This commit flips it around so we trim trailing whitespace when parsing.

We don't yet actually use this property's value for anything. Once we do
so, maybe we'll care more about them being stored as 4 characters
always, but for now this avoids us needing a special step during
computation.
2025-11-18 17:22:03 +01:00
Jelle Raaijmakers
61f9b324c7 LibWeb: Always serialize CSSScale with at least two values 2025-11-18 14:44:49 +00:00
Jelle Raaijmakers
3083b19b09 LibWeb: Show bounding_rect in PushStackingContext dump 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
740629a3a8 LibWeb: Pass reference to bounding rect for Skia paint style 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
ba40da5e5f LibWeb: Rename DisplayList's apply_filters to apply_filter 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
d7ebc4eef4 LibWeb: Remove PaintableBox const_casts from ViewportPaintable
They're not necessary here - no functional changes.
2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
9547889a6b LibWeb: Remove unused include from StackingContext 2025-11-18 15:10:58 +01:00
Jelle Raaijmakers
871f121c75 Everywhere: Validate // NOTE: ... and // NB: ... comments 2025-11-18 09:07:37 -05:00
Jelle Raaijmakers
41eb7251e4 LibWeb: Convert Ladybird notes in spec steps to // NB: ...
We have a couple of ways to designate spec notes and (our) developer
notes in comments, but we never really settled on a single approach. As
a result, we have a bit of a mixed bag of note comments on our hands.

To the extent that I could find them, I changed developer notes to
`// NB: ...` and changed spec notes to `// NOTE: ...`. The rationale for
this is that in most web specs, notes are prefixed by `NOTE: ...` so
this makes it easier to copy paste verbatim. The choice for `NB: ...` is
pretty arbitrary, but it makes it stand out from the regular spec notes
and it was already in wide use in our codebase.
2025-11-18 09:07:37 -05:00
Jelle Raaijmakers
9394c9a10b LibWeb: Deduplicate transformation creation logic
We had two code blocks responsible for turning a
TransformationStyleValue into a Transformation; get rid of one.
2025-11-18 14:36:26 +01:00
Jelle Raaijmakers
15fa6676b0 LibWeb: Simplify generation of perspective() matrix transform
A value of `perspective(none)` should result in the identity matrix. But
instead of creating that identity matrix explicitly, just break and
default to the identity matrix at the bottom of this method.
2025-11-18 14:36:26 +01:00