Commit graph

71492 commits

Author SHA1 Message Date
Sam Atkins
60fc23e916 LibWeb/CSS: Use Optional instead of auto lengths in Size
Any type of Size which has no LengthPercentage value now uses an empty
optional instead of making an auto Length as before.

We also now serialize a `fit-content` Size as `fit-content` instead of
`fit-content(auto)`, though this doesn't affect test results and I
didn't identify where it's actually used.
2025-09-04 13:31:24 +01:00
Sam Atkins
d10eaa996e LibWeb/CSS: Use empty optional for stretch in FitContentSV
...instead of using an `auto` Length.
2025-09-04 13:31:24 +01:00
Sam Atkins
f57ffc3655 LibWeb/CSS: Introduce a LengthPercentageOrAuto type 2025-09-04 13:31:24 +01:00
Sam Atkins
240536acaa LibWeb: Remove auto length from SourceSet
The spec is a bit awkward here: A few algorithms create an "empty"
SourceSet, and then assign its source-size value a few steps later, so
we have a temporary state with no length. In order to avoid complicating
the types with Optional, I've chosen to just assign it to 0px.
Previously we used `auto`, but `auto` is not a valid value here - it is
used inside the "parse a sizes attribute" algorithm, but that always
returns an actual length (or calc).
2025-09-04 13:31:24 +01:00
Sam Atkins
577564a1a2 LibWeb/CSS: Add LengthOrAutoOrCalculated
It's `LengthOrCalculated` for places that want `<length> | auto`.
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
9b27aaa00c LibWeb/CSS: Use LengthOrAuto for clip rects 2025-09-04 13:31:24 +01:00
Sam Atkins
f663c0a72d LibWeb/CSS: Introduce a LengthOrAuto type
`clip: rect()` in particular wants this for its parameters.
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
Sam Atkins
ae40c7ed95 LibWeb/CSS: Use Size in GridSize
Reduces a bunch of duplicate logic here for holding different sizing
functions, and also removes a user of `auto` Length.
2025-09-04 13:31:24 +01:00
Sam Atkins
ad5f7c56c1 LibWeb/CSS: Prepare Size for use in GridSize
Make it constructible from a LengthPercentage, report whether it
contains a length-percentage, and add an equality operator.
2025-09-04 13:31:24 +01:00
Callum Law
d3e04c96d9 LibWeb: Simplify SourceSet::normalize_source_densities
Relative lengths should be resolved against the initial font rather than
the element's font so all the work around updating layout is unnecessary
2025-09-04 10:05:44 +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
Jelle Raaijmakers
8986e1f1ec LibWeb: Merge nested editing hosts
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
If a node with `contenteditable=true/plaintextonly` is the child of an
editable node or an editing host, we should make it editable instead of
an editing host. This effectively merges nested editing hosts together,
which is how other browsers deal with this as well.

Gains us 5 WPT subtest passes in `editing`.
2025-09-04 00:24:55 +02:00
Jelle Raaijmakers
3931c0336b LibWeb: Clean up some editing-related code
No functional changes.
2025-09-04 00:24:55 +02:00
Kenneth Myhra
dd83634121 LibWeb/FileAPI: Remove redundant if condition
We have already verified above that options->type is not empty.
2025-09-03 21:43:36 +02:00
Kenneth Myhra
a021134457 LibWeb/FileAPI: Make sure to always run the constructor steps for Blob
Previously we did not execute the constructor steps if we constructed a
Blob from a ByteBuffer and a String. Though we only construct a Blob
from ByteBuffer and String internally we still need to run these steps.

By creating the new type 'BlobPartsOrByteBuffer' we can consolidate
those two approaches to creating a Blob into our already existing
constructor steps.
2025-09-03 21:43:36 +02:00
InvalidUsernameException
f9a54d6439 Tests/LibWeb: Do not crash test runner when screenshot sizes differ
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
This regressed in 0f642ecb5c.
2025-09-03 17:31:21 +02:00
InvalidUsernameException
a259ed4db6 Tests/LibWeb: Do not leak multiple GB of screenshots in the test runner
For every ref tests actual and expected screenshots are taken. These
screenshots are only needed while the individual test executes. However,
they are never freed during the run, leading to a continuous increase in
memory usage of the test runner while executing ref tests.

With the number of ref tests growing, this currently amounts to nearly 3
GB of uncompressed bitmap data being held in memory. Lets avoid that by
clearing the screenshot data at the end of each test. With this change
applied, the memory usage of test-web stays stable and below 100 MB for
the entire test run.
2025-09-03 17:31:21 +02:00
Luke Wilde
18c0739bbb LibJS: Copy base object of LHS of assignment to preserve eval order
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
Previously, the given test would create an object with the test
property that pointed to itself.

This is because `temp = temp.test || {}` overwrote the `temp` local
register, and `temp.test = temp` used the new object instead of the
original one it fetched.

Allows https://www.yorkshiretea.co.uk/ to load, which was failing in
Gsap library initialization.
2025-09-02 12:59:52 +01:00
ayeteadoe
454e6a6f7f LibWeb/Gamepad: Forward declare SDL components to fix Windows build
We have to prevent from including any SDL headers in LibWeb headers.
Otherwise there will be transitive Windows.h includes that will
re-declare some of our existing forward decls/defines in
LibCore/SocketAddressWindows.h
2025-09-02 11:11:12 +01:00
Tim Ledbetter
5ce518f493 LibWeb: Change iterable<T> declaration order to match specifications 2025-09-02 10:41:33 +01:00
Tim Ledbetter
fdbd25967b LibIDL: Allow iterable<T> to be defined before property getter
Previously, an error would occur if an `iterable<T>` was defined before
the required value iterator. An is now also reported if an`iterable<T>`
is defined before a pair iterator, previously this error would only be
reported if the iterable was defined after the pair iterator.
2025-09-02 10:41:33 +01:00
Luke Wilde
9adf27f009 LibWeb: Add tests for Gamepad API by utilising virtual SDL3 joysticks
Some checks failed
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
Build Dev Container Image / build (push) Has been cancelled
2025-09-01 21:10:47 +02:00
Luke Wilde
74e0483ea5 LibWeb: Implement the Gamepad API with SDL3 2025-09-01 21:10:47 +02:00
Luke Wilde
50dcd8fc85 Meta+WebContent+LibWeb: Add, link and initialize SDL3 2025-09-01 21:10:47 +02:00
Luke Wilde
36d5e814ef IDLGenerator: Use fully qualified type names for namespace conflicts 2025-09-01 21:10:47 +02:00
Tete17
848020a9a1 LibWeb: Add more WPT test for TrustedTypes
We now implement 100% of the idlharness :)
2025-09-01 16:19:24 +01:00
Tete17
b6a16ed3c6 LibWeb: Implement get_trusted_type_compliant_string algorithm 2025-09-01 16:19:24 +01:00
Tete17
ab82c4c5fc LibWeb: Implement Content Security Check for sink types 2025-09-01 16:19:24 +01:00
Tete17
a5c631aff3 LibWeb: Implement Does Sink Require Trusted Types algo 2025-09-01 16:19:24 +01:00
Tete17
8df173e1bd LibWeb: Add require-trusted-types-for Directive
This is meant to configure the behaviour of an injection sinks when a
string is passed.
2025-09-01 16:19:24 +01:00
Tete17
2083708897 LibWeb: Enumerate all injection sinks relevant to the TrustedTypes spec
This enables us to more strictly control the available sinks we support.
2025-09-01 16:19:24 +01:00
Tete17
af933c2721 LibWeb: Implement last 2 remaining FIXME's on TrustedTypePolicyFactory
emptyHTML is used to avoid having to create a no-op policy while
emptyScript is used to detect if the browser supports the spec natively.
2025-09-01 16:19:24 +01:00
Tete17
4f9eb78b9d LibWeb: Refactor magic string in favour of TrustedTypeName 2025-09-01 16:19:24 +01:00
Tim Ledbetter
7dade36d96 LibWeb: Ensure SVG image element respects viewBox
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
Previously, any active viewBox was ignored by SVG image elements.
2025-09-01 13:28:35 +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
39dc604642 LibWeb: Return unanimated font-size in ComputedProperties::font_size()
1a3da3d introduced a crash as we assumed that font-size values were
always stored in their computed forms, this isn't correct for animated
font-size values.

As a temporary workaround until we store animated font-sizes in their
computed form we will return the non-animated value - this restores the
functionality prior to 1a3da3d
2025-09-01 12:28:53 +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
Jelle Raaijmakers
a0b7d0542c LibWeb: Misc. code cleanup of LayoutState
No functional changes.
2025-09-01 11:20:43 +01:00
Jelle Raaijmakers
64093f7d26 LibWeb: Detach paint tree from layout tree in one go
We used to only walk the paintable root tree from the layout root and
detach paintables from there. In some cases, this could leave paintables
behind, so we added another loop that iterates over all layout nodes and
detaches their paintables, if any remained.

Instead of traversing two trees like this, just traverse the layout tree
once and detach the inclusive descendant's paintables, similar to how we
deal with the DOM tree immediately after that.
2025-09-01 11:20:43 +01:00
Jelle Raaijmakers
f122e1f78a LibWeb: Let PaintableBox be const for longer in LayoutState
Makes it clearer where we're modifying it. No functional changes.
2025-09-01 11:20:43 +01:00
Ali Mohammad Pur
4462348916 Everywhere: Slap some [[clang::lifetimebound]] where appropriate
This first pass only applies to the following two cases:
- Public functions returning a view type into an object they own
- Public ctors storing a view type

This catches a grand total of one (1) issue, which is fixed in
the previous commit.
2025-09-01 11:11:38 +02:00
Ali Mohammad Pur
8b3e888920 LibMedia: Don't store view into deleted ByteString
DecoderError::formatted() made a ByteString, took a view into it,
dropped the ByteString, then propagated the (now invalid) view back to
the caller as an error.
Since the object has to keep the ByteString alive, keep it as a variant
to make sure the "happy" path with no alloc remains alloc-free.
2025-09-01 11:11:38 +02:00
Aliaksandr Kalenik
0ef61ad813 LibWeb: Skip flexible tracks expansion if there's no any of them [GFC]
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
We could skip calculating fr unit size if we know there's no flexible
tracks.
2025-08-31 19:13:14 +02:00
Aliaksandr Kalenik
7b1a97c109 LibWeb: Skip calculating item's min-content size if possible [GFC]
We could skip doing item's intrinsic min-content layout if we know for
sure that there's no tracks with intrinsic sizing function to distribute
the min-content size to.
2025-08-31 19:13:14 +02:00
Andreas Kling
f89afe8e27 LibJS: Allocate context up front in SuperCallWithArgumentArray
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
This also removes the last user of Interpreter's argument buffer
allocation API, which we've used to repeatedly shoot ourselves in the
foot. Good-bye!
2025-08-31 15:24:37 +02:00
Andreas Kling
996ea109b3 LibJS: Allocate context up front when calling with argument array
This necessitated splitting CallWithArgumentArray into three variants,
one for each call type (call, construct and direct eval).
2025-08-31 15:24:37 +02:00
Andreas Kling
e5b07858a2 LibJS: Allocate Call{Construct,DirectEval,Builtin) contexts up front
We already do this for normal Call contexts, so this is just continuing
to propagate the same pattern to other instructions.

Fixes #6026
2025-08-31 15:24:37 +02:00
Idan Horowitz
849ade88ce LibWeb: Fire change events on deletion in FormAssociated Text Elements
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
Previously we would only trigger change events on insertion, which
resulted in javascript code missing changes due to deletion.

This makes the calculator on the MDN simple web worker demo update on
deletion as well.
2025-08-31 01:47:52 +02:00