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

69344 commits

Author SHA1 Message Date
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
eec4365542 LibWeb/CSS: Extract SerializationMode into its own header
Prep for using this to serialize dimension types, and perhaps other
things in the future.
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
Daniel Bertalan
2058fb1144 CMake: Set CMAKE_POSITION_INDEPENDENT_CODE instead of manual -fPIC
If we are doing a statically linked build, there is no need for full
`-fPIC`, just `-fpie` is enough (which lets the compiler assume that
global variables can be accessed directly without the GOT, etc.). CMake
does the right thing already when we set the `POSITION_INDEPENDENT_CODE`
property.
2025-05-16 17:40:49 -06:00
Sam Atkins
ffdf0268dd LibWeb/CSS: Make debug messages in parse_simple_selector() more useful 2025-05-17 00:30:44 +02: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
Jelle Raaijmakers
1c77b42a44 LibWeb: Add two FIXMEs about input events' missing .data value
For both `<input>` and `<textarea>` elements, we actually need to
provide the input events with the strings that were added to them.
2025-05-17 00:29:19 +02:00
Jelle Raaijmakers
e941965b01 LibWeb: Use TemporaryChange instead of ScopeGuard
This is a more idiomatic way to temporarily change a value. No
functional changes.
2025-05-17 00:29:19 +02:00
Jelle Raaijmakers
ac46ec0b2e LibWeb: Start integrating the editing API with user keyboard input
This reworks EventHandler so text insertion, backspace, delete and
return actions are now handled by the Editing API. This was the whole
point of the execCommand spec, to provide an implementation of both
editing commands and the expected editing behavior on user input.

Responsibility of firing the `input` event is moved from EventHandler to
the Editing API, which also gets rid of duplicate events whenever
dealing with `<input>` or `<textarea>` events.

The `beforeinput` event still needs to be fired by `EventHandler`
however, since that is never fired by `execCommand()`.
2025-05-17 00:29:19 +02:00
Andrew Kaster
564f5ca2cc AK: Propagate -U flag to dependencies when built as a static library
We added a weak symbol to AK to support overriding the default assertion
handler for test cases. However, on macOS, we need to explicitly mark
the possibly-null symbol as 'it's ok for this to be undefined'.

When AK is a shared library, the flag can be applied to the link step of
the dylib, but when it's a static library, we need to apply it to the
executable that links against it.
2025-05-16 14:59:44 -06:00
ayeteadoe
656586a0e5 Meta: Enforce symbol annotation for EXPLICIT_SYMBOL_EXPORT on Windows 2025-05-16 14:33:04 -06:00
ayeteadoe
275a180246 LibTest: Remove unused CrashTest infrastructure
Now that all EXPECT_CRASH related macros have been replaced in
favour of using EXPECT_DEATH related macros, CrashTest is no
longer used and can be deleted.
2025-05-16 13:23:32 -06: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
ayeteadoe
dc707e6ed8 AK: Expose ak_assertion_handler weak symbol for custom death handling
When a `VERIFY()` assertion fails `ak_verification_failed` is invoked
which means the program will invoke `__builtin_trap` and immediately
quit. But with this change we have now allowed for an optional hook
into `ak_*_failed` that lets us perform some custom
action before program exits. This foundation is what we will
(ab)use to implement death tests without the process cloning
CrashTest infrastructure.
2025-05-16 13:23:32 -06:00
ayeteadoe
d35486cb74 LibTest: Explicitly export symbols 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
d852ae17e8 LibWeb/CSS: Make @page selector parsing accessible
Mostly minor changes - the code has moved, and has to support Token or
ComponentValue TokenStreams, but otherwise it's the same.
2025-05-16 16:42:10 +01:00
Sam Atkins
107b47f884 LibWeb/CSS: Move PageSelector into its own files
The main motivation here is that the CSS Parser needs to know about
PageSelectorList so that we can parse one in
`CSSPageRule::set_selector_text()`. Including all of `CSSPageRule.h`
there would pull in a lot of other headers that aren't needed.
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
aplefull
68ddc7006d LibMedia: Implement conversion of BT601 primaries 2025-05-16 12:13:13 +01:00
stelar7
9e7fb5efbc LibWeb/IDB: Update spec step wording 2025-05-16 12:10:16 +01:00
stelar7
c1d63b5b28 LibWeb/IDB: Implement queue_a_database_task 2025-05-16 12:10:16 +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
aa9fa88428 LibWeb/CSS: Treat at-rule names insensitively to determine context type
`@MeDiA` is entirely valid.
2025-05-16 11:01:39 +01:00
Sam Atkins
101f6b1d7e Tests: Import CSSMarginRule tests 2025-05-16 11:01:39 +01:00
Tim Ledbetter
2903defcfc Revert "LibJS+LibWeb: Return Vector<PropertyKey> from…
internal_own_property_keys"

This reverts commit 5ee810f772.
2025-05-16 06:33:09 +01:00
Tim Ledbetter
8cd9275416 Revert "LibJS: Ensure keys vector capacity in…
Object::internal_own_property_keys"

This reverts commit 27ba216e3f.
2025-05-16 06:33:09 +01:00
Sam Atkins
3f18331594 LibWeb/HTML: Do not allow named window targeting with noopener
Corresponds to dfdafb4b29

We fail the test for this, but we actually do create the separate popup
windows correctly (when popups aren't blocked!) but the test checks
`window.name` which we incorrectly return the empty string for.
https://wpt.live/html/browsers/windows/auxiliary-browsing-contexts/named-lookup-noopener.html
2025-05-16 10:21:09 +12:00
Sam Atkins
08419a6d8f LibWeb/HTML: Correct show_popover() invocations
Corresponds to 47f854c66e
2025-05-16 10:21:09 +12:00
Sam Atkins
2efad4c941 LibWeb/HTML: Fire load event for non-string javascript: URLs
Corresponds to 8abe559982

The relevant test doesn't pass, so we're probably missing some other
part of this mechanism:
https://wpt.live/html/semantics/embedded-content/the-embed-element/embed-javascript-url.html
2025-05-16 10:21:09 +12:00
Aliaksandr Kalenik
27ba216e3f LibJS: Ensure keys vector capacity in Object::internal_own_property_keys
12% improvement on MicroBench/object-keys.js
2025-05-15 14:12:18 -04:00
Aliaksandr Kalenik
5ee810f772 LibJS+LibWeb: Return Vector<PropertyKey> from internal_own_property_keys
By doing that we avoid lots of `PropertyKey` -> `Value` -> `PropertyKey`
transforms, which are quite expensive because of underlying
`FlyString` -> `PrimitiveString` -> `FlyString` conversions.

10% improvement on MicroBench/object-keys.js
2025-05-15 14:12:18 -04:00