Commit graph

72984 commits

Author SHA1 Message Date
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
8a02161481 Documentation: Standardize our spec note comment prefixes 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
Jelle Raaijmakers
e4dc2663ba LibWeb: Reimplement transform interpolation according to spec
We had a partial implementation of transformation function interpolation
that did not support numerical interpolation of simple functions (e.g.
`scale(0)` -> `scale(1)`). This refactors the interpolation to follow
the spec more closely.

Gains us 267 WPT subtest passes in `css/css-transforms`.

Fixes #6774.
2025-11-18 14:36:26 +01:00
Timothy Flynn
911ecf1450 AK: Avoid copying the iterable container in AK::enumerate
There are actually a couple of issues here:

1. We are not properly perfect-forwarding the iterable to the Enumerator
   member. We are using the class template as the constructor type, but
   we would actually have to do something like this to achieve perfect
   forwarding:

   template <typname Iter = Iterable>
   Enumerator(Iter&&)

2. The begin / end methods on Enumerator (although they return by const-
   ref) are making copies during for-each loops. The compiler basically
   generates this when we call enumerate:

   for (auto it = Enumerator::begin(); it != Enumerator::end(); ++it)

   The creation of `it` above actually creates a copy of the returned
   Enumerator instance.

To avoid all of this, let's create an intermediate structure to act as
the enumerated iterator. This structure does not hold the iterable and
thus is fine to copy. We can then let the compiler handle forwarding
the iterable to the Enumerator.

Cherry-picked from:
0edcd19615
2025-11-18 13:31:52 +01:00
Aliaksandr Kalenik
195a67ed80 LibWeb: Delete dead code from Node::append_child() 2025-11-17 23:59:27 +01:00
Rocco Corsi
5fb78ae455 LibJS: Correct completion_cell typo in GeneratorObject 2025-11-17 23:43:04 +01:00
Andreas Kling
04238d0f3f LibJS: Make AsyncGenerator and GeneratorObject factories infallible
These should never fail.
2025-11-17 23:42:51 +01:00
Andreas Kling
d8f5971ddf LibJS: Allow constructing generator from function with null "prototype"
Fixes 4 test262 tests and simplifies some upcoming stuff.
2025-11-17 23:42:51 +01:00
Tim Ledbetter
acce880359 Tests: Disable naturalWidth-naturalHeight-width-height.tentative.html
This test is currently failing fairly frequently on CI.
2025-11-17 18:49:21 +00:00
Sam Atkins
1ae4429f3b LibWeb/CSS: Stop inserting whitespace in TokenStream::dump_string()
Another one I missed before!
2025-11-17 19:11:48 +01:00
Sam Atkins
eaece1d12c LibWeb/CSS: Stop inserting whitespace when serializing SimpleBlocks
I missed this in #6646. It mostly affects debug logging, but it's nice
when logs reflect reality.
2025-11-17 19:11:48 +01:00
Lorenz A
5dbb857c40 Tests/LibWeb: Prevent flake with iframe loading in gamepad-iframe.html
If `sendMessageAndWait` sends a message before the iframe is setup and
listening we would wait indefinitely making the test timeout.
2025-11-17 17:21:31 +01:00
Zaggy1024
0664e9fbf5 Tests: Ensure that AudioDataProvider never outputs overlapping blocks 2025-11-17 16:51:18 +01:00
Zaggy1024
ae5e200dfc LibMedia: Move overlapping audio block correction to the data provider
This prevents PlaybackManager's seek while enabling an audio track from
causing the AudioMixingSink to push audio blocks forward unnecessarily.
Previously, the seek would cause the initial block or blocks to repeat
from the perspective of AudioMixingSink, so it would think that it
needs to shift the first block after the seek forward by a few samples.
By moving this to the AudioDataProvider, we can clear the last sample
index every time the decoder is flushed, ensuring that the block
shifting always makes sense.

By doing this in AudioMixingSink instead of the Decoder
implementations, we avoid having to duplicate this shifting logic
across multiple implementations.

This also fixes an issue where multiple audio blocks occupying the same
timestamp would be skipped while seeking, causing a significant break
in audio.
2025-11-17 16:51:18 +01:00
Zaggy1024
7e325d64f5 LibMedia: Use [from/to]_time_units in FFmpegDemuxer and AudioMixingSink 2025-11-17 16:51:18 +01:00
Zaggy1024
a1358fa970 AK+Tests: Add time units conversion functions to Duration
These take a numerator and denominator defining the unit in a fractions
of a second. Conversion is done in integers, meaning that these must
clamp when approaching numeric limits.
2025-11-17 16:51:18 +01:00
Callum Law
ec14948175 LibWeb: Handle calc percentages when interpolating scale function
Also clean up the corresponding handling in
TransformationStyleValue::to_transformation
2025-11-16 22:50:01 +01:00
Timothy Flynn
15e4deb831 LibJS: Remove "era" from Temporal's DateTimeFormat formatting options
This is an editorial change in the Temporal proposal. See:
0ecf157

The test added here would previously throw:

    TypeError: Unable to determine format for Temporal.PlainDate
2025-11-16 07:59:59 -05:00
Andreas Kling
a94335dc5d LibWeb: Block rendering while waiting for CSS @import downloads
The implementation here is a ad-hoc, but there's no clear spec for
exactly how to handle "critical subresources" blocking rendering.

For now, this is overly conservative but fixes ugly FOUC on some
websites like https://hey.com/
2025-11-16 09:14:18 +01:00
Tim Ledbetter
36c6079dbc LibWeb+LibGfx: Implement SVGFEMorphologyElement
This filter primitive is used to erode or dilate an image.
2025-11-15 16:08:53 +01:00
Andreas Kling
837d5fb7ea RequestServer: Add heuristic cacheability and freshness per RFC 9111
This commit extends is_cacheable() to allow storage of responses that
rely on heuristic cacheability, including status codes defined as
heuristically cacheable.

We implement heuristic freshness lifetime calculation based on the
Last-Modified header as guidance, and apply it when no explicit
expiration information is present.
2025-11-15 10:07:49 -05:00
Andreas Kling
880a7e6c2a RequestServer: Don't update Content-Length during cache revalidation
We were treating Content-Type as exempt from header updates during cache
revalidation and incorrectly allowing Content-Length to get overwritten
when handling an HTTP 304 response.

This caused cached entries to end up with a mismatched Content-Length
that described the validating response instead of the stored body.
2025-11-15 10:07:49 -05:00
Pavel Shliak
0311d40425 UI/AppKit: Fix tab overview toolbar identifier typo 2025-11-15 08:13:11 -05:00
Tim Ledbetter
fdd3975104 LibWeb: Don't run update_the_image_data() algorithm if already started
This ensures that events are not fired if the image source is updated
while it is being fetched.
2025-11-15 12:39:37 +01:00
Andreas Kling
66263f142b LibWeb: Add StyleScope to keep style caches per Document/ShadowRoot
Before this change, we've been maintaining various StyleComputer caches
at the document level.

This made sense for old-school documents without shadow trees, since
all the style information was document-wide anyway. However, documents
with many shadow trees ended up suffering since any time you mutated
a style sheet inside a shadow tree, *all* style caches for the entire
document would get invalidated.

This was particularly expensive on Reddit, which has tons of shadow
trees with their own style elements. Every time we'd create one of their
custom elements, we'd invalidate the document-level "rule cache" and
have to rebuild it, taking about ~60ms each time (ouch).

This commit introduces a new object called StyleScope.

Every Document and ShadowRoot has its own StyleScope. Rule caches etc
are moved from StyleComputer to StyleScope.

Rule cache invalidation now happens at StyleScope level. As an example,
rule cache rebuilds now take ~1ms on Reddit instead of ~60ms.

This is largely a mechanical change, moving things around, but there's
one key detail to be aware of: due to the :host selector, which works
across the shadow DOM boundary and reaches from inside a shadow tree out
into the light tree, there are various places where we have to check
both the shadow tree's StyleScope *and* the document-level StyleScope
in order to get all rules that may apply.
2025-11-14 22:05:33 +01:00
Aliaksandr Kalenik
70b5496ecd LibWeb: Account for box-sizing in max-content contribution [GFC]
Use `calculate_inner_height()` and `calculate_inner_width()`, which
account for box-sizing, to resolve the item's size in max-content
contribution calculations.
2025-11-14 16:24:30 +01:00
Tim Ledbetter
e3cdeada77 LibWeb: Add --headless=manual option to run until explicit exit
This headless mode will stay open until it is closed by manually or by
calling `window.close()`.
2025-11-14 08:58:18 -05:00
Aliaksandr Kalenik
57c925cfa9 LibWeb: Reset text-shadow if needed after paint-only properties update
Previously we would not propagate text-shadow changes when it's changed
from some value to none.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/6580
2025-11-14 12:49:36 +01:00
Timothy Flynn
c7e4a99219 LibJS: Handle negativity in Temporal's ApplyUnsignedRoundingMode
I don't fully understand the BigInt math here, as the computation for
d1 and d2 don't align with the spec due to BigInt logic. This was
discussed a bit in SerenityOS's Discord some years ago:

https://discord.com/channels/830522505605283862/851522357734408232/978786665306918932

But some new tests in test262 indicate that we need to handle negative
values here, instead of just throwing away the sign.
2025-11-14 06:32:49 -05:00
Sam Atkins
48854a8e74 LibWeb/CSS: Resolve calc percentages as lengths in basic-shape functions
Fixes a crash on https://www.lego.com/en-gb/product/game-boy-72046 :^)

The apparent regressions in clip-path-interpolation-xywh-rect.html are
because of false positives. Something about the test was causing it to
compare two wrong values that happened to be the same. Now one of the
values is correct, they don't match.
2025-11-14 09:55:09 +00:00
Sam Atkins
d98cc50736 LibWeb/MathML: Stop shadowing value local variable 2025-11-14 09:55:02 +00:00
Sam Atkins
e561749164 LibWeb/MathML: Parse mathcolor and mathbackground as <color>
The difference is that parsing as the `color` property's value also
allows the CSS-wide keywords, which we don't want here.

The added test cases make sure that those keywords are *not* valid:
- `color` should inherit its parent value of `orange`
- `background-color` doesn't inherit, so should be its initial value of
  `transparent`
2025-11-14 09:55:02 +00:00
Sam Atkins
2512a934d6 LibWeb/MathML: Combine mspace height and depth when both are valid 2025-11-14 09:55:02 +00:00
Sam Atkins
1dfdfa37ea LibWeb/MathML: Parse mathml attributes as <length>s
`HTML::parse_dimension_value()` doesn't parse units except for `%` for
percentages; it just ignores them and treats it as a number of pixels.
Now that we can parse `<length>` and pals directly, do that instead,
which makes non-px units work.
2025-11-14 09:55:02 +00:00
Sam Atkins
7aef3245ea LibWeb/CSS: Expose method for parsing a type of StyleValue
In a few places, user code wants to parse a `<color>` or `<length>` etc,
but we didn't have a way to do so, so they would do something
similar-ish instead, like parse the value of the `color` property.
Let's make that available instead.
2025-11-14 09:55:02 +00:00
Sam Atkins
fd559341e3 LibWeb/SVG: Parse mask attribute as the mask CSS property
We now have support for the various mask longhands so we no longer need
this hack.
2025-11-14 09:55:02 +00:00
Sam Atkins
d61791e6e8 LibWeb/SVG: Use adjust_computed_style() to change <symbol> display
...Instead of misusing the presentational hint mechanism.
2025-11-14 09:55:02 +00:00
mikiubo
88e19ebc11 LibWeb: Handle empty string namespaces in selector matching
Per the CSS Namespaces spec, an empty string declared in an
@namespace rule represents no namespace.

Fixes WPT:
- css/css-namespaces/prefix-002.xml
- css/css-namespaces/prefix-003.xml
2025-11-14 08:16:53 +00:00
Psychpsyo
6951ef4ee3 Meta: Validate proper formatting for FIXMEs and AD-HOCs 2025-11-13 15:56:04 +01:00
Psychpsyo
100f37995f Everywhere: Clean up AD-HOC and FIXME comments without colons 2025-11-13 15:56:04 +01:00
Psychpsyo
edccb92da7 LibWeb: Make CSSPerspective correctly clamp its input for toMatrix() 2025-11-13 15:47:00 +01:00
stelar7
684c543ddb LibWeb/IDB: Handle cursor iteration more correctly 2025-11-13 08:52:16 -05:00
Timothy Flynn
a8514a2c29 LibJS: Do not assume cyclic modules have a cycle root
This is a normative change in the ECMA-262 spec. See:
939b993
2025-11-13 14:05:18 +01:00
Timothy Flynn
1d4f431eb4 LibWeb: Add a crash test for re-importing throwing cyclic modules
There was a crash in JS::CyclicModule::evaluate due to a spec bug that
we worked around years ago (1dc9769f7d).

This bug has now been fixed in ECMA-262. This adds a regression crash
test to ensure we don't crash still after implementing that fix, as this
is really only reachable from an embedder.
2025-11-13 14:05:18 +01:00
Hendiadyoin1
39a2a854be AK: Ignore -Wfree-nonheap-object on RefCounted::unref
GCC 15 seems to raise a false positive here in some cases

(cherry picked from commit 129c3ec0df061930e58f6d15d2ee4ad3e7599aad)
2025-11-13 13:52:07 +01:00