Commit graph

2338 commits

Author SHA1 Message Date
Sam Atkins
089f70a918 LibWeb/CSS: Reify StyleValues in StylePropertyMap get()/getAll()
The limitations right now are:
- We don't know if a property is a list or not.
- We always reify as a CSSStyleValue directly.

So, we pass some tests but only ones that expect a CSSStyleValue.
2025-08-18 10:12:53 +01:00
Sam Atkins
b80930ae34 LibWeb/CSS: Connect up StylePropertyMaps to their source
After looking into this more, the `[[declarations]]` slot does not seem
to need to be a literal map of property names and values. Instead, it
can just point at the source (an element or style declaration), and
then direct all read or write operations to that.

This means the `has()` and `delete()` methods actually work now.

A few remaining failures in these tests are because of:
- StylePropertyMap[ReadOnly]s not being iterable yet
- We're not populating an element's custom properties map, which get
  fixed whenever someone gets around to producing proper computed
  values of them.
2025-08-18 10:12:53 +01:00
Glenn Skrzypczak
c01dc5900a LibWeb/HTML: Check all radio buttons in group for required attribute
This fixes a bug in the algorithm for determining if radio buttons are
missing their value. Previously it was only checked if the button
itself is required. Now the algorithm checks if the radio button group
contains a required radio button in order to determine if the value is
required.
2025-08-17 22:27:14 +02: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
Timothy Flynn
017ae80668 LibWeb: Validate form submissions whose submitter is not form-associated
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
The spec for checking the no-validate state ends with a default return
value of "false". However, we were only hitting this case for form-
associated elements. If the submitter is the form itself, we want to
enter the form validation steps.
2025-08-15 15:28:37 +02:00
Timothy Flynn
c369f68eff LibWeb: Delete entire graphemes when the delete/backspace key is pressed
We currently delete a single code unit. If the user presses backspace on
a multi code point emoji, they are going to expect the entire emoji to
be removed. This now matches the behavior of Chrome and Firefox.
2025-08-14 22:21:51 +02:00
Timothy Flynn
76bab90812 LibWeb: Use rendered text to find word boundaries when double-clicking
This effectively reverts da26941b50.

When the user double-clicks a word on screen, they are interacting with
the rendered text, which has e.g. whitespace collapsing applied. If we
acquire word boundaries from the raw text, the resulting selection is
not right.

We still have issues with acquiring the right selection via APIs such as
`document.getSelection`. The offsets computed here are effectively then
applied to the raw text. But this issue is present all over EventHandler
and this patch at least makes the selection visually accurate.
2025-08-14 19:36:38 +02:00
Glenn Skrzypczak
d25d62e74c AK/Time+LibWeb/HTML: Fix ISO8601 week conversions
This reimplements conversions between unix date times and ISO8601
weeks. The new algorithms also do not use loops, so they should be
faster.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
ec807d40dd LibWeb/HTML: Correctly convert number to time/local datetime string
This fixes a bug where non-zero milliseconds were previously not
included if the second component was zero.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
354fd56046 LibWeb/HTML: Step to next value without step mismatch
Inputs now correctly step to the next valid value if they suffer a step
mismatch.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
a127f77602 LibWeb/HTML: Implement default value of range inputs
Range inputs now always uses the default value if the value attribute
is not set and the input is not dirty.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
aea8650d8b LibWeb/HTML: Enforce constraints on range inputs
This extends the sanitization algorithm for range inputs in order to
prevent overflow, underflow and step mismatch.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
57376f8701 LibWeb/HTML: Ensure the year of month and week values is greater than 0
The validation algorithm for month and week inputs now also checks if
the year is greater than zero.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
544a6b21fc LibWeb/HTML: Correctly normalize local datetime values
Now trailing zeros in the second and millisecond part of local datetime
values are removed during normalization.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
cac2ee41b9 LibWeb/HTML: Correctly compute whether element is mutable
This adapts the implementation of `is_mutable` to align more closely
with the spec. Specifically, it is now also taken into account whether
the element is enabled.
2025-08-14 11:05:28 -04:00
CountBleck
ec051bdec2 LibWeb: Import css/selectors/user-valid.html from WPT 2025-08-14 11:55:02 +02:00
norbiros
783ae44462 LibWeb: Fix color interpolation by premultiplying alpha
The current Color::interpolate_color method does not follow the specs
properly. Started improving it by handling premultiplied alpha in color
interpolation.

Only one WPT test covers this (color-transition-premultiplied), which we
currently pass due to a different approach in Color.mixed_with.
2025-08-14 11:09:05 +02:00
stelar7
9e66f49b44 LibWeb/Tests: Update IDB keyorder test file 2025-08-14 09:31:56 +01:00
Jelle Raaijmakers
7078769ba3 LibWeb: Don't indicate focus for all form associated elements
This was a misinterpretation of the spec; we should only indicate focus
if the form associated element supports keyboard input, for which
FormAssociatedTextControlElement is a much better match.
2025-08-13 09:44:38 -04:00
Sam Atkins
911274a84d LibWeb/CSS: Implement ElementCSSInlineStyle.attributeStyleMap
Again, this isn't yet very usable, but it does appease some tests.
2025-08-13 09:47:50 +01:00
Sam Atkins
215d8b8076 LibWeb/CSS: Implement CSSStyleRule.styleMap
StylePropertyMap is just a stub, so this doesn't yet accomplish much.
2025-08-13 09:47:50 +01:00
Sam Atkins
3bb54ffd59 LibWeb/CSS: Stub out StylePropertyMap 2025-08-13 09:47:50 +01:00
Sam Atkins
c768cc7208 LibWeb/CSS: Implement Element.computedStyleMap()
Currently the map doesn't return any values, so it's not very useful,
but this does make a few tests pass just by existing. :^)
2025-08-13 09:47:50 +01:00
Sam Atkins
1620fc5bf6 LibWeb/CSS: Stub out StylePropertyMapReadOnly
Nothing yet produces this, and the useful parts of get() and get_all()
will have to wait until type reification is implemented.
2025-08-13 09:47:50 +01:00
Sam Atkins
882288bf86 LibWeb/CSS: Stub out CSSStyleValue 2025-08-13 09:47:50 +01:00
Sam Atkins
7ec374c74c Tests: Import tests for CSS typed OM
This is everything except some failing ref-tests, and
`css/css-typed-om/the-stylepropertymap/properties/*` because importing
a test for every property feels excessive.
2025-08-13 09:47:50 +01:00
Sam Atkins
503d41d02d LibWeb/CSS: Implement the :heading/:heading() pseudo-class
Corresponds to part of
65dc095e44
2025-08-13 09:47:28 +01:00
Lukas Schmidt
c2fc4b25cd LibWeb: Implement HTMLElement.draggable()
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
2025-08-12 17:15:06 +01:00
Callum Law
778da0175e LibWeb: Clamp and censor top-level calc results
We now clamp the values returned from calc into the allowed range (where
we know it) and censor any `NaN`s to `0` both when we resolve and when
we serialize.

Gains us 76 WPT passes.
2025-08-11 17:10:04 +01:00
Callum Law
1a9dd70792 LibWeb: Serialize NumberStyleValue with 6 decimal places of precision 2025-08-11 17:10:04 +01:00
Callum Law
7182a537f3 LibWeb: Reduce inaccuracies when creating rotation matrices
When converting rotate transform functions `sin` and `cos` can sometimes
be inaccurate. To avoid these inaccuracies we:
 - Mod the angle to minimise inaccuracies in the first place.
 - Discard tiny (smaller than epsilon) values returned by `sin` and
   `cos` as inaccuracies.

This is in line with  other browsers (e.g. Gecko and WebKit).
2025-08-11 17:10:04 +01:00
Tete17
7559084b22 LibWeb: Add wpt test for createPolicy and createXXX
This gives us at least 72 new tests :)
2025-08-11 12:21:31 +01:00
Tete17
adaad653ca LibWeb: Implement TrustedScriptURL class 2025-08-11 12:21:31 +01:00
Tete17
56cab6955a LibWeb: Implement TrustedScript type
This turns out to be very similar to TrustedHTML.
2025-08-11 12:21:31 +01:00
Tete17
90bcc16a7b LibWeb: Add TrustedTypePolicy class
It is mostly a skeleton with no actual implementation.
2025-08-11 12:21:31 +01:00
Tete17
0a147aa9a1 LibWeb: Implement TrustedHTML class
The TrustedHTML interface represents a string that a developer can
confidently insert into an injection sink that will render it as HTML.

These objects are immutable wrappers around a string, constructed via a
TrustedTypePolicy’s createHTML method.
2025-08-11 12:21:31 +01:00
Tete17
68c55b0ef1 LibWeb: Implement getPropertyType for TrustedTypePolicyFactory
This allows authors to check if a Trusted Type is required for the given
Elements property.

This adds 28 more passing WPT tests :)
2025-08-11 12:21:31 +01:00
Sam Atkins
7c8c05ee82 LibWeb/Layout: Support visibility:collapse on table-row elements
When a table row (or its group) is set to collapse, the row takes up no
vertical space in the layout.

We have to account for this in multiple places, so I've cached whether a
row is collapsed in the TableGrid::Row.
2025-08-11 11:07:47 +01:00
Sam Atkins
3b97bdc7bf Tests: Import WPT tests for table rows with visibility:collapse
These mostly fail for now.
2025-08-11 11:07:47 +01:00
Timothy Flynn
57b5df21c7 LibWeb: Select the entire input when double clicking password fields
This matches the behavior of other browsers, and hides any indication
of word boundaries in the password.
2025-08-10 11:05:49 +02:00
Idan Horowitz
70efa8c1c5 LibWeb: Implement CookieChangeEvent 2025-08-08 13:09:58 -04:00
Idan Horowitz
d6c2893663 LibWeb: Add initial CookieStore support 2025-08-08 13:09:58 -04:00
Sam Atkins
7157d19f56 LibWeb/CSS: Separate IntegerSV and NumberSV from CSSUnitValue
This inheritance exists for typed-om classes, but StyleValues aren't
typed-om.

Somehow this makes our z-index interpolation slightly more correct. 🎉
2025-08-08 15:19:03 +01:00
Callum Law
e260ba54e0 LibWeb: Propagate NaN in CSS clamp function
Gains us 10 WPT tests.
2025-08-08 11:43:49 +01:00
Callum Law
4ba54a7a1c LibWeb: Handle NaN and Infinite values in CSS round function
Gains us 10 WPT tests
2025-08-08 11:43:49 +01:00
Callum Law
376b992f0e LibWeb: Handle NaN within CSS min and max functions
Gains us 10 WPT tests
2025-08-08 11:43:49 +01:00
Callum Law
9e1ace28a6 LibWeb: Import WPT tests related to handling non-finite values in calcs 2025-08-08 11:43:49 +01:00
Callum Law
a1037e28d6 LibWeb: Improve support for CalculatedStyleValue in scale
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
- Properly serialize CalculatedStyleValue components
- Allow CSV to be the 'Z' component in interpolated value

Gains us 52 WPT tests
2025-08-08 09:45:00 +01:00
Callum Law
39fdcbc526 LibWeb: Improve support for CalculatedStyleValue in translate
- Omit calcs that are resolved to `0px` from the serialized value
- Allow CSV to be the 'Z' component in interpolated value.
- Allow calcs with mixed percentages in the first two arguments.

To achieve the third item above the concept of a "special" value parsing
context has been added - this will also be useful for instance for
different arguments of color functions having different contexts.

Gains us 23 WPT tests
2025-08-08 09:45:00 +01:00
Edwin Hoksberg
ef9a3a2327 LibWeb: Import serial idl harness wpt tests 2025-08-08 10:23:17 +02:00