Commit Graph

1824 Commits

Author SHA1 Message Date
Tim Ledbetter
1d2e4e4273 LibWeb: Use StringBuilder when serializing basic grid types 2026-01-09 10:00:58 +01:00
Tim Ledbetter
17ee0e3a19 LibWeb: Use StringBuilder when serializing more CSS types 2026-01-09 10:00:58 +01:00
Tim Ledbetter
d28d04f78e LibWeb: Make InterpolationMethod serialization take a StringBuilder 2026-01-09 10:00:58 +01:00
Tim Ledbetter
b4cf7e8060 LibWeb: Avoid String allocations in easing values serialization methods 2026-01-09 10:00:58 +01:00
Tim Ledbetter
0d7f2b8cba LibWeb: Avoid String allocations in BasicShape serialization methods 2026-01-09 10:00:58 +01:00
Tim Ledbetter
a27d269721 LibWeb: Pass StringBuilder around during StyleValue serialization
Previously, some StyleValues created a large number of intermediate
strings during serialization. Passing a StringBUilder into the
serialization function allows us to avoid a large number of these
unnecessary allocations.
2026-01-09 10:00:58 +01:00
Jelle Raaijmakers
ae20ecf857 AK+Everywhere: Add Vector::contains(predicate) and use it
No functional changes.
2026-01-08 15:27:30 +00:00
Callum Law
2ba1141e3c LibWeb: Don't round when absolutizing lengths
Lengths should be rounded at use-time rather than compute-time

Also removes an unnecessary if statement which was always true
2026-01-08 10:51:35 +01:00
Callum Law
09799e794e LibWeb: Update Length::absolutize() to take a ResolutionContext
All callers are passing individual values from a `ResolutionContext`
anyway so we may as well do it in a single place.
2026-01-08 10:51:35 +01:00
Callum Law
30c6f45702 LibWeb: Remove unused Length::absolutized() 2026-01-08 10:51:35 +01:00
Andreas Kling
a9cc425cde LibJS+LibWeb: Add missing GC marking visits
This adds visit_edges(Cell::Visitor&) methods to various helper structs
that contain GC pointers, and makes sure they are called from owning
GC-heap-allocated objects as needed.

These were found by our Clang plugin after expanding its capabilities.
The added rules will be enforced by CI going forward.
2026-01-07 12:48:58 +01:00
Callum Law
388616b315 LibWeb: More efficiently pack ComputedValues struct
This reduces the size of `ComputedValues` from 3240 bytes to 3064 bytes
2026-01-06 20:32:14 +01:00
Aliaksandr Kalenik
d7fb5ba35f LibWeb: Use value-comparing RefPtr in ColorStopListElement
The color stop members were RefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same gradient
color values were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
b6da3aaa3f LibWeb: Use value-comparing RefPtr in CursorStyleValue
The x and y members were RefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same values
were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
9cd583ff6e LibWeb: Use value-comparing RefPtr in TextIndentStyleValue
The member type was NonnullRefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same values
were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Aliaksandr Kalenik
fee49c3837 LibWeb: Use value-comparing RefPtr in ScrollbarColorStyleValue
The member types were NonnullRefPtr which compares by pointer identity.
This caused false positives in style invalidation when the same color
values were recomputed as different objects.
2026-01-06 13:23:00 +00:00
Tim Ledbetter
e4fb4d7c1a LibWeb: Extract animation-composition value from keyframe at-rules
Previously, we weren't respecting the value of this property, so the
composite operation always defaulted to
`AnimationComposition::Replace`.
2026-01-06 12:58:54 +01:00
Tim Ledbetter
2ff77589df LibWeb: Add FontFaceSetLoadEvent 2026-01-06 12:24:42 +01:00
Tim Ledbetter
581d6ce6e7 LibWeb: Mark font status promise as handled when rejecting it 2026-01-06 12:24:42 +01:00
Tim Ledbetter
3ec53f5a3f LibWeb: Clamp filter function values to valid range when interpolating 2026-01-06 12:13:13 +01:00
Tim Ledbetter
5de5e7522b LibWeb: Implement interpolation of drop-shadow() filter functions 2026-01-06 12:13:13 +01:00
Tim Ledbetter
584e0996c9 LibWeb: Store color as a StyleValue in FilterOperation::DropShadow 2026-01-06 12:13:13 +01:00
Callum Law
72a00a17cc LibWeb: Omit nonzero fill rule when serializing polygon()
Gains us ~160 WPT passes
2026-01-06 10:49:51 +00:00
Callum Law
ed8eab03d0 LibWeb: Support interpolation of BorderRadiusRectStyleValue 2026-01-06 10:50:06 +01:00
Callum Law
4f5bab7e5d LibWeb: Support border radius in xywh() function 2026-01-06 10:50:06 +01:00
Callum Law
02a8d22a4e LibWeb: Support border radius in rect() function 2026-01-06 10:50:06 +01:00
Callum Law
1b7567cc86 LibWeb: Support parsing of border radius in inset() function
Respecting this value during basic shape path resolution is yet to be
implemented
2026-01-06 10:50:06 +01:00
Callum Law
84c6fd5730 LibWeb: Make parsing of border-radius value reusable
This is also useful for `<basic-shape-rect>`
2026-01-06 10:50:06 +01:00
Callum Law
cb1425877a LibWeb: Serialize inset() arguments as positional value list 2026-01-06 10:50:06 +01:00
Callum Law
00af50d49e LibWeb: Make serialization of positional value list reusable
This is useful for more than just shorthands (e.g. it is also useful for
the arguments of the `inset()` function)
2026-01-06 10:50:06 +01:00
Tim Ledbetter
3fd4eb56ee LibWeb: Implement FontFaceSet.clear() 2026-01-05 16:15:58 +00:00
Tim Ledbetter
6e0bdd79e4 LibWeb: Mark FontFace as CSS-disconnected when font-face rule is removed 2026-01-05 16:15:58 +00:00
Tim Ledbetter
7b8099bb89 LibWeb: Disconnect and replace FontFace on @font-face src change 2026-01-05 16:15:58 +00:00
Tim Ledbetter
dab22f770d LibWeb: Add a corresponding FontFace object for a parsed @font-face rule 2026-01-05 16:15:58 +00:00
Tim Ledbetter
2a8db3b1f9 LibWeb: Propagate FontFace changes to CSSFontFaceRule 2026-01-05 16:15:58 +00:00
Callum Law
96a4e33eaf LibWeb: Resolve circle()/ellipse() position keywords at parse time 2026-01-05 11:42:19 +00:00
Callum Law
41b2496d3e LibWeb: Clamp <radial-size> calculated length percentages
The spec requires `<radial-size>` to be non-negative
2026-01-05 11:42:19 +00:00
Callum Law
2e66203ede LibWeb: Add early return from ComputedProperties::animations()
If all the values of `animation-name` are `none` we can exit early and
save a bunch of work.

Reduces time spent in this function from 1.23% to 0.01% when loading
https://en.wikipedia.org/wiki/2023_in_American_television
2026-01-05 11:35:26 +00:00
Callum Law
79740b04b3 LibWeb: Don't generate layer for background-image none entry
Reduces the time spent in `background_layers()` from 1.5% to 0.04% when
loading https://en.wikipedia.org/wiki/2023_in_American_television
2026-01-05 11:35:26 +00:00
Callum Law
1708ce2e2b LibWeb: Propagate background-clip value for color layer separately
This is required for an optimization in a later commit
2026-01-05 11:35:26 +00:00
Callum Law
558f034007 LibWeb: Consolidate transition computation
Previously the logic to compute transitions was split across
`ComputedProperties`, `StyleComputer`, and `Animatable` - this commit
consolidates it all in `ComputedProperties`
2026-01-05 11:35:26 +00:00
Aliaksandr Kalenik
3353ec9663 LibWeb: Add result caching for :has() pseudo-class matching
The `:has()` pseudo-class requires traversing descendants (or siblings)
to find matches.

With this change we cache results keyed by `(Selector*, Element*)`
pairs. The cache is stored in `StyleComputer` and cleared at the start
of each style computation pass in `Document::update_style()`.

When `:has()` uses a descendant combinator and we find a match, we also
cache that all ancestors between the matching descendant and the
anchor match. For example with `div:has(.target)`:

```html
<div id="A">  <!-- checking :has(.target) here -->
  <div id="B">
    <div id="C">
      <span class="target"/>
    </div>
  </div>
</div>
```

When we find `.target` while checking `div#A`, we also cache that
`div#B` and `div#C` match `:has(.target)` since they also contain
`.target`. Later when styling these elements, we get cache hits and skip
traversal.
2026-01-04 19:36:40 +01:00
Callum Law
64010c78ab LibWeb: Store ColorStopListElement::transition_hint as a RefPtr
There's no need for us to wrap this in an optional struct.
2026-01-03 02:30:59 +01:00
matjojo
9314cc3a30 LibWeb: Absolutize transition hint in ColorStopListElement 2026-01-02 21:48:31 +01:00
Callum Law
acc8b90549 LibWeb: Improve gradient position serialization
`EdgeStyleValues` which consist of an offset of a `calc()`s which
resolves to 50% should be considered "centered" for
`SerializationMode::ResolvedValue` for the purpose of omitting the
position value from gradient serialization.
2026-01-02 11:43:10 +01:00
Callum Law
6964593377 LibWeb: Add absolutized method to EdgeStyleValue
Fixes #7192.

We absolutize `EdgeStyleValue` to always be relative to the top/left
edge which allows for some simplification.
2026-01-02 11:43:10 +01:00
Callum Law
727058dfcd LibWeb: Add absolutized method to PositionStyleValue
This is a non-functional change for now since it's descendent
`EdgeStyleValue`s don't yet have their corresponding `absolutized`
method
2026-01-02 11:43:10 +01:00
Callum Law
e6ddb7db9e LibWeb: Store EdgeStyleValue sub-values directly
As well as being required to implement absolutization this also means we
now bypass a limitation with `LengthPercentage` where we would always
use `SerializationMode::Normal` for the constituent lengths which gains
us some WPT passes
2026-01-02 11:43:10 +01:00
Callum Law
6d12c94800 LibWeb: Simplify parsing of background-position-{x,y} 2026-01-02 11:43:10 +01:00
Gingeh
5c0e707f01 LibWeb: Don't crash when rounded background image is too large 2025-12-30 12:26:55 +01:00