Commit graph

8838 commits

Author SHA1 Message Date
Pavel Shliak
6dfcdaa0d2 LibGfx: Unify bitmap set_pixel() using templates 2024-12-12 15:13:44 -07:00
Pavel Shliak
24b68259b4 LibGfx: Remove unnecessary include 2024-12-12 15:13:44 -07:00
Luke Warlow
fcf6cc27f2 LibWeb: Implement popover beforetoggle and toggle events 2024-12-12 15:10:33 -07:00
Ben Wiederhake
872a6a11a4 WebCrypto: Unspoof correctness of AES-GSM encryption/decryption 2024-12-12 21:48:57 +01:00
Nathan van der Kamp
a276cf2d5e LibWeb: Add PopOverInvokerElement and use it in HTMLButtonElement
The popoverTargetElement seems to be one of the only cases of a
reflected Element? attribute in the HTML spec, the behaviour of which
is specified in section 2.6.1.

Buttons can't actually toggle popovers yet because showing/hiding
popovers is not implemented yet.
2024-12-12 17:11:27 +00:00
Tim Ledbetter
7d2a037d03 LibWeb: Align execute_async_script variable name with the latest spec 2024-12-12 05:16:18 -08:00
sideshowbarker
50e7e9f58d LibWeb: Assign “dir”, “dd”, “dt” default ARIA roles per-spec
Also, import http://wpt.live/html-aam/dir-role.tentative.html (which
provides test/regression coverage for the “dir” change).
2024-12-12 05:13:45 -08:00
sideshowbarker
ccbc436e85 LibWeb: Support the “image” synonym for the “img” ARIA role
Additionally: For “img” elements with empty “alt” attributes, change the
default role to the newer, preferred “none” synonym for the older
“presentation” role; import https://wpt.fyi/results/html-aam/roles.html
(which provides test/regression coverage for these changes).
2024-12-12 05:13:45 -08:00
sideshowbarker
6e24f23aa0 LibWeb: Add support for the “mark” ARIA role 2024-12-12 05:13:45 -08:00
sideshowbarker
96540e9f89 LibWeb: Add support for the “suggestion” ARIA role 2024-12-12 08:53:20 +00:00
Timothy Flynn
68164aa7ec LibWeb: Run the object representation task when the active state changes
Currently, the following JS snippet will hang indefinitely:

    new DOMParser().parseFromString("<object>", "text/html");

Because the document into which the object is inserted is not active. So
the task queued to run the representation steps will never run.

This patch implements the spec steps to rerun the representation steps
when the active state changes, and avoid the hang when the object is
created in an inactive document.
2024-12-11 17:38:31 -07:00
Timothy Flynn
a2419b5f4e LibWeb: Add a document observer to be notified upon becoming active 2024-12-11 17:38:31 -07:00
Timothy Flynn
9a62e33517 LibWeb: Protect document observers from GC during observer invocation
We currently (sometimes) copy the observer map to a vector for iteration
to ensure we are not iterating over the map if the callback happens to
remove the observer. But that list was not protected from GC.

This patch ensures we protect that list, and makes all document observer
notifiers protected from removal during iteration.
2024-12-11 17:38:31 -07:00
sideshowbarker
e49fe384d1 LibWeb: Align default “th” and “td” roles with HTML-AAM spec and tests
This change aligns the default roles for “th” and “td” elements with the
requirements in the HTML-AAM spec, and with the corresponding WPT tests
at https://wpt.fyi/results/html-aam/table-roles.html, and with the
behavior in other engines.

Otherwise, without this change, the default role values for “th” and
“td” elements in some cases don’t match the behavior in other engines,
and don’t match the expected results for the corresponding WPT tests.
2024-12-11 16:55:07 -07:00
sideshowbarker
2d638485a8 LibWeb: Assign “orphaned” li elements the default ARIA role “none”
This change makes Ladybird conform to the current requirements at
https://w3c.github.io/core-aam/#roleMappingComputedRole in the “Core
Accessibility API Mappings” spec for the case of “orphaned” li elements;
that is, any li element which doesn’t have a role=list ancestor.

The core-aam spec requires that in such cases, the li element must not
be assigned the “listitem” role but instead must be treated as if it had
no role at all.
2024-12-11 16:43:55 -07:00
Feng Yu
824e91ffdb LibWeb: Ensure Headers API can handle non-ascii characters
This patch ensure Headers object's associated header list
is ISO-8859-1 encoded when set using `Infra::isomorphic_encode`,
and correctly decoded using `Infra::isomorphic_decode`.

Follow-up of https://github.com/LadybirdBrowser/ladybird/pull/1893
2024-12-11 16:40:36 -07:00
Lucas CHOLLET
5e62f548db LibWeb/CSS: Serialize CSSColor without relying on RGB
This gives us 140 subtests pass in:
css/css-color/parsing/color-valid-color-function.html
2024-12-11 16:37:22 -07:00
Feng Yu
9c243caac4 LibWeb: Add statusText validation for Response constructor
Implemented validation to ensure `statusText` matches the
`reason-phrase` token production.

This change fixes a WPT subtest which I have imported.
2024-12-11 16:34:10 -07:00
Pavel Shliak
d5cdda0b40 LibWeb: Load external scripts in SVG 2024-12-11 16:29:42 -07:00
Lucas CHOLLET
dd283768a8 LibWeb/CSS: Allow none values in the color() function 2024-12-11 22:38:14 +00:00
Simek
e7ef8da7f3 LibWeb/ARIA: Add missing structure roles 2024-12-11 10:32:40 -08:00
Jelle Raaijmakers
d14fd8a6c8 LibWeb: Update spec steps in Selection
Resolves two FIXMEs in `::collapse()` and `::select_all_children()`.
2024-12-11 19:11:13 +01:00
Timothy Flynn
943ec820fc LibWeb: Avoid dereferencing an empty optional URL
Here, "null" means the empty optional. We don't need to also check if
the URL is valid; the url will be null if it was originally invalid.
2024-12-11 09:33:46 -08:00
Timothy Flynn
0bc55424c8 LibJS: Fix variable reference in CreateDateTimeFormat
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/8acd353
2024-12-11 08:43:54 -08:00
Timothy Flynn
002b0ea7c7 LibJS: Remove dead code from ZonedDateTime.prototype.toLocaleString
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/065cf94
2024-12-11 08:43:54 -08:00
Timothy Flynn
b9ac4557d6 LibJS: Change variable name of parsed time zone offset
This is an editorial change in the Temporal proposal. See:
https://github.com/tc39/proposal-temporal/commit/30d17d3
2024-12-11 08:43:54 -08:00
Shannon Booth
99073c0561 LibWeb: Move ad hoc CallbackType helper method to CallbackType header
Abstract operations of a stream does not seem like the correct home for
this function.
2024-12-11 15:11:21 +01:00
Shannon Booth
93f258deb7 LibWeb/Streams: Do not expose some non-standard functions in header
These are non-standard and only needed internally as implementation
details in the implementation of AbstractOperations, so let's keep them
at a file-local level.
2024-12-11 15:11:21 +01:00
Shannon Booth
19bbfb023a LibWeb/Streams: Move "set up transform stream" to TransformStream
This is not marked as an AO in the spec, and is a publically exported
API exposed on TransformStream.
2024-12-11 15:11:21 +01:00
Shannon Booth
3f572d9ab7 LibWeb/Streams: Move ReadableStream functions out of AbstractOperations
These are not defined in the abstract operations section of the spec and
are the publically exported Stream APIs exposed on ReadableStream.
2024-12-11 15:11:21 +01:00
Shannon Booth
c6d0f87bb7 LibWeb/Streams: Put algorithm definitions in a separate header file
To solve a future cyclic dependency problem.
2024-12-11 15:11:21 +01:00
Shannon Booth
f110edebd1 LibWeb/HTML: Encoding parse a URL when setting a href URL
Fixes many WPT encoding regression tests which regressed in
fe891727dc.
2024-12-11 09:48:17 +01:00
Shannon Booth
4b069344e0 LibWeb/HTML: Fix crash in window open steps on empty URL string 2024-12-10 17:16:07 -08:00
rmg-x
e4fb25bf63 LibGfx: Redirect PNG errors and warnings to our own logging functions
Before, libpng would use its own internal logging mechanism to print
non-fatal errors and warnings to stdout/stderr. This made it confusing
when trying to search the Ladybird codebase for those messages as they
didn't exist.

This commit uses `png_set_error_fn` from libpng to redirect those
messages to our own custom logging functions instead.
2024-12-10 11:58:58 -07:00
Timothy Flynn
d835a00bee LibWeb: Use Fetch to retrieve HTMLObjectElement data URLs
This eliminates the use of ResourceLoader in HTMLObjectElement. The spec
steps around fetching have been slightly updated since we've last looked
at this, so those are updated here.

Regarding the text test change: we cannot rely on the data: URL being
fetched synchronously. It will occur on a deferred task now. This does
match the behavior of other browsers, as they also will not have run the
fallback representation steps as of DOMContentLoaded.
2024-12-10 10:37:01 -08:00
Timothy Flynn
fe891727dc LibWeb: Use correct URL parsing methods throughout LibWeb
There are essentially 3 URL parsing AOs defined by the spec:
1. Parse a URL
2. Encoding parse a URL
3. Encoding parse a URL and serialize the result

Further, these are replicated between the Document and the ESO.

This patch defines these methods in accordance with the spec and updates
existing users to invoke the correct method. In places where the correct
method is ambiguous, we use the encoding parser to preserve existing ad-
hoc behavior.
2024-12-10 10:37:01 -08:00
Jelle Raaijmakers
495006ddb5 LibWeb: Implement document.execCommand('insertLinebreak') 2024-12-10 19:34:38 +01:00
Tim Ledbetter
a44b18236c LibWeb: Add an Internals.headless attribute
This returns true if the browser is running in headless mode.
2024-12-10 10:31:47 -08:00
Tim Ledbetter
e764df15eb LibWebView+WebContent: Inform WebContent process if browser is headless 2024-12-10 10:31:47 -08:00
Timothy Flynn
520bf6c9be LibWeb: Return a better error message for invalid byte strings
We are currently returning LibJS's invalid code point message, but not
formatting it with the bad value. So we get something like:

    Unhandled JavaScript exception: [TypeError] Invalid code point {},
    must be an integer no less than 0 and no greater than 0x10FFFF

So not only is the error unformatted, but it's inaccurate; in this case,
the byte cannot be larger than 255.
2024-12-10 10:30:14 -08:00
Simek
a64432ec13 LibWeb/ARIA: Add missing menuitemradio widget role 2024-12-10 07:41:10 -08:00
Luke Wilde
d2acf32aae LibWeb: Register Wasm memory grow hook in constructor of Memory objects
Previously it would only register the hook for JavaScript constructed
Memory objects. This allows Ruffle to load again.
2024-12-10 15:54:20 +01:00
Luke Wilde
023c3aa5b0 LibWeb: Respect subarrays in Crypto#getRandomBytes
It is the responsibility of code that deals with TypedArrays to apply
the byte offset and byte length. Not doing this caused Unity Web to
crash, as they call getRandomValues with views into their full main
memory. Previously, it would fill their entire memory of about 33.5 MB
with random bytes.
2024-12-10 06:44:00 -08:00
Jelle Raaijmakers
30ec8c1d4d LibWeb: Implement "delete the selection" for the editing API 2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
fd949ee3dd LibWeb: Only set selection focus if an associated DOM node was found
The relation from a paintable to a DOM node is not always set.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
15e3db5932 LibWeb: Add internals.mouseDown(x, y)
This triggers a mouse button press without the up event, allowing us to
e.g. simulate a selection by moving the mouse while keeping the button
depressed.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
bfb87b24a3 LibWeb: Use verify_cast in insertParagraph command
No functional changes.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
1c55153d43 LibWeb: Refactor "editable" and "editing host" concepts
The DOM spec defines what it means for an element to be an "editing
host", and the Editing spec does the same for the "editable" concept.
Replace our `Node::is_editable()` implementation with these
spec-compliant algorithms.

An editing host is an element that has the properties to make its
contents effectively editable. Editable elements are descendants of an
editing host. Concepts like the inheritable contenteditable attribute
are propagated through the editable algorithm.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
f88c13a58c LibWeb: Prevent null deref in collapsed whitespace check
The spec even warned us about the reference potentially being null.
2024-12-10 14:54:19 +01:00
Jelle Raaijmakers
d5143db081 LibWeb: Skip node trees outside of range in insertParagraph
Instead of recursively iterating all descendants of the common ancestor
of the new line range that are not contained by that range, skip the
entire node tree as soon as we determine they're not.
2024-12-10 14:54:19 +01:00