Commit graph

11520 commits

Author SHA1 Message Date
Andreas Kling
a76f420207 LibJS: Add fast path for division of two numbers
We already had fast paths for Add, Sub and Mul. Might as well do Div.

1.18x speed-up on this micro-benchmark:

    (() => {
        let a = 1234;
        for (let i = 0; i < 100_000_000; ++i)
            a / a;
    })()
2025-10-11 20:08:58 +02:00
Andreas Kling
755c8d8cd6 LibJS: Sprinkle [[likely]] on the fast paths in ValueInlines.h
1.04x speed-up on JetStream/quicksort.c.js
2025-10-11 20:08:58 +02:00
Andreas Kling
7462c10ee2 LibJS: Sprinkle [[unlikely]] on the PutBy* cache miss code paths
These caches are gonna be hitting most of the time, so let's give the
compiler a hint about this.

1.01x speed-up on MicroBench/pic-add-own.js
2025-10-11 20:08:58 +02:00
Andreas Kling
b47f8f94fe LibJS: Split PutBy* instructions into specialized per-kind variants
This allows the compiler to fold away lots of unused code for each kind.

1.10x speed-up on MicroBench/pic-add-own.js :^)
2025-10-11 20:08:58 +02:00
Andreas Kling
d13b4f3e39 LibJS: Remove unused member PutPrivateById::m_kind
Private property puts never have a PutKind.
2025-10-11 20:08:58 +02:00
Andreas Kling
e7a3c4dbad LibJS: Rename Bytecode::Op::PropertyKind => Bytecode::PutKind
This is only used to specify how a property is being added to an object
by Put* instructions, so let's call it PutKind.

Also add an enumeration X macro for it to prepare for upcoming
specializations.
2025-10-11 20:08:58 +02:00
Tim Ledbetter
1c10421316 LibWeb: Support font-stretch SVG presentation attribute 2025-10-11 08:12:38 +01:00
Tim Ledbetter
14be5106d7 LibWeb: Add missing SVG presentation attributes 2025-10-11 08:12:38 +01:00
Timothy Flynn
0cae8dd712 LibWeb: Do not drop favicon resolution callbacks
Commit 77f6edaf71 tried to map the promise
returned from the ImageCodecPlugin to the same promise type used for SVG
decoding. However, `map` drops the existing resolution callbacks on the
floor.

Instead, let's keep the ImageCodecPlugin promise alone, and resolve the
returned promise explicitly.
2025-10-10 15:10:20 -04:00
Timothy Flynn
e57176b484 LibWebView: Move headless clipboard management to LibWebView
We only supported headless clipboard management in test-web. So when WPT
tests the clipboard APIs, we would blindly try to access the Qt app,
which does not exist.

Note that the AppKit UI has no such restriction, as the NSPasteboard is
accessible even without a GUI.
2025-10-10 15:10:03 -04:00
Timothy Flynn
a4a15b9a1e LibWeb+UI/AppKit: Ignore unknown clipboard MIME types
This prevents the AppKit UI from sending unknown MIME types to LibWeb,
where we would previously blindly dereference the result of parsing the
MIME string. We now ignore unknown MIME types as well.
2025-10-10 15:10:03 -04:00
Dowsley
c6b289c3dc LibWeb: Derive implicit aria-level for h1–h6 from tag name 2025-10-10 17:18:02 +01:00
Aliaksandr Kalenik
d7f830cdd1 LibWeb: Execute rasterization callback on the rendering thread
Previously, we enqueued a task on the main thread's event loop to
execute the callback. This meant that even though the rendering thread
had finished producing the next frame, there was still a delay before
the main thread notified the UI process.

This change makes the rendering thread execute the callback directly.
This should be safe, as the only pointer captured by the callback is the
traversable `PageClient`, which is expected to remain alive for as long
as the rendering thread exists. The callback then invokes either
`page_did_paint()` or `page_did_take_screenshot()`, both of which
enqueue an IPC message, which is safe to do since `SendQueue` is
protected by a mutex.
2025-10-10 17:25:55 +02:00
Aliaksandr Kalenik
9e3e581e14 LibWeb: Delete unused m_combined_css_transform from PaintableBox 2025-10-10 16:58:51 +02:00
Aliaksandr Kalenik
72aaef5a0f LibWeb: Delete non-const layout_node_with_style_and_box_metrics()
...from PaintableBox. It was used exclusively to go to corresponding DOM
node which could be done via direct DOM node pointer owned by paintable.
2025-10-10 16:58:51 +02:00
Aliaksandr Kalenik
0fbadba2e1 LibWeb: Add a test to ensure "resize" event on VV is fired on pinch-zoom 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
835081d66e LibWeb+LibWebView+WebContent: Reset pinch-to-zoom state on Ctrl/Cmd+0 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
eb4c616974 LibWeb: Dispatch "resize" event on VisualViewport size change 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
9862d8b4a6 LibWeb: Implement pinch-to-zoom support
Adds pinch event handling that adjusts the VisualViewport scale and
offset. VisualViewport's (offset, scale) is then used to construct a
transformation matrix which is applied before display list execution.
2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
b477c6bfc4 LibWeb: Implement VisualViewport aware viewport scrolling
Implements spec algorithm for viewport scrolling that first checks if
it's possible to use delta to move the visual viewport before falling
back to scrolling the layout viewport. This is a part of pinch-to-zoom
support.
2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
7ba34e8bd1 LibGfx: Implement AffineTransform::to_matrix() 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
c630de17ab LibWeb+UI+WebContent: Pipe pinch events from AppKit UI to WebContent 2025-10-10 15:37:45 +02:00
Lorenz A
e6831003c6 LibWeb: Check for Svg & MathML tags in stack of open elements scope
list & button scope need to check svg & mathml elements besides the list
from s_base_list see
https://html.spec.whatwg.org/multipage/parsing.html#has-an-element-in-the-specific-scope
2025-10-10 12:09:20 +01:00
Manuel Zahariev
9d77221c4d LibWeb/CSS: Add support for content to the ::marker pseudo-element
A ::marker pseudo-element is created for list item nodes (nodes
with display:list-item).

Before:
    - The content of the ::marker element is created magically from
    the value of the ordinal (for <ol>) or from a template (for <ul>).
    The style `content` is ignored for ::marker pseudo-elements.

After:
    - If a "list item node" has CSS `content` specified for its ::marker
    pseudo-element, use this to layout the pseudo-element,
    https://drafts.csswg.org/css-lists-3/#content-property
    - Otherwise, layout the list item node as before.
2025-10-10 12:02:16 +01:00
Aliaksandr Kalenik
83fb690bce LibWeb: Remove usage of layout_node() in dom_node_for_event_dispatch
No need to go through layout node when paintable has a direct pointer to
the DOM node.
2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
b786935169 LibWeb: Delete CheckBoxPaintable::layout_box()
No need for this method when we could reach into DOM node directly from
Paintable.
2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
38ca745a59 LibWeb: Delete CanvasPaintable::layout_box()
No need for this method when we could reach into DOM node directly from
Paintable.
2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
d3f40e9a72 LibWeb: Delete AudioPaintable::layout_box()
No need for this method when we could reach into DOM node directly from
Paintable.
2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
33a8fbd22c LibWeb: Delete unused SVGGraphicsPaintable::layout_box() 2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
3675560804 LibWeb: Delete unused SVGSVGPaintable::layout_box() 2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
2c2584ee99 LibWeb: Delete VideoPaintable::layout_box()
No need for this method when we could reach into DOM node directly from
Paintable.
2025-10-10 09:03:39 +02:00
Aliaksandr Kalenik
5c699e1a45 LibWeb: Delete NavigableContainerViewportPaintable::layout_box()
No need for this method when we could reach into DOM node directly from
Paintable.
2025-10-10 09:03:39 +02:00
lukasxcs
c1ff2a845c LibWeb: Implement DataTransfer.set_data() 2025-10-10 08:02:16 +01:00
Adam Patterson
120bba597d LibJS: Remove using-declaration.js from .prettierignore
This is the second and final commit to remove using-declaration from
.prettierignore. While there is standard formatting changes here, there
is also scoping changes for the 'using' declarations due to the
following error:

Libraries/LibJS/Tests/using-declaration.js: SyntaxError:
Using declaration cannot appear in the top level when source
type is `script` or in the bare case statement.
2025-10-09 15:49:49 -04:00
Adam Patterson
052013f8e6 LibJS: Partially format using-declaration.js with prettier
This contains prettier formatting fixes for using-declaration.js. The
file isn't fully formatted at this state. There is a minor scoping code
change that must happen in the next commit to be able to remove this
file from .prettierignore, but I wanted to separate the code change from
the formatting change to improve the review process.

This contains formatting and changing single quotes to double quotes.
2025-10-09 15:49:49 -04:00
Adam Patterson
0eac4cc6ad LibJS: Remove files from .prettierignore
.prettierignore had files listed for an issue with 'using' declarations,
this is no longer an issue for prettier (tested on 3.6.2).
2025-10-09 15:49:49 -04:00
Sam Atkins
f61c67792d LibWeb/CSS: Allow setting shorthand values with StylePropertyMap.set()
Shorthands should be broken up into their longhands, instead of setting
them directly.

There's a catch here with our "positional value list shorthands" like
`margin`: Setting margin to a single value like `CSSUnitValue(10, "px")`
is supposed to fail here, but our type-checking code thinks it's valid
because our JSON for `margin` says it accepts lengths. This is the same
kind of issue that we had for `cursor` discussed in the
"LibWeb/CSS: Support converting CSSUnitValue to a StyleValue" commit.

Will get us a few subtest passes for every shorthand that's tested.
2025-10-09 16:14:58 +02:00
Sam Atkins
0015ee310c LibWeb/CSS: Support converting CSSUnparsedValue to a StyleValue
Unfortunately this doesn't pass a lot of tests, because we strip out
whitespace when parsing property values. In particular, the WPT suite
tests with this:

```js
new CSSUnparsedValue([' ', new CSSVariableReferenceValue('--A')])
```

...which gets the whitespace stripped from the string, meaning when we
convert the value back to JS, we get the equivalent of this:

```js
new CSSUnparsedValue(['', new CSSVariableReferenceValue('--A')])
```

...and that's not the same so the test fails.
2025-10-09 16:14:58 +02:00
Sam Atkins
9ef523ebb2 LibWeb/CSS: Prevent infinite recursion in CSSUnparsedValue::to_string()
As noted in the linked spec issue, it's possible for an author to
construct a CSSUnparsedValue that contains itself, meaning
serialization would be infinitely recursive. So instead, detect that
and then return an empty string, which copies Blink's solution to this
issue.

Stops `css/css-typed-om/cycle-in-unparsed-value-crash.html` from
crashing after we implement converting a CSSUnparsedValue to an
UnresolvedStyleValue, as that relies on serialization.
2025-10-09 16:14:58 +02:00
Sam Atkins
882bdbb019 LibWeb/CSS: Stop asserting that UnresolvedSV contains an ASF
Typed-OM means that the author can set a property's value to a
CSSUnparsedValue, which may or may not have any arbitrary substitution
functions in it. This VERIFY was just there to catch parsing bugs that
created UnresolvedStyleValues unnecessarily, and removing it is
harmless.
2025-10-09 16:14:58 +02:00
Sam Atkins
97a9082251 LibWeb/CSS: Check for var() after converting strings in Typed OM set()
This avoids regressions in the next commit.

See the linked spec issue for details. Without this, we end up doing the
wrong thing in cases like this, from a WPT test:

```js
styleMap.set('transition-duration', '1s', 'var(--A)');
```

`'var(--A)'` is a string, not a CSSVariableReferenceValue or
CSSUnparsedValue. Following the spec literally, we wouldn't throw a
TypeError here, even though we really should: The purpose of the check
is for list-valued properties, to prevent authors putting a series of
tokens that would represent multiple list items, into a single list
item slot.

So, we delay the check until after we've converted strings into values.
This does mean we're checking StyleValues instead of CSSStyleValues,
and it also means we've done more work before rejecting the input as
invalid. But correctness is nice. :^)
2025-10-09 16:14:58 +02:00
Sam Atkins
3644e75de1 LibWeb/CSS: Allow setting any property to CSS-wide keywords in typed OM
A minor thing I missed before. Gets us 4 WPT passes per property that's
tested, which is quite a lot.
2025-10-09 16:14:58 +02:00
Sam Atkins
b2d55e4caa LibWeb/CSS: Support converting CSSUnitValue to a StyleValue
A lone CSSUnitValue can now be converted to a dimension StyleValue of
the relevant type, as long as the property allows that type. If the
value is out of the allowed range, it's wrapped in calc().

There are a few failing tests still, involving setting a negative
percentage and expecting to read the computed value as 0. Those also
fail in Chromium, and a similar negative-length test expects a negative
computed value (not 0), so this appears to be an incorrect test.

Also, we regress some of the `cursor` tests. This is because our "does
property X accept type Y?" code is too naive: `cursor` is defined to
accept "number [-∞,∞]" in the JSON, and that value range is used when
clamping the result of calculations or interpolation. But because that
entry is there, we think a single number is a valid value for `cursor`.
Solving this generally is a larger task than I want to take on right
now. :^)
2025-10-09 16:14:58 +02:00
Sam Atkins
bd545af210 LibWeb/CSS: Support calculated percentages in line-height
Without this, the imported test will crash once we implement
`CSSUnitValue::create_an_internal_representation()`.
2025-10-09 16:14:58 +02:00
Lorenz A
6f31d9a40d LibWeb: Ensure Noah's Ark clause is called in the Parser 2025-10-09 12:24:45 +01:00
Callum Law
102edf638d LibWeb: Support interpolation of SuperellipseStyleValue 2025-10-09 10:23:20 +01:00
Callum Law
20a2e8ab12 LibWeb: Store corner-*-shape properties in computed form 2025-10-09 10:23:20 +01:00
Callum Law
397e39f316 LibWeb: Support corner-*-shape logical properties 2025-10-09 10:23:20 +01:00
Callum Law
7305b3fa28 LibWeb: Parse corner-*-shape physical shorthands 2025-10-09 10:23:20 +01:00
Callum Law
814efa9809 LibWeb: Parse corner-*-shape physical longhands 2025-10-09 10:23:20 +01:00