Commit graph

72183 commits

Author SHA1 Message Date
Timothy Flynn
411aed96ab LibDatabase: Support all C++ integral types in SQL storage 2025-10-14 13:40:33 +02:00
Timothy Flynn
187d02c45d LibDatabase+LibWebView: Extract our SQLite wrapper to its own library
It currently lives in LibWebView as it was only used for cookies and
local storage, both of which are managed in the UI process. Let's move
it to its own library now to allow other processes to use it, without
having to depend on LibWebView (and therefore LibWeb).
2025-10-14 13:40:33 +02:00
Timothy Flynn
e433dee543 LibCore: Add a system wrapper to pipe a file
This uses splice on Linux and mmap+write elsewhere to transfer a file to
a pipe. Note we cannot use sendfile because (at least on macOS) the
receiving fd must be a socket.
2025-10-14 13:40:33 +02:00
Timothy Flynn
62e52640d0 LibCore: Add a standard path for cache data 2025-10-14 13:40:33 +02:00
Jelle Raaijmakers
d349e91339 CI: Inject COMMIT file into archives when missing
This allows us to run js-benchmarks against older commits and have the
workflow correctly identify the commit used to build the binaries. In
order to actually build commits where the wasm binary was not yet built,
we have to account for missing archives as well.
2025-10-14 12:47:25 +02:00
ayeteadoe
0d5136ae5c LibWeb: Add support for bitmap scaling in createImageBitmap() 2025-10-14 12:19:33 +02:00
ayeteadoe
05f3bd0fa8 Tests/LibWeb: Import several scaling createImageBitmap() tests 2025-10-14 12:19:33 +02:00
Tim Ledbetter
0bdb831c68 LibWeb: Avoid null dereference in ListItemBox specified content check 2025-10-14 10:27:11 +01:00
Tim Ledbetter
2f5481284d Meta: Don't attempt to download WPT test resources from external URLs 2025-10-14 10:27:11 +01:00
stelar7
61185d98aa LibWeb/IDB: Adjust how negative numbers increment the key generator
Directly mapping a negative double to a u64 causes it to wrap around
to the max value. We work around this here by comparing as doubles,
and only incrementing the generator if the new value is greater

Fixes #6455
2025-10-14 10:26:28 +01:00
Aliaksandr Kalenik
207f313b4b LibWeb: Delete unused Document::set_visibility_state() 2025-10-14 11:23:29 +02:00
Aliaksandr Kalenik
4853e2ffb1 LibWeb: Don't reach into layout node to check if paintable is SVG 2025-10-14 11:23:29 +02:00
Aliaksandr Kalenik
881ef21d40 LibWeb: Get rid of SVGPathPaintable::layout_box()
It was used exclusively to get corresponding DOM node pointer, which is
unnecessary indirection as Paintable owns the DOM node pointer directly.
2025-10-14 11:23:29 +02:00
Aliaksandr Kalenik
f706c883eb LibWeb: Don't reach into layout node to check if Paintable is positioned
We copy this information into Paintable, so it could be taken directly
from there.
2025-10-14 11:23:29 +02:00
Aliaksandr Kalenik
9e838cffb4 LibWeb: Copy "is inert" attribute into Paintable
...instead of reaching into DOM tree during hit-testing in order to
figure out if an element is inert. This is a part of the effert to make
possible running hit-testing solely based on data contained by the
paintable tree.
2025-10-14 11:23:29 +02:00
Aliaksandr Kalenik
81aeee3fb4 LibWeb: Get rid of PaintableBox::is_viewport()
This function used layout node pointer to check if it's corresponding to
viewport. There is no need for that, since `is_viewport_paintable()`
does exactly the same check without going through layout node.
2025-10-14 11:23:29 +02:00
InvalidUsernameException
1ffb0ca311 LibWeb: Remove redundant function parameter
This function can really only be called with a box and its containing
block, otherwise the results are not meaningful. Instead of passing
these two dependent values separatly, reduce it down to a single
parameter to not make the function appear more general than it is.
2025-10-14 10:23:27 +02:00
InvalidUsernameException
70c46e081d LibWeb: Correctly calculate nested positioned elements' static position
If there are multiple nested `position: fixed` or `position: absolute`
elements that are positioned based on their static position due to not
specifying any insets, we sum up all their ancestor offsets to calculate
said static position.

However, these offsets represent the offset to the containing block. So
summing up all the ancestor blocks will count elements multiple times
for cases where the containing block is not based on the closest element
capable of forming a containing block (i.e. absolute and fixed position
elements) when multiple such elements are nested.

With this change we only iterate over ancestors forming containing
blocks instead of over all ancestors boxes. To sum up everything between
the box currently being positioned and its containing block, we start
the iteration on the parent box of the current box.

This fixes 3 WPT tests that I could find. But these tests are not
intended to test the error cases fixed here, they just incidentally rely
on the correct behavior. As such, I have added dedicated tests myself.
Note that two of the tests already pass on master, but they seemed like
a good cases to have anyway.
2025-10-14 10:23:27 +02:00
Andreas Kling
0e4450f4b3 LibJS: Avoid function call if @@hasInstance is default implementation
This makes the instanceof operator signficantly faster by avoiding a
generic function call to @@hasInstance unless it has been overridden.

1.15x speed-up on Octane/earley-boyer.js
2025-10-13 17:15:44 +02:00
Andreas Kling
5a7b0a07cb LibJS: Mark global function declarations as globals
This allows us to use the GetGlobal and SetGlobal bytecode instructions
for them, enabling cached accesses.

2.62x speed-up on this Fibonacci program:

    function fib(n) {
        return n < 2 ? n : fib(n - 1) + fib(n - 2);
    }
    for (let i = 0; i < 50_000; ++i)
        fib(10);
2025-10-13 17:15:44 +02:00
Rocco Corsi
44d2a74eeb LibJS: Increase the stack limit when ASAN enabled
Linux, x86_64, Sanitizer, GNU runners on GitHub Action fail randomly
with a stack overflow on recursive test called:
Libraries/LibJS/Tests/runtime-error-call-stack-size.js
2025-10-13 09:07:39 -04:00
Tete17
460ffcbe1d LibWeb: Add new passing WPT tests 2025-10-13 13:22:01 +01:00
Tete17
18199f8f2a LibWeb: Hook TrustedTypes to the ServiceWorkers api 2025-10-13 13:22:01 +01:00
Tete17
74aa7e8a82 LibWeb: Hook TrustedTypes to the Workers api 2025-10-13 13:22:01 +01:00
Tete17
e6ac064a34 LibWeb: Hook TrustedTypes to the SharedWorkers api 2025-10-13 13:22:01 +01:00
Tete17
bd4e3fd3e0 LibWeb: Hook TrustedTypes to the Range Dom api 2025-10-13 13:22:01 +01:00
Tim Ledbetter
701ef22952 LibWeb: Use correct percentage basis when resolving line height 2025-10-13 10:17:58 +01:00
Sam Atkins
078bc1a471 LibWeb/CSS: Allow converting CSSMathValues to StyleValues
Because we store calculations as a tree of CalculationNodes inside a
CalculatedStyleValue, instead of a tree of StyleValues directly, this
implements a create_calculation_node() method on CSSNumericValue.
CSSMathValue::create_an_internal_representation() then calls
create_calculation_node() on itself, and wraps it in a
CalculatedStyleValue.

Lots of WPT passes again! Some regressions, which are expected: `cursor`
fails a test for the same reason it fails other that set it to some
kind of numeric value: We don't distinguish between "can contain a
number" and "can accept a number by itself". This will affect any
similar properties, but overall this is a big improvement.
2025-10-13 09:59:38 +01:00
Sam Atkins
37cffba30e LibWeb/CSS: Forward-declare some calculation-related types
Saves us having to include CalculatedStyleValue.h from some headers.
2025-10-13 09:59:38 +01:00
Sam Atkins
df7abe1dc2 LibWeb/CSS: Extract CSSUnitValue -> CSS Value code
create_numeric_value() will be used next to create a CalculationNode,
and I didn't want to have to duplicate the "create a value based on the
unit name" code.

No behaviour change.
2025-10-13 09:59:38 +01:00
Sam Atkins
0afa93e639 LibWeb/CSS: Add a Property -> CalculationContext factory method
We have this code duplicated in multiple places, and we'll want to
handle registered custom properties too at some point, so wrap it in a
reusable `CalculationContext::for_property()` method.

Noticed while doing this that ValueParsingContext will eventually need
to take a PropertyNameAndID, not a PropertyID, so I've added a FIXME.
2025-10-13 09:59:38 +01:00
=
a3e973970a LibWeb/CSS: Check overflow value before determining box baseline
The CSS spec says the baseline of an inline-block should be the bottom
margin when either the overflow property is not 'visible' or there are
no in-flow line boxes. Previously, only the latter case was checked.

This fixes 1 WPT test:
https://wpt.live/css/css-align/baseline-of-scrollable-1a.html
2025-10-13 09:47:32 +01:00
Tim Ledbetter
1a640b1d95 LibWeb: Avoid crash when shadow root has null focused area 2025-10-12 22:50:12 +01:00
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
Timothy Flynn
281bf227ad Meta: Support importing WPT resources in fetch() invocations 2025-10-10 15:10:03 -04:00
Timothy Flynn
a229a9d7e1 Meta: Store parsed WPT resources as a set
If a resource appears in a test more than once, such as:

    <script src="/foo.png">
    <script src="/foo.png">

Then we end up replacing "/foo.png" in the test source that many times
as we iterate over the resource array, like so:

    source.replace("/foo.png", "../foo.png")

So we end up with:

    <script src="..../foo.png">
    <script src="..../foo.png">

Store the resources as a set instead.
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