Commit graph

71080 commits

Author SHA1 Message Date
Callum Law
ba62679a7a LibWeb: Make text cursor same height as text
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
Previously we would paint the cursor the entire height of the text
fragment - this didn't look great with large line-heights. Now we only
paint it the height of the actual text, with the top of the cursor
aligning with the font "ascent" and the bottom the "descent".
2025-08-16 15:47:44 +02:00
Callum Law
71b039a721 LibWeb: Use document's global object in is_base_allowed_for_document
Previously we were using the document's window - this was both contrary
to spec and causing crashes when the document did not have a window (for
instance the `temp_document` in `HTMLParser::parse_html_fragment`.

This means we no longer crash when navigating between pages on
https://rocketlabcorp.com
2025-08-16 14:19:05 +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
Sam Atkins
888cb038e8 LibWeb/CSS: Expose a couple of types on PaintWorklet and LayoutWorklet
This has no actual effect, but it's nice to remove the FIXMEs.
2025-08-15 09:21:28 +02:00
Sam Atkins
6be9f0757f LibIDL: Add LayoutWorklet and PaintWorklet parsing
We don't support these yet, but this avoids having to comment out IDL
definitions that are exposed to them.
2025-08-15 09:21:28 +02:00
Sam Atkins
24c5dc2f7f LibIDL: Deduplicate code that parses an ExposedTo name 2025-08-15 09:21:28 +02:00
Sam Atkins
80a6dc4da0 LibIDL: Make ExposedTo an enum class 2025-08-15 09:21:28 +02: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
Timothy Flynn
76bab90812 LibWeb: Use rendered text to find word boundaries when double-clicking
This effectively reverts da26941b50.

When the user double-clicks a word on screen, they are interacting with
the rendered text, which has e.g. whitespace collapsing applied. If we
acquire word boundaries from the raw text, the resulting selection is
not right.

We still have issues with acquiring the right selection via APIs such as
`document.getSelection`. The offsets computed here are effectively then
applied to the raw text. But this issue is present all over EventHandler
and this patch at least makes the selection visually accurate.
2025-08-14 19:36:38 +02:00
Timothy Flynn
e314ca5e9d LibJS: Introduce ParseMonthCode and CreateMonthCode Temporal AOs
This is an editorial change in the Temporal proposal. See:
28357ea
32f4b02
f860ac6
e6f565d
2025-08-14 11:35:28 -04:00
Timothy Flynn
0f4d5d3abc LibJS: Remove no-op call to ValidateTemporalUnitValue
This is an editorial change in the Temporal proposal. See:
07c924b
2025-08-14 11:35:28 -04: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
ec051bdec2 LibWeb: Import css/selectors/user-valid.html from WPT 2025-08-14 11:55:02 +02: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
norbiros
783ae44462 LibWeb: Fix color interpolation by premultiplying alpha
The current Color::interpolate_color method does not follow the specs
properly. Started improving it by handling premultiplied alpha in color
interpolation.

Only one WPT test covers this (color-transition-premultiplied), which we
currently pass due to a different approach in Color.mixed_with.
2025-08-14 11:09:05 +02:00
ayeteadoe
d91d28dc2a Meta: Replace lint-clang-format.sh with lint-clang-format.py
Currently you need to use Git Bash or alternative bash implementations
to fully run the pre-commit checks on Windows. This will now allow
for formatting changes without bash.
2025-08-14 10:57:31 +02:00
stelar7
8addd5771f LibWeb/IDB: Add debug dump to Keys 2025-08-14 09:31:56 +01:00
stelar7
9e66f49b44 LibWeb/Tests: Update IDB keyorder test file 2025-08-14 09:31:56 +01:00
stelar7
75054aeecd LibWeb/IDB: Allow null errors during abort 2025-08-14 09:31:56 +01:00
stelar7
474b748275 LibWeb/IDB: Check the request error instead of the transaction 2025-08-14 09:31:56 +01:00
stelar7
a7bcb1b0c5 LibWeb/IDB: Dont set state in IDBTransaction::abort 2025-08-14 09:31:56 +01: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
cf61171864 LibJS: Port remaining bytecode identifiers to UTF-16 2025-08-14 10:27:08 +02:00
Timothy Flynn
829fd25264 LibJS: Add a UTF-16 variant of Value::to_string_without_side_effects 2025-08-14 10:27:08 +02:00
Timothy Flynn
c87122eb32 LibJS: Add a method to stringify a BigInt to UTF-16
And remove the ByteString variant while we are here.
2025-08-14 10:27:08 +02:00
Luke Wilde
12dc771186 CI: Create wasm artifact and use it in the js-benchmarks workflow 2025-08-14 10:02:35 +02:00
Jamie Mansfield
73a05f9163 LibWeb: Implement VTTCue.position 2025-08-13 23:05:50 +02:00
Jamie Mansfield
8204143b08 LibWeb: Implement VTTCue.line 2025-08-13 23:05:50 +02:00
Jelle Raaijmakers
9080af4085 RequestServer: Don't set CURLOPT_HTTPGET _and_ CURLOPT_CUSTOMREQUEST
Some checks failed
CI / macOS, arm64, Sanitizer, Clang (push) Has been cancelled
CI / Linux, x86_64, Fuzzers, Clang (push) Has been cancelled
CI / Linux, x86_64, Sanitizer, GNU (push) Has been cancelled
CI / Linux, x86_64, Sanitizer, Clang (push) Has been cancelled
Package the js repl as a binary artifact / Linux, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / macOS, arm64 (push) Has been cancelled
Package the js repl as a binary artifact / Linux, x86_64 (push) Has been cancelled
Run test262 and test-wasm / run_and_update_results (push) Has been cancelled
Lint Code / lint (push) Has been cancelled
Label PRs with merge conflicts / auto-labeler (push) Has been cancelled
Push notes / build (push) Has been cancelled
We always set CURLOPT_CUSTOMREQUEST, so we can skip setting
CURLOPT_HTTPGET.
2025-08-13 10:30:04 -04:00
Jelle Raaijmakers
ed57d2de98 RequestServer: Don't return unused bool when setting curl options 2025-08-13 10:30:04 -04:00
Jelle Raaijmakers
da351ac468 RequestServer: Pass nullptr instead of an unused variable 2025-08-13 10:30:04 -04:00
Jelle Raaijmakers
585e4ed875 RequestServer: Add some useful dbgln_if()s
In trying to debug request handling, I've found these to help
understanding what's going on behind the scenes.
2025-08-13 10:30:04 -04:00
Jelle Raaijmakers
41cf150a5b LibDNS+RequestServer: Don't construct Vectors to validate DNS response
Instead of filling vectors and returning them just to invoke
`.is_empty()`, forward the calls to the underlying vectors directly.
2025-08-13 10:30:04 -04: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
00182a2405 LibJS: Port the JS lexer and parser to UTF-16
This ports the lexer to UTF-16 and deals with the immediate fallout up
to the AST. The AST will be dealt with in upcoming commits.

The lexer will still accept UTF-8 strings as input, and will transcode
them to UTF-16 for lexing. This doesn't actually incur a new allocation,
as we were already converting the input StringView to a ByteString for
each lexer.

One immediate logical benefit here is that we do not need to know off-
hand how many UTF-8 bytes some special code points occupy. They all
happen to be a single UTF-16 code unit. So instead of advancing the
lexer by 3 positions in some cases, we can just always advance by 1.
2025-08-13 09:56:13 -04:00
Timothy Flynn
eb74781a2d LibJS: Keep the lookahead lexer alive after parsing its next token
Currently, the lexer holds a ByteString, which is always heap-allocated.
When we create a copy of the lexer for the lookahead token, that token
will outlive the lexer copy. The token holds a couple of string views
into the lexer's source string. This is fine for now, because the source
string will be kept alive by the original lexer.

But if the lexer were to hold a String or Utf16String, short strings
will be stored on the stack due to SSO. Thus the token will hold views
into released stack data. We need to keep the lookahead lexer alive to
prevent UAF on views into its source string.
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
36c7302178 AK: Optimize the UTF-16 StringBuilder for ASCII storage
When we build a UTF-16 string, we currently always switch to the UTF-16
storage mode inside StringBuilder. Then when it comes time to create the
string, we switch the storage to ASCII if possible (by shifting the
underlying bytes up).

Instead, let's start out with ASCII storage and then switch to UTF-16
storage once we see a non-ASCII code point. For most strings, this will
avoid allocating 2x the memory, and avoids many ASCII validation calls.
2025-08-13 09:56:13 -04:00
Timothy Flynn
99d7e08dff AK: Templatize GenericLexer for UTF-16 strings
We now define GenericLexer as a template to allow using it with UTF-16
strings. To keep existing users happy, the template is defined in the
Detail namespace. Then AK::GenericLexer is an alias for a char-based
view, and AK::Utf16GenericLexer is an alias for a char16-based view.
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