Commit graph

1075 commits

Author SHA1 Message Date
Jelle Raaijmakers
518c048eb4 LibWeb+WebContent: Rename Document::focused_element to ::focused_area
And make it a DOM::Node, not DOM::Element. This makes everything flow
much better, such as spec texts that explicitly mention "focused area"
as the fact that we don't necessarily need to traverse a tree of
elements, since a Node can be focusable as well.

Eventually this will need to be a struct with a separate "focused area"
and "DOM anchor", but this change will make it easier to achieve that.
2025-08-26 10:25:59 +02:00
Tim Ledbetter
cb1a1a5cb5 LibWeb: Replace is<T>() with as_if<T>() where possible
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-08-25 18:45:00 +02:00
Andreas Kling
79b30e7c9a LibWeb: Create a new painter after resizing canvas element backing store
Otherwise, we just keep painting into the old backing store. This fixes
an issue where the main spreadsheet area in Google Sheets was not
visually updating, despite everything looking good in memory.
2025-08-24 16:36:24 +02:00
ayeteadoe
3df8e00d91 LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Tim Ledbetter
aadd563592 LibWeb: Replace usages of dynamic_cast with as and as_if
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-08-22 20:26:09 +02:00
Timothy Flynn
c3f4d32162 LibWeb: Extract FormAssociatedElement's grapheme edge code to a helper
The edge detection will be used at least in hit testing.
2025-08-22 14:06:46 +02:00
Andreas Kling
ec2b568919 LibWeb: Add missing StyleInvalidationReason for HTMLDialogElement
We were accidentally using NodeRemove instead of a unique reason.
2025-08-20 09:14:58 +02:00
Timothy Flynn
0e4fb9ae73 LibWeb: Ensure up/down arrow navigation is grapheme-aware
Previously, it was possible for an up/down arrow press to place the
cursor in the middle of a multi-code point grapheme cluster. We want to
prevent this in a way that matches the behavior of other browsers.

Both Chrome and Firefox will map the starting position to a visually
equivalent position in the target line with harfbuzz and ICU segmenters.
The need for this is explained in a code comment. The result is a much
more natural feeling of text navigation.
2025-08-18 13:17:28 +02:00
Jelle Raaijmakers
ff5f80a196 LibWeb: Add HTMLElement::uses_button_layout()
This suits the spec a bit better, and exposes the fact that we were
allowing `::ImageButton` to use the button layout although it is never
specified that it should do so. Tests were rebaselined for this.
2025-08-18 11:04:34 +01:00
Glenn Skrzypczak
c01dc5900a LibWeb/HTML: Check all radio buttons in group for required attribute
This fixes a bug in the algorithm for determining if radio buttons are
missing their value. Previously it was only checked if the button
itself is required. Now the algorithm checks if the radio button group
contains a required radio button in order to determine if the value is
required.
2025-08-17 22:27:14 +02:00
Vaxry
040ccc3b42 LibWeb: Allow loading style sheets without a MIME type
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
Some websites do not specify the MIME type of style sheets, instead
using as= or just leaving it empty.

Both Chromium and Firefox do load them regardless, so let's do it too.
2025-08-17 02:34:35 +02:00
Timothy Flynn
017ae80668 LibWeb: Validate form submissions whose submitter is not form-associated
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 spec for checking the no-validate state ends with a default return
value of "false". However, we were only hitting this case for form-
associated elements. If the submitter is the form itself, we want to
enter the form validation steps.
2025-08-15 15:28:37 +02:00
mikiubo
23aadc02ca LibWeb: Implement up/down arrow navigation in textarea 2025-08-15 06:32:11 -04:00
Timothy Flynn
c369f68eff LibWeb: Delete entire graphemes when the delete/backspace key is pressed
We currently delete a single code unit. If the user presses backspace on
a multi code point emoji, they are going to expect the entire emoji to
be removed. This now matches the behavior of Chrome and Firefox.
2025-08-14 22:21:51 +02:00
Glenn Skrzypczak
d25d62e74c AK/Time+LibWeb/HTML: Fix ISO8601 week conversions
This reimplements conversions between unix date times and ISO8601
weeks. The new algorithms also do not use loops, so they should be
faster.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
ec807d40dd LibWeb/HTML: Correctly convert number to time/local datetime string
This fixes a bug where non-zero milliseconds were previously not
included if the second component was zero.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
354fd56046 LibWeb/HTML: Step to next value without step mismatch
Inputs now correctly step to the next valid value if they suffer a step
mismatch.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
a127f77602 LibWeb/HTML: Implement default value of range inputs
Range inputs now always uses the default value if the value attribute
is not set and the input is not dirty.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
aea8650d8b LibWeb/HTML: Enforce constraints on range inputs
This extends the sanitization algorithm for range inputs in order to
prevent overflow, underflow and step mismatch.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
57376f8701 LibWeb/HTML: Ensure the year of month and week values is greater than 0
The validation algorithm for month and week inputs now also checks if
the year is greater than zero.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
544a6b21fc LibWeb/HTML: Correctly normalize local datetime values
Now trailing zeros in the second and millisecond part of local datetime
values are removed during normalization.
2025-08-14 11:05:28 -04:00
Glenn Skrzypczak
cac2ee41b9 LibWeb/HTML: Correctly compute whether element is mutable
This adapts the implementation of `is_mutable` to align more closely
with the spec. Specifically, it is now also taken into account whether
the element is enabled.
2025-08-14 11:05:28 -04:00
Kenneth Myhra
1228063a85 LibWeb: Enforce Integrity Policy on Fetch requests 2025-08-14 13:37:38 +01:00
CountBleck
d49fb169bc LibWeb: Correct typos for user validity of form elements on submission
The spec and comments say "set field's user validity to true", but we
now actually set it to true and not false.

This passes one subtest in WPT's css/selectors/user-valid.html.
2025-08-14 11:55:02 +02:00
Timothy Flynn
70db474cf0 LibJS+LibWeb: Port interned bytecode strings to UTF-16
This was almost a no-op, except we intern JS exception messages. So the
bulk of this patch is porting exception messages to UTF-16.
2025-08-14 10:27:08 +02:00
Timothy Flynn
62d85dd90a LibJS: Port RegExp flags and patterns to UTF-16 2025-08-13 09:56:13 -04:00
Timothy Flynn
b955c9b2a9 LibJS: Port the Identifier AST (and related) nodes to UTF-16
This eliminates quite a lot of UTF-8 / UTF-16 churn.
2025-08-13 09:56:13 -04:00
Timothy Flynn
8472e469f4 AK+LibJS+LibWeb: Recognize that our UTF-16 string is actually WTF-16
For the web, we allow a wobbly UTF-16 encoding (i.e. lonely surrogates
are permitted). Only in a few exceptional cases do we strictly require
valid UTF-16. As such, our `validate(AllowLonelySurrogates::Yes)` calls
will always succeed. It's a wasted effort to ever make such a check.

This patch eliminates such invocations. The validation methods will now
only check for strict UTF-16, and are only invoked when needed.
2025-08-13 09:56:13 -04:00
Timothy Flynn
28d9d3a2c7 AK+Libraries: Reduce API surface of GenericLexer a bit
* Remove completely unused methods.
* Deduplicate methods that were overloaded with both StringView and
  char const* parameters.

A future commit will templatize GenericLexer by char type. This patch
serves to make that a tiny bit easier.
2025-08-13 09:56:13 -04:00
Lukas Schmidt
c2fc4b25cd LibWeb: Implement HTMLElement.draggable()
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-08-12 17:15:06 +01:00
Sam Atkins
615034433b LibWeb/HTML: Add missing if to <details> attribute_changed() logic 2025-08-12 15:53:51 +02:00
Kenneth Myhra
e9246c15d9 LibWeb: Pass top-level navigation initiator origin to Fetch's Request 2025-08-12 07:08:33 -04:00
Andreas Kling
bd7599ccfc LibCore: Remove macro-generated EventReceiver::try_create(...) factories
We can just use the infallible factory everywhere instead.
2025-08-11 16:55:25 +02:00
Sam Atkins
4bcfc4bacc LibWeb/HTML: Add cross-site ancestor flag to environment
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
Corresponds to baec061a70
2025-08-11 11:08:04 +01:00
Sam Atkins
cfdc4bad7c LibWeb: Update more navigation code to spec
Partly corresponds to 80ebad5fbf

This is mostly to handle null source_documents, which is something that
needs more work elsewhere. The spec change above is about the deferred
fetch quota.
2025-08-11 11:08:04 +01:00
Sam Atkins
0e5fd11bdc LibWeb/HTML: Create navigation params for browser-UI navigations
Step 4 corresponds to 3b6a99b1d9

The rest is from some earlier spec change.
2025-08-11 11:08:04 +01:00
Sam Atkins
cf969abba7 LibWeb/HTML: Add missing "else" to create_navigation_params_by_fetching 2025-08-11 11:08:04 +01:00
Sam Atkins
0b998b8379 LibWeb: Update base URL change processing
Corresponds to 49f5cd381e
2025-08-11 11:08:04 +01:00
Idan Horowitz
5545d38d7a LibWeb: Implement CookieStore::get(name) 2025-08-08 13:09:58 -04:00
Idan Horowitz
d6c2893663 LibWeb: Add initial CookieStore support 2025-08-08 13:09:58 -04:00
Timothy Flynn
4a8c70b3a5 LibWeb: Parse CSS/image URLs using DOMURL::parse
DOMURL::parse handles blob URLs.
2025-08-08 17:47:51 +01:00
Timothy Flynn
9e474a4eb0 LibWeb: Add missing includes to SharedResourceRequest
Missing Cell.h and Ptr.h were causing a bunch of clangd errors. Also
remove unused includes while we're here.
2025-08-08 17:47:51 +01:00
Sam Atkins
6cad3f1921 LibWeb/CSS: Rename CSSColorValue -> ColorStyleValue
The typed-om class will be a separate thing.
2025-08-08 15:19:03 +01:00
Sam Atkins
99bce9a94d LibWeb/CSS: Replace CSSUnitValue with DimensionStyleValue
CSSUnitValue is a typed-om type which we will implement separately in
the future. However, it still seems useful to give our dimension values
a base class. (Maybe they could be templated in the future?) So instead
of deleting it entirely, rename it to DimensionStyleValue and make its
API match our style better.
2025-08-08 15:19:03 +01:00
Sam Atkins
4e92ab52e3 LibWeb/CSS: Rename CSSKeywordValue -> KeywordStyleValue
The typed-om CSSKeywordValue will need to be a separate class.
2025-08-08 15:19:03 +01:00
Sam Atkins
c57975c9fd LibWeb: Move and rename CSSStyleValue to StyleValues/StyleValue.{h,cpp}
This reverts 0e3487b9ab.

Back when I made that change, I thought we could make our StyleValue
classes match the typed-om definitions directly. However, they have
different requirements. Typed-om types need to be mutable and GCed,
whereas StyleValues are immutable and ideally wouldn't require a JS VM.

While I was already making such a cataclysmic change, I've moved it into
the StyleValues directory, because it *not* being there has bothered me
for a long time. 😅
2025-08-08 15:19:03 +01:00
Edwin Hoksberg
1be31c103f LibWeb: Stub WebSerial API 2025-08-08 10:23:17 +02:00
Luke Wilde
59162342e6 LibWeb: Set LinkProcessingOptions' cryptographic_nonce_metadata
Fixes external CSS being blocked on https://beatsaver.com/, where they
have a `style-src` directive set to `'self' 'nonce-[value]'`

Relates to #5643, but does not make the website load.
2025-08-07 19:26:57 +02:00
Luke Wilde
1d57df6e26 LibWeb/CSP: Implement the sandbox directive 2025-08-07 19:24:39 +02:00
Luke Wilde
40bb50ac60 LibWeb: Parse and propagate the iframe sandbox attribute 2025-08-07 19:24:39 +02:00