Commit graph

3575 commits

Author SHA1 Message Date
Mikkel Krautz
c48a78e37f LibWeb: Fix copyright headers with inconsistent > characters 2025-05-12 11:21:04 -06:00
Shannon Booth
b478274e0b LibWeb: Use infra sorting for URLSearchParam's sort()
Adopts editiorial change to the URL spec of:

59979a1
2025-05-12 11:20:32 +02:00
Shannon Booth
74334ea1ce LibWeb: Only use code unit length for is_code_unit_prefix
Fixes a crash in the included test.
2025-05-12 11:20:32 +02:00
Shannon Booth
1cd09724f1 LibWeb/Infra: Ignore OOM for utf16 conversion in 'is code unit prefix' 2025-05-12 11:20:32 +02:00
Psychpsyo
91159df0dd LibWeb: Draw text even if it needs to go into a 0-size inline box 2025-05-12 10:49:46 +02:00
Andreas Kling
096eed35cc LibWeb: Avoid O(n^2) traversal in play-or-cancel-animations logic
Some checks are pending
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The play_or_cancel_animations_after_display_property_change() helper
was being called by Node::inserted() and Node::removed_from() and then
recursing into the shadow-including subtree.

This had quadratic complexity since inserted() and removed_from() are
themselves already invoked recursively for everything in the
shadow-including subtree.

Only one caller of this API actually needed the recursive behavior,
so this patch moves that responsibility to the caller and puts the logic
in style recomputation instead.

1.02x speedup on Speedometer's TodoMVC-jQuery.
2025-05-11 20:22:17 +02:00
InvalidUsernameException
029bcf13fd Libweb: Invalidate layout for the value-attribute of li-elements 2025-05-11 01:14:31 +02:00
InvalidUsernameException
370098514a LibWeb: Invalidate layout for ol-attributes that affect it 2025-05-11 01:14:31 +02:00
Andreas Kling
263b125782 LibWeb: Let HTMLTokenizer walk over code points instead of UTF-8
Instead of using UTF-8 iterators to traverse the HTMLTokenizer input
stream one code point at a time, we now do a one-shot conversion up
front from the input encoding to a Vector<u32> of Unicode code points.

This simplifies the tokenizer logic somewhat, and ends up being faster
as well, so win-win.

1.02x speedup on Speedometer 2.1
2025-05-11 01:13:20 +02:00
Andrew Kaster
accb77fda9 LibWeb: Add missing WebIDL/Types include to MediaCapabilities.h
This causes a build failure when building a clang module for LibWeb.
2025-05-09 23:14:27 -06:00
Jelle Raaijmakers
70b52e0994 LibWeb: Use efficient background repeat path for either direction
We're able to efficiently draw repeated bitmaps through Skia, but for
backgrounds we only did so if the background was `repeat-x` _and_
`repeat-y`, and not if just one was set. This meant that for backgrounds
that were only repeating in one direction, we were taking the slow path.
Turns out that this slow path also produced graphical artifacts when
zooming in and out, so let's not do that :^)
2025-05-09 21:37:48 +02:00
Timothy Flynn
30e8f3f1ad LibWeb: Update the <details> layout tree when it is opened/closed
Otherwise, the arrow painted next to the <details> element does not
update.

Using a screenshot test here because apparently the direction of the
arrow has no effect on the layout or paint trees.
2025-05-09 21:37:14 +02:00
Andreas Kling
f61df9d34c LibWeb: Don't throw away UA shadow trees willy-nilly
We were unnecessarily discarding the shadow trees of various elements
when they were removed or detached from the DOM.

This especially caused a *lot* of churn when creating input elements via
setting .innerHTML on something. We ended up building each input
element's shadow tree 3 times instead of 1.

The original issue that we were trying to solve by discarding shadow
trees appears to have been solved elsewhere, and nothing else seems to
break by just allowing them to remain in place.

1.05x speedup on Speedometer's TodoMVC-jQuery.
2025-05-09 12:49:04 -04:00
Jelle Raaijmakers
123abe0e79 LibWeb: Overlap float space and left margins for all shared ancestors
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
We would only correct for the left margin of the containing block of the
child box that we are laying out, but we actually need to correct for
all left margins up until the containing block that contains both the
float and the child box.

Fixes #4639.
2025-05-09 14:13:02 +02:00
Sam Atkins
90d466e7e9 LibWeb: Add dumping code for keyframe/keyframes rules 2025-05-08 16:21:32 +01:00
Sam Atkins
fbdef98307 LibWeb: Dump CSSDescriptors in a generic way
This replaces the need for bespoke (and verbose) dumping for each
at-rule that has descriptors.
2025-05-08 16:21:32 +01:00
Sam Atkins
f0ce4f43a6 LibWeb: Make unknown webkit pseudo-elements safe to dump
This fixes a couple of crashes when dumping the style sheets on
ladybird.org
2025-05-08 16:21:32 +01:00
Sam Atkins
0925a32558 LibWeb/CSS: Extract a CSSDescriptors base class
This holds the boilerplate that's needed by any CSSStyleDeclaration
subclass that holds Descriptors. CSSFontFaceDescriptors now only has to
worry about initialization and its own exposed properties.
2025-05-08 16:21:32 +01:00
Kenneth Myhra
6941b63890 LibWeb: Add {,de}serialization steps for ImageData 2025-05-09 02:12:01 +12:00
Kenneth Myhra
5b4644d198 LibWeb: Use WebIDL types for IDL exposed attributes 2025-05-09 02:12:01 +12:00
stelar7
fa207c8fc6 LibWeb/IDB: Implement IDBObjectStore::clear 2025-05-08 14:13:21 +01:00
stelar7
637f35c0eb LibWeb/IDB: Implement clear_an_object_store 2025-05-08 14:13:21 +01:00
stelar7
aa35ced34f LibWeb/IDB: Implement IDBObjectStore::delete 2025-05-08 14:13:21 +01:00
stelar7
1fe6060ff9 LibWeb/IDB: Improve error messages slightly 2025-05-08 14:13:21 +01:00
stelar7
63e1cc7b50 LibWeb/IDB: Implement IDBIndex::open_cursor 2025-05-08 14:13:21 +01:00
stelar7
8f876e824b LibWeb/IDB: Implement IDBCursor::primary_key 2025-05-08 14:13:21 +01:00
stelar7
141093e032 LibWeb/IDB: Implement IDBCursor::effective_key 2025-05-08 14:13:21 +01:00
Jelle Raaijmakers
f996fb9d80 LibWeb: Translate special WebDriver keys for backspace, tab and return
Some checks failed
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled
These private code points are used extensively by WebDriver clients,
such as the WPT suite.
2025-05-08 07:06:02 -04:00
Timothy Flynn
c846616d51 LibWeb: Adjust positions by the scroll offset for scrollbar hit testing
This ensures we scroll to the correct position when dragging a scrollbar
or clicking its gutter.
2025-05-08 10:40:58 +01:00
Timothy Flynn
22532c769c LibWeb: Be less lenient in scrollbar hit testing
A scrollbar contains a mouse position only if its gutter rect contains
that position. We were incorrectly deciding a position was contained if
it fell to the right of a vertical scrollbar, or below a horizontal
scrollbar.
2025-05-08 10:40:58 +01:00
Sam Atkins
a8529629e2 LibWeb/HTML: Update "is script closable" to current spec
Corresponds to d7fc63a84a
and 7a48703e77
2025-05-08 10:39:34 +01:00
Ali Mohammad Pur
638a354b29 LibWeb/WebAssembly: Throw appropriate errors as defined by the spec 2025-05-08 03:35:11 -06:00
Ali Mohammad Pur
333ba93d49 LibWeb/WebAssembly: Define the hacky 'native' errors given in the spec
These cannot be implemented "correctly" as the set of native errors as
defined by ecma262 is closed, but we can get pretty close.
2025-05-08 03:35:11 -06:00
Francesco Gazzetta
5610f5a865 LibWeb/HTML: Add missing include to CanvasRenderingContext2D.cpp
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Fixes linking of CanvasRenderingContext2D on some systems:

    [2959/3075] Linking CXX shared library lib/liblagom-web.so.0.0.0
    FAILED: lib/liblagom-web.so.0.0.0
    : && /nix/store/f0m6caffiykyvsjim9376a3hx2yj2ghj-gcc-wrapper-14.2.1.20250322/bin/g++ -fPIC -O3 -DNDEBUG  -fstack-protector-strong -Wl,-z,defs -Wl,--no-undefined -Wl,--no-allow-shlib-undefined -Wl,--dependency-file=Lagom/Libraries/LibWeb/CMakeFiles/LibWeb.dir/link.d -shared -Wl,-soname,liblagom-web.so.0 -o lib/liblagom-web.so.0.0.0 @CMakeFiles/LibWeb.rsp && :
    /nix/store/hzw38c3f7s0w200cgk9645z53al7k8lw-binutils-2.44/bin/ld: Lagom/Libraries/LibWeb/CMakeFiles/LibWeb.dir/HTML/CanvasRenderingContext2D.cpp.o: in function `Web::HTML::CanvasRenderingContext2D::context_attributes_from_options(JS::VM&, JS::Value) [clone .localalias]':
    CanvasRenderingContext2D.cpp:(.text+0x355a): undefined reference to `JS::Value::to_boolean() const'
    /nix/store/hzw38c3f7s0w200cgk9645z53al7k8lw-binutils-2.44/bin/ld: CanvasRenderingContext2D.cpp:(.text+0x38e6): undefined reference to `JS::Value::to_boolean() const'
    /nix/store/hzw38c3f7s0w200cgk9645z53al7k8lw-binutils-2.44/bin/ld: CanvasRenderingContext2D.cpp:(.text+0x3d67): undefined reference to `JS::Value::to_boolean() const'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

Co-authored-by: Timothy Flynn <trflynn89@pm.me>
2025-05-07 16:53:09 -04:00
Jelle Raaijmakers
d424dc1b32 LibWeb: Assign new wrapped node list to container for insertParagraph
Forgot to implement this part of the spec.
2025-05-07 16:11:31 +02:00
Jelle Raaijmakers
c56f7d9cde LibWeb: Invalidate sibling style for :only-child and :*-of-type
After f7a3f785a8, sibling nodes' styles
were no longer invalidated after a node was removed. This reuses the
flag for `:first-child` and `:last-child` to indicate that a node's
style might be affected by any structural change in its siblings.

Fixes #4631.

Resolves the `:only-child` ACID3 failure as documented in #1231.
2025-05-07 14:55:12 +03:00
Psychpsyo
dbece92637 LibWeb: Make elements with 'opacity: 0' respond to hit-testing
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, 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
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-05-07 01:45:07 +03:00
Lyra
39dae6fb2d LibWeb: Fix SRI handling of badly-formatted strings 2025-05-06 13:02:58 -04:00
Timothy Flynn
0da7441b9b LibWeb: Set the initiator type for script-initiated CSS requests
Similar to other ad-hoc behavior in this method, we need to handle
requests which are not associated with a style sheet. For example:

    <script>
        const element = document.createElement('div');
        element.style['background'] = 'url(https://foo.com/img.png)';
        document.body.appendChild(element);
    </script>

Will not be associated with a style sheet.

This is needed to ensure we fire a PerformanceResourceTiming event for
this resource load. This is not currently testable in CI, as this event
is also gated by HTTP/S requests.
2025-05-06 17:37:34 +01:00
Timothy Flynn
4fc8443757 LibWeb: Translate scrollbar gutters by the cumulative scroll offset
This `translate_by` function is invoked with the cumulative scroll
offset during display list execution. Applying the offset to the gutter
was missed in 66e422b4f1.
2025-05-06 16:38:23 +03:00
stelar7
9d5f6108e4 LibWeb/IDB: Implement recent spec changes 2025-05-06 13:30:37 +01:00
Mark Langen
6cbb5d2785 LibWeb: Parse and propagate touch-action CSS property
Co-authored-by: Sam Atkins <sam@ladybird.org>
2025-05-06 12:22:01 +01:00
stelar7
2774068ca0 LibWeb/IDB: Initialize the index set in a ObjectStore handle 2025-05-06 11:16:01 +02:00
stelar7
0ed71d87ca LibWeb/IDB: Dont move away the name when creating an Index 2025-05-06 11:16:01 +02:00
stelar7
f3a31c98ea LibWeb/IDB: Use correct key comparison when doing Index lookup 2025-05-06 11:16:01 +02:00
stelar7
64c4bea189 LibWeb/IDB: Implement IDBCursor::continue 2025-05-06 11:16:01 +02:00
stelar7
08f73db773 LibWeb/IDB: Return undefined if request was an error 2025-05-06 11:16:01 +02:00
stelar7
d0156e2c88 LibWeb/IDB: Use invalidation reason when returning DataError 2025-05-06 11:16:01 +02:00
stelar7
05fe37619a LibWeb/IDB: Implement IDBObjectStore::open_cursor 2025-05-06 11:16:01 +02:00
stelar7
98d08b27e4 LibWeb/IDB: Implement iterate_a_cursor 2025-05-06 11:16:01 +02:00