Commit graph

1395 commits

Author SHA1 Message Date
Andreas Kling
8cb371b2ce LibWeb: Decode X25519 keys as base64url + throw on bogus key data
This makes the X25519 importKey tests from WPT actually run.
2024-11-24 23:28:23 +01:00
Andreas Kling
e0def9d745 Tests: Import WPT importKey tests for Ed25519 and X25519 2024-11-24 23:28:23 +01:00
Milo van der Tier
15741350ba LibWeb: Make replaceData create new surrogate pairs
When inserting a new utf-16 surrogate next to an existing surrogate
with replaceData, the surrogates would not get merged correctly into a
single code point. This is because internally the text data is stored
as utf-8, and the two surrogates would be converted seperately. This
has now been fixed by first recreating the whole string in utf-16 and
then converting it back to utf-8.

It's not the most efficient solution, but this fixes at least 6 WPT
subtests.
2024-11-24 13:04:06 +00:00
Andreas Kling
01f4bbbba7 LibWeb: Abandon Node.replaceChild() if removal rejigs the DOM
This isn't directly in the spec, but since replaceChild is implemented
in terms of remove + insert, the removal step may cause arbitrary code
to execute, and so we have to verify that the replaceChild inputs still
make sense afterwards, before doing the insertion.

This roughly matches what WebKit does, and makes a bunch of HTML parsing
tests in WPT stop asserting.
2024-11-24 11:45:23 +01:00
Andreas Kling
5c70436cb2 LibWeb: Teach more of HTMLTokenizer to stop at the insertion point
In particular, input character lookahead now knows how to stop at the
insertion point marker if needed.

This makes it possible to do amazing things like having document.write()
insert doctypes one character at a time.
2024-11-24 11:45:23 +01:00
Kenneth Myhra
968c38e54f LibWeb: Implement FetchController::abort() 2024-11-24 11:11:44 +01:00
Kenneth Myhra
4c5019f89c LibWeb: Add serialization and deserilization steps to DOMException
This makes DOMException a Serializable object.
2024-11-24 11:11:44 +01:00
Andrew Kaster
5be4825504 LibWeb: Report exceptions from custom element upgrades to global object
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
2024-11-24 00:15:59 +00:00
Milo van der Tier
54b0476d70 LibWeb: Handle second condition in NamedNodeMap's property names
This removes the FIXME and fixes a WPT subtest.
2024-11-23 23:21:50 +00:00
Tim Ledbetter
f378f41526 LibWeb: Use correct comparison logic in NamedNodeMap::get_attribute()
Previously, we were doing a case insensitive comparison, which could
return the wrong result if the attribute name was uppercase.
2024-11-23 21:19:28 +00:00
Jonne Ransijn
a0fb092d94 LibWeb: Transform PaintableBox::hit_test positions
Elements with transforms were tested on their pre-transformed
positions, causing incorrect hits.

Copy the position transformation done in `StackingContext::hit_test`
to ensure that hit tests are done on the _actual_ position.
2024-11-23 22:06:32 +01:00
Andreas Kling
69367194a6 LibWeb: Make HTML tokenizer stop at insertion point after state switch
If we reach the insertion point at the same time as we switch to another
tokenizer state, we have to bail immediately without proceeding with the
next code point. Otherwise we'd fetch the next token, get an EOF marker,
and then proceed as if we're at the end of the input stream, even though
more data may be coming (with more calls to document.write()..)
2024-11-23 19:19:31 +01:00
Andreas Kling
701ed8470d Tests: Import a bunch of WPT tests related to dynamic markup insertion 2024-11-23 19:19:31 +01:00
Shannon Booth
e565e3c557 LibWeb: Implement BroadcastChannel.postMessage
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
The repository being in static storage is a bit of a hodgepodge, but in
line with how our current storage partitioning is done. We should
eventually move this, along with other across browsing context APIs to a
proper location at a later stage. But for now, this makes progress on
the meat of the BroadcastChannel API.
2024-11-23 16:43:55 +01:00
Andreas Kling
d3ee49b092 LibWeb: Avoid an infinite recursion in replaced element sizing
In the case where we had a preferred aspect ratio and a natural height
but no natural width, we'd get into ping-ponging infinite recursion by
trying to find the width to resolve the height to resolve the width to
resolve the height...
2024-11-23 16:39:45 +01:00
Andreas Kling
1b4763f75f LibWeb: Allow border="0" on HTMLObjectElement 2024-11-23 14:41:41 +01:00
Andreas Kling
6e85363a84 LibWeb: Allow border="0" on HTMLInputElement 2024-11-23 14:41:41 +01:00
Andreas Kling
1288452bc3 LibWeb: Honor border attribute on HTMLImageElement 2024-11-23 14:41:41 +01:00
Andreas Kling
e781aab274 LibWeb: Honor the various margin attributes in HTMLBodyElement
This one is particularly weird as there's a priority order, and we even
have to look at attributes from the container element if we're inside a
subframe.
2024-11-23 14:41:41 +01:00
Andreas Kling
97aa608c13 Tests: Import WPT test for pixel length attributes 2024-11-23 14:41:41 +01:00
Psychpsyo
3e536a4cd7 LibWeb: Implement more IntersectionObserver attributes 2024-11-23 09:52:32 +01:00
Gingeh
7444f76b0d LibWeb: Make querySelectorAll match each element at most once 2024-11-23 09:49:33 +01:00
Gingeh
bb678e75f9 LibWeb: Reject selectors with named namespaces in querySelectorAll 2024-11-23 09:49:33 +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
Gingeh
a2cf1d17fd LibWeb: Require CSS combinators to be followed by a simple selector 2024-11-23 09:49:33 +01:00
Gingeh
bb5678a175 LibWeb: Don't allow trailing commas in selector lists
comma-separated list != #-multiplier
2024-11-23 09:49:33 +01:00
sideshowbarker
8965698ce7 LibWeb: Support accessible-name computation for SVG elements
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
This change adds support for computing accessible names for SVG
elements, per the https://w3c.github.io/svg-aam/#mapping_additional_nd
spec requirements. Otherwise, without this change, accessible names for
SVG elements don’t get exposed as expected.
2024-11-23 04:34:23 +00:00
Shannon Booth
3fffd1129c LibWeb: Implement overload resolution for sequence types
Fixes: #2508
2024-11-23 02:38:21 +00:00
Andreas Kling
9a7c9286c4 LibWeb: Support individual scale CSS property
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
2024-11-22 20:06:44 +01:00
Andreas Kling
66a821e731 LibWeb: Support individual translate CSS property 2024-11-22 20:06:44 +01:00
Andreas Kling
d6f7fccf49 Tests: Import a bunch of WPT tests from /css/css-transforms 2024-11-22 20:06:44 +01:00
Psychpsyo
3f5fff79ae LibWeb: Update checkbox focus lost test 2024-11-22 13:58:36 +00:00
Psychpsyo
c75dda8f8b LibWeb: Stop radio buttons firing change events when losing focus 2024-11-22 13:58:36 +00:00
Shannon Booth
75b7a3e413 LibWeb: Add definitions for PointerEvent event handlers
Also removing a FIXME about not covering all of the event names as it is
not exactly clear when such a FIXME would be addressed, especially as
these come from multiple specifications.
2024-11-22 14:33:58 +01:00
Aliaksandr Kalenik
8614e0f856 LibWeb: Dispatch pointer events in EventHandler
Now, along with the mouse events we also dispatch pointerup, pointerdown
and pointermove.

With this change shape painting works on https://excalidraw.com/
2024-11-22 00:32:58 +01:00
rmg-x
e4dc758343 LibWeb/CSS: Check for matching custom properties on parent elements
Previously, we were only checking the current element and not the
parents in `ResolvedCSSStyleDeclaration::custom_property()` which wasn't
correct.
2024-11-22 00:32:19 +01:00
Tim Ledbetter
00f6a2b744 LibWeb: Use ByteString arguments for XMLHttpRequest.setRequestHeader()
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
2024-11-21 15:49:48 -05:00
Andreas Kling
6dc61f895d LibWeb: Make getComputedStyle(e).getPropertyValue() see custom props
A lot of WPT tests rely on this mechanism to test unrelated things.
2024-11-21 21:16:03 +01:00
Tim Ledbetter
ea0e434d1d LibWeb: Allow FormData entry list to be mutated within a FormDataEvent
Previously, the list was copied when constructing the FormData object,
then the original list was passed to the event, meaning any changes to
the list that happened within the event would not be reflected outside
of it.
2024-11-21 20:25:26 +01:00
Andreas Kling
fbe9395928 LibWeb: Stop treating intrinsic size keywords as auto in CSS heights
This commit introduces proper handling of three intrinsic size keywords
when used for CSS heights:

- min-content
- max-content
- fit-content

This necessitated a few plumbing changes, since we can't resolve these
values without having access to containing block widths.

This fixes some visual glitches on https://www.supabase.com/ as well
as a number of WPT tests. It also improves the appearance of dialogs.
2024-11-21 19:21:51 +01:00
Nico Weber
94b97aa365 LibWeb: Plumbing for svg stroke-dasharray 2024-11-21 18:56:45 +01:00
Aliaksandr Kalenik
c0e90a2a68 LibWeb: Dispatch "click" event on input control associated with <label>
For example, in the following HTML:
```html
<label>
    <input type="radio" name="fruit" value="apple" id="radio1">
    <span class="box"></span>
</label>
```

When any descendant of a <label> element is clicked, a "click" event
must be dispatched on the <input> element nested within the <label>, in
addition to the "click" event dispatched on the clicked descendant.

Previously, this behavior was implemented only for text node descendants
by "overriding" the mouse event target using `mouse_event_target()` in
the TextPaintable. This approach was incorrect because it was limited to
text nodes, whereas the behavior should apply to any box. Moreover, the
"click" event for the input control must be dispatched *in addition* to
the event on the clicked element, rather than redirecting it.
2024-11-21 16:11:03 +01:00
Psychpsyo
7f989765f5 LibWeb: Fix MouseEvent position values
The clientX and clientY values are, as per the spec, the offset from
the viewport.
This makes them actually be that and also fixes up the calculations
for offsetX, offsetY, pageX and pageY.
I assume all of these got messed up in some sort of refactor in the
past.

The spec comment from the now-removed
compute_mouse_event_client_offset() function sadly has no convenient
place to be anymore so, for now, it is just gone as well.
Personally, I think it'd make sense to refactor a lot of this file so
that not every mouse event repeats a large chunk of (almost) identical
code. That way there'd be a nice place to put the comment without
repeating it all over the file.
But that is out of the scope of this PR.

Also: I know, offsetX and Y are not fully fixed yet, they still
don't ignore the element's CSS transforms but I am working on that
in a new PR.
2024-11-21 13:22:22 +01:00
Aliaksandr Kalenik
41c172c663 LibWeb: Allow custom properties in getPropertyPriority() 2024-11-21 13:16:08 +01:00
Aliaksandr Kalenik
ac5699c8fc LibWeb: Allow custom properties in CSSStyleDeclaration.removeProperty() 2024-11-21 13:16:08 +01:00
Aliaksandr Kalenik
ce26e5d757 LibWeb: Allow custom properties in CSSStyleDeclaration.getPropertyValue 2024-11-21 13:16:08 +01:00
Aliaksandr Kalenik
3a2cc1aa20 LibWeb: Allow custom properties in CSSStyleDeclaration.setProperty()
This change fixes unhoverable toolbar on https://excalidraw.com/
The problem was that React.js uses setProperty() to add style properties
specified in the "style" attribute in the virtual DOM, and we were
failing to add the CSS variable used to set the "pointer-events" value
to "all".
2024-11-21 13:16:08 +01:00
devgianlu
009f328308 LibWeb: Implement ECDH.generateKey 2024-11-21 11:45:22 +01:00
Shannon Booth
d6bcd3fb0b LibWeb: Make CallbackType take a realm instead of settings object
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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
Push notes / build (push) Waiting to run
In line with the ShadowRealm proposal changes in the WebIDL spec:
webidl#1437 and supporting changes in HTML spec.

This is required for ShadowRealms as they have no relevant settings
object on the shadow realm, so fixes a crash in the QueueingStrategy
test in this commit.
2024-11-20 18:01:21 -07:00
Shannon Booth
d527c5df5d LibWeb: Allow using queuing strategies on globals other than Window
These interfaces are exposed on *, meaning it should work for workers
and our newly added shadow realm global object by being stored on the
universal global scope mixin.
2024-11-20 18:01:21 -07:00