Commit graph

208 commits

Author SHA1 Message Date
Callum Law
44eaa7ad98 LibWeb: Avoid overwriting non-animated font-weight when computing font
Previously if we would overwrite the non-animated font-size with the
animated font-size if it was set.

Loses us 2 WPT tests but this is in line with other browsers
2025-09-19 10:06:33 +01:00
Callum Law
39484e2027 LibWeb: Store font-weight in ComputedProperties in computed form
We now also more closely follow the spec when computing values for
font-weight and we now:
 - Support relative lengths in `calc()`s
 - Properly clamp `calc()`s
 - Support relative keywords (e.g. lighter, bolder)
 - Respect that font-weight can be a non-integer number.

This does expose a few false positives in the font-weight-computed.html
WPT test. This is because we don't recompute non-inherited font-weight
within `recompute_inherited_style` which means that relative keyword
values can fall out of sync with their parent's value. These previously
passed as we treated `bolder` and `lighter` as aliases for `bold` and
`normal` respectively.
2025-09-19 10:06:33 +01:00
Callum Law
cfbe0244d4 LibWeb: Use computed value of font-size in keyframes
Remaining test failures in font-size-interpolation-00* are either:
 - Rounding of font-size to CSSPixels when setting the expected value
 - Not clamping negative values from the point of view of
   getComputedStyle (used values are still clamped)
2025-09-19 10:06:33 +01:00
Callum Law
64d2f0d55a LibWeb: Avoid overwriting non-animated font-size when computing font
Previously if we would overwrite the non-animated font-size with the
animated font-size if it was set.

Gains us 8 WPT tests and means we now fail 9 others in line with other
browsers.
2025-09-19 10:06:33 +01:00
Callum Law
c6049e6853 LibWeb: Remove StyleComputer::root_element_font_metrics_for_element
This method is now unused so can be removed
2025-09-19 10:06:33 +01:00
Callum Law
e9faf056f1 LibWeb: Decouple font-size computation from compute_font_for_syle_values
There are other places we want to convert font-size into it's computed
form than just when we are loading the font (e.g. computing keyframes).

Gains us 36 WPT passes as we now correctly clamp negative calc values.
2025-09-19 10:06:33 +01:00
Callum Law
d6754307f9 LibWeb: Separate relative sizes from absolute_size_mapping
Having relative sizes handled in this function was misleading
2025-09-19 10:06:33 +01:00
Callum Law
b80e6a4d30 LibWeb: Rename get_inherit_value to get_non_animated_inherit_value
This more acurately represents what it does.
2025-09-19 10:06:33 +01:00
Tim Ledbetter
9b15517052 LibWeb: Apply composite operator to keyframe effects 2025-09-18 16:46:06 +01:00
Sam Atkins
95aceb6ec9 LibWeb: Store custom properties in an OrderedHashMap
We are expected to preserve their order within a style declaration, so
let's do that. Passes 1 tracked WPT subtest.
2025-09-18 14:59:14 +02:00
Marcos Del Sol Vives
40792aa85d LibWeb/CSS: Fix compilation with CSS_TRANSITIONS_DEBUG
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
A new parameter was added to Web::CSS::StyleValue::to_string() in
PR #2820 but this debug message was never updated. If
CSS_TRANSITIONS_DEBUG was enabled, compilation would fail.
2025-09-13 23:33:57 +02:00
Callum Law
858450922b LibWeb: Parse and compute text-underline-offset property 2025-09-12 07:07:15 +01:00
Sam Atkins
524a161a51 LibWeb: Take AbstractElement in start_a_transition() 2025-09-11 18:45:35 +02:00
Sam Atkins
e6bb0ab000 LibWeb/CSS: Take AbstractElement in compute_transitioned_properties() 2025-09-11 18:45:35 +02:00
Sam Atkins
77f1057992 LibWeb/CSS: Take AbstractElement in cascade_custom_properties() 2025-09-11 18:45:35 +02:00
Sam Atkins
b49d00996b LibWeb/CSS: Take AbstractElement in compute_text_align() 2025-09-11 18:45:35 +02:00
Sam Atkins
fa790e5095 LibWeb/CSS: Take AbstractElement in for_each_matching_rules() 2025-09-11 18:45:35 +02:00
Sam Atkins
cdc4f7c989 LibWeb/CSS: Take AbstractElement to compute alias mapping contexts 2025-09-11 18:45:35 +02:00
Sam Atkins
cdbaa73576 LibWeb/CSS: Take AbstractElement in box-type transformation functions 2025-09-11 18:45:35 +02:00
Sam Atkins
44e70d9087 LibWeb/CSS: Take AbstractElement in compute_cascaded_values() 2025-09-11 18:45:35 +02:00
Sam Atkins
82d194ba99 LibWeb/CSS: Take AbstractElement in start_needed_transitions() 2025-09-11 18:45:35 +02:00
Sam Atkins
acb211174d LibWeb/CSS: Take AbstractElement in MatchingRule collection 2025-09-11 18:45:35 +02:00
Sam Atkins
50c0b4549c LibWeb/CSS: Take AbstractElement in collect_animation_into() 2025-09-11 18:45:35 +02:00
Sam Atkins
b2ee4a9444 LibWeb/CSS: Take AbstractElement in StyleComputer::compute_properties()
As noted, the chunk of this method that deals with animations could do
with some helpers on AbstractElement, but I'm leaving that until it's
clearer how animations and pseudo-elements should interact.
2025-09-11 18:45:35 +02:00
Sam Atkins
0293176429 LibWeb/CSS: Take AbstractElement in StyleComputer::get_*_inherit_value() 2025-09-11 18:45:35 +02:00
Sam Atkins
64c3319147 LibWeb/CSS: Take AbstractElement in font computation methods 2025-09-11 18:45:35 +02:00
Sam Atkins
263c51f6ac LibWeb/CSS: Take AbstractElement in compute_pe_style_if_needed() 2025-09-11 18:45:35 +02:00
Sam Atkins
cee84d22a0 LibWeb/CSS: Take AbstractElement in cascade_declarations() 2025-09-11 18:45:35 +02:00
Sam Atkins
8706a6165d LibWeb: Take AbstractElement in compute_style_impl() 2025-09-11 18:45:35 +02:00
Sam Atkins
27aab90e66 LibWeb: Take AbstractElement in StyleComputer::compute_style() 2025-09-11 18:45:35 +02:00
Sam Atkins
916e24de30 LibWeb/CSS: Take AbstractElement in resolve_unresolved_properties() 2025-09-11 18:45:35 +02:00
Sam Atkins
83aee2c7fc LibWeb: Take AbstractElement in resolve_unresolved_style_value() 2025-09-11 18:45:35 +02:00
Sam Atkins
b3e32445d3 LibWeb/CSS: Use generated FooUnit types instead of Foo::Type
I've also renamed the `m_type` and `type()` members to be `m_unit` and
`unit()` instead, to match what they actually are.
2025-09-11 17:06:44 +01:00
Callum Law
a46453f234 LibWeb: Map logical alias transition properties to physical counterparts
Transitions apply after logical properties are mapped to their physical
counterparts so we should apply this mapping to `transition` properties

Gains us 20 WPT tests.
2025-09-11 06:08:07 +01:00
Callum Law
62176391dd LibWeb: Include z-index in transition: all
Gains us 37 WPT tests.
2025-09-11 06:08:07 +01:00
Callum Law
0209e502cf LibWeb: Use expanded longhands when computing transition properties
Using longhands rather than expanded longhands meant for instance that
we wouldn't transition `border-top-width` if we had `border` as the
transition property.
2025-09-11 06:08:07 +01:00
Tim Ledbetter
bd7348949a LibWeb: Make word-spacing and letter-spacing default value compute to 0 2025-09-10 16:12:29 +01:00
Callum Law
a7e5ded188 LibWeb: Add generic logic for parsing "positional-value-list-shorthands"
Continues the work started in #5386 to simplify handling of positional
value list shorthand properties.

Previously we would parse these as `StyleValueList`s and then rely on
`StyleComputer::for_each_property_expanding_shorthands` to expand them
into longhands.

This required a bit of work to handle `ShorthandStyleValue`s for the
`@page` `margin` descriptor.
2025-09-09 11:45:47 +02:00
Callum Law
5a7eaf6f73 LibWeb: Store flood-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
91e88ad6e8 LibWeb: Store stroke-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
c045969234 LibWeb: Store stop-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
9434b08bed LibWeb: Store fill-opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Callum Law
1ba84de4f6 LibWeb: Store opacity in computed form in ComputedProperties 2025-09-08 11:03:32 +01:00
Aliaksandr Kalenik
4c7da460dc LibWeb: Add ::slotted() pseudo-element support
Implements `::slotted()` to enough extent we could pass the imported WPT
test and make substantial layout correctness improvement on
https://www.rottentomatoes.com/
2025-09-04 09:51:34 +01:00
Callum Law
56c4e8199b LibWeb: Clamp negative font-size when loading font
`font-size` can end up with a negative value - either due to `calc`
being resolved using the old method which doesn't clamp the value, or
interpolation - in this case we should clamp negative values to zero.

Gains us 36 new WPT passes and fixes crashes in the three imported
tests.
2025-09-01 12:28:53 +01:00
Callum Law
1052ee20b0 LibWeb: Move snap_a_length_as_a_border_width to StyleComputer.cpp
All users are in this file so it makes more sense to have it here
2025-08-28 09:29:46 +01:00
Callum Law
0ce6cc38b7 LibWeb: Store outline-width in computed form in ComputedProperties
We now also store `outline-width` in ComputedValues as a `CSSPixels`
since we know it's an absolute length at `apply_style` time - this saves
us some work in converting to CSSPixels during layout.

Gains us 46 new passes since we now interpolate keywords (thick, thin,
etc) correctly.

Also loses us 4 WPT tests as we longer clamp negative values produced by
interpolation from the point of view of getComputedStyle (although the
'used' value is still clamped).
2025-08-28 09:29:46 +01:00
Callum Law
6eae92511f LibWeb: Store border-*-width in computed form in ComputedProperties
Gains us 112 new passes since we now interpolate keywords (thick, thin,
etc) correctly.

Also loses us 4 WPT tests as we longer clamp negative values produced by
interpolation from the point of view of getComputedStyle (although the
'used' value is still clamped).
2025-08-28 09:29:46 +01:00
Callum Law
d4aa40a9fe LibWeb: Use computed not just absolutized value when computing keyframes
No functionality changes as we don't yet implement computing any
property values using this method.
2025-08-28 09:29:46 +01:00
Callum Law
f9e5332d16 LibWeb: Initial work to store ComputedProperties in computed form
`StyleValue`s stored within `ComputedProperties` should be in their
computed forms, this is for various reasons including:
 - Inheritance should be of computed values
 - Animations should work on computed values
 - Triggering transitions should work on computed values

Currently we store `StyleValue`s in an absolutized version of the
specified value - this is equivalent to the computed form in many cases
which is why this hasn't been causing significant issues but there are
some cases - such as `border-*-width` keywords where this is not the
case.

No functionality change as we are yet to implement any properties
2025-08-28 09:29:46 +01:00