Commit graph

71091 commits

Author SHA1 Message Date
Luke Wilde
0faf96fa1b Meta/curl: Update to 8.15.0
This includes the patch for issue 17917, so we can remove our custom
patch :^)
2025-07-21 15:09:35 +02:00
Aliaksandr Kalenik
4319e6b80e LibWeb: Don't put unlayered rules into into empty "service" layer
Fixes bug when `build_matching_rule_set()` mistakenly included all
unlayered rules twice. This was caused by mistakenly including all
unlayered rules into `""` named "service" layer, because we couldn't
tell if FlyString = `""` means no layer or layer named `""`.
2025-07-21 12:33:35 +01:00
Jelle Raaijmakers
7ea0f13cd9 CI: Actually pass down secrets to lagom-template.yml
By default, reusable workflows do not inherit secrets. This caused our
vcpkg source asset cache to never be updated.
2025-07-21 11:58:03 +02:00
Jelle Raaijmakers
62236fa503 CI: Enable vcpkg cache update for fuzzers build
This was a cache race condition between the fuzzers and sanitizer
builds, where the vcpkg binary cache could have been updated before the
sanitizer builds started doing their vcpkg install, causing the source
assets to never be updated at all.
2025-07-21 11:58:03 +02:00
Tim Ledbetter
1263d58689 LibWeb: Ignore zero width when calculating SVG intrinsic aspect ratio
Previously, an SVG with width of zero would have am intrinsic aspect
ratio of zero. With this change, if an SVG has a width or height of
zero, the intrinsic aspect ratio is determined by the SVG's viewbox.
2025-07-21 11:29:25 +02:00
Sam Atkins
16ef883e44 IDLGenerators: Update spec steps for "internally create a new object..."
Also wrap these in {} so it's clearer which steps are from this, and
which are from the HTML algorithm.
2025-07-21 10:05:32 +01:00
Sam Atkins
3ca879776f IDLGenerators: Allow initialize() as an IDL member name
While not a C++ keyword, we already define a `Foo::initialize()` method
on every generated binding type, so we need to avoid clashing with that.
2025-07-21 10:05:32 +01:00
Sam Atkins
ef252d63c8 IDLGenerators: Add support for default values on bool dictionary members 2025-07-21 10:05:32 +01:00
Sam Atkins
11e2dbb555 LibWeb/CSS: Support text-justify: distribute legacy value alias
...for `text-justify: inter-character`.

We previously had this mapped in Enums.json, but the behaviour is
different: `a=b` in Enums.json keeps `a` around but makes it behave the
same as `b`. A legacy name alias is instead expected to replace `a`
with `b`, so we have to do that separately.
2025-07-21 10:04:42 +01:00
Sam Atkins
db75405881 LibWeb/CSS: Support overlay keyword as alias to auto in overflow
We don't yet have a system for "legacy value aliases", but until we have
a lot of them we can handle them manually.

We also have to do this in two places because
parse_css_value_for_property() doesn't call any property-specific
parsing code.
2025-07-21 10:04:42 +01:00
Andreas Kling
128b66e30d LibWeb: Avoid duplicate work when computing style
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
Before this change we were running the CSS cascade machinery twice per
element:

- First, to compute the "logical alias mapping context" based on
  writing-mode and pals.

- Then, to compute all properties.

This patch factors out the heaviest work from the cascade machinery
to a separate step that can be run only once. This step will:

- Collect all the matching rules for the element
- Resolve custom properties for the element

We still perform the per-element cascade twice, but now this is hogging
less than 1% of CPU time when typing on Discord (compared to 9% before.)
2025-07-20 17:22:23 -04:00
rmgx
98b45b4137 Meta: Remove ladybird.sh 2025-07-20 20:51:51 +02:00
Manuel Zahariev
3bc0504abb Documentation: Troubleshoot double free race condition on exit 2025-07-20 13:30:31 -04:00
Michael Manganiello
89036dd70c LibWeb: Fix size computation for elements with max-width and max-height
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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 specification [1] indicates that the tentative used width and height
should be computed first, and if they exceed the `max-width` or
`max-height`, the rules should be applied again using the computed
values of `max-width` and `max-height`.

The only required change to follow the spec is to remove the early
`return` statements, in both `compute_width_for_replaced_element`
and `compute_height_for_replaced_element`.

Fixes #5100.

[1] https://www.w3.org/TR/CSS22/visudet.html#min-max-widths
2025-07-20 17:34:19 +02:00
Luke Wilde
45127aee88 LibWeb: Check if transferred ImageBitmap is exposed in target realm
This was forgotten in ed3d0d7.
2025-07-21 00:52:07 +12:00
Gingeh
28774efa22 LibWeb: Don't crash when drawing null image from offscreen canvas
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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-07-20 08:54:53 +02:00
Gingeh
55129644d5 LibWeb: Don't crash when root element becomes a popover or fullscreen 2025-07-20 08:54:53 +02:00
Gingeh
f38e07e0c5 LibWeb: Don't crash when an unknown property begins with a single dash 2025-07-20 08:54:53 +02:00
Tim Ledbetter
48417152df LibWeb: Don't crash when creating empty bitmap from a HTMLCanvasElement 2025-07-20 16:26:57 +12:00
Tim Ledbetter
bd83f5bde6 test-web: Treat files in images directories as resources for WPT tests 2025-07-20 16:26:57 +12:00
Tim Ledbetter
4a223ad085 Meta: Don't check png sizes for images imported from WPT 2025-07-20 16:26:57 +12:00
Tim Ledbetter
7874f325a8 LibWeb: Implement InputEvent.getTargetRanges()
This returns a list of ranges that would be affected by a change to the
DOM if the input event is not cancelled.
2025-07-20 12:34:14 +12:00
Kenneth Myhra
ed3d0d76ec LibWeb: Implement transfer {,receiving} steps for ImageBitmap 2025-07-20 12:30:43 +12:00
Kenneth Myhra
c0976b18e0 LibWeb: Implement {,de}serialization steps for ImageBitmap
To make {,de}serialization of ImageBitmap work we also had to add
support for creating an ImageBitmap from a HTMLCanvasElement in
WindowOrWorkerGlobalScopeMixin::create_image_bitmap_impl().
2025-07-20 12:30:43 +12:00
Kenneth Myhra
7b4ee57037 LibWeb: Add get_bitmap_from_surface() and use it from to_blob()
This refactors out the reading part of Gfx::Bitmap from
HtmlCanvasElement::surface(). We can then reuse this from
WindowOrWorkerGlobalScopeMixin::create_image_bitmap_impl() when we
create an ImageBitmap from a HtmlCanvasElement.
2025-07-20 12:30:43 +12:00
Kenneth Myhra
09f336bf8f LibGfx: Use static_cast instead of C-style cast 2025-07-20 12:30:43 +12:00
Kenneth Myhra
2394845d58 LibWeb: Align specification step text with current specification 2025-07-20 12:30:43 +12:00
Timothy Flynn
27d139e817 LibWeb: Define Wasm native errors correctly
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
1. Fix typos in some macro invocations of these error types. We now use
   a single xmacro to instantiate error definitions to prevent such
   errors in the future.

2. Use the "WebAssembly." prefix as needed.

3. Allocate the error constructors and prototypes with `realm.create`
   rather than `heap.allocate`. The latter does not invoke `initialize`
   methods. This exposed the next issue:

4. Use the correct intrinsic prototype in the error constructor. We were
   using the base native error prototype. We unfortunately cannot invoke
   OrdinaryCreateFromConstructor from LibJS directly with the correct
   prototype, so an implementation was added here.

5. Use intrinsic accessors to create the constructors. I don't think
   this one was actually a fix, but it makes the setup look more like
   other built-ins.
2025-07-19 16:48:01 -04:00
Timothy Flynn
6b3f796e5b LibWeb: Propagate errors from module instantiation 2025-07-19 16:48:01 -04:00
Timothy Flynn
a458a7d35b LibWeb: Do not coerce object IDL types to JS objects
We should bail with a TypeError if the provided value is not a JS object
already.
2025-07-19 16:48:01 -04:00
Timothy Flynn
7b14da14d8 Tests/LibWeb: Import tests for incorrect Wasm instantiations 2025-07-19 16:48:01 -04:00
ayeteadoe
f468f702d5 CMake: Update default BUILD_PRESET arg to Release in WPT.sh
The presets were recently refactored and 'default' was
renamed to 'Release', but keeping it in sync with
any consumer shell scripts was missed.
2025-07-19 21:03:51 +02:00
Andreas Kling
92221f0c57 LibWeb: Apply all animations and transitions before invalidating style
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
This fixes an issue where only the last KeyframeEffect applied to an
element would actually have an effect on the computed properties.

It was particularly noticeable when animating a shorthand property like
border-width, since only one of the border edges would have its width
actually animate.

By deferring the invalidation until all animations have been processed,
we also reduce the amount of work that gets done on pages with many
animations/transitions per element. Discord is very fond of this for
example.
2025-07-19 11:08:46 -04:00
Andrew Kaster
50422eb563 Tests: Add XHTML tests for CDATA, PIs and Comment nodes in the DOM 2025-07-19 14:56:20 +02:00
Andrew Kaster
f9f854b493 LibWeb: Preserve comments in XML documents 2025-07-19 14:56:20 +02:00
Andrew Kaster
9d93d37644 LibWeb: Listen for CDATASections and ProcessingInstructions in XML docs
Using the new hooks in the XML Parser's listener interface, we now
append DOM nodes for CDATASections and ProcessingInstructions
to the document as they are encountered. This commit also fixes where
comment nodes are appended, ensuring they are added to the current node
instead of the document root.
2025-07-19 14:56:20 +02:00
Andrew Kaster
d9976b98b9 LibXML: Add parser hooks for CDATASection and ProcessingInstructions
This allows listeners to be notified when a CDATASection or
ProcessingInstruction is encountered during parsing. The non-listener
path still has the incorrect behavior of silently treating CDATASection
as Text nodes, but this allows listeners to handle them correctly.
2025-07-19 14:56:20 +02:00
Luke Wilde
5a1de8a187 LibWeb/CSP: Implement the child-src directive
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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-07-19 17:15:21 +12:00
Luke Wilde
c5748437db LibWeb/CSP: Implement the default-src directive 2025-07-19 17:15:21 +12:00
Luke Wilde
25425f63ba LibWeb/CSP: Implement the worker-src directive 2025-07-19 17:15:21 +12:00
Aliaksandr Kalenik
714ff4e3f9 LibWeb: Fix previous style calculation for CSS transitions on pseudo
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / 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
...elements. Adds missing pseudo-element type passed into computed
properties getter.

Previously, due to this bug, we were using the element's computed
properties as the previous computed properties for its pseudo-elements.
This caused an excessive number of unintended CSS transitions to run.
The issue was particularly noticeable in Discord's emoji picker, where
each emoji has `::after` pseudo-element. We were incorrectly triggering
transitions on all their properties, resulting in significant
unnecessary work in style computation and animation event dispatching.
2025-07-18 21:19:37 +02:00
Aliaksandr Kalenik
2fc405f1b2 LibWeb: Allow to pass pseudo-element type in computed properties getter
...and setter. We had lots of places where we check if pseudo-element
type is specified and then use `pseudo_element_computed_properties()` or
`computed_properties()`. This change moves these checks from caller side
to the getter and setter.
2025-07-18 21:19:37 +02:00
Jelle Raaijmakers
86dc3ce001 AK: Add dbgln_dump() macro
This turns:

  dbgln_dump(some_expression() + 1);

Into:

  dbgln("some_expression() + 1: {}", (some_expression() + 1));
2025-07-18 14:40:00 -04:00
Timothy Flynn
9582895759 AK+LibJS+LibWeb+LibRegex: Replace AK::Utf16Data with AK::Utf16String 2025-07-18 12:45:38 -04:00
Timothy Flynn
a43cb15e81 LibJS+LibWeb: Replace JS::Utf16String with AK::Utf16String 2025-07-18 12:45:38 -04:00
Timothy Flynn
d40e3af697 AK: Implement UTF-16 string-to-number conversions 2025-07-18 12:45:38 -04:00
Timothy Flynn
6e0290ecaa AK: Define some UTF-16 helper methods
* contains
* escape_html_entities
* replace
* to_ascii_lowercase
* to_ascii_uppercase
* to_ascii_titlecase
* trim
* trim_whitespace
2025-07-18 12:45:38 -04:00
Timothy Flynn
7f069efbc4 AK: Implement a flyweight string for Utf16String
Utf16FlyString more or less works exactly the same as FlyString. It will
store the raw encoded data of the string instance. If the string is a
short ASCII string, Utf16FlyString holds the ShortString bytes; else,
Utf16FlyString holds a pointer to the Utf16StringData.
2025-07-18 12:45:38 -04:00
Timothy Flynn
2803d66d87 AK: Support UTF-16 string formatting
The underlying storage used during string formatting is StringBuilder.
To support UTF-16 strings, this patch allows callers to specify a mode
during StringBuilder construction. The default mode is UTF-8, for which
StringBuilder remains unchanged.

In UTF-16 mode, we treat the StringBuilder's internal ByteBuffer as a
series of u16 code units. Appending a single character will append 2
bytes for that character (cast to a char16_t). Appending a StringView
will transcode the string to UTF-16.

Utf16String also gains the same memory optimization that we added for
String, where we hand-off the underlying buffer to Utf16String to avoid
having to re-allocate.

In the future, we may want to further optimize for ASCII strings. For
example, we could defer committing to the u16-esque storage until we
see a non-ASCII code point.
2025-07-18 12:45:38 -04:00
Timothy Flynn
fe676585f5 AK: Add a UTF-16 string with optimized short- and ASCII-string storage
This is a strictly UTF-16 string with some optimizations for ASCII.

* If created from a short UTF-8 or UTF-16 string that is also ASCII,
  then the string is stored in an inlined byte buffer.

* If created with a long UTF-8 or UTF-16 string that is also ASCII,
  then the string is stored in an outlined char buffer.

* If created with a short or long UTF-8 or UTF-16 string that is not
  ASCII, then the string is stored in an outlined char16 buffer.

We do not store short non-ASCII text in the inlined buffer to avoid
confusion with operations such as `length_in_code_units` and
`code_unit_at`. For example, "😀" would be stored as 4 UTF-8 bytes
in short string form. But we still want `length_in_code_units` to
be 2, and `code_unit_at(0)` to be 0xD83D.
2025-07-18 12:45:38 -04:00