Commit graph

65 commits

Author SHA1 Message Date
Sam Atkins
3916e33276 LibWeb/CSS: Parse the container-type property
This applies size, inline-size, and style containment in some cases.
There are other WPT tests for that, but we seem to not implement enough
of containment for this to have an effect so I've not imported those.

Gets us 35 WPT subtests.
2025-09-30 22:05:45 +01:00
Pascal Pomper
5b1eba7ac8 LibWeb: Position absolute block-level boxes below previous siblings
Some checks are pending
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (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
Whether an absbox is positioned below or to the right of its previous
sibling in an `InlineFormattingContext` is determined by the
display-outside value before blockification, so we store the
pre-blockification `display` value in `ComputedValues` to access it in
`InlineFormattingContext` and position the box accordingly.
2025-09-29 18:37:53 +02:00
Callum Law
af32413dec LibWeb: Store line-height in ComputedProperties in computed form
We now fail a few more tests in properties-value-inherit-001.txt as we
no longer overwrite the non-animated value of `line-height` with the
animated value, this is in line with other major browsers.
2025-09-23 15:57:32 +01:00
Callum Law
dc41d045d8 LibWeb: Store font-style in ComputedProperties in computed form 2025-09-19 10:06:33 +01:00
Callum Law
335c8c7ffb LibWeb: Store font-width in ComputedProperties in computed form 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
34b8947ca0 LibWeb: Support text-underline-position: under 2025-09-15 15:24:20 +01:00
Callum Law
815e77c04d LibWeb: Respect text-underline-offset when rendering underlines 2025-09-12 07:07:15 +01:00
Tim Ledbetter
831088939a LibWeb: Return word-spacing computed value as CSSPixels 2025-09-10 16:12:29 +01:00
Tim Ledbetter
099247d502 LibWeb: Return letter-spacing computed value as CSSPixels 2025-09-10 16:12:29 +01:00
Callum Law
f061f565b9 LibWeb: Remove unused ComputedProperties::resolve_opacity_value 2025-09-08 11:03:32 +01:00
Sam Atkins
dd122e2f74 LibWeb: Make LengthBox hold LengthPercentageOrAuto
Not every user of this requires an `auto` state, but most do.

This has quite a big diff but most of that is mechanical:
LengthPercentageOrAuto has `resolved_or_auto()` instead of `resolved()`,
and `to_px_or_zero()` instead of `to_px()`, to make their output
clearer.
2025-09-04 13:31:24 +01:00
Sam Atkins
1a3246b560 LibWeb/CSS: Stop allowing auto in ComputedProperties::length_percentage
We only had one user of this which allows `auto`, which is length_box().
So, inline the code there, remove the `auto` branch from
length_percentage(), and then remove length_percentage_or_fallback()
entirely as nobody uses it any more.
2025-09-04 13:31:24 +01:00
Sam Atkins
381d3bf4e0 LibWeb: Stop pretending text-decoration-thickness is a LengthPercentage
It has two keywords: auto and from-font. from-font isn't handled
properly yet, but at least we have a FIXME for it now. :^)
2025-09-04 13:31:24 +01:00
Callum Law
6fcaceedd9 LibWeb: Clamp negative computed values for padding-* properties
Interpolation can leave `padding-*` values as negative - this should be
handled by interpolation clamping it to the allowed range of values
but we don't yet do that. As a stop gap we can clamp this before setting
it in ComputedValues.

This fixes 3 crashes and gains us 11 passes in the imported WPT tests
2025-09-01 12:28:53 +01:00
Tim Ledbetter
a87a9156d5 LibWeb/CSS: Parse the paint-order property 2025-08-28 10:31:09 +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
912ffc3f84 LibWeb: Remove unnecessary ComputedProperties::maybe_null_property
We know that all (longhand) properties have a value so this is
unnecessary.
2025-08-26 12:17:55 +02:00
Callum Law
6bccc7c242 LibWeb: Don't allocate space for shorthands in ComputedProperties
Only longhands have computed values so allocating space for shorthands
is just wasted memory
2025-08-26 12:17:55 +02:00
Callum Law
1ba64a1d7e LibWeb: Remove StyleComputer as friend of ComputedProperties
Everything we need to do with ComputedProperties in StyleComputer can be
done via the public APIs
2025-08-26 12:17:55 +02:00
Callum Law
1a3da3d825 LibWeb: Don't store separate computed value for font_size
The StyleValue stored in m_property_values is already in it's computed
form and it's trivial to pull the underlying value out so there is no
need to store this separately.

Also removes unnecessary handling of percentage values in
`absolutize_values` - this is already handled within `compute_font`.
2025-08-26 12:17:55 +02:00
ayeteadoe
3df8e00d91 LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Callum Law
9330bf4b72 LibWeb: Propagate animated values in recompute_inherited_style
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, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (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
As `recompute_inherited_style` works in-place rather than building
ComputedProperties from scratch we need to keep track of which animated
properties are inherited to know whether we should remove them when we
have no more inherited value.
2025-08-21 10:46:55 +01:00
Tim Ledbetter
1d745884be LibWeb: Parse the shape-rendering property 2025-08-19 09:47:28 +01:00
Tim Ledbetter
4f663ca6e7 LibWeb: Parse the will-change property
This property provides a hint to the rendering engine about properties
that are likely to change in the near future, allowing for early
optimizations to be applied.
2025-08-18 12:36:37 +01:00
Tim Ledbetter
ad06ac0d58 LibWeb: Implement the color-interpolation property for SVG gradients
This changes the operating color space for gradient `<linearGradient>`
and `<radialGradient>` elements.
2025-08-17 10:51:05 +02:00
Sam Atkins
c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00
Callum Law
a70a397501 LibWeb: Support percentages in word-spacing
Fixes crash in the created test as well as https://wpt.live/css/css-text
/word-spacing/reference/word-spacing-percent-001-ref.html. The WPT test
hasn't been imported as it passing is currently a false-positive due to
the fact that we don't yet respect `word-spacing` in most cases.
2025-08-05 11:43:55 +01:00
Callum Law
344d6199da LibWeb: Use correct colors for SVGFEFloodElement::flood_color
Previously we would always render floods as black, we now use the
computed color.

We also now support relative lengths within any `calc`s present.
2025-08-04 11:29:05 +01:00
Callum Law
3b52b1139a LibWeb: Support relative lengths in stop-color calcs 2025-08-04 11:29:05 +01:00
Callum Law
a19a6deaa4 LibWeb: Take a ColorResolutionContext in color_or_fallback
Taking a ColorResolutionContext directly instead of creating one from a
layout node allows us to call this from places where we don't have a
layout node.
2025-08-04 11:29:05 +01:00
Lucien Fiorini
d3684a36b0 LibWeb/SVG: Add FEFloodElement 2025-07-09 18:07:12 +01:00
Tim Ledbetter
68035a2b8d LibWeb/CSS: Add the text-rendering property 2025-06-27 16:51:30 +01:00
Gingeh
b85a8a23a7 LibWeb: Handle percentage font-size values 2025-06-24 12:42:26 +01:00
Tim Ledbetter
9b6da84fff LibWeb/CSS: Implement the font-kerning property
This sets whether the kerning information stored on the current font is
used.
2025-06-23 13:26:48 +01:00
Sam Atkins
c1d4323cf7 LibWeb: Support counter-* properties on pseudo-elements
There are multiple things happening here which are interconnected:

- We now use AbstractElement to refer to the source of a counter, which
  means we also need to pass that around to compute `content`.

- Give AbstractElement new helper methods that are needed by
  CountersSet, so it doesn't have to care whether it's dealing with a
  true Element or PseudoElement.

- The CountersSet algorithms now walk the layout tree instead of DOM
  tree, so TreeBuilder needs to wait until the layout node exists
  before it resolves counters for it.

- Resolve counters when creating a pseudo-element's layout node. We
  awkwardly compute the `content` value up to twice: Once to figure out
  what kind of node we need to make, and then if it's a string, we do
  so again after counters are resolved so we can get the true value of
  any `counter()` functions. This will need adjusting in the future but
  it works for now.
2025-06-19 12:35:31 +01:00
Tim Ledbetter
e0af205d69 LibWeb/CSS: Implement the empty-cells property
This property sets whether table borders and backgrounds are painted
if a given table cell has no visible content.
2025-06-18 14:55:03 +01:00
Tim Ledbetter
e2d0d8e2b9 LibWeb/CSS: Implement the scrollbar-color property
This allows the user to set the scrollbar thumb and track colors.
2025-06-02 00:17:51 +02:00
Callum Law
94f5a51820 LibWeb: Convert white-space CSS property to shorthand
This exposed a few bugs which caused the following tests to behave
incorrectly:
- `tab-size-text-wrap.html`: This previously relied on a bug where we
  incorrectly treated `white-space: pre` as allowing text wrapping. The
  fix here is to implement the text-wrap CSS shorthand property.

- `execCommand-preserveWhitespace.html`: We don't correctly serialize
  shorthand properties. This is covered by an existing FIXME in
  `CSSStyleProperties::serialized()`

- `white-space-shorthand.html`: The last 5 subtests here fail as we
  don't correctly handle shorthand properties in
  `CSSStyleProperties::remove_property()`. This is covered by an
  existing FIXME in said function.
2025-05-29 12:04:28 +02:00
Callum Law
9480b1fc5c LibWeb: Parse and propagate white-space-trim CSS property 2025-05-29 12:04:28 +02:00
Callum Law
50bdd2cb85 LibWeb: Parse and propagate text-wrap-mode CSS property 2025-05-29 12:04:28 +02:00
Callum Law
ea30356fba LibWeb: Parse and propagate white-space-collapse CSS property 2025-05-29 12:04:28 +02:00
Aliaksandr Kalenik
6a029fb6d9 LibWeb: Reset animated CSS properties for pseudo elements
Previously we were resetting animated properties if animation effect's
target is not a pseudo element.
2025-05-28 17:35:59 +01:00
Mark Langen
6cbb5d2785 LibWeb: Parse and propagate touch-action CSS property
Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-05-06 12:22:01 +01:00
Jelle Raaijmakers
71665fa504 LibWeb: Scale font size by 1.15 for line-height: normal
Browsers such as Chrome and Firefox apply an arbitrary scale to the
current font size if `normal` is used for `line-height`. Firefox uses
1.2 while Chrome uses 1.15. Let's go with the latter for now, it's
relatively easy to change if we ever want to go back on that decision.

This also requires updating the expectations for a lot of layout tests.
The upside of this is that it's a bit easier to compare our layout
results to other browsers', especially Chrome.
2025-05-05 13:15:56 +02:00
Andreas Kling
e1777f6e79 LibWeb: Make :hover invalidation logic reusable for all pseudo classes
We achieve this by keeping track of all checked pseudo class selectors
in the SelectorEngine code. We also give StyleComputer per-pseudo-class
rule caches.
2025-04-17 19:45:55 +02:00
Andrew Kaster
be2dd91289 LibGfx+LibWeb: Store Typeface and Font-related types in RefPtr to const 2025-04-16 10:41:44 -06:00
Sam Atkins
86be8abfbf LibWeb/CSS: Const-correct ComputedProperties::set_computed_font_list()
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, 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
This shouldn't be const, and that means the two members don't have to be
mutable.
2025-04-09 15:32:04 +02:00
mkljczk
79c22e0d86 LibWeb: Use font with space in range for first_available_computed_font 2025-04-09 12:14:04 +01:00
Tim Ledbetter
88d35c547c LibWeb/CSS: Implement the caret-color property 2025-03-09 19:36:29 +01:00