Commit graph

2183 commits

Author SHA1 Message Date
Shannon Booth
ef793d8679 LibWeb/HTML: Support blob URLs in HTMLLinkElement
We are meant to apply the 'URL parser' here, which indicates that
this should work with Blob URLs.
2025-01-21 10:49:39 +00:00
Jelle Raaijmakers
d967f56936 LibWeb: Require existing Selection for .execCommand("selectAll")
Disable the command if no selection is available. This is a spec bug:

https://github.com/w3c/editing/issues/475

Fixes #3325
2025-01-21 02:27:50 +00:00
Andreas Kling
96e074b38f LibWeb: Make SVGSVGElement.getElementById() return Element? (nullable)
This is wrong in the spec, and there's already a bug open.
2025-01-21 02:06:33 +01:00
Feng Yu
8b097b38dd LibWeb: Implement formData() for "multipart/form-data" 2025-01-20 23:33:51 +00:00
Andreas Kling
7ae46bf8b7 LibWeb: Allow partial update of SVG subtrees in layout tree
We were incorrectly always appending to the nearest ancestor in the
partial update case, even when the node was eligible for replacement.
2025-01-21 00:08:25 +01:00
Aliaksandr Kalenik
3b81d9d91d LibWeb: Delete "names used in attribute selectors" from SelectorInsights
These are no longer needed because it's possible to tell if attribute
name is used in any selector by using invalidation sets.
2025-01-20 18:23:34 +01:00
Aliaksandr Kalenik
e0051db62e LibWeb: Use invalidation sets for "style" attribute invalidation 2025-01-20 18:23:34 +01:00
Gingeh
bf36d829ef LibWeb: Only reload link on rel change if it became a stylesheet 2025-01-20 18:21:20 +01:00
Shannon Booth
fe7d7f6f6b LibWeb/HTML: Enable callbacks in postMessage deserialization
Interestingly, the spec has a note saying:

> window.postMessage() performs StructuredSerializeWithTransfer on
> its arguments, but is careful to do so immediately, inside the
> synchronous portion of its algorithm. Thus it is able to use the
> algorithms without needing to prepare to run script and prepare
> to run a callback.

But there is no note about the deserialization steps. In any case, we do
need callbacks enabled here.
2025-01-20 07:52:30 -05:00
Shannon Booth
bfbc0124c0 LibWeb/HTML: Pubically expose entangled port and post message steps
These are needed for the implementation of Transferable streams.
2025-01-20 07:52:30 -05:00
Shannon Booth
9f0660c8f0 LibWeb/HTML: Start MessagePort's port messsge queue in onmessage setter
...Which doesn't do anything given start() itself doesn't do anything,
but this is a subtle enough point of the spec that it seems worthwhile
to implement now for whenever this does become meaningful.
2025-01-20 07:52:30 -05:00
Shannon Booth
f8df624171 LibWeb/HTML: Do not use macro to implement MessagePort event handlers
This is not really any more code, and will make it easier to implement
the custom behaviour specified for the onmessage setter.
2025-01-20 07:52:30 -05:00
Timothy Flynn
43dc0f52a6 LibWeb: Do not run microtasks when the event loop is paused
For example, running `alert(1)` will pause the event loop, during which
time no JavaScript should execute. This patch extends this disruption to
microtasks. This avoids a crash inside the microtask executor, which
asserts the JS execution context stack is empty.

This makes us behave the same as Firefox in the following page:

    <script>
        queueMicrotask(() => {
            console.log("inside microtask");
        });

        alert("hi");
    </script>

Before the aforementioned assertion was added, we would execute that
microtask before showing the alert. Firefox does not do this, and now
we don't either.
2025-01-19 20:47:50 +00:00
Aliaksandr Kalenik
34bf833a0a LibWeb: Expand invalidation sets usage to any attribute change
Before this change invalidation sets were only used for "class" and "id"
attribute changes.
2025-01-19 19:54:38 +01:00
Aliaksandr Kalenik
039e0d478a LibWeb: Use invalidation sets for id attribute style invalidation 2025-01-19 19:54:38 +01:00
Aliaksandr Kalenik
c5f2a88f69 LibWeb: Use invalidation sets to reduce style recalculation
Implements idea described in
https://docs.google.com/document/d/1vEW86DaeVs4uQzNFI5R-_xS9TcS1Cs_EUsHRSgCHGu8

Invalidation sets are used to reduce the number of elements marked for
style recalculation by collecting metadata from style rules about the
dependencies between properties that could affect an element’s style.

Currently, this optimization is only applied to style invalidation
triggered by class list mutations on an element.
2025-01-19 19:54:38 +01:00
Gingeh
58c78cb003 LibWeb: Update the select label when option's children are changed 2025-01-19 19:22:32 +01:00
Tim Ledbetter
c87f80454b LibWeb/WebAudio: Implement automation rate constraints
Some nodes have parameters whose automation rate is not allowed to be
changed. This change enforces that constraint for all parameters it
applies to.
2025-01-19 17:24:55 +01:00
Tim Ledbetter
575edf8a90 LibWeb: Use correct automation rate for AudioBufferSourceNode parameters 2025-01-19 17:24:55 +01:00
Tim Ledbetter
400aefb784 LibWeb: Resolve SVGImageElement source URL correctly
This fixes an issue where an SVGImageElement, whose source was a
relative URL would not load inside an iframe.
2025-01-19 15:02:38 +01:00
Shannon Booth
b7512deada LibWeb/SVG: Fix crash when SVG use element is used on an external SVG
We were previously crashing when invoking 'scroll to the fragment' on
such documents as it was unable to find the active document. This is
as a result of our AD-HOC implementation not setting up the document
fully to mark it is active before running the parser.

Fixes a crash on https://tweakers.net.
2025-01-19 15:01:39 +01:00
Andreas Kling
ceb6348811 LibWeb: Invalidate entire layout tree on SVG <use> clone instantiation
This is sub-optimal but let's rebuild the whole tree for now, since this
case gets quite complicated and there are more valuable things to chase
after first.

Thanks to Gingeh for the reduced test case!
2025-01-19 14:38:14 +01:00
Andreas Kling
e5d521bef8 LibWeb: Enable partial layout tree update in a bunch of cases
These common cases now cause us to invalidate the layout tree starting
at the relevant parent node instead of invalidating the entire tree.

- DOM node insertion
- DOM node removal
- innerHTML setter
- textContent setter

This makes a lot of dynamic content much faster. For example, demos
on shadertoy.com go from ~18 fps to ~28 fps on my machine.
2025-01-18 21:01:01 +01:00
Andreas Kling
c01d810e5a LibWeb: Implement partial layout tree updates
DOM nodes now have two additional flags:

- Needs layout tree update
- Child needs layout tree update

These work similarly to the needs-style-update flags, but instead signal
the need to rebuild the corresponding part of the layout tree.

When a specific DOM node needs a layout tree update, we try to create
a new subtree starting at that node, and then replace the subtree in the
old layout tree with the newly created subtree.

This required some refactoring in TreeBuilder so that we can skip over
entire subtrees during a tree update.

Note that no partial updates happen yet (as of this commit) since we
always invalidate the full layout tree still. That will change in the
next commit.
2025-01-18 21:01:01 +01:00
Andreas Kling
b41a490e40 LibWeb: Don't (anonymously) wrap table boxes that are already wrapped
Instead just update the existing wrapper with computed values from the
table box, to insure that upside-down "inheritance" works as expected.

This allows table fixup to run on partially updated layout trees without
adding a new layer of unnecessary wrappers every time.
2025-01-18 21:01:01 +01:00
Andreas Kling
e8b5667a9e LibWeb: Add TreeNode<T>::replace_child(new_child, old_child)
This will be used to make local patches to layout trees.
2025-01-18 21:01:01 +01:00
Shannon Booth
add8bf4790 LibWeb/Streams: Ensure pending pull into's objects are visited by GC
While PendingPullIntos are typically visted by their controller there
were some cases that we were removing those references from the
controller and storing them in a SinglyLinkedList on the stack which
is not safe.

Instead, make PendingPullInto a GC::Cell type, which also allows us
to remove an awkward copy of the struct where the underlying reference
was previously being destroyed.
2025-01-18 10:26:40 +01:00
Tim Ledbetter
5fd130b02d LibWeb: Add BaseAudioContext.createStereoPanner() factory method 2025-01-18 10:20:41 +01:00
Tim Ledbetter
56907e2de6 LibWeb: Add StereoPannerNode interface 2025-01-18 10:20:41 +01:00
Tim Ledbetter
31532e36a8 LibWeb: Add AudioContext.createMediaElementSource() factory method 2025-01-17 19:04:47 +00:00
Tim Ledbetter
aa39aa50f7 LibWeb: Add MediaElementAudioSourceNode interface 2025-01-17 19:04:47 +00:00
devgianlu
991cb8942d LibWeb: Always return a KeyAlgorithm from RsaHashedKeyAlgorithm
The spec never mentions the possibility for the `hash` member of
`RsaHashedKeyAlgorithm` to be a string, it should be a `KeyAlgorithm`
object containing a `name` string member.

Spec: https://w3c.github.io/webcrypto/#dfn-RsaHashedKeyAlgorithm
2025-01-17 12:43:03 +01:00
devgianlu
999f456ba4 LibWeb: Support RSASSA-PKCS1-v1_5 in WebCryptoAPI 2025-01-17 12:43:03 +01:00
devgianlu
e05ee9d297 LibWeb: Support RSA-PSS in WebCryptoAPI 2025-01-17 12:43:03 +01:00
Timothy Flynn
59a4203cf0 LibWeb: Implement the exclusive <details> accordion
This is a relatively new feature which allows naming <details> groups to
ensure only one <details> element in that group is opened at a time.
2025-01-17 10:13:35 +01:00
Timothy Flynn
1fb1d5fcb9 LibWeb: Update the HTMLDetailsElement attribute change steps
No functional change here, but this contains spec steps to handle the
'name' attribute (not implemented here).
2025-01-17 10:13:35 +01:00
Sam Atkins
b3b9eea986 LibWeb/CSS: Merge RotationStyleValue into TransformationStyleValue
Same again, although rotation is more complicated: `rotate`
is "equivalent to" multiple different transform function depending on
its arguments. So we can parse as one of those instead of the full
`rotate3d()`, but then need to handle this when serializing.
2025-01-17 10:12:39 +01:00
Sam Atkins
03a4ecce19 LibWeb/CSS: Merge TranslationStyleValue into TransformationStyleValue
As with ScaleStyleValue, the serialization is the only unique part of
this class, and we can just move it over.
2025-01-17 10:12:39 +01:00
Sam Atkins
ac15e626dd LibWeb/CSS: Merge ScaleStyleValue into TransformationStyleValue
The only ways this varies from the `scale()` function is with parsing
and serialization. Parsing stays separate, and serialization is done by
telling `TransformationStyleValue` which property it is, and overriding
its normal `to_string()` code for properties other than `transform`.
2025-01-17 10:12:39 +01:00
Sam Atkins
bd5d1b092a LibWeb/CSS: Move TransformationSV -> Transformation code into TSV 2025-01-17 10:12:39 +01:00
Sam Atkins
01d782a5ca LibWeb/CSS: Return TransformationStyleValue values by reference
Avoid copying the vector when we read from it.
2025-01-17 10:12:39 +01:00
Noah Bright
6c6bf322ea LibWeb/WebAudio: Define and partially implement AnalyserNode
https://webaudio.github.io/web-audio-api/#AnalyserNode

Most of the interface is naively implemented. Container types
probably need adjusted (Vector<double> is used for all the processing).
A Fourier Transform is needed, but that's waiting on either a 3rd
party library or a complex number type.

There are lots of simple miscellaneous filters that need to be applied.
It could be reasonable to implement from scratch, supposing that
it can be parallelized. It might be hard to find one library with
everything. Not my call though.

Some additional scaffolding around blocks and render quanta is
probably needed before this is developed much further, which
probably comes in at the level of the AudioNode.

Co-authored-by: Tim Ledbetter <tim.ledbetter@ladybird.org>
2025-01-17 10:11:24 +01:00
aplefull
50445dc9ef LibWeb: Don't add extra gap when placing flex items in reverse order 2025-01-17 10:10:43 +01:00
Shannon Booth
ac9670fb55 LibWeb/HTML: Fix grammar in spec note for error checking serialization
See: https://github.com/whatwg/html/commit/90720ff
2025-01-17 10:08:42 +01:00
Shannon Booth
76397c9ecd LibWeb: Use finalize for cleaning up all navigables
The use of this HashMap looks very spooky, but let's at least use
finalize when cleaning them up on destruction to make things slightly
less dangerous looking.
2025-01-17 10:08:42 +01:00
Timothy Flynn
0c09a099a5 LibWeb: Add missing #include to InputEventsTarget.h
While investigating an issue with Unicode::Segmenter (the result of
which is passed to functions in this file), this missing include was
causing clangd to be unable to find non-virtual implementations.
2025-01-16 23:22:48 +01:00
Tim Ledbetter
d7ff409032 LibWeb: Align OfflineAudioContext constructors with current spec steps 2025-01-16 13:56:18 +00:00
Tim Ledbetter
f01ccf5424 LibWeb: Align AudioContext constructor with current spec steps 2025-01-16 13:56:18 +00:00
Shannon Booth
c33d72bb41 LibWeb/Fetch: Remove FIXME for since fixed spec bug 2025-01-16 01:16:47 +00:00
Tim Ledbetter
3d20587911 LibWeb: Fetch source file when HTMLTrackElement src attribute changes
This commit begins to implement the track processing model. When the
`src` attribute is updated, we now fetch the given source file.
Currently, we always fire an `error` event once fetching is completed,
as we don't support processing the fetched data.
2025-01-15 20:59:18 +01:00