Commit Graph

1172 Commits

Author SHA1 Message Date
Sam Atkins
492cfc58d9 LibWeb/CSS: Add flags for element-backed & tree-abiding pseudo-elements
Generate a couple of functions for checking if a pseudo-element fits
these categories.
2026-04-08 10:37:05 +01:00
Shannon Booth
bb0f244667 LibWeb: Remove ShadowRealm HTML integration 2026-04-05 13:57:58 +02:00
Shannon Booth
f27bc38aa7 Everywhere: Remove ShadowRealm support
The proposal has not seemed to progress for a while, and there is
a open issue about module imports which breaks HTML integration.
While we could probably make an AD-HOC change to fix that issue,
it is deep enough in the JS engine that I am not particularly
keen on making that change.

Until other browsers begin to make positive signals about shipping
ShadowRealms, let's remove our implementation for now.

There is still some cleanup that can be done with regard to the
HTML integration, but there are a few more items that need to be
untangled there.
2026-04-05 13:57:58 +02:00
Shannon Booth
85765ccb5c LibWeb: Factor newTarget prototype setup into WebIDL helper 2026-04-05 02:09:39 +02:00
Shannon Booth
b05c56cbb6 LibWeb/Bindings: Fix LegacyUnenumerableNamedProperties enumerability
The boolean was mistakenly reversed.
2026-04-03 18:33:45 +02:00
Shannon Booth
379461e047 LibWeb: Make global prototype chains immutable
Per https://webidl.spec.whatwg.org/#interface-prototype-object any
global platform object should reject prototype changes (besides
from ShadowRealmGlobalScope), and interface prototype objects on
global prototype chains must be immutable.

We already handled parts of this on the globals themselves, but not
the full chain.

Also align some spec comments to the latest WebIDL spec.
2026-04-03 18:33:45 +02:00
Psychpsyo
f4a86c8466 LibWeb: Implement enough of WebXR for xrSession_end test to pass 2026-04-03 13:14:33 +02:00
Timothy Flynn
2e2a99a379 LibWeb: Add a stub for the Cache interface
The Cache and CacheStorage interfaces are quite intertwined. A Cache
object can only be created through CacheStorage, so the Cache interface
cannot be tested on its own. So adding just this stub will allow
implementing the CacheStorage interfaces that create Cache objects. We
can then implement the Cache interface piecemeal.
2026-04-03 11:04:12 +02:00
Zaggy1024
a54a86c024 Meta: Treat MediaSource as a platform object
This allows URL.createObjectURL(new MediaSource()) to succeed.
2026-04-01 02:54:22 -05:00
Callum Law
071b000d9f LibWeb: Only allow ASFs in descriptor values if explicitly supported
`@function` descriptors are the only ones that support ASFs, while most
descriptors enforce this through their syntaxes implicitly disallowing
ASFs, this wasn't the case for `@property/initial-value`.

We now explictly disallow ASFs unless they are marked as allowed within
`Descriptors.json`.
2026-03-30 19:57:36 +01:00
Sam Atkins
ed6a5f25a0 LibWeb: Implement scoped custom element registries 2026-03-27 19:49:55 +00:00
Sam Atkins
ecbd846272 LibWeb/DOM: Implement DocumentOrShadowRoot.customElementRegistry
Step towards scoped custom element registries.
2026-03-27 19:49:55 +00:00
Callum Law
e7243f0090 LibWeb: Support custom descriptors
Some at-rules (i.e. `@function`) require us to support custom
descriptors (e.g. `--foo`).

We do this by adding `DescriptorID::Custom` and using a new
`DescriptorNameAndID` class in a bunch of places where we previously
just used `DescriptorID`
2026-03-27 11:19:28 +00:00
Jonathan Gamble
793a4eeb8e Meta: Support nullable BufferSource as Optional in IDL generator
This IDL change is needed for webaudio's WaveShaperNode, where a
null BufferSource for a curve attribute results in a zero-length buffer.

WebGL also has a nullable BufferSource arg in bufferData(...). But
there, a null data/srcData value returns GL_INVALID_VALUE.
2026-03-27 00:03:39 +01:00
Callum Law
0ab06e119e LibWeb: Use i32 max for clamping 'infinite' calculated integers
This required us to change our range values from `float`s to `double`s
since `float` can't exactly represent i32 max
2026-03-26 12:30:01 +01:00
Luke Wilde
cfd795f907 LibWeb+IDLGenerators: Support nullable union types 2026-03-25 13:18:15 +00:00
Callum Law
500ca417ce LibWeb: Map logical aliases at compute rather than cascade time
This requires us to front load computation of writing-mode and direction
before we encounter any logical aliases or their physical counterparts
so that we can create a mapping context.

Doing this at compute rather than cascade time achieves a few things:
 1) Brings us into line with the spec
 2) Avoids the double cascade that was previously required to compute
    mapping contexts
 3) We now compute values of logical aliases, while
    `style_value_for_computed_property` maps logical aliases to their
    physical counterparts, this didn't account for all cases (i.e. if
    there was no layout node, Typed OM, etc).
 4) Removes a hurdle to moving other upstream processes (i.e. arbitrary
    substitution function resolution, custom property computation) to
    compute time as the spec requires.
2026-03-25 12:53:22 +00:00
Callum Law
d0a868dcfb LibWeb: Add method to map from physical to logical property
This will be required in later commit.

The implementation could do with some optimization
2026-03-25 12:53:22 +00:00
Callum Law
d284ff96fe LibWeb: Nest logical property group physical properties
In a later commit we will also add logical properties in here
2026-03-25 12:53:22 +00:00
Shannon Booth
3a95df60f9 LibWeb/Bindings: Deduplicate cpp type name normalization
This was copy and pasted twice.
2026-03-19 22:14:26 +01:00
Shannon Booth
0803ace948 LibWeb/Bindings: Factor out function for generating dictionary to cpp 2026-03-19 22:14:26 +01:00
Shannon Booth
f04e7d88d5 LibWeb/Bindings: Add a forward declaration of generate_to_cpp
generate_to_cpp is called recursively, such as when generating
dictionary values. To support factoring this (massive) function
into functions, add a forward declaration.
2026-03-19 22:14:26 +01:00
Shannon Booth
92f4fc2cb9 LibWeb/Bindings: Don't use parameter type in may_be_null checks
Whether a converted value may be null should only depend on the presence
and value of an optional default, not the nullability of the type being
passed in.
2026-03-19 22:14:26 +01:00
Shannon Booth
71ba774083 LibWeb/Bindings: Don’t set @@unscopables in unforgeable attribute setup
[Unscopable] members should only affect the interface prototype’s
@@unscopables object. The bindings generator was also creating an empty
@@unscopables object in define_unforgeable_attributes(), installing it
as an own property on instances.
2026-03-19 20:44:36 +01:00
Shannon Booth
19af2bebc7 LibWeb/Bindings: Implement LegacyLenientThis extended attribute 2026-03-14 00:08:20 +01:00
Shannon Booth
604b79403c LibWeb/Bindings: Add early returns to attribute setter codegen
Previously we avoided early returns and used `else if` chains instead,
since returning early could prevent other required code generation
steps from running. This structure diverged from the specification and
makes implementing [LegacyLenientThis] more difficult.

Now that attribute setter logic has been moved into its own function,
the necessary code generation can run independently, allowing us to
use early returns where appropriate.

No functional impact.
2026-03-14 00:08:20 +01:00
Shannon Booth
4b92e0f0c2 LibWeb/Bindings: Factor out attribute setter code generation
No functional impact.
2026-03-14 00:08:20 +01:00
Shannon Booth
dcce7e63c6 LibWeb/Bindings: Remove redundant HTML::Window check in impl_from
This is covered by the @fully_qualified_name@ type check just below,
WindowProxy is the only special case that we need to handle at the
IDL layer. Also split this into two separate functions while we
are at it, as this function as-is is performing a few different
specification steps all at once.
2026-03-14 00:08:20 +01:00
Jelle Raaijmakers
fb353a64c1 LibWeb: Detect promise-returning IDL callbacks correctly
The code generator checked is_object() to detect Promise return types,
but Promise<T> is a ParameterizedType, so the check always failed and
caused crashes in WebContent in throwing callback functions.
2026-03-12 10:38:43 +01:00
Shannon Booth
e555edd770 LibWeb/Bindings: Implement callback interface object bindings
Generate correct bindings for callback interfaces: only create an
interface object when the interface declares constants, and set up
the prototype correctly.

This also lets us tidy up some IDL for these callback interfaces.
2026-03-11 21:16:44 +01:00
Shannon Booth
6a2540213a LibWeb/Bindings: Use implemented names for imported IDL headers
The bindings generator derived imported interface headers from the IDL
file name. That only works when the IDL name, implemented C++ type, and
header basename all match.

Interfaces with [ImplementedAs] break that assumption, since the
generated bindings need to include the implementation header rather than
the header implied by the IDL file name.

This fixes a compile error in a future commit where EventListener
callback interface is split into its own IDL file with an
ImplementedAs of IDLEventListener.
2026-03-11 21:16:44 +01:00
Jonathan Gamble
938ca3dbad Meta: Fix optional dictionary wrapping in IDL generator
Handle Optional<T> and Optional<Variant<...>> correctly when wrapping
dictionary members, and make ComputedEffectTiming.localTime optional
to distinguish absence from null.
2026-03-10 22:49:19 +01:00
Jelle Raaijmakers
703bef336a Meta/IDLGenerators: Do not call resolve_overload() if possible
For overload sets of size 1, we don't need to call into
`resolve_overload()` preventing many heap allocations. This effectively
removed EffectiveOverloadSet / resolve_overload from profiles for me on
slither.io.
2026-02-27 11:42:38 -05:00
Jelle Raaijmakers
0d262ac558 Meta/IDLGenerators: Make use of as_if<T> for union type checks 2026-02-27 11:42:38 -05:00
Luke Wilde
09e00677eb IDLGenerators: Support Experimental extended attribute on IDL attributes 2026-02-24 17:08:48 +01:00
Sam Atkins
f657a4b71b LibWeb/CSS: Parse @font-face { font-weight } with two values
WPT has coverage for matching but not parsing, so the test is homemade.
2026-02-24 10:05:09 +00:00
Luke Wilde
79de597f8a IDLGenerator: Implement LegacyLenientSetter 2026-02-23 18:44:26 +00:00
Ben Wiederhake
b765a3a261 LibWeb: Remove unused header in IDLGenerators 2026-02-23 12:15:23 +01:00
Jelle Raaijmakers
1745926fc6 AK+Everywhere: Use MurmurHash3 for int/u64 hashing
Rework our hash functions a bit for significant better performance:

* Rename int_hash to u32_hash to mirror u64_hash.
* Make pair_int_hash call u64_hash instead of multiple u32_hash()es.
* Implement MurmurHash3's fmix32 and fmix64 for u32_hash and u64_hash.

On my machine, this speeds up u32_hash by 20%, u64_hash by ~290%, and
pair_int_hash by ~260%.

We lose the property that an input of 0 results in something that is not
0. I've experimented with an offset to both hash functions, but it
resulted in a measurable performance degradation for u64_hash. If
there's a good use case for 0 not to result in 0, we can always add in
that offset as a countermeasure in the future.
2026-02-20 22:47:24 +01:00
Callum Law
f0434655f9 LibWeb: Reduce recompilation from editing Enums.json
Reduces the recompilation caused by editing `Enums.json` from ~1528 to
~327
2026-02-19 11:27:06 +00:00
Timothy Flynn
8ad1c72ed3 LibWeb+LibWebView+Services: Add a flag to enable experimental interfaces
This adds the --expose-experimental-interfaces command line flag to
enable experimental IDL interfaces. Any IDL interface with Experimental
in its exposed attributes will be disabled by default.

The problem is that by stubbing out or partially implementing interfaces
in LibWeb, we actually make some sites behave worse. For example, the
OffscreenCanvas interface being exposed makes sites believe we fully
support it, even though we don't. If the interface was not exposed,
these sites may fall back to ordinary canvas objects. Similarly, to
use YouTube, we currently have to patch out MSE interfaces.

This flag will allow developers to iteratively work on features,
without breaking such sites. We enable experimental interfaces during
tests.
2026-02-17 22:17:50 +01:00
Ben Wiederhake
dab83d35d1 AK: Remove unused include from ByteString 2026-02-17 12:38:51 +00:00
Callum Law
3f8da74e63 LibIDL+Meta: Add support for WebIDL maplike declarations on interfaces
Currently we only support string keys and numeric sequence values.

This is heavily based on the implementation of `setlike`.
2026-02-17 12:25:27 +00:00
Shannon Booth
bc93ba4530 LibWeb/Bindings: Implement [SecureContext] extended attribute
Unfortunately this is a bit of a pain to test as it is surprisingly
difficult to create a non secure context in our test harness.
This is because both file scheme URLs and localhost are considered
secure contexts.

To test this, add a very specific internals setter to change the
top level origin of the environment for the current realm.
2026-02-14 20:22:40 +01:00
Shannon Booth
6bdced0014 Meta: Simplify arguments to add_interface in WindowOrWorker 2026-02-14 20:22:40 +01:00
Shannon Booth
303f85e8e4 LibWeb/Bindings: Implement 'is exposed' using the InterfaceName enum 2026-02-14 20:22:40 +01:00
Shannon Booth
7a6301f58a LibWeb/Bindings: Generate an enum of all interface names 2026-02-14 20:22:40 +01:00
Callum Law
63584321fe LibWeb: Skip property computation in some cases
There are cases where we can skip the property value computation process
because we know that the computed value will be equal to the specified
value
2026-02-13 21:54:06 +01:00
Callum Law
32da7edf5e LibWeb: Compute font properties the same as other properties
Previously we computed font properties separately from other properties
for two reasons:
  1) These font properties were computed using a different length
     resolution context than the rest of the properties.
  2) These properties were required to be computed before creating the
     length resolution context for the rest of the properties.

The first issue was solved in the previous commit by introducing a
generic method to get the computation context for a property, and
the second is solved in this commit by computing properties in the
required order.

This simplifies the code a bit and opens up some opportunities for
optimization.
2026-02-13 21:54:06 +01:00
Niccolo Antonelli Dziri
94ca0dcbef IDLGenerators: Translate boolean? silent = null to Optional<bool>
It was prevously translating it to just `bool` instead of
`Optional<bool>`.

Required elements in dictionary (such as in Notification.idl
for the NotificationAction) were treated as Optional<T> like the other
non-required elements. Now it's just the type without the Optional.

Co-authored-by: Zaggy1024 <gregory.bertilson@gmail.com>
2026-02-13 16:47:42 +00:00