Commit graph

4446 commits

Author SHA1 Message Date
Shannon Booth
00cef330ef LibWeb: Partition Blob URL fetches by Storage Key
This was a security mechanism introduced in the fetch spec, with
supporting AOs added to the FileAPI spec.
2025-01-21 19:22:07 +00:00
Tim Ledbetter
a0b0e91d4f LibWeb: Disallow Editing API calls on non-HTML documents
This is not directly mentioned in the Editing API spec, but all major
browsers do this and there is a WPT for this behavior.
2025-01-21 19:08:37 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Andreas Kling
a0b44ff5e7 LibWeb: Iterate over a copy of associated form controls in form.reset()
DOM structure may change during reset algorithm invocation, which may
lead to form controls being unregistered.
2025-01-21 17:02:51 +01:00
InvalidUsernameException
6a798732b9 Tests: Add tests that verify object-fit and -position with zoom 2025-01-21 16:05:12 +01:00
InvalidUsernameException
f39433d6b0 LibWeb: Calculate image size in CSS pixels
Previously most of the calculations for `object-fit` and
`object-position` were based on device pixels, meaning that images would
render differently based on zoom and DPI settings. Instead those
calculations now use css pixels and only the final draw-call is based
on device-pixels.
2025-01-21 16:05:12 +01:00
InvalidUsernameException
de71eb9b13 LibWeb: Accept TableWrapper as containing block for abspos items
When an element is displayed as table, an anonymous table wrapper box
needs to be created for it. Among others, the position property of the
table element is then applied to the anonymous table wrapper box
instead. If the table happens to be positioned absolutely, the table
wrapper box may become the containing block for absolutely positioned
elements inside the table.

In the original code however, anonymous layout nodes were excluded from
becoming the containing block for an absolutely positioned element.
Because of this, the containing block was calculated to be the first
suitable parent block of the table wrapper box.

This incorrect containing block would result in a crash later on when
trying to size the absolutely positioned element inside the table. To
prevent this crash, the anonymous table wrapper box is now allowed to
become the containing block for absolutely positioned elements inside
a table.

The definition of containing block for an absolutely positioned element
in the spec does not mention anything about skipping anonymous boxes.
Additionally the rules for absolute positioning of tables
(https://www.w3.org/TR/css-tables-3/#abspos-boxes-in-table-root) imply
that a table wrapper box is indeed able to be the containing block for
absolutely positioned elements.
2025-01-21 15:24:05 +01:00
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
Gingeh
bf36d829ef LibWeb: Only reload link on rel change if it became a stylesheet 2025-01-20 18:21:20 +01:00
mikiubo
cd576e594d LibXml: Notify listener when doctype is parsed 2025-01-20 14:48:19 +01: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
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
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
b798b1c07d Tests: Add some tests for partial layout tree updates 2025-01-18 21:01:01 +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
Timothy Flynn
26c2484c2f LibJS: Implement the AsyncDisposableStack interface
This is very similar to the DisposableStack interface, except disposal
of resources is promise-based.
2025-01-17 20:46:32 +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
devgianlu
3eeb35e787 LibCrypto: Implement RSA_PSS_EMSA with OpenSSL 2025-01-17 12:43:03 +01:00
Ali Mohammad Pur
cce000d57c LibRegex: Don't repeat the same fork again
If some state has already been tried, skip over it as it would never
lead to a match regardless.
This fixes performance/memory issues in cases like
/(a+)+b/.exec("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
or
/(a|a?)+b/...

Fixes #2622.
2025-01-17 10:13:51 +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
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
Tim Ledbetter
ded19eaab8 Tests: Convert existing text test to crash test 2025-01-17 09:08:15 +01:00
Timothy Flynn
e6b7c8cde2 LibUnicode: Consistently reject out-of-bounds segmenter indices
In the UTF-8 implementation, this prevents out-of-bounds access of the
underlying text data, as the ICU macro would essentially do something
akin to `text[text.length()]`.

The UTF-16 implementation already checks for out-of-bounds, but would
previously return 0. We now return an empty Optional in both impls. This
doesn't affect LibJS (the user of the UTF-16 impl), as it already does
bounds checking before invoking LibUnicode APIs.
2025-01-16 23:22:48 +01:00
Tim Ledbetter
f01ccf5424 LibWeb: Align AudioContext constructor with current spec steps 2025-01-16 13:56:18 +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
Shannon Booth
51102254b5 LibWeb/HTML: Scroll to the fragment before loading the document
Otherwise nowhere ends up scrolling to the fragment specified by the
fragment in document's URL. This fixes ladybird scrolling to the
correct location in the document when navigating to a link that
has a fragment, e.g:

https://html.spec.whatwg.org/multipage/browsing-the-web.html#try-to-scroll-to-the-fragment

As well as use of the :target selector.
2025-01-15 12:43:48 +00:00
Shannon Booth
e74ca82083 LibWeb/XHR: Isomorphic decode accessing XMLHttpRequest response headers
Fixes a crash on:

https://wpt.live/html/browsers/browsing-the-web/navigating-across-documents/refresh/subresource.any.html
2025-01-15 12:35:56 +00:00
Shannon Booth
7b637b1eee LibWeb/HTML: Only use maxlength <input> attribute when applicable 2025-01-15 11:41:39 +01:00
stelar7
439245b14a LibWeb: Import WPT tests for IDBKeyRange 2025-01-14 23:46:09 +01:00
Psychpsyo
8cd2fe3d08 LibWeb: Fix CSS clip-path ignoring scroll position 2025-01-13 20:03:28 -07:00
Aliaksandr Kalenik
98691810b1 LibWeb: Fix insert/delete rule invalidation for adopted style sheets
Invalidation for adopted style sheets was broken because we had an
assumption that "active" style sheet is always attached to
StyleSheetList which is not true for adopted style sheets. This change
addresses that by keeping track of all documents/shadow roots that own
a style sheet and notifying them about invalidation instead of going
through the StyleSheetList.
2025-01-13 23:03:07 +01:00
devgianlu
a59b48cffc LibCrypto+LibWeb: Replace RSA_OAEP-EME implementation
This replaces the old `OAEP` implementation with one backed by OpenSSL.
The changes also include some added modularity to the RSA class by
making the `RSA_EME` and `RSA_EMSE` for encryption/decryption and
signing/verifying respectively.
2025-01-13 17:00:18 +01:00
devgianlu
70bc26e32a LibCrypto+LibTLS: Replace RSA_PKCS1-EMSA implementation
This commit replaces the old implementation of `EMSA_PKCS1_V1_5` with
one backed by OpenSSL. In doing so, the `sign` and `verify` methods of
RSA have been modified to behave like expected and not just be
encryption and decryption.

I was not able to split this commit because the changes to `verify` and
`sign` break pretty much everything.
2025-01-13 17:00:18 +01:00
devgianlu
4b832b67fb LibWeb: Add RSA-OAEP WPT tests
This serve as a regression check for the next commits
2025-01-13 17:00:18 +01:00
devgianlu
0fc02d4d00 LibCrypto: Make PKSystem methods return a ByteBuffer directly
It used to be that the caller would supply a buffer to write the output
to. This created an anti-pattern in multiple places where the caller
would allocate a `ByteBuffer` and then use `.bytes()` to provide it to
the `PKSystem` method. Then the callee would resize the output buffer
and reassign it, but because the resize was on `Bytes` and not on
`ByteBuffer`, the caller using the latter would cause a bug.

Additionally, in pretty much all cases the buffer was pre-allocated
shortly before.
2025-01-13 17:00:18 +01:00
Noah Bright
18b4dc2153 LibWeb: Update add_libweb_test.py to support Screenshot, Ref, and Layout
Changed the usage from `add_libweb_test.py test_name.html` to
`add_libweb_test.py test_name.html test_type` with no default,
and supports automatically generating input/output files in the
right directories for test types Screenshot, Text, Ref, and Layout.

Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-01-13 14:25:26 +00:00
Psychpsyo
bb5d1ac4a3 LibWeb: Fix CSS tag seletor case sensitivity for SVG elements
They can appear in HTML documents but must not be matched
according to the HTML spec.
2025-01-13 12:11:34 +00:00
Psychpsyo
7757df5bb5 LibWeb: Implement CSS 'isolation' property 2025-01-13 11:07:55 +00:00