Commit graph

1714 commits

Author SHA1 Message Date
InvalidUsernameException
ce2c4a3417 LibGfx+LibWeb: Fix compile errors in clang-cl from recent header cleanup
The recent commits 28ba610f32 and
70c4ed261f adjusted some include
directives to avoid excessive recompilation when changing some header
files. This has broken compilation with clang-cl on Windows without
getting noticed before the PRs were merged.
2025-11-30 08:45:29 -05:00
InvalidUsernameException
28ba610f32 Everywhere: Avoid large rebuilds when editing (Immutable)Bitmap headers
This reduces the number of recompiled files as follow:
- Bitmap.h: 1309 -> 101
- ImmutableBitmap.h: 1218 -> 75
2025-11-28 18:32:48 +01:00
Callum Law
63538c8a75 LibWeb: Prefer transitioned property values over important
CSS transitions have a higher precedence in the cascade than important
properties
2025-11-28 16:15:49 +00:00
Callum Law
9afb523be3 LibWeb: Remove unnecessary parse_list_of_time_values function
We can achieve the same thing by using
`parse_simple_comma_separated_value_list`
2025-11-28 16:15:49 +00:00
Callum Law
b0ab94c00c LibWeb: Allow multiple values for transition-behavior 2025-11-28 16:15:49 +00:00
Callum Law
70c4ed261f LibWeb: Reduce the number of headers CSS Parser.h is included in
Reduces the rebuild required when editing this file
2025-11-28 16:15:49 +00:00
Callum Law
8a197b7ee5 LibWeb: Produce correct resolved value for animation-duration 2025-11-28 13:24:11 +00:00
Callum Law
c8d91c127e LibWeb: Parse view() for the animation-timeline CSS property 2025-11-28 13:24:11 +00:00
Callum Law
7d70714eac LibWeb: Parse scroll() for the animation-timeline CSS property 2025-11-28 13:24:11 +00:00
Callum Law
5bbcd0a48f LibWeb: Parse the animation-timeline CSS property 2025-11-28 13:24:11 +00:00
Callum Law
d79aba68d2 LibWeb: Allow reset-only longhands in coordinating value list shorthands
Required for `animation-timeline` and the various `animation-trigger-*`
properties within the `animation` coordinating value list
2025-11-28 13:24:11 +00:00
Callum Law
6bb7224f4e LibWeb: Parse the view-timeline shorthand CSS property
The remaining failing tests in view-timeline-shorthand.html are due to
either:
 a) incorrect tests, see web-platform-tests/wpt#56181 or;
 b) a wider issue where we collapse coordinating value list longhand
properties to a single value when we shouldn't.
2025-11-28 13:24:11 +00:00
Callum Law
e093c76eea LibWeb: Parse the view-timeline-inset CSS property 2025-11-28 13:24:11 +00:00
Callum Law
21ff35691a LibWeb: Parse the view-timeline-axis CSS property 2025-11-28 13:24:11 +00:00
Callum Law
d9d3e66197 LibWeb: Parse the view-timeline-name CSS property 2025-11-28 13:24:11 +00:00
Callum Law
13ce2d1857 LibWeb: Parse the scroll-timeline shorthand CSS property
The remaining failing tests in scroll-timeline-shorthand.html are due to
either:
 a) incorrect tests, see web-platform-tests/wpt#56181 or;
 b) a wider issue where we collapse coordinating value list longhand
properties to a single value when we shouldn't.
2025-11-28 13:24:11 +00:00
Callum Law
992b0a4dc6 LibWeb: Parse the scroll-timeline-axis CSS property 2025-11-28 13:24:11 +00:00
Callum Law
e95f326f3d LibWeb: Parse the scroll-timeline-name CSS property 2025-11-28 13:24:11 +00:00
Callum Law
826e947920 LibWeb: Propagate 'auto' value of animation-duration
Avoids a crash when `animation-duration` was `auto`
2025-11-28 13:24:11 +00:00
Timothy Flynn
3dce6766a3 LibWeb: Extract some CORS and MIME Fetch helpers to their own files
An upcoming commit will migrate the contents of Headers.h/cpp to LibHTTP
for use outside of LibWeb. These CORS and MIME helpers depend on other
LibWeb facilities, however, so they cannot be moved.
2025-11-27 14:57:29 +01:00
Psychpsyo
693dd7b6f6 LibWeb: Avoid unnecessary sorting work when getting animations
This way, the list is not re-sorted on every recursive call.
2025-11-26 22:19:23 +01:00
Callum Law
46acdbd10a LibWeb: Avoid registering unnecessary transitions
Reduces time spent in `StyleComputer::compute_properties` when loading
https://en.wikipedia.org/wiki/2023_in_American_television from ~37% to
~13%
2025-11-23 09:43:24 +01:00
Callum Law
67a3d0f1aa LibWeb: Consider cancelled (idle) transitions as "completed" 2025-11-23 09:43:24 +01:00
Callum Law
b2b889e1da LibWeb: Ensure registered transitions are reflective of properties
Previously we would only update these if:
a) We had a cascaded value for `transition-property`
b) The source of that cascaded value had changed since we last
   registered transitions

This meant that there were a lot of changes we didn't apply:
 - Changes exclusively to properties other than `transition-property`
   (e.g. `transition-duration`, `transition-behavior`, etc)
 - Removing the `transition-property` property
 - Updating the `transition-property` property in a way that didn't
   change it's source (e.g. setting it within inline-style)

Unfortunately this does mean that we now register transitions for all
properties on most elements since "all" is the initial value for
"transition-property" which isn't great for performance, but that can be
looked at in later commits.
2025-11-23 09:43:24 +01:00
Callum Law
46abc0e8e2 LibWeb: Handle calc in multi-argument rotate property interpolation
Previously we assumed the angle would always be an `AngleStyleValue` but
it can also be a `CalculatedStyleValue`

Fixes #6870
2025-11-23 09:43:24 +01:00
Callum Law
025274cd86 LibWeb: Don't deassociate animations when deregistering transitions
Also renames the `clear_transitions` function to clarify this doesn't
affect the associated transition animations.

This fixes an issue where transitions weren't being cancelled when the
relevant transition-property entry was no longer present
2025-11-23 09:43:24 +01:00
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
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
Callum Law
408bbead31 LibWeb: Don't mangle inherited properties when updating animated style 2025-11-21 09:24:53 +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
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
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
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
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
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
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
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
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
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
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