Commit graph

66798 commits

Author SHA1 Message Date
Luke Wilde
f3f51f2547 LibWebView: Consider wss a secure scheme for Secure cookies 2025-01-21 21:36:05 +01:00
Aliaksandr Kalenik
c50e89bb73 LibWeb: Don't include changed attribute twice in changed_properties
Changed attribute name is always added into this list right before
`invalidate_style()` is called.
2025-01-21 21:07:47 +01:00
Aliaksandr Kalenik
3c41bdbf92 LibWeb: Optimize style invalidation for presentational hint attributes
Use invalidation sets for presentational hint attribute invalidation
instead of falling back to full descendants and siblings invalidation.
The only difference for presentational hint attributes is that we always
have to invalidate the style of element itself.
2025-01-21 21:07:47 +01:00
Gingeh
f3f1db7725 LibWeb: Cache the margin box rect for floating boxes 2025-01-21 21:06:55 +01:00
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
Shannon Booth
70df8122b1 LibWeb/Storage: Add a storage key getter that takes a URL::Origin
When we serialize blob URL entries we do not serialize the entire
environment settings object and only use it's origin. To allow
a Blob URL entry to access its relevant storage key, add a getter
that simply takes an origin.
2025-01-21 19:22:07 +00:00
Shannon Booth
ca3d9d9ee0 LibURL+LibWeb+LibIPC: Represent blob URL entry's object using structs
Instead of just putting in members directly, wrap them up in structs
which represent what a URL blob entry is meant to hold per the spec.
This makes more obvious what this is meant to represent, such as the
ByteBuffer being used to represent the bytes behind a Blob.

This also allows us to use a stronger type for a function that needs
to return a Blob URL entry's object.
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
Jelle Raaijmakers
2cee6aeba3 LibWeb: Use as_if in Editing API where useful
This arguably improves readability in a couple of places. No functional
changes.
2025-01-21 17:50:13 +00:00
Sam Atkins
d40ccb97ec LibWeb/HTML: Update Navigable::choose_a_navigable() to latest spec
This corresponds to part of https://github.com/whatwg/html/pull/10818
2025-01-21 18:17:18 +01:00
Sam Atkins
6f8d3014ea LibWeb/HTML: Update Document::create_and_initialize() to latest spec
This corresponds to part of https://github.com/whatwg/html/pull/10818
2025-01-21 18:17:18 +01:00
Sam Atkins
9a7ce901b7 LibURL: Gracefully handle a host having no public suffix
Specifically, after implementing some recent spec changes to navigables,
we end up calling `get_public_suffix("localhost")` here, which returns
OptionalNone. This would previously crash.

Our get_public_suffix() seems a little incorrect. From the spec:
> If no rules match, the prevailing rule is "*".
> https://github.com/publicsuffix/list/wiki/Format#algorithm

However, ours returns an empty Optional in that case. To avoid breaking
other users of it, this patch modifies Host's uses of it, rather than
the function itself.
2025-01-21 18:17:18 +01:00
Sam Atkins
c073127b99 LibWeb/DOM: Return Document's Origin by reference
We don't want to have to copy these unnecessarily.
2025-01-21 18:17:18 +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
Andreas Kling
34a8f51eb8 LibGC: Add ability to construct RootVector<T> from a span of T 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
5cc9a5802d LibWeb+UI: Add internals API to set browser 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
Timothy Flynn
b64a355a30 LibJS: Remove support for the "assert" keyword for import attributes
This was removed from the spec some time ago. See:
https://github.com/tc39/proposal-import-attributes/commit/14286bb
2025-01-21 14:58:32 +01:00
Timothy Flynn
47ba231a9b LibJS: Do not consume "with" tokens in import statements as identifiers
The "with" statement is its own token (TokenType::With), and thus would
fail to parse as an identifier. We've already asserted that the token
we are parsing is "with" or "assert", so just consume it.
2025-01-21 14:58:32 +01:00
Timothy Flynn
2c3077d929 LibJS: Implement InnerModuleLoading as a free function
It is currently implemented as a member of CyclicModule. However, as the
spec indicates, this must be invokable with non-CyclicModule modules. In
several of the call sites, we are blindly casting to a CyclicModule;
this will fail for e.g. JSON modules.
2025-01-21 14:58:32 +01:00
Timothy Flynn
049109452e LibJS: Do not attempt to link modules which have failed to load
Linking a module has assertions about the module's state, namely that
the state is not "new". The state remains "new" if loading the module
has failed. See: https://tc39.es/ecma262/#figure-module-graph-missing

    In any case, this exception causes a loading failure, which results
    in A's [[Status]] remaining new.

So we must propagate that failure, instead of blindly moving on to the
linking steps.
2025-01-21 14:58:32 +01:00
Timothy Flynn
7d420bbd3d LibJS: Update the noted grammar for ImportDeclaration 2025-01-21 14:58:32 +01:00
Timothy Flynn
263fd9b7c6 LibJS: Add missing spec prose to FinishLoadingImportedModule 2025-01-21 14:58:32 +01:00
Timothy Flynn
fc20e61e72 AK: Introduce an as_if<OutputType>() cast
We currently have a fair amount of code of the form:

    if (is<Child>(parent)) {
        auto& child = static_cast<Child&>(parent);

        if (child.foo()) {
        }
    }

This new cast allows us to instead write code of the form:

    if (auto* child = as_if<Child>(parent); child && child->foo()) {
    }

N.B. The name "as_if" was chosen because we are considering renaming
verify_cast to "as".

Co-authored-by: Tim Ledbetter <tim.ledbetter@ladybird.org>
2025-01-21 14:58:32 +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
Rok Povsic
026fc6c1ca UI/Qt: Add '.com' to the URL if CTRL is held while pressing return 2025-01-20 19:21:56 +00: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
mikiubo
cd576e594d LibXml: Notify listener when doctype is parsed 2025-01-20 14:48:19 +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