Commit graph

1016 commits

Author SHA1 Message Date
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 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
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() 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
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
Timothy Flynn
1bc80848fb AK+LibWeb: Add a UTF-16 starts/ends with wrapper for a single code unit 2025-08-07 02:05:50 +02:00
Luke Wilde
4aa355658f LibWeb/CSP: Implement the base-uri directive 2025-08-07 00:45:31 +02:00
Aliaksandr Kalenik
7a34bc2700 LibWeb: Re-evaluate media queries only when things they depend on change
Before this change we were re-evaluating media queries on every frame
which adds up in 1-4% in profiles on Discord.
2025-08-05 17:24:34 +02:00
Timothy Flynn
2dc0a3b3ce AK: Add trim methods to Utf16String that skip allocation when not needed
If the string does not begin with any of the provided code units, we do
not need to create a new string.
2025-08-05 15:13:36 +02:00
Timothy Flynn
0efa98a57a LibJS+LibWeb+WebContent: Port JS::PropertyKey to UTF-16
This has quite a lot of fall out. But the majority of it is just type or
UDL substitution, where the changes just fall through to other function
calls.

By changing property key storage to UTF-16, the main affected areas are:
* NativeFunction names must now be UTF-16
* Bytecode identifiers must now be UTF-16
* Module/binding names must now be UTF-16
2025-08-05 07:07:15 -04:00
Idan Horowitz
aeb7b442d3 LibWeb: Add initial support for bitmap cropping to createImageBitmap 2025-08-04 23:39:11 +02:00
Callum Law
e0e00220fe LibWeb: Handle Auto resolution within Page::preferred_color_scheme
Handling this here means we don't have to it within individual callers
2025-08-04 11:29:05 +01:00
Callum Law
46153910ec LibWeb: Update to_color to take ColorResolutionContext
Using a generic context argument will allow us to resolve colors in
places where we have all the required information but not in the form of
a layout node as was expected previously.
2025-08-04 11:29:05 +01:00
Idan Horowitz
ba6b82464c LibWeb: Add initial support for SVGImageElement in createImageBitmap 2025-08-03 21:47:48 +02:00