Commit graph

639 commits

Author SHA1 Message Date
Gingeh
84150f972f LibWeb: Properly serialize position/edge style values 2024-12-13 11:35:38 +00:00
sideshowbarker
583ca6af89 LibWeb: Implement <input type=checkbox switch> experimentally
In conformance with the requirements of the spec PR at
https://github.com/whatwg/html/pull/9546, this change adds support for
the “switch” attribute for type=checkbox “input” elements — which is
shipping in Safari (since Safari 17.4). This change also implements
support for exposing it to AT users with role=switch.
2024-12-13 11:31:27 +00:00
Lucas CHOLLET
5e62f548db LibWeb/CSS: Serialize CSSColor without relying on RGB
This gives us 140 subtests pass in:
css/css-color/parsing/color-valid-color-function.html
2024-12-11 16:37:22 -07:00
Lucas CHOLLET
dd283768a8 LibWeb/CSS: Allow none values in the color() function 2024-12-11 22:38:14 +00:00
Timothy Flynn
fe891727dc LibWeb: Use correct URL parsing methods throughout LibWeb
There are essentially 3 URL parsing AOs defined by the spec:
1. Parse a URL
2. Encoding parse a URL
3. Encoding parse a URL and serialize the result

Further, these are replicated between the Document and the ESO.

This patch defines these methods in accordance with the spec and updates
existing users to invoke the correct method. In places where the correct
method is ambiguous, we use the encoding parser to preserve existing ad-
hoc behavior.
2024-12-10 10:37:01 -08:00
Jelle Raaijmakers
1c55153d43 LibWeb: Refactor "editable" and "editing host" concepts
The DOM spec defines what it means for an element to be an "editing
host", and the Editing spec does the same for the "editable" concept.
Replace our `Node::is_editable()` implementation with these
spec-compliant algorithms.

An editing host is an element that has the properties to make its
contents effectively editable. Editable elements are descendants of an
editing host. Concepts like the inheritable contenteditable attribute
are propagated through the editable algorithm.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
1514197e36 LibWeb: Remove dom_ from dom_exception_to_throw_completion
We're not converting `WebIDL::DOMException`, but `WebIDL::Exception`
instead.
2024-12-09 20:02:51 -07:00
Pavel Shliak
617ad9c3a5 LibWeb: Move expensive-to-copy arguments 2024-12-09 13:55:03 +01:00
Pavel Shliak
399af2416a LibWeb: Do not pass cheap-to-copy enums by reference 2024-12-09 13:55:03 +01:00
Andreas Kling
6d7bb074fc LibWeb: Don't serialize resolved CSS color values as named colors
With all the plumbing in place, we can handle this quirk at the
serialization layer.

This allows us to remove the pass where StyleComputer would loop over
all computed values and replace any color values with new values
stripped of their original name strings.
2024-12-07 08:31:03 +00:00
Andreas Kling
b3c4b4fd97 LibWeb: Serialize resolved CSS values in dedicated serialization mode
This doesn't actually do anything differently yet, but it will in the
very next commit.
2024-12-07 08:31:03 +00:00
Andreas Kling
e85c3c97fb LibWeb: Add mode flag to CSSStyleValue::to_string()
This will be used to differentiate between serialization for resolved
style (i.e window.getComputedStyle()) and serialization for all other
purposes.
2024-12-07 08:31:03 +00:00
Luke Warlow
eb1c60f37b LibWeb: Implement popover methods
Implements basics of showPopover, hidePopover and togglePopover.
2024-12-06 12:39:14 +00:00
Luke Warlow
b17bbe6d1f LibWeb: Implement ::details-content pseudo element
Details' contents matches a new details-content pseudo element.

Further work is required to make this pseudo-element behave per spec.

This pseudo should be element-backed per
https://drafts.csswg.org/css-pseudo/#element-backed
2024-12-06 07:16:41 +00:00
Luke Warlow
7c9a162f99 LibWeb: Remove :closed pseudo class
This was removed from the spec.
2024-12-06 04:49:36 +00:00
Sam Atkins
bc77f84359 LibWeb: Stop passing Realm unnecessarily to parse CSS properties
Also use the parse_css_value() helper in cases where we previously
constructed a Parser manually.
2024-12-05 19:59:57 +01:00
Sam Atkins
ee9db99961 LibWeb: Remove unused Realm arg from StyleComputer::get_inherit_value()
We no longer need this now that property_initial_value() doesn't take a
Realm.
2024-12-05 19:59:57 +01:00
Sam Atkins
2c3c821305 LibWeb: Remove Realm parameter from property_initial_value()
We don't need the Realm to parse a style value.

Fixes #2720
2024-12-05 19:59:57 +01:00
Sam Atkins
863ce746dc LibWeb/CSS: Make ParsingContext's Realm optional
We only need a Realm to allocate CSSOM objects on the GC heap. Style
values are not such objects, and over time, we'll be changing the
parser to only produce non-CSSOM objects.
2024-12-05 19:59:57 +01:00
Luke Warlow
fdee82d203 LibWeb: Implement ::file-selector-button pseudo element
The button for a file input now matches `::file-selector-button`.
2024-12-05 10:49:57 +00:00
Shannon Booth
0fa54c2327 LibURL+LibWeb: Make URL::serialize return a String
Simplifying a bunch of uneeded error handling around the place.
2024-12-04 16:34:13 +00:00
Yuval Carmon
3ff8c5c8f1 LibWeb/CSS: Block shadow host matching in DOM
Fixes an issue where selectors inside a shadow root could incorrectly
match their shadow host directly using selectors like #host,
instead of requiring :host pseudo-class selectors.

Fixes issue #2319
2024-12-04 16:19:32 +00:00
Lucas CHOLLET
6804ce348e LibWeb/CSS: Interpret NaN as 0 when resolving alpha and rgb values
Fixes the crash in css/css-color/parsing/color-valid-hwb.html.

The crash was probably introduced in 248e4bb5, as it was the first
commit to VERIFY that the value given to `Color::with_opacity` were in
the correct range. As the values in color-valid-hwb.html were resolved
as NaN, the check never passed.
2024-12-04 16:11:41 +00:00
Milo van der Tier
1882a2e19b LibWeb/CSS: Pass Length::ResolutionContext to resolve_integer
The length resolution context might be needed even when resolving an
integer value, since it might contain a sign() function with length
values inside. This fixes a WPT subtest.
2024-12-04 12:26:50 +00:00
Milo van der Tier
8bec80ac47 LibWeb/CSS: Allow calc() values in media queries
It was initially thought that the spec disallows them, but this turned
out to be incorrect. This fixes several WPT tests.
2024-12-04 12:26:50 +00:00
Lucas CHOLLET
ad3dd547b7 LibWeb/CSS: Shorten the length of srgb serialization
The WPT tests require the shortest possible serialization that support
an 8 bits roundtrip.

As an example, `128` is serialized to `0.5` while `127` needs more
precision and thus will be serialized to `0.498`.

This commit fixes 33 WPT subtests in css/css-color.
2024-12-04 11:30:44 +00:00
Lucas CHOLLET
ded6695c52 LibWeb/CSS: Remove unused serialization helpers 2024-12-04 11:30:44 +00:00
Jonne Ransijn
acaf01bf7b LibWeb: Do not normalize border radii containing their initial values
Most computed border-radii contain their initial values, and since the
normalized initial border radii are always zero, there is no need to do
expensive floating point math to normalize them.
2024-12-04 08:30:22 +00:00
Jonne Ransijn
d7596a0a61 AK: Don't implicitly convert Optional<T&> to Optional<T>
C++ will jovially select the implicit conversion operator, even if it's
complete bogus, such as for unknown-size types or non-destructible
types. Therefore, all such conversions (which incur a copy) must
(unfortunately) be explicit so that non-copyable types continue to work.

NOTE: We make an exception for trivially copyable types, since they
are, well, trivially copyable.

Co-authored-by: kleines Filmröllchen <filmroellchen@serenityos.org>
2024-12-04 01:58:22 +01:00
Gingeh
0afd7f166a LibWeb: Improve grid-template-area parsing and serialization 2024-12-02 16:19:47 +00:00
Gingeh
e1f4e8e6c2 LibWeb: Move CSS character type definitions to new header 2024-12-02 16:19:47 +00:00
Jonne Ransijn
3f5e32ee84 LibWeb: Stop allocating Tokens and ComponentValues unnecessarily
When the "Consume a component value from input, and do nothing."
step in `Parser::consume_the_remnants_of_a_bad_declaration` was
executed, it would allocate a `ComponentValue` that was then
immediately discarded.

Add explicitly `{}_and_do_nothing` functions for this case that never
allocate a `ComponentValue` in the first place.

Also remove a `(Token)` cast, which was unnecessarily copying a `Token`
as well.
2024-12-01 11:30:06 +01:00
Netanel Haber
d743fcb376 LibWeb: Take namespace into account when matching attribute 2024-11-30 16:47:14 +00:00
Sam Atkins
8e3adbe082 LibWeb: Serialize text-decoration closer to spec
This gets us 32 WPT subtest passes that I'm aware of. :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
671d3e8a48 LibWeb/CSS: Sort text-decoration-line values in spec order
This wins us 49 WPT subtest passes! :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
9453c25925 LibWeb/CSS: Don't repeat CSS-wide keywords when serializing shorthands
Regardless of what the shorthand property is, if all its longhands are
the same CSS-wide keyword such as "initial" or "inherit", then it's the
same as the shorthand being that value.

This gets us 2 WPT subtest passes.
2024-11-30 11:01:12 +01:00
Sam Atkins
0c39d07b4d LibWeb/CSS: Serialize overflow correctly
When the x and y values are the same, we only want to serialize one.

This gets us 10 local WPT subtest passes. :^)
2024-11-30 11:01:12 +01:00
Sam Atkins
e4d55a6037 LibWeb/CSS: Use ShorthandStyleValue to serialize shorthands
This wins us 65 new WPT subtest passes! It also shows up that we're
doing the wrong thing in ShorthandStyleValue in places, notably with
the grid properties. However, having one place to fix instead of two
will make it easier to correct them. :^)

In order to be fully correct, we should use the algorithm here:
https://drafts.csswg.org/cssom/#serialize-a-css-value

However, it's quite hand-wavy. What we do have in the meantime is
`ShorthandStyleValue::to_string()`, where we special-case the
serialization rules for shorthands with a generic fallback that's
equivalent to what the previous `get_property_value()` code was doing.
2024-11-30 11:01:12 +01:00
Sam Atkins
bc17a3c2eb LibWeb: Correctly skip "decimal" in counter() serialization
It's not a keyword, it's a custom-ident. The simplest way of comparing
is by serializing it as a string.

This gets us 2 subtest passes.
2024-11-30 11:01:12 +01:00
Sam Atkins
917d659f8b LibWeb/CSS: Remove unwanted newline from list serialization
Gets us 1 subtest pass.
2024-11-30 11:01:12 +01:00
Sam Atkins
8cdb8ca193 LibWeb/CSS: Add missing commas to rect() serialization
Gets us 1 WPT subtest pass.
2024-11-30 11:01:12 +01:00
Sam Atkins
5bcd9abc42 LibWeb/CSS: Serialize background-repeat correctly
This gets us 4 WPT subtest passes.
2024-11-30 11:01:12 +01:00
Tim Ledbetter
8ad3479e0e LibWeb: Update Screen IDL definition to not inherit from EventTarget 2024-11-26 18:44:26 +01:00
Glenn Skrzypczak
1e67b85571 LibWeb/Animation: Support progress values outside of [0,1]
If the progress is not in [0,1], the first two or the last two
keyframes are now used for interpolation outside the interval.
2024-11-25 18:10:24 +01:00
Glenn Skrzypczak
0d15cc4672 LibWeb/Animation: Fall back to discrete animation in more cases
Use discrete animation when the number of components or the types
of corresponding components do not match. This commit does not cover
all cases, but adds FIXME comments in the appropriate places.
2024-11-25 18:10:24 +01:00
Milo van der Tier
aa33acf3a2 LibWeb: Update existing style object when setting style attribute
Previously any existing ElementInlineCSSStyleDeclaration would get
overwritten by e.setAttribute("style", ...), while it should be updated
instead.

This fixes 2 WPT subtests.
2024-11-25 17:16:29 +01:00
Milo van der Tier
6bb8bf189f LibWeb: Store CSS color name in CSSRGB
When serializing an sRGB color value that originated from a named color,
it should return the color name converted to ASCII lowercase. This
requires storing the color name (if it has one).

This change also requires explicitly removing the color names when
computing style, because computed color values do not retain their name.
It also requires removing a caching optimization in create_from_color(),
because adding the name means that the cached value might be wrong.

This fixes some WPT subtests, and also required updating some of our own
tests.
2024-11-25 11:51:50 +01:00
Psychpsyo
628e1d9853 LibWeb: Fix incorrect spec link for the @supports rule 2024-11-23 18:44:38 +00:00
Psychpsyo
3e536a4cd7 LibWeb: Implement more IntersectionObserver attributes 2024-11-23 09:52:32 +01:00
Gingeh
ba0cc7fe46 LibWeb: Use correct case-sensitivity when matching attribute selectors
Also removed get_attribute_with_lowercase_qualified_name
because it was buggy, duplicated logic, and now unused.
2024-11-23 09:49:33 +01:00