1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00
Commit graph

5259 commits

Author SHA1 Message Date
Shannon Booth
14d5c638eb LibWeb/HTML: Use find flattened slots in assignedElements/assignedNodes
This is very awkward, and should be improved, but this improves
our support for slots :^)
2025-05-19 23:26:02 +12:00
Shannon Booth
98c45f3f03 Tests/LibWeb: Import a bunch of slots WPT tests 2025-05-19 23:26:02 +12:00
Tim Ledbetter
c4d298674b Tests: Re-enable interpolation tests
These run significantly faster than they did when they did when they
were disabled.
2025-05-19 11:31:47 +01:00
Tim Ledbetter
09f4d90594 LibWeb: Clamp interpolated values to the range of their numeric type
This fixes a UBSAN warning that we previously hit when interpolating
color values.
2025-05-19 11:31:47 +01:00
Tim Ledbetter
7d7bab7cac LibWeb: Ensure resolved border-width values are non-negative 2025-05-19 09:55:09 +02:00
Ashton
5f5ae6bf8b AK: Replace wchar_t formatting with char32_t
This makes TestFormat fully cross-platform as we no longer have to
work around the 16 vs 32-bit wide strings
2025-05-18 19:18:13 -06:00
Ashton
4b3a3b0856 AK: Remove redundant TestPrint test
This test was only useful when AK/PrintfImplementation.h existed. But
that was removed 11 months ago, so since then this has just been
testing std library functions not implemented by us.
2025-05-18 19:18:13 -06:00
Andreas Kling
cef9564728 LibWeb: Only serialize CSS numbers with up to 5 decimals
This fixes an issue where we'd serialize some floating point numbers
with excessive precision, resulting in unpleasant-looking numbers like
0.49999999999999999 and such.

At least 90 new subtests passing on WPT, possibly more. :^)
2025-05-18 17:23:34 +02:00
Andreas Kling
f813c495ae Tests: Import a WPT test for sin(), cos() and tan() serialization 2025-05-18 17:23:34 +02:00
Andreas Kling
734bc2a0ea AK: Strip trailing zero decimals in default formatting of float numbers
This gives us a more human-looking serialization of numbers by default,
and in case a fixed number of decimal digits is actually wanted, we
still have the 'f' specifier.
2025-05-18 17:23:34 +02:00
Sam Atkins
233022c473 LibWeb/CSS: Allow empty trailing group when parsing comma-separated list
There's discussion in the linked spec issue, but the short version is,
this algorithm will see "foo,bar," as a list of two groups, with "foo"
in the first group and "bar" in the second. However, users of this want
to get a list of three groups, with the last one being empty. So, do
that!
2025-05-17 07:53:24 +01:00
Sam Atkins
338282f74d LibWeb/CSS: Treat x resolution unit separately from dppx
Tests show that we need to preserve whether x or dppx units were used,
so the simplest way is to treat them separately.
2025-05-17 07:53:24 +01:00
Sam Atkins
443f9e5afb LibWeb/CSS: Make dimension types serialize in resolved form
Some dimensions would always serialize in a canonical unit, others never
did, and others we manually would do so in their StyleValue. This
commit moves all of that into the dimension types, which means for
example that Length can apply its special rounding.

Our local serialization test now produces the same output as other
browsers. :^)
2025-05-17 07:53:24 +01:00
Sam Atkins
2748522924 Tests: Import matchMedia() test 2025-05-17 07:53:24 +01:00
Callum Law
2bb40b615a LibWeb: Allow parsing of <quirky-color> 2025-05-17 06:47:55 +01:00
Sam Atkins
7de5032e73 LibWeb/CSS: Serialize the initial combinator of relative selectors
Selector::serialize() is used for both normal and relative selectors.
For the latter, we need to serialize their initial combinator, and for
the former, we always set the initial combinator as None anyway, so
this would be a no-op there.

Gets us 3 WPT passes.
2025-05-17 00:30:44 +02:00
Sam Atkins
8536e23674 LibWeb/CSS: Parse an ident in :dir(), not a keyword
The spec requires us to accept any ident here, not just ltr/rtl, and
also serialize it back out. That means we need to keep the original
string around.

In order to not call keyword_from_string() every time we want to match
a :dir() selector, we still attempt to parse the keyword and keep it
around.

A small behaviour change is that now we'll serialize the ident with its
original casing, instead of always lowercase. Chrome and Firefox
disagree on this, so I think either is fine until that can be
officially decided.

Gets us 2 WPT passes (including 1 from the as-yet-unmerged :dir() test).
2025-05-17 00:30:44 +02:00
Sam Atkins
7aed541ed0 LibWeb/CSS: Automatically serialize functional pseudo-class arguments
The spec gives us a hard-coded list of functional pseudo-classes and how
to serialize them - but this list is incomplete and likely to always be
outdated compared to the list of pseudo-classes that exist. So instead,
use the generated metadata we already have to serialize their arguments
based on their type.

This fixes :dir() and :has(), which previously did not serialize their
arguments.

Gets us 26 passes (including 6 from that as-yet-unmerged :dir() test).
2025-05-17 00:30:44 +02:00
Sam Atkins
5f144f366d Tests: Create a test for :dir() parsing/serialization
Submitted to WPT as https://github.com/web-platform-tests/wpt/pull/52598
but in the meantime here's a local version.

The spec for this isn't super thorough, so the tests are based on how
Chrome and Firefox behave. Specifically, Firefox returns the ltr/rtl
keyword in lowercase but Chrome keeps the original case for it.

We currently fail most of these but that will be fixed in subsequent
commits.
2025-05-17 00:30:44 +02:00
Sam Atkins
26d71207d4 LibWeb/CSS: Treat *|* selector like * when serializing
1 new WPT pass.
2025-05-17 00:30:44 +02:00
Sam Atkins
eb98bd1a36 Tests: Import some selector pseudo-class parsing tests 2025-05-17 00:30:44 +02:00
Jelle Raaijmakers
a1467c22d3 LibWeb: Add new whitespace-preserving editing command
Major browsers seem to preserve `white-space: pre/pre-wrap` styles in a
`<div>` when deleting the current selection through an editing command.
The idiomatic way to support this is to have a command with a "relevant
CSS property" to make sure the value is recorded and restored where
appropriate, however, no such command exists.

Create a custom command (internal to Ladybird) that implements this
behavior.
2025-05-17 00:29:19 +02:00
ayeteadoe
744fd91d0b LibTest: Support death tests without child process cloning
A challenge for getting LibTest working on Windows has always
been CrashTest. It implements death tests similar to Google Test
where a child process is cloned to invoke the expression that
should abort/terminate the program. Then the exit code of the
child is used by the parent test process to verify if the
application correctly aborted/terminated due to invoking
the expression.

The problem was that finding an equivalent way to port Crash::run()
to Windows was not looking very likely as publicly exposed Win32/
Native APIs have no equivalent to fork(); however, Windows actually
does have native support for process cloning via undocumented NT
APIs that clever people reverse engineered and published, see
`NtCreateUserProcess()`.

All that being said, this `EXPECT_DEATH()` implementation avoids
needing to use a child process in general, allowing us to remove
CrashTest in favour of a single cross-platform solution for death
tests.
2025-05-16 13:23:32 -06:00
Andreas Kling
2194cbde4b LibWeb: Stub out SVGGraphicsElement.getCTM()
We already did this for getScreenCTM().
2025-05-16 20:36:07 +02:00
Andreas Kling
1dc6425ede LibWeb: Implement SVGElement.viewportElement 2025-05-16 20:36:07 +02:00
Andreas Kling
879cba762b LibWeb: Implement Document.rootElement (SVG2 extension to Document) 2025-05-16 20:36:07 +02:00
Andreas Kling
e6f75801b1 LibWeb: Import WPT test for checking all the basic SVG interfaces exist 2025-05-16 20:36:07 +02:00
Jelle Raaijmakers
170e599bd9 LibWeb: Always set the Y offset of the current block in BFC
Originally part of a fix in 15103d172c, it
appears that this is no longer necessary and received a better fix in a
more recent commit. Resolves a visual regression with the ACID3 test.
2025-05-16 20:33:27 +02:00
Sam Atkins
c9484e279f LibWeb/CSS: Implement CSSPageRule.setSelectorText()
Gets us 12 WPT subtest passes.
2025-05-16 16:42:10 +01:00
Sam Atkins
869abe0b21 LibWeb/CSS: Match *-namespace selectors against all attributes
Previously we only matched against the first attribute with a given
local name. What we actually want to do is look at each attribute with
that local name in turn and only return false if none of them match.

Also remove a hack for HTML elements in HTML documents, where we would
refuse to match any namespaced attributes. This doesn't seem to be
based on the spec, but we had regressions without it, until now. :^)

Gets us 21 more WPT subtest passes.
2025-05-16 16:41:57 +01:00
Sam Atkins
ecdfb96a0a LibWeb/CSS: Limit case-insensitive default comparison to HTML attributes
The HTML spec gives us a list of HTML attributes that must have their
values compared case-insensitively by default (when the attribute
selector does not specify a case-sensitiveness). However, ifwe have a
namespace, then we are not looking for an HTML attribute, so this
should not apply.

Gets us 8 more WPT subtest passes.
2025-05-16 16:41:57 +01:00
Sam Atkins
d9113e45f0 LibWeb/CSS: Discard trailing whitespace inside attribute selectors
This gets us 84 more subtests, so everything in this syntax test passes.
2025-05-16 16:41:57 +01:00
Sam Atkins
3914bf05fb LibWeb/CSS: Serialize * namespace in attribute selectors
Gets us 13 WPT subtest passes.
2025-05-16 16:41:57 +01:00
Sam Atkins
a56ce0f6fa Tests: Import attribute-selector case-sensitivity tests 2025-05-16 16:41:57 +01:00
Jelle Raaijmakers
29f1648bc5 LibWeb: Do not override whitespace handling for editable elements
This condition no longer seems to be necessary for anything, and it
caused newlines to not render correctly in editable nodes.
2025-05-16 12:08:29 +01:00
Jelle Raaijmakers
a48e693ea1 LibWeb: Add tests for styleWithCSS and useCSS editing commands 2025-05-16 12:07:35 +01:00
Sam Atkins
870f24f181 LibWeb/CSS: Add basic implementation of CSSMarginRule
This is a bit under-specced, specifically there's no definition of
CSSMarginDescriptors so I've gone with CSSStyleProperties for now. Gets
us 17 WPT subtests.
2025-05-16 11:01:39 +01:00
Sam Atkins
101f6b1d7e Tests: Import CSSMarginRule tests 2025-05-16 11:01:39 +01:00
Sam Atkins
1fe29ac642 LibWeb/CSS: Bring :lang() matching closer to spec
With this, we pass the 8 ref tests in css/selectors/selectors-4/ which
previously failed. This is not technically a full implementation, as we
are supposed to first canonicalize the language range and tag, but that
will require downloading and processing the IANA language subtag
registry:

https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

That's significantly more work, and WPT doesn't seem to test any cases
that require that, so we can leave it for now.
2025-05-15 16:40:44 +01:00
Ben Eidson
e0e513e9fc LibWeb/MimeSniff: Add WebM signature sniffing and VINT parsing
Adds `matches_webm_signature()` and `parse_vint()` helpers per WPT
spec. Uses these helpers to resolve the WebM FIXME that was in
`match_an_audio_or_video_type_pattern()`.
2025-05-15 09:39:19 -06:00
Jelle Raaijmakers
c3a5e8e266 LibWeb: Invalidate viewport's text blocks cache on layout update
156c1083e9 introduced a text blocks cache
for better performance when searching through text on a page, but when
we partially recreate the layout tree, this cache does not get
invalidated. We now rebuild the entire text blocks cache after a layout
update.
2025-05-15 11:44:32 +01:00
Sam Atkins
3a235e9050 LibWeb/CSS: Parse @page bleed, marks, page-orientation descriptors
These don't have WPT tests so I've added some myself.
2025-05-15 09:53:29 +01:00
Sam Atkins
9415bffd9b LibWeb/CSS: Parse @page size descriptor 2025-05-15 09:53:29 +01:00
Sam Atkins
d8c6b872a3 LibWeb/CSS: Allow descriptors to be shorthands
I was wrong when I added those notes before about this being impossible,
it's *very* possible, for example with the `@page margin` descriptor.
However, until we have a large number of these shorthands and not just a
single example, we can get away with hard-coding support for it.
2025-05-15 09:53:29 +01:00
Sam Atkins
1aa5631610 LibWeb/CSS: Parse @page selectors
Ideally we'd be able to share the code between page selectors and style
ones, but given how simple page selectors are, some code duplication is
the simpler option.
2025-05-15 09:53:29 +01:00
Sam Atkins
aaf07ae30d LibWeb: Add basic implementation of @page
This doesn't support selectors, and the only descriptors for now are for
margins.
2025-05-15 09:53:29 +01:00
Sam Atkins
1002464322 Tests: Import WPT CSSOM and parsing tests for @page 2025-05-15 09:53:29 +01:00
Sam Atkins
4edafb35cd LibWeb/CSS: Use PendingSubstitutionValue for unresolved shorthands
Previously, we would just assign the UnresolvedStyleValue to each
longhand, which was completely wrong but happened to work if it was a
ShorthandStyleValue (because that's basically a list of "set property X
to Y", and doesn't care which property it's the value of).

For example, the included `var-in-margin-shorthand.html` test would:
1. Set `margin-top` to `var(--a) 10px`
2. Resolve it to `margin-top: 5px 10px`
3. Reject that as invalid

What now happens is:
1. Set `margin-top` to a PendingSubstitutionValue
2. Resolve `margin` to `5px 10px`
3. Expand that out into its longhands
4. `margin-top` is `5px` 🎉

In order to support this, `for_each_property_expanding_shorthands()` now
runs the callback for the shorthand too if it's an unresolved or
pending-substitution value. This is so that we can store those in the
CascadedProperties until they can be resolved - otherwise, by the time
we want to resolve them, we don't have them any more.

`cascade_declarations()` has an unfortunate hack: it tracks, for each
declaration, which properties have already been given values, so that
it can avoid overwriting an actual value with a pending one. This is
necessary because of the unfortunate way that CSSStyleProperties holds
expanded longhands, and not just the original declarations. The spec
disagrees with itself about this, but we do need to do that expansion
for `element.style` to work correctly. This HashTable is unfortunate
but it does solve the problem until a better solution can be found.
2025-05-14 11:46:47 +01:00
ayeteadoe
11bca38f91 CMake: Build LibRegex tests in Tests/LibRegex not Meta/Lagom
As LibRegex was not specified in TEST_DIRECTORIES, the existing
Tests/LibRegex subdirectory was not actually included during
configuration. Also the RegexLibC test has not been needed
since migration away from Serenitys LibC was done, so
that test has been fully removed. I also renamed the
Regex.cpp test to TestRegex.cpp to match the naming
convention of most test targets.
2025-05-14 02:05:12 -06:00
ayeteadoe
8864b3e9d1 CMake: Build LibCore tests in Tests/LibCore not Meta/Lagom
As LibCore was not specified in TEST_DIRECTORIES, the existing
Tests/LibCore subdirectory was not actually included during
configuration.
2025-05-14 02:05:12 -06:00