Commit graph

10127 commits

Author SHA1 Message Date
Sam Atkins
9079be850b LibWeb/CSS: Include guaranteed-invalid value in ComponentValue
Treating these like any other ComponentValue means not having to convert
between different types of Vector, and that we will be able to use
TokenStream to parse the "argument grammars" of arbitrary substitution
functions.
2025-07-09 16:44:20 +01:00
Sam Atkins
b5ed910f1f LibWeb: Rename "var_or_attr" to "arbitrary_substitution_function"
This is the spec term, and will apply to many more things than var() and
attr().
2025-07-09 16:44:20 +01:00
Sam Atkins
8f01297182 LibWeb: Remove now-invalid attr() type support
Previously the type argument in attr() could be the name of a CSS type
on its own. This has changed, and now only `raw-string`
(previously `string`) or the name of a dimension unit is allowed. Other
types and more complex grammar use the `type()` function, which we
don't yet support.

I've updated the syntax comment, but not the algorithm itself, which
will be reimplemented in a later commit.
2025-07-09 16:44:20 +01:00
Sam Atkins
a6ff088984 LibWeb/CSS: Stop converting at-rule names to lowercase
This basically reverts a6efdb1068.

The test added there still passes without the ad-hoc behaviour, so let's
remove it.
2025-07-09 15:04:57 +01:00
Sam Atkins
d5bee680b0 LibWeb/CSS: Construct all CSS Tokens in a consistent way
Add `create_foo()` static methods for the missing Token::Types, and use
them in the Tokenizer. This means we slightly deviate from the spec now:
it says "create foo token... set its bar to 32", but we now just wait
and construct the Token fully-formed. But those cases are short so it
should still be clear what we're doing.

This makes it possible to construct all kinds of Token elsewhere, such
as for testing purposes.
2025-07-09 15:04:57 +01:00
Tim Ledbetter
57dd85e4ac LibWeb/DOM: Throw errors from correct realm in Node::move_node() 2025-07-09 15:59:06 +02:00
Andreas Kling
aae0b52403 LibWeb: Resolve mask/clip in foreignObject's own coordinate space
We were neglecting to resolve these correctly, which caused them to get
the same metrics as the nearest viewport above the foreignObject.
2025-07-09 14:36:08 +02:00
Andreas Kling
f5f3cd041a LibWeb: Apply SVG viewbox transform to foreignObject elements 2025-07-09 14:36:08 +02:00
Andreas Kling
f343a418b2 LibWeb: Never split SVG foreignObject for inline continuations
This would produce a bizarre layout tree and certainly not yield
expected results.
2025-07-09 14:36:08 +02:00
Andreas Kling
b4708510fb LibWeb: Layout foreignObject as block-level element with hidden overflow
This is according to the default user-agent style from the SVG2 spec.

In order for this to work correctly, we also have to assign width and
height to foreignObject boxes during SVG layout, since they are handled
manually by SVGFormattingContext.
2025-07-09 14:36:08 +02:00
Andreas Kling
b3fd939628 LibWeb: Make sure we run selectors for mixed-case tag names
Before this change, we would never apply CSS rules where the selector
had a mixed-case tag name. This happened because our rule caches would
key them on the lowercased tag name, but we didn't lowercase the tag
name when fetching things from the cache.

This uncovered the fact that the SVG2 spec has a bunch of style applied
to non-rendered elements in a way that doesn't match other browsers.
Instead of blindly following the spec, we now match other browsers.
2025-07-09 14:36:08 +02:00
Andreas Kling
61df035612 LibWeb: Show element namespace URI in DOM tree dumps
This is helpful when debugging SVG-in-HTML content.
2025-07-09 14:36:08 +02:00
Andreas Kling
ddcb87fb40 LibWeb: Make TreeBuilder nicer to SVG foreignObject
This patch does two things:

1. Makes TreeBuilder never cross the foreignObject boundary when looking
   for an appropriate insertion parent. Before this change, we would
   sometimes make things inside the foreignObject DOM subtree have
   layout nodes outside the foreignObject.

2. Makes foreignObject boxes participate in the anonymous wrapping of
   inline-level boxes. This is particularly imporant for absolutely
   positioned elements inside foreignObject, which were previously
   getting incorrectly wrapped if there was any text (even empty)
   preceding the abspos element.
2025-07-09 14:36:08 +02:00
Andreas Kling
07838016c8 LibWeb: Make layout code aware that we create BFC for foreignObject
We were already always doing this, but through an unusual mechanism:
SVG layout creates a BFC on the stack when laying out foreignObject
subtrees.

This change makes the rest of the layout system aware of this, and
also allows it to be reflected in layout dumps.
2025-07-09 14:36:08 +02:00
Andreas Kling
0cf9a4543a LibWeb: Make SVG foreignObject establish a new stacking context
This matches the behavior of Blink and Gecko, but not WebKit.
2025-07-09 14:36:08 +02:00
Andreas Kling
dab1fd265d test-web: Dump stacking context tree in layout test output
This will allow us to test (and catch regressions in) stacking context
tree construction and updates, etc.
2025-07-09 14:36:08 +02:00
Callum Law
f46bd7f5eb LibWeb: Create enum for <line-width> keywords 2025-07-09 13:28:12 +02:00
Sam Atkins
0809eacd97 LibWeb/CSS: Update definition for cursor property
No functional changes. The main difference is renaming the cursor enum
to match the spec term `<cursor-predefined>`, which is a bit more
verbose but clearer in meaning.

Corresponds to 1a57a4025c
2025-07-09 13:21:26 +02:00
Veeti Paananen
c3e470569e LibWeb: Preserve File last modified timestamp in FormData copies
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
+1 WPT pass
2025-07-09 10:20:52 +01:00
Callum Law
da40419c5b LibWeb: Support border-{block,inline} shorthands
Gains us 4 WPT tests
2025-07-09 10:10:38 +01:00
Callum Law
d280cf56e6 LibWeb: Handle border-{inline,block}-* properties with a single value
Gains us 14 WPT tests
2025-07-09 10:10:38 +01:00
Callum Law
7d50dba3fc LibWeb: Deduplicate logic in for_each_property_expanding_shorthands 2025-07-09 10:10:38 +01:00
Callum Law
56c68aedea LibWeb: Remove special parsing of physical border longhands
Parsing of these properties is handled by the default behaviour.

No functionality changes.
2025-07-09 10:10:38 +01:00
Shannon Booth
24d522afce LibWeb/DOM: Avoid passing null to valid name prefix
Applies spec change of 1b4bd48
which we already happened to be doing to avoid crashing.
2025-07-09 10:57:14 +02:00
Shannon Booth
642a2430a9 LibWeb/DOM: Properly extract local name and prefix from strict split
Previously we were taking the local name from everything after the
first ':', instead of second element of strictly splitting qualified
name.
2025-07-09 10:57:14 +02:00
Veeti Paananen
c834c594ac LibWeb: Set correct content and document types in DOMParser
It appears this was removed by accident in an earlier commit, regressing
the included WPT test.
2025-07-09 20:10:11 +12:00
Aliaksandr Kalenik
bfa978c501 LibWeb: Remove unnecessary save/restore generated for stacking context
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
2025-07-08 23:54:35 +02:00
Aliaksandr Kalenik
8d9920af16 LibWeb: Account for natural aspect ratio in calculate_min_content_height
By the time we calculate the min-content height, the width is already
known, so we can use it to calculate the height based on the natural
aspect ratio.
2025-07-08 22:35:04 +02:00
Sam Atkins
69d4811ef7 LibWeb: Generate logical property mappings
To support this, how we declare logical property aliases has changed.
Instead of `logical-alias-for` being a list of properties, it's now an
object with a `group` and `mapping`. The group is the name of a logical
property group in LogicalPropertyGroups.json. The mapping is which
side/dimension/corner this property is. Hopefully it's self-explanatory
enough.

The generated code is very much a copy of what was previously in
`StyleComputer::map_logical_alias_to_physical_property_id()`, so there
should be no behaviour change.
2025-07-08 11:45:15 -06:00
Callum Law
36e2d25efa LibWeb: Parse grid track placements closer to spec
This brings parsing of grid-row-* and grid-column-* properties (and
their associated shorthands) more inline with spec.

Changes:
- Only set omitted properties for combined-value shorthands (e.g.
  `grid-row: a` rather than `grid-row: a / b`) if the single value is
  `<custom-ident>`.

- `[ [ <integer [-∞,-1]> | <integer [1,∞]> ] && <custom-ident>? ]`:
  - Properly resolve `calc`s for `<integer>` that rely on compute-time
    information.

- `[ span && [ <integer [1,∞]> || <custom-ident> ] ]`
  - Allow `calc`s for `<integer>`
  - Allow `<custom-ident>`

There is still work to be done to properly use these parsed values.

Gains us 46 WPT tests.
2025-07-08 17:26:16 +01:00
Sam Atkins
a424a06d45 LibWeb/DOM: Copy document's allow declarative shadow roots when cloning
Corresponds to 77920094a4
2025-07-08 17:08:39 +01:00
Sam Atkins
5c365884dd LibWeb/HTML: Update HTMLScriptElement.idl to match current spec
Corresponds to e21d9ff0d6

As far as I can tell, none of the rest of this change requires
modifications on our end.
2025-07-08 17:08:39 +01:00
Sam Atkins
0cfa243baa LibWeb/HTML: Update "create policy container from fetch response" spec
Corresponds to 83cc45b9c5
2025-07-08 17:08:39 +01:00
Sam Atkins
0d34f70d95 LibWeb/HTML: Queue a task to resolve createImageBitmap
Corresponds to e288a0efe5
2025-07-08 17:08:39 +01:00
Sam Atkins
df2b2d2c14 LibWeb/HTML: Fix return value checking for unload cancellation
Corresponds to 4467ddf323
2025-07-08 17:08:39 +01:00
Sam Atkins
91e8a19391 LibWeb: Always set [[ErrorToRethrow]] for import validation errors
Corresponds to f6fb04a11f
2025-07-08 17:08:39 +01:00
Sam Atkins
4e854ca44a LibWeb/HTML: Provide a fallback for validation anchor
Corresponds to daa3016b40

Also import a related test.
2025-07-08 17:08:39 +01:00
Sam Atkins
da8a29376f LibWeb: Use ThrowCompletion AO to create throw completions
Corresponds to 4989b3457f
2025-07-08 17:08:39 +01:00
Sam Atkins
b05fe0127b LibWeb/HTML: Allow more characters in custom element names
Corresponds to 78d2678789

And import a related test.
2025-07-08 17:08:39 +01:00
Sam Atkins
af17f38bbf LibWeb/HTML: Implement and use "optional value"
Corresponds to f3444c23ff

Also import a test.
2025-07-08 17:08:39 +01:00
Sam Atkins
22cc36eeaa LibWeb/HTML: Replace "zero" with "0" in some places
Corresponds to 706b986010
2025-07-08 17:08:39 +01:00
Sam Atkins
e74afec9c5 LibWeb: Capitalize "No Popover state" consistently
Corresponds partly to 8035a256bf
2025-07-08 17:08:39 +01:00
Timothy Flynn
8cec9e7557 LibJS+LibUnicode: Remove unused FormatNumericToString AO 2025-07-08 11:19:27 -04:00
Jelle Raaijmakers
e96fd53eda Revert "LibWebView: Add Arial Unicode MS to the list of Sans Serif (...)
(...) fallbacks"

This reverts commit 9e7b40747f. This
caused most bold headings to display as regular headings, since Arial
Unicode MS does not support other styles (as opposed to Arial).

We need a better font selection algorithm to properly support selecting
fonts for specific glyphs. Issue #2332 exists to keep track of
supporting less frequently used glyphs.
2025-07-08 09:17:32 -04:00
Jelle Raaijmakers
ead0a2c78a Everywhere: Rename serenity_main to ladybird_main
No functional changes.
2025-07-08 09:17:16 -04:00
Timothy Flynn
af671f58ed LibCore: Revert change to simplify tracking of notifers and poll structs
The issue with that refactor was that the same fd can be used in more
than one notifier. This reverts us back to using 2 members to track the
notifiers in play.
2025-07-08 13:53:27 +01:00
Sam Atkins
b711b01f76 LibWeb/CSS: Remove comment that free space is distributed
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, 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
Corresponds to 24c1b60e9a
2025-07-08 10:24:49 +01:00
Sam Atkins
d9aeffa302 LibWeb/CSS: Adjust grammar definitions
Corresponds to:
e2903b127e
1b4ea44fc8
2025-07-08 10:24:49 +01:00
Aliaksandr Kalenik
b87e01e304 LibWeb: Skip recording display list items with color.alpha() == 0
Cuts display list size, mostly because now we avoid lots of FillRect
previusly recorded for boxes with transparent background.

Website      | DisplayList Items Before | DisplayList Items After
-------------|--------------------------|-------------------------
ladybird.org | 1431                     | 1117
null.com     | 4714                     | 4484
discord.com  | 5360                     | 4992
2025-07-08 10:24:11 +02:00
Aliaksandr Kalenik
46097c6753 LibWeb: Avoid unnecessary save/restore in paint_background()
`paint_background()` is invoked for each PaintableBox, so by avoiding
save/restore pair emitted for each call, we substantially decrease
display list size.

Website      | DisplayList Items Before | DisplayList Items After
-------------|--------------------------|-------------------------
ladybird.org | 2753                     | 1431
null.com     | 5298                     | 4714
discord.com  | 6598                     | 5360
2025-07-08 10:24:11 +02:00