Commit graph

36110 commits

Author SHA1 Message Date
Timothy Flynn
04648d93d4 LibWeb: Do not store resize observer entries in a plain vector
This is not safe from GC. Unfortunately we cannot add a test to capture
the issue, as the allocation which may trigger GC is internal and not
observable from JS.
2024-11-01 00:35:54 +01:00
Timothy Flynn
be1d400369 LibWebView: Add a browser flag to collect garbage after each allocation 2024-11-01 00:35:54 +01:00
stelar7
171af8de33 LibWeb: Implement AES-GCM.generateKey 2024-10-31 23:33:56 +01:00
stelar7
196d99352a LibWeb: Stub out AES-GCM.decrypt 2024-10-31 23:33:56 +01:00
stelar7
2672acf9c4 LibWeb: Stub out AES-GCM.encrypt 2024-10-31 23:33:56 +01:00
stelar7
3dd80d2a6e LibWeb: Implement AES-GCM.exportKey 2024-10-31 23:33:56 +01:00
stelar7
e53b3f5fb1 LibWeb: Implement AES-GCM.importKey 2024-10-31 23:33:56 +01:00
stelar7
80d37a6def LibWeb: Implement AES-GCM.getKeyLength 2024-10-31 23:33:56 +01:00
Jonne Ransijn
a733e2a31c LibWeb: Fix use-after-move in URLSearchParams::update
This was previously still valid since the `Optional<String>` move
constructor copied its input, but since the move is now destructive,
the code no longer works.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
a70ed6a2ad AK: Add OptionalBase class to reduce code duplication
Using CRTP and `static_cast`s because "deducing this" is
still not fully supported yet.
2024-10-31 23:26:22 +01:00
Sam Atkins
f80fca2dee LibWeb/HTML: Update legacy color parsing steps to match spec
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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-10-31 19:23:23 +00:00
Aliaksandr Kalenik
46db0febf7 LibUnicode+LibWeb: Move should_continue_beyond_word helper in Segmenter 2024-10-31 19:04:07 +00:00
Aliaksandr Kalenik
fb23fd328b LibWeb: Simplify empty string allocation in handle_delete() 2024-10-31 19:04:07 +00:00
Aliaksandr Kalenik
bdaac6ce48 LibWeb: Bring back FIXME about using UTF-16 length in handle_insert()
It was accidentally removed in a8077f79cc
2024-10-31 19:04:07 +00:00
Aliaksandr Kalenik
54d7314bd9 LibWeb: Remove unnecessary double cast in PaintableFragment 2024-10-31 19:04:07 +00:00
Aliaksandr Kalenik
835181e9d8 LibWeb: Move constructor and visit_edges in .cpp for EditingHostManager 2024-10-31 19:04:07 +00:00
Aliaksandr Kalenik
3ac7ba7f58 LibWeb: Fix alphabetical sorting in LibWeb/Forward.h 2024-10-31 19:04:07 +00:00
Timothy Flynn
d188aaf288 LibWeb: Protect animation frame callbacks from GC while they execute
Stealing the callbacks from the AnimationFrameCallbackDriver made them
no longer safe from GC. Continue to store them on the class until we
have finished their execution.
2024-10-31 15:37:47 +01:00
stelar7
f6991a2955 LibWeb: Bring performance.now() closer to spec 2024-10-31 14:10:13 +01:00
Sam Atkins
f31c18756b LibWeb: Update spec comments using "Type(Foo)" -> "is a Foo" 2024-10-31 14:01:51 +01:00
Sam Atkins
00e613c7df LibWeb/HTML: Guard showModal() with fully active check
This corresponds to this spec change:
https://github.com/whatwg/html/pull/10705

(We don't implement showPopover() yet.)
2024-10-31 14:01:15 +01:00
Sergei Azarkin
2199fde5a9 LibWeb: Support shorthands when setting style attribute
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
Better support for CSS shorthands when setting the style attribute. This
improves some tests in WPT /css/css-align/default-alignment/*shorthand.
When setting the style attribute in JS via element.style = '..' or the
setAttribute method, shorthand properties were not expanded to longhand
properties.
2024-10-31 12:23:03 +00:00
Sam Atkins
99c66f49fb LibJS: Update console spec's use of "Type()" -> "is a"
Corresponds to the change in this PR:
https://github.com/whatwg/console/pull/241
2024-10-31 08:16:19 -04:00
Gingeh
3467076dbc LibWeb+LibGfx: Keep path properties when cloning and implement fill-rule 2024-10-31 10:30:24 +00:00
Gingeh
a7e83c38ee LibWeb: Implement missing basic shapes 2024-10-31 10:30:24 +00:00
Jelle Raaijmakers
76e638b4ca LibWeb: Use right interface for custom SVG and MathML elements
The DOM spec gets overridden by both the SVG2 and MathML core specs in
that unknown elements should not inherit DOM::Element, but
SVG::SVGElement and MathML::MathMLElement respectively.
2024-10-31 09:58:59 +00:00
Jelle Raaijmakers
84fe8d675b LibWeb: Implement HTMLOrSVGElement.nonce
There are two FIXMEs remaining that depend on a functional
PolicyContainer, which we ignore for now and always behave like a CSP is
set.
2024-10-31 10:46:21 +01:00
Jelle Raaijmakers
8dcab69779 LibWeb: Remove unused includes from HTMLElement and SVGElement 2024-10-31 10:46:21 +01:00
Jelle Raaijmakers
5f84c2c3af LibWeb: Factor out HTMLOrSVGElement
This is a mixin in the IDL, so let's treat it as a mixin in our code and
let both SVGElement and MathMLElement reuse the implementations that we
wrote for HTMLElement.
2024-10-31 10:46:21 +01:00
stelar7
f9b511a7d6 LibWeb: Implement X25519.exportKey 2024-10-31 09:52:24 +01:00
stelar7
b281fa2b24 LibWeb: Implement X25519.importKey 2024-10-31 09:52:24 +01:00
stelar7
5e98c3f763 LibTLS: Add support for parsing curve25519 and curve448 2024-10-31 09:52:24 +01:00
stelar7
944f00c489 LibWeb: Implement X25519.generateKey 2024-10-31 09:52:24 +01:00
stelar7
8c5e5adc8a LibWeb: Implement X25519.deriveBits 2024-10-31 09:52:24 +01:00
Christoffer Sandberg
84c881fc66 LibJS: Count code-points instead of bytes for syntax highlight
This fixes issue #1847, a crash on view-source
for https://chalmers.se
2024-10-31 08:43:14 +00:00
Pavel Shliak
c78c706422 WebAudio: Initialize BiquadFilterNode properly
That helps to pass WPT tests
under webaudio/the-audio-api/the-biquadfilternode-interface/ctor-biquadfilter.html
2024-10-31 09:18:54 +01:00
sideshowbarker
51912bf0da Documentation: Make updates to align better with new issue template 2024-10-31 09:18:08 +01:00
Gingeh
4ecf56cadf LibWeb: Allow calculated values in css filters 2024-10-31 08:19:46 +01:00
stelar7
af3383df09 LibWeb: Implement AES-CTR.decrypt 2024-10-31 08:15:00 +01:00
stelar7
74403d7f1e LibWeb: Implement AES-CTR.encrypt 2024-10-31 08:15:00 +01:00
stelar7
55ef1c758a LibWeb: Implement AES-CTR.generateKey 2024-10-31 08:15:00 +01:00
stelar7
4b2120d919 LibWeb: Implement AES-CTR.exportKey 2024-10-31 08:15:00 +01:00
stelar7
030cbef532 LibWeb: Implement AES-CTR.getKeyLength 2024-10-31 08:15:00 +01:00
stelar7
0864436383 LibWeb: Implement AES-CTR.importKey 2024-10-31 08:15:00 +01:00
Tim Ledbetter
21a32e4b6d LibWeb: Don't crash when parsing large floating point number values
Previously, attempting to parse a floating point number with an integer
part larger than `(2 ^ 31) - 1` would cause the browser to crash. We now
avoid this by converting the integer part of the number to a `double`
rather than an `i32`.
2024-10-31 08:05:25 +01:00
Timothy Flynn
f064c6e930 LibWeb+WebContent+WebDriver: Make the screenshot endpoints asynchronous
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
These were the last WebDriver endpoints spinning the event loop.
2024-10-31 02:39:36 +00:00
Timothy Flynn
d9e5ae66a7 LibWeb: Allocate AnimationFrameCallbackDriver on the JS heap
This avoids needing to creating root handles for each heap-allocated
object captured in the animation callback. An upcoming commit would add
several of these.
2024-10-31 02:39:36 +00:00
justus2510
144907f5bd LibGfx: Apply Exif orientation for PNG images
Fixes wpt/png/exif-chunk.html.

At some point there should probably be some mechanism to handle this
outside of the individual decoder plugins. The TIFF decoder seems to
have its own version of this, and as far as I can tell, the JPEG decoder
doesn't handle this at all, even though that's probably the most common
use case for Exif orientations. :^)
2024-10-31 02:18:08 +00:00
sideshowbarker
1b4e609eb2 LibWeb: Expose Node::accessible_name via window.internals
This adds window.internals.getComputedLabel, for exposing
Node::accessible_name (for accessibility-testing purposes).
2024-10-31 01:16:47 +00:00
sideshowbarker
65bda00274 LibWeb: Support getting accessible name for labeled form controls
This change implements the “C: Embedded Control” step at
https://w3c.github.io/accname/#step2C in the “Accessible Name and
Description Computation” spec — to compute the accessible names for
labeled form controls.
2024-10-31 01:16:47 +00:00
Timothy Flynn
e8cd3749c8 LibWeb: Implement WebDriver shadow references according to the spec
Similar to commit a9c858fc78, this patch
implements the WebDriver spec concept of shadow references grouped
according to their browsing context groups.
2024-10-31 00:42:29 +00:00
Timothy Flynn
ad9d623664 WebContent+WebDriver: Make the element locator endpoints asynchronous
We currently spin the event loop to wait for the specified element to
become available. As we've seen with other endpoints, this can result
in dead locks if another web component also spins the event loop.

This patch makes the locator implementations asynchronous.
2024-10-31 00:42:29 +00:00
Jelle Raaijmakers
a0ee86db04 LibWeb: Prevent painting grid items twice as a stacking context
We paint grid item nodes as a stacking context when they have no
`z-index` style set. However, a grid item could already have a stacking
context established - for example, when the `filter` style is applied.
This causes these nodes to be drawn twice.

Skip painting grid item nodes if a stacking context is already present.
2024-10-31 00:59:32 +01:00
Jelle Raaijmakers
185335ac63 LibWeb: Remove superfluous VERIFY from StackingContext
We just checked if it's an SVG box, let's not do it again.
2024-10-31 00:59:32 +01:00
Sam Atkins
760943d584 LibWeb/CSS: Correct matching of calc() against <number-percentage>
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 seems to have vanished from the spec, but in any case, we still
need it. Without this change we erroneously thought that calculations
that match <percentage> did not match <number-percentage>.
2024-10-30 20:58:16 +01:00
Shannon Booth
797b0d0f43 LibJS+LibWeb: Remove remaining use and reference to SafeFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
716e86f042 LibJS: Use HeapFunction for async body closure in Array.fromAsync 2024-10-30 20:55:45 +01:00
Shannon Booth
e6d1123ce8 LibWeb: Make ResourceLoader callbacks HeapFunctions 2024-10-30 20:55:45 +01:00
Shannon Booth
1c18b900e2 LibWeb: Port EventLoop::spin_XXX to HeapFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
29cea5bd24 LibWeb: Make EventLoopPlugin::deferred_invoke take a HeapFunction 2024-10-30 20:55:45 +01:00
Shannon Booth
7487a782db LibWeb: Use HeapFunction for EventLoopPlugin::spin_until 2024-10-30 20:55:45 +01:00
Shannon Booth
de1a805898 LibWeb: Use HeapFunction for Platform::Timer 2024-10-30 20:55:45 +01:00
Shannon Booth
ede3c91688 LibWeb: Make Platform::Timer GC-allocated
This will allow us to remove the use of SafeFunction in it's
implementation. This requires a fair amount of plumbing to wire up the
GC heap to the appropriate places in order to create the timers.
2024-10-30 20:55:45 +01:00
Shannon Booth
e44702f090 LibWeb: Construct ResourceLoader with a GC Heap
This will allow us to easily make use of HeapFunctions instead of
SafeFunction for all of the callbacks in ResourceLoader.
2024-10-30 20:55:45 +01:00
Aliaksandr Kalenik
a8077f79cc LibWeb: Separate text control input events handling from contenteditable
This input event handling change is intended to address the following
design issues:
- Having `DOM::Position` is unnecessary complexity when `Selection`
  exists because caret position could be described by the selection
  object with a collapsed state. Before this change, we had to
  synchronize those whenever one of them was modified, and there were
  already bugs caused by that, i.e., caret position was not changed when
  selection offset was modified from the JS side.
- Selection API exposes selection offset within `<textarea>` and
  `<input>`, which is not supposed to happen. These objects should
  manage their selection state by themselves and have selection offset
  even when they are not displayed.
- `EventHandler` looks only at `DOM::Text` owned by `DOM::Position`
  while doing text manipulations. It works fine for `<input>` and
  `<textarea>`, but `contenteditable` needs to consider all text
  descendant text nodes; i.e., if the cursor is moved outside of
  `DOM::Text`, we need to look for an adjacent text node to move the
  cursor there.

With this change, `EventHandler` no longer does direct manipulations on
caret position or text content, but instead delegates them to the active
`InputEventsTarget`, which could be either
`FormAssociatedTextControlElement` (for `<input>` and `<textarea>`) or
`EditingHostManager` (for `contenteditable`). The `Selection` object is
used to manage both selection and caret position for `contenteditable`,
and text control elements manage their own selection state that is not
exposed by Selection API.

This change improves text editing on Discord, as now we don't have to
refocus the `contenteditable` element after character input. The problem
was that selection manipulations from the JS side were not propagated
to `DOM::Position`.

I expect this change to make future correctness improvements for
`contenteditable` (and `designMode`) easier, as now it's decoupled from
`<input>` and `<textarea>` and separated from `EventHandler`, which is
quite a busy file.
2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
380907cd48 LibWeb: Allow TextCursor hit-testing mode select empty contenteditable 2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
20852443d3 LibWeb: Clamp end offset in CharacterData::replace_data()
Makes this method to not fail if updating of start offset (which happens
before update of the end offset) already moved end offset to the end of
string on the following step:

> 1. If range’s root is not equal to node’s root, or if bp is after the
     range’s end, set range’s end to bp.
2024-10-30 19:29:56 +01:00
Aliaksandr Kalenik
da26941b50 LibWeb: Use cached word segmenter for word selection in EventHandler 2024-10-30 19:29:56 +01:00
Sam Atkins
51fc87bc1b LibWeb/CSS: Return 0 from CSSRule.type for non-spec types
We use the CSSRule::Type enum for identifying the type of a CSSRule, but
the spec requires that only some of these types are exposed via the
`type` attribute. For the rest, we're required to return 0, so let's do
so. :^)
2024-10-30 17:30:58 +01:00
Pavel Shliak
4998385c7a LibAudio: Initialize GainNode properly
That helps to pass WPT tests
under /webaudio/the-audio-api/the-gainnode-interface/ctor-gain.html
2024-10-30 17:30:51 +01:00
Aliaksandr Kalenik
04289fe24e LibWeb: Remove usage of math functions from std namespace
Fixes compilation error with clang from Homebrew introduced in
https://github.com/LadybirdBrowser/ladybird/pull/1962
2024-10-30 17:10:31 +01:00
Florian Cramer
df7cac539e LibXML: Set the doctype when parsing via Parser::parse_with_listener
This fixes at least one WPT test under /domparsing
2024-10-30 14:53:36 +01:00
Gingeh
bd25d0b1b4 LibWeb: Parse drop-shadow filter with missing or starting color
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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-10-30 12:41:02 +01:00
Pavel Shliak
0e9c865805 LibWeb: Remove variable self-assignment 2024-10-30 07:40:24 -04:00
Andreas Kling
3180df3337 LibJS: Parse dates like "Tuesday, October 29, 2024, 18:00 UTC"
This format is used on https://jetbrains.com/
2024-10-30 10:47:48 +01:00
Khaled Lakehal
14e1e55319 LibWeb: Implement HTML spec-compliant rules for floating-point parsing
Attempt to implement HTML specs for parsing floating-point number
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
2024-10-30 10:47:41 +01:00
Pavel Shliak
ba71cb1ca4 LibJS: Add calendar id getter to ZonedDateTimePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
2ad48b64ca LibJS: Add calendar id getter to PlainMonthDayPrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
0e1e8c908e LibJS: Add calendar id getter to PlainYearMonthPrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
44fa8410c0 LibJS: Add calendar id getter to PlainDateTimePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
f7cf7382c9 LibJS: Add calendar id getter to PlainDatePrototype 2024-10-30 10:29:48 +01:00
Pavel Shliak
e60c1ddd4d LibJS: Adds calendar_id identifier 2024-10-30 10:29:48 +01:00
Jonne Ransijn
ff6020c207 LibJS: Optimize IsStringWellFormedUnicode using simdutf
`simdutf` has a function for this that is much faster.
2024-10-30 10:28:24 +01:00
Alan Kemp
d2fbbabd89 LibWeb: Pageshow event dispatched by the user agent should be trusted
The spec says that "isTrusted is a convenience that indicates whether
an event is dispatched by the user agent (as opposed to using
dispatchEvent())"

But when dispatching a pageshow event the flag was incorrectly set
to false.

This fixes https://wpt.fyi/results/html/syntax/parsing/the-end.html
2024-10-30 10:27:20 +01:00
Andreas Kling
64f18a93c2 LibWeb: Make align-content on flex container behave more correctly
In particular, this property now interacts correctly when the flex
container has flex-wrap: wrap-reverse.

This caused some "regressions" in WPT tests for negative overflow in
flex containers, but the previous behavior wasn't correct either,
it just happened to give false positives on tests.
2024-10-30 10:17:21 +01:00
Timothy Flynn
7b3a3c2066 LibJS+LibWeb: Remove now-unused lexical environment override
In our current bytecode interpreter, this override cannot work anyways.
2024-10-30 08:50:31 +01:00
Timothy Flynn
2e71e300ee WebContent: Restore ability to use Inspector accessors like "$0"
We implement these built-in accessors via a lexical environment override
on the inspected document's global scope. However, ClassicScript will
parse the script we provide as a JS program, in which any evaluated
bindings will be interpreted as global bindings. Our global binding
lookup in the bytecode interpreter does not search the lexical env for
the binding, thus scripts like "$0" fail to evaluate.

Instead, we can create an ECMAScriptFunctionObject to evaluate scripts
entered into the Inspector. These are not evaluated as JS programs, and
thus any evaluated bindings are interpreted as non-global bindings. The
lexical environment override we set will then be considered.
2024-10-30 08:50:31 +01:00
Timothy Flynn
99d4c2de29 LibWeb: Make WebDriver's script executor public and a bit more general
The steps to execute a function body in WebDriver is exactly the
behavior we want with the Inspector.
2024-10-30 08:50:31 +01:00
Tim Ledbetter
464a875416 LibWebSocket: Don't send closing frame if connection is already closed 2024-10-30 08:48:17 +01:00
Aliaksandr Kalenik
e95226839e LibWeb: Fix infinite recursion when max-width is min/max-content in GFC
Treat max-width as auto when it's specified to min/max-content and
available size is intrinsic constraint.

Fixes stack overflow on https://claude.ai/
2024-10-30 08:47:52 +01:00
Nico Weber
421cf8d9bf LibWeb: Parse stroke-{linejoin,miterlimit} attributes
Some checks are pending
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
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, 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
Similar to LadybirdBrowser/ladybird#1714.

We don't implement the linejoin values `miter-clip` and `arcs`, because
according to the SVG 2 spec:

> The values miter-clip and arcs of the stroke-linejoin property are at
> risk. There are no known browser implementations. See issue Github
> issue w3c/svgwg#592.

Nothing uses this yet. The next step is to change
SVGPathPaintable::paint() to read `graphics_element.stroke_linejoin()`
and `graphics_element.stroke_miterlimit()` when painting.
2024-10-29 22:37:00 +00:00
Nico Weber
eafcd82e82 LibWeb: Support stroke-linecap as attribute as well
This should have been part of #1714.

(stroke-linecap still isn't implemented, but once it is, it will
now work in attribute form as well.)
2024-10-29 22:37:00 +00:00
Piotr
205155a7ab LibWeb: Set textarea rows and cols default value if 0
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (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 cols and rows attributes are limited to only positive numbers with
fallback. The cols IDL attribute's default value is 20. The rows IDL
attribute's default value is 2.

The default value was returned only for the negative number. I added an
additional check for the case when the attribute is 0 to match the
specification.
2024-10-29 16:05:32 +01:00
stelar7
2b65e86ec7 LibWeb: Add debug log message for missing calc() context 2024-10-29 14:40:40 +00:00
stelar7
488436fb54 LibWeb: Parse the rotate css property 2024-10-29 14:40:40 +00:00
Pavel Shliak
8ac60273a6 LibAudio: Manage channelCount in DynamicsCompressorNode
That helps to pass more WPT tests
under /webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html
2024-10-29 13:31:52 +00:00
Pavel Shliak
f2ed59879f LibAudio: Manage channelCountMode in DynamicsCompressorNode
That helps to pass more WPT tests
under /webaudio/the-audio-api/the-dynamicscompressornode-interface/ctor-dynamicscompressor.html
2024-10-29 13:31:52 +00:00
Tim Ledbetter
472d5e87e9 Meta+LibCore: Include git hash in version string
If the `LADYBIRD_GIT_VERSION` environment variable is set, then use it
to set the version number printed by the `--version` argument.
2024-10-29 13:30:12 +00:00
Tim Ledbetter
e815847f86 LibCore: Remove SerenityOS specific version number code 2024-10-29 13:30:12 +00:00
Gingeh
ebb8342cf2 LibWeb: Implement and use "isomorphic decoding" 2024-10-29 08:26:13 -04:00
Timothy Flynn
3ca2ee9c72 LibWeb+WebContent+WebDriver+UI: Make window min/maximize asynchronous
This follows suit of previous changes to never block the WebContent
process in WebDriver endpoints.
2024-10-29 11:03:20 +00:00
Timothy Flynn
9e10010c54 LibWeb: Add a document observer for visibility state changes 2024-10-29 11:03:20 +00:00
Timothy Flynn
bc67bdb160 LibWeb+UI: Initialize the system visibility state to 'hidden'
Not only does this match the spec, but otherwise when the UI process
sends us the initial visibility update, we would ignore the message as
we believed we were already visible (thus the update would not reach the
document).
2024-10-29 11:03:20 +00:00
Timothy Flynn
fa83cc722c LibWeb+WebContent+WebDriver+UI: Make window rect updates asynchronous
It's currently possible for window size/position updates to hang, as the
underlying IPCs are synchronous. This updates the WebDriver endpoint to
be async, to unblock the WebContent process while the update is ongoing.
The UI process is now responsible for informing WebContent when the
update is complete.
2024-10-29 11:03:20 +00:00
Timothy Flynn
102a125ea5 UI/AppKit: Inform WebContent of the UI window position/size
This is required for APIs like window.screenX, as well as for WebDriver
and WPT.
2024-10-29 11:03:20 +00:00
Timothy Flynn
47af8c6733 LibWeb: Defer handling of WebDriver endpoint invocations
We can currently crash on WebDriver session shutdown when we receive a
Delete Session command. This destroys the WebDriver client while we are
inside the client's socket's on_ready_to_read callback. This is not
allowed by AK::Function.

To avoid this, we now only read data from the socket in the callback. We
then defer handling the message to break out of the callback.
2024-10-28 23:27:25 +01:00
Timothy Flynn
db1bcb2c56 LibHTTP: Make HttpRequest default-movable
Otherwise, clangd correctly warns that this type is only copyable.
2024-10-28 23:27:25 +01:00
Lucas CHOLLET
f253246a6c LibWeb/CSS: Add support for the lch color function
This makes us pass all `css/css-color/lch-00*.html` tests.
2024-10-28 23:26:19 +01:00
Lucas CHOLLET
e8fc731b8c LibWeb/CSS: Introduce a base class for LCH-based color values
This will be used by both CSSLCH and CSSOKLCH.
2024-10-28 23:26:19 +01:00
Lucas CHOLLET
7a94709cd2 LibWeb/CSS: Factorize the parsing code for lch-like color functions 2024-10-28 23:26:19 +01:00
Shannon Booth
2c5cfbb968 LibWeb: Expose MessagePort.postMessage(message, transfer)
The overload resolution is no longer an issue, and we already had this
implemented :^)
2024-10-28 22:56:39 +01:00
Shannon Booth
897ba19e0f LibWeb: Use FIXME extended attribute for ServiceWorker.postMessage
The old FIXME is no longer relevant :^)
2024-10-28 22:56:39 +01:00
Shannon Booth
bf81e2fd64 LibWeb: Implement Worker.postMessage(message, transfer) 2024-10-28 22:56:39 +01:00
Shannon Booth
755b63132b LibWeb: Implement DedicatedWorkerGlobalScope postMessage(msg, transfer)
Unfortunately the added test (which passes locally) is skipped as it is
based off other Worker tests which are also skipped due to being flakey
in CI.
2024-10-28 22:56:39 +01:00
Shannon Booth
70599d3f8d LibWeb: Add support for dictionaries in overload resolution
By making use of the known set of supported dictionary names in that
overload set. Note that this list is typically very small (the max that
we have currently is 1).
2024-10-28 22:56:39 +01:00
Lucas CHOLLET
48bbebc636 LibWeb/CSS: Start parsing the color() function
This is really bare bone as we only support the `xyz-d50` color space
for the moment.

It makes us pass the following WPT tests:
 - css/css-color/predefined-016.html
 - css/css-color/xyz-d50-001.html
 - css/css-color/xyz-d50-002.html
2024-10-28 22:55:57 +01:00
Grubre
a6794627b0 LibWeb: Use Element::lang() in matches_lang_pseudo_class
The previous implementation went up the DOM tree until it found lang
attribute. The new version uses lang() function from the spec.
2024-10-28 17:55:05 -04:00
Grubre
95c511a3f6 LibWeb: Use the correct locale when applying titlecase
Previously with lang="nl" and text-transform: capitalize, inner text
"ijsland" would turn to "Ijsland" instead of "IJsland", now it's as it
should be.

This fixes:
https://wpt.fyi/results/css/css-text/text-transform/text-transform-tailoring-001.html
2024-10-28 17:55:05 -04:00
Grubre
5ac1a24255 LibWeb: Implement lang() function for DOM::Element
This is in accordance with:
https://html.spec.whatwg.org/multipage/dom.html#the-lang-and-xml:lang-attributes
2024-10-28 17:55:05 -04:00
Jonne Ransijn
5c1bbd3eff LibWeb: Make CSSRule::type() non-virtual
All its overrides return constants, and without virtual dispatch the
`qualified_layer_name` and `absolutized_selectors` functions can benefit
from slightly better optimizations.

`CSSRule`s aren't allocated that often, so the memory impact is minimal.
2024-10-28 22:53:57 +01:00
Kostya Farber
2f41be733f LibWeb: Add word spacing to tab size correctly
We should be adding the computed value for word spacing not letter
spacing twice.
2024-10-28 22:53:37 +01:00
Jelle Raaijmakers
1b82cb43c2 LibWeb+LibGfx: Fix SVG userSpaceOnUse gradient coordinate transformation
We were transforming coordinates for SVG gradients in a pretty
convoluted way: an inverse, unscaled transformation matrix was set up in
order to work around some (old?) technical limitations.

Rework this so the coordinate transformation no longer needs to be
inversed. This fixes gradients with "userSpaceOnUse" for its
gradientUnits attribute, which might cause coordinates to lie outside of
the bounding box of the gradient.

Two tests have updated reference screenshots with minor pixel updates;
this is probably the result of floating point precision improvements by
not inversing the matrix.

One test (svg-text-effects) has a bigger change: the gradient stops seem
to have moved along the text. This does seem to match other browsers
slightly better, so I'm moving forward with this ref update.
2024-10-28 22:53:17 +01:00
Jelle Raaijmakers
4d7da9878d LibWeb: Implement gradient offset clamping for color stops 2024-10-28 22:53:17 +01:00
Jelle Raaijmakers
66925a3d80 LibWeb: Misc. SVG improvements
No functional changes: added spec comments, moved some code, removed an
unused member.
2024-10-28 22:53:17 +01:00
Ben Wiederhake
3553861046 LibWeb: Omit padding in WebCrypto AES-CBC exportKey 2024-10-28 21:15:59 +01:00
Lucas CHOLLET
15121d63ad LibWeb/CSS: Make all children of CSSLabLike share the create() method
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
Small code deduplication. NFC.
2024-10-28 20:35:57 +01:00
Ben Wiederhake
4a6ce210b0 LibWeb: Refuse to fill float array with random values
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 passes an additional test in WPT:
WebCryptoAPI/getRandomValues.any
2024-10-28 10:42:27 +01:00
Michael Boonstra
157dbbad83 LibWebView: Fix ProcessAndClient template deduction
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 resolves compiler errors in HelperProcess.cpp when instantiating
Process::spawn() with various client types like WebContentClient and
RequestClient.
2024-10-27 19:57:53 -07:00
Jonne Ransijn
c97af00355 LibCore: Respect system hard limit in set_resource_limits
This avoids an "Invalid argument (errno=22)" error
on systems with lower hard limits.
2024-10-27 16:15:43 -04:00
Andreas Kling
c5a54f1166 LibWeb: Allow intrinsic size keywords for min-height and max-height 2024-10-27 21:02:54 +01:00
Andreas Kling
5a9d538acc LibWeb: Disallow none for min-width and min-height 2024-10-27 21:02:54 +01:00
Andreas Kling
6c75a93ec0 LibWeb: Fix select element state update in three ways
1. We were not propagating selectedness updates from option to select
   if the option was inside an optgroup.

2. When two or more options were selected, we were always favoring the
   last one in tree order, instead of the last one that got checked.

3. We were neglecting to return in the `display size is 1` case when
   all elements were disabled.

This was covered by some of the :has() selector tests. :^)
2024-10-27 18:40:20 +01:00
Andreas Kling
6dad8ea584 LibWeb: Move pessimistic :has() invalidation hack to invalidate_style()
We basically need to do this for every invocation of invalidate_style()
right now, so let's just do it inside invalidate_style() itself.

Fixes one missing invalidation issue caught by a WPT test. :^)
2024-10-27 18:40:20 +01:00
Andreas Kling
9e080e197c LibWeb: Make :has() actually work for non-descendant relative selectors
The traversal for these was incorrect and awkward. Now it's less
incorrect but still very awkward. We should find better ways to
implement this, but for now this at least passes many more WPT tests.
2024-10-27 13:33:46 +01:00
Andreas Kling
f24b91b01e LibWeb: Invalidate whole document style on attr change if :has() present
This sucks, and we're gonna have to do better, but for now let's
invalidate the whole document's style, so that we get correct behavior
if there are :has() selectors present.
2024-10-27 13:33:46 +01:00
Andreas Kling
690d9c8752 LibWeb: Be more thorough when marking selectors as "contains :has()"
We were missing this flag on a lot of selectors, which led to
insufficient invalidation in some cases.
2024-10-27 13:33:46 +01:00
Jonne Ransijn
07cd7d479f LibWeb: Remove reference counting for CSS::StyleProperties
`AK::CopyOnWrite` already does reference counting, so there is no need
to do it again.
2024-10-27 13:26:30 +01:00
Andreas Kling
ec0838b84e LibWeb: Implement HTMLElement.innerText closer to spec
And here's the wild part: instead of cloning WPT tests, import the
relevant WPT tests that this fixes into our own test suite.

This works by adding a small Ladybird-specific callback in
resources/testharnessreport.js (which is what that file is meant for!)

Note that these run as text tests, and so they must signal the runner
when they are done. Tests using the "usual" WPT harness should just
work, but tests that do something more freestyle will need manual
signaling if they are to be imported.

I've also increased the test timeout here from 30 to 60 seconds,
to accommodate the larger WPT-style tests.
2024-10-27 12:10:28 +01:00
Jonne Ransijn
afe74afa9e LibWeb/Fetch: Do not clone stored responses
Some checks are pending
Push notes / build (push) Waiting to run
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
Reading the RFC9111 spec makes it clear that the stored response was
not intended to be cloned. This is because there is a "clone response"
operation that is used in other places, but never for stored responses.
2024-10-27 11:28:37 +01:00
Jonne Ransijn
c7a51ed297 LibWeb/Fetch: Update cached responses when revalidating
Responses returned from `http_network_or_cache_fetch` were copied
directly from the cache, which is incorrect, since revalidation may
later modify the response, or even invalidate it, such as when the
`Access-Control-Allow-Origin` header is changed.

This fixes WPT test [wpt/cors/304.htm](http://wpt.live/cors/304.htm)
2024-10-27 11:28:37 +01:00
stelar7
96c053b36e LibCrypto: Remove some debug spam from RSA generation 2024-10-27 11:26:12 +01:00
stelar7
37f2818e90 LibWeb: Fix modulus length being wrong for RSA-OAEP key import 2024-10-27 11:26:12 +01:00
stelar7
23fc04d264 LibWeb: Implement RSAOAEP.decrypt() 2024-10-27 11:26:12 +01:00
stelar7
378808f6ba LibCrypto: Implement OAEP decode from newer spec 2024-10-27 11:26:12 +01:00
stelar7
3b423f1852 LibWeb: Add and use new name() helper on HashAlgorithmIdentifier 2024-10-27 11:26:12 +01:00
stelar7
48bd094712 LibWeb: Implement RSAOAEP.encrypt() 2024-10-27 11:26:12 +01:00
stelar7
6fc268f588 LibCrypto: Implement OAEP encode from newer spec 2024-10-27 11:26:12 +01:00
stelar7
b2b500ba82 LibCrypto: Extend OAEP test with RSA example 2024-10-27 11:26:12 +01:00
Kostya Farber
2dc788df00 LibWeb: Bring tab-size closer to the spec
When the css tab-size property is a number, we need to add
the associated letter-spacing and word-spacing to it's width.
2024-10-27 11:03:35 +01:00
Magnus Johansson
c6f77f4818 LibWeb: Fallback to auto when aspect ratio is degenerate as per spec
When aspect-ratio is degenerate (e.g. 0/1 or 1/0) we should
fallback to the same behaviour as `aspect-ratio: auto` according to spec
This commit explicitly handles this case and fixes five WPT test in
css/css-sizing/aspect-ratio (zero-or-infinity-[006-010])
2024-10-27 10:56:17 +01:00
Chase Knowlden
20376adbc3 LibWeb/HTML: Start implementing the download attribute 2024-10-27 10:23:45 +01:00
Ankush Chatterjee
85356094b5 LibWeb/CSS: Add math expression support for transform-origin 2024-10-27 10:21:22 +01:00
Lucas CHOLLET
3406b69614 LibGfx+LibWeb/CSS: Add support for the lab() color function
The support in LibWeb is quite easy as the previous commits introduced
helpers to support lab-like colors.

Now for the methods in Color:
 - The formulas in `from_lab()` are derived from the CIEXYZ to CIELAB
   formulas the "Colorimetry" paper published by the CIE.
 - The conversion in `from_xyz50()` can be decomposed in multiple steps
   XYZ D50 -> XYZ D65 -> Linear sRGB -> sRGB. The two first conversion
   are done with a singular matrix operation. This matrix was generated
   with a Python script [1].

This commit makes us pass all the `css/css-color/lab-00*.html` WPT
tests (0 to 7 at the time of writing).

[1] Python script used to generate the XYZ D50 -> Linear sRGB
conversion:

```python
import numpy as np

# http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
# First let's convert from D50 to D65 using the Bradford method.
m_a = np.array([
    [0.8951000, 0.2664000, -0.1614000],
    [-0.7502000, 1.7135000, 0.0367000],
    [0.0389000, -0.0685000, 1.0296000]
])

# D50
chromaticities_source = np.array([0.96422, 1, 0.82521])
# D65
chromaticities_destination = np.array([0.9505, 1, 1.0890])

cone_response_source = m_a @ chromaticities_source
cone_response_destination = m_a @ chromaticities_destination

cone_response_ratio = cone_response_destination / cone_response_source
m = np.linalg.inv(m_a) @ np.diagflat(cone_response_ratio) @ m_a

D50_to_D65 = m

# https://en.wikipedia.org/wiki/SRGB#From_CIE_XYZ_to_sRGB
# Then, the matrix to convert to linear sRGB.
xyz_65_to_srgb = np.array([
    [3.2406, - 1.5372, - 0.4986],
    [-0.9689, + 1.8758, 0.0415],
    [0.0557, - 0.2040, 1.0570]
])

# Finally, let's retrieve the final transformation.
xyz_50_to_srgb = xyz_65_to_srgb @ D50_to_D65

print(xyz_50_to_srgb)
```
2024-10-27 10:20:03 +01:00
Lucas CHOLLET
8efa046e0c LibWeb/CSS: Make CSSOKLab inherit from a new CSSLabLike class
This class provides the common base for both CSSOKLab and the future
CSSLab classes.
2024-10-27 10:20:03 +01:00
Lucas CHOLLET
707bcaf604 LibWeb/CSS: Extract code to parse a lab-like color value
This is currently only used for `oklab()` but will soon be also used for
`lab()` as well.
2024-10-27 10:20:03 +01:00
Simek
c9c67a6f24 LibWeb: Correct default ARIA Roles for few tags 2024-10-27 10:17:12 +01:00
Jonne Ransijn
8409178a11 LibWeb: Return Web::CSS::Selector::pseudo_element by reference
This avoids many allocations and deallocations.
2024-10-27 09:33:17 +01:00
Shannon Booth
5d7a7a43c4 LibWeb: Add temp execution context for resolving promise in AudioContext
Fixes a crash seen on twitter.com, namely from the 'resume' function.
2024-10-27 08:10:11 +01:00
Ben Wiederhake
b1056121f2 LibWeb: Implement WebCrypto AES-CBC decrypt operation
This lets us pass an additional (roughly) 15 WPT tests:
WebCryptoAPI/encrypt_decrypt/aes_cbc.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
eb193251b8 LibWeb: Implement WebCrypto AES-CBC encrypt operation
This lets us pass an additional (roughly) 20 WPT tests:
WebCryptoAPI/encrypt_decrypt/aes_cbc.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
d86dcac4f7 LibWeb: Implement WebCrypto AES-CBC generateKey operation
This is progress towards passing more WPT tests, although none of them
gets green due to this commit.
2024-10-26 17:50:22 +02:00
Ben Wiederhake
9255a1ac2e LibWeb: Implement WebCrypto AES-CBC exportKey operation
This lets us pass an additional (roughly) 40 WPT tests:
WebCryptoAPI/import_export/symmetric_importKey.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
6f88376e24 LibWeb: Implement WebCrypto AES-CBC importKey operation
This alone lets us pass around 40 WPT tests:
WebCryptoAPI/import_export/symmetric_importKey.https.any
2024-10-26 17:50:22 +02:00
Ben Wiederhake
92d4cb7b09 LibCrypto: Fix and test CBC with CMS and ZeroLen padding 2024-10-26 17:50:22 +02:00
Jonne Ransijn
6e86ad65e9 LibGfx: Use FlyString for family name
This value gets converted to FlyString a lot, so let's just make it
a FlyString in the first place!
2024-10-26 17:40:56 +02:00
samu698
7865fbfe6d LibJS: Don't generate useless jumps for if statement
If statements without an else clause generated jumps to the next
instruction, this commit fixes the if statement generation so that it
dosen't produce them anymore.

This is an example of JS code that generates the useless jumps
(a => if(a){}) ();
2024-10-26 17:39:37 +02:00
Andreas Kling
257ebea364 LibJS: Store RegExp flags as a bitmask
This avoids having to do O(n) contains() in the various flag accessors.

Yields a ~20% speed-up on the following microbenchmark:

    const re = /foo/dgimsvy;
    for (let i = 0; i < 1_000_000; ++i)
        re.flags;
2024-10-26 15:42:57 +02:00
Jelle Raaijmakers
8fd59899fc LibWeb: Paint drop shadow filters 2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
c99fad77e1 LibWeb: Fix filter: drop-shadow argument parsing
We were not discarding enough whitespace to actually get to the radius
and color values.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
2d544a0d8c LibWeb: Remove LibGfx-specific blur radius modification 2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
6c642d168d LibWeb: Apply correct clamping for each individual color filter
We were always clamping the amount, but this is actually defined per
filter. This allows the brightness filter to go beyond 100%, for
example.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
1b9c50b664 LibWeb: Implement CSS filter painting
We can reuse our implementation for `backdrop-filter` and use it as a
painting filter for each stacking context.
2024-10-26 11:26:42 +02:00
Jelle Raaijmakers
29974de852 LibWeb: Parse and store filter property
This shares its implementation with `backdrop-filter`.
2024-10-26 11:26:42 +02:00
Timothy Flynn
0722a3b1c0 LibWeb+WebContent+WebDriver: Asynchronously wait for dialog dismissal
There was a timing issue here where WebDriver would dismiss a dialog,
and then invoke another endpoint before the dialog was actually closed.
This is because the dismissal first has to hop over to the UI process to
close the graphical dialog, which then asynchronously informs WebContent
of the result. It's not until WebContent receives that result that the
dialog is considered closed, thus those subsequent endpoints would abort
due a dialog being "open".

We now wait for dialogs to be fully closed before returning from the
dismissal endpoints.
2024-10-26 11:25:42 +02:00
Timothy Flynn
bf0bc62654 WebContent+WebDriver: Asynchronously wait for navigations to complete
Similar to commit c2cf65adac, we should
avoid spinning the event loop from the WebContent-side of the WebDriver
connection. This can result in deadlocks if another component in LibWeb
also spins the event loop.

The AO to await navigations has two event loop spinners - waiting for
the navigation to complete and for the document to reach the target
readiness state. We now use NavigationObserver and DocumentObserver to
be notified when these conditions are met. And we use the same async IPC
mechanism as script execution to notify the WebDriver process when all
conditions are met (or timed out).
2024-10-26 11:25:42 +02:00
Timothy Flynn
8598d4670d LibWeb: Move WebDriver's HeapTimer helper class to its own file
And generalize it a tiny bit to be reusable outside of ExecuteScript.
2024-10-26 11:25:42 +02:00
Timothy Flynn
74ef9dc393 LibWeb: Add a NavigationObserver to be notified of navigable updates
This contains a hook to be notified when a navigable navigation is
complete, to be used by WebDriver.
2024-10-26 11:25:42 +02:00
Timothy Flynn
247307a2a2 LibWeb: Allow removing DocumentObserver hooks
Some callers (namely WebDriver) will want to stop receiving updates from
the DocumentObserver.
2024-10-26 11:25:42 +02:00
Timothy Flynn
0bbe836f8c LibWeb: Add a DocumentObserver hook to be notified of readyState changes 2024-10-26 11:25:42 +02:00
Kostya Farber
44b1c4f2b5 LibWeb: Parse the word-break 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-14, 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-10-26 00:18:02 +02:00
Ben Wiederhake
124bd115a1 LibWeb: Fix crash when importing malformed RSAOAEP key
This fixes a crash in WPT:
WebCryptoAPI/import_export/rsa_importKey.https.any

This allows us to pass 240 tests!
2024-10-26 00:14:42 +02:00
Ben Wiederhake
efad0b5676 LibWeb: Remove dead write in HKDF/PBKDF importKey operation
This corresponds to a recent change in the spec:
https://github.com/w3c/webcrypto/pull/379
2024-10-25 23:50:31 +02:00
Ben Wiederhake
ee3b86c3f8 LibWeb: Remove superfluous step in HKDF deriveBits operation
This corresponds to a recent change in the spec:
https://github.com/w3c/webcrypto/pull/372
Inspired by the following review comment:
https://github.com/LadybirdBrowser/ladybird/pull/1877#discussion_r1807648283
2024-10-25 23:50:31 +02:00
Andrew Kaster
2c3531ab78 LibWeb: Move JS::Promise <-> WebIDL conversion into IDL
This change also removes as much direct use of JS::Promise in LibWeb
as possible. When specs refer to `Promise<T>` they should be assumed
to be referring to the WebIDL Promise type, not the JS::Promise type.

The one exception is the HostPromiseRejectionTracker hook on the JS
VM. This facility and its associated sets and events are intended to
expose the exact opaque object handles that were rejected to author
code. This is not possible with the WebIDL Promise type, so we have
to use JS::Promise or JS::Object to hold onto the promises.

It also exposes which specs need some updates in the area of
promises. WebDriver stands out in this regard. WebAudio could use
some more cross-references to WebIDL as well to clarify things.
2024-10-25 14:04:21 -06:00
Andrew Kaster
52c449293a LibWeb: Update PromiseRejectionEvent's promise field to be object
This change was made in the HTML spec to address a comment from the
Gecko team for the Streams API in
a20ca78975

It also opens the door for some more Promise related refactors.
2024-10-25 14:04:21 -06:00
Jelle Raaijmakers
352a66390f LibWeb: Do not resolve inline block height early if height is definite
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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 condition was included to implement flex containers with auto
height, but it actually can reset the definitive height to 0 for inline
blocks with only replaced elements such as an SVG. Removing the
condition does not break any in-tree test, so let's improve the
situation on the SVG side of things for now.
2024-10-25 15:13:30 +02:00
stelar7
d16414b61e LibJS: Extend supported date string formats 2024-10-25 07:24:22 -04:00
Jonne Ransijn
cc0fce3983 LibWeb: Fix infinite loop in Storage::internal_own_property_keys
Since `Storage::item_value` never returns an empty Optional,
and since `PlatformObject::is_supported_property_index` only
returns false when `item_value` returns an empty Optional,
the loop in `PlatformObject::internal_own_property_keys` will
never terminate when executed on a `Storage` instance.

This fix allows youtube.com to load successfully :^)
2024-10-25 12:42:29 +02:00
Andreas Kling
3536ba9a88 LibWeb: Use Document::hidden() instead of comparing state to "hidden"
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, 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
Just noticed this unnecessary string comparison in the rendering task.
2024-10-25 10:21:12 +02:00
Andreas Kling
5c6b879715 LibWeb: Don't allocate a new HeapFunction 60 times per second
We can reuse the same HeapFunction when queueing up a rendering task
on the HTML event loop. No need to create extra work for the garbage
collector like this.
2024-10-25 10:21:12 +02:00
Ali Mohammad Pur
1b127ac082 LibRegex: Apply atomic loop rewrite in one more case
This commit makes LibRegex's atomic loop rewrite opt also accept cases
where the follow block jumps to the end of the forking block
(which is essentially a loop without a proper header in fancy clothes)

This makes patterns like /([^x]*)x/ where the loop is not _immediately_
followed by a block significantly faster.
2024-10-25 09:15:51 +02:00
Jelle Raaijmakers
0de403fede AK+LibJS: Add [[nodiscard]] to operator* in common types
The order of precedence with the `*` operator sometimes makes it a bit
harder to detect whether or not the result is actually used. Let's fail
compilation if anyone tries to discard the result.
2024-10-25 09:15:28 +02:00
Jelle Raaijmakers
5ab07f277c LibWeb: Actually resolve promises in AudioContext
...instead of just dereferencing the function.

Co-authored-by: Andrew Kaster <andrew@ladybird.org>
2024-10-25 09:15:28 +02:00
Andreas Kling
206479b2b5 LibJS: Cache UTF-16 strings on the VM
We were already caching UTF-8 and byte strings, so let's add a cache
for UTF-16 strings as well. This is particularly profitable whenever we
run regular expressions, since the output of regex execution is a set of
UTF-16 strings.

Note that this is a weak cache like the other JS string caches, meaning
that strings are removed from the cache as they are garbage collected.

This avoids billions of PrimitiveString allocations across a run of WPT,
significantly reducing GC activity.
2024-10-24 19:00:00 -04:00
Timothy Flynn
e89d889219 LibWeb+WebContent: Ensure elements are in view before clicking them
This implements a couple of missing steps in the Element Click endpoint.
2024-10-24 18:59:51 -04:00
Timothy Flynn
0286eb4e3e LibWeb: Return a MarkedVector from Document::elements_from_point
A plain vector is not protected from GC.
2024-10-24 18:59:51 -04:00
Timothy Flynn
9682b150ac WebContent: Do not raise errors from invoking element.scrollIntoView
The spec does not say to do this. We must instead implement methods to
validate the element after attempting to scroll.
2024-10-24 18:59:51 -04:00
Timothy Flynn
9f872d9aab WebContent: Do not use NodeIterator to iterate DOM nodes backwards
A NodeIterator rooted at some element cannot produce an element before
that root. That is, in a DOM tree such as:

    <div id=one><div id=two><div id=three></div></div></div>

If we create a NodeIterator rooted at element `three`, then invoking the
previousNode() method on that iterator is guaranteed to return null.

There was also a bug here where if we ever did enter the while() loop,
we would have looped indefinitely, as we were not updating the current
node.
2024-10-24 18:59:51 -04:00
Timothy Flynn
a9c858fc78 LibWeb: Implement WebDriver element references according to the spec
Our currently ad-hoc method of tracking element references is basically
a process-wide map, rather than grouping elements according to their
browsing context groups. This prevents us from recognizing when an
element reference is invalid due to its browsing context having been
closed.

This implements the WebDriver spec concept of element references grouped
according to their browsing context groups.

This patch is a bit noisy because we now need to plumb the current BC
through to the element reference AOs.
2024-10-24 18:59:51 -04:00
sideshowbarker
ede6924db8 LibWeb: Complete support for all ARIA properties in current spec
This change completes handling for all ARIA properties defined in the
current ARIA spec — by adding handling for the following properties:

- aria-braillelabel
- aria-brailleroledescription
- aria-colindextext
- aria-description
- aria-rowindextext
2024-10-24 22:21:46 +02:00