Commit Graph

1134 Commits

Author SHA1 Message Date
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
Shannon Booth
39976bb4b8 LibWeb/Bindings: Use DefineDataPropertyOrThrow in Replaceable setter 2026-02-07 11:49:36 +01:00
Shannon Booth
1d3e48cce8 LibWeb/Bindings: Use JS Get for [PutForwards] attribute setter
Previously we were invoking the c++ getter, which is clearly not
correct.
2026-02-06 19:23:30 +01:00
Shannon Booth
c71d6d3b20 LibWeb/Bindings: Do not throw on [PutForwards] attribute setter 2026-02-06 19:23:30 +01:00
Shannon Booth
932a20423f LibWeb/Bindings: Treat missing attribute setter argument as undefined
Fold attribute setter handling into the shared [Replaceable] and
[PutForwards] paths, aligning the implementation more closely with the
WebIDL specification.

This change unfortunately introduces a regression in a WebAssembly
JS API test that expects attribute setters to throw when invoked
with no arguments (rather than treating the missing argument as
undefined). The exact specification text that mandates this
behavior for the WASM API is unclear to me.

The new behaviour seems like it would be more compatible in the
general case by not throwing an exception for all of the other
cases, so this commit accepts this as a regression until the
reasoning for needing to throw can be determined.
2026-02-06 19:23:30 +01:00
Shannon Booth
aa6b9ed318 LibWeb/Bindings: Treat no args as undefined for Replaceable/PutForwards 2026-02-06 19:23:30 +01:00
Shannon Booth
a5bbe4e44d LibWeb/Bindings: Add spec comments for PutForwards and Replaceable
No functional change intended, this is just intending to make it
obvious where the previous implementation was not following the
specification.
2026-02-06 19:23:30 +01:00
Andreas Kling
74a80b7bfc LibJS: Mark JS::Cell::initialize() as MUST_UPCALL
Intermediate classes in the initialize() chain set up prototypes and
define properties. Forgetting to call Base::initialize() in any
override would silently skip that setup.
2026-02-06 13:50:54 +01:00
Andreas Kling
706eb0018c LibGC+LibWeb: Mark two GC::Cell functions as MUST_UPCALL
Let's make sure that subclasses always call their base class when
overriding these virtuals:

- void finalize()
- void visit_edges(Visitor&)
2026-02-06 13:50:54 +01:00
Psychpsyo
617b8cb247 LibWeb: Implement the very basics of XRSession 2026-02-04 15:08:37 +01:00
Callum Law
85d64a1215 LibWeb: Parse @counter-style additive-symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
ecfdf252b8 LibWeb: Parse @counter-style symbols descriptor 2026-02-03 09:58:47 +00:00
Callum Law
1f8c9cf662 LibWeb: Parse @counter-style fallback descriptor 2026-02-03 09:58:47 +00:00
Callum Law
9b376240f9 LibWeb: Parse @counter-style pad descriptor 2026-02-03 09:58:47 +00:00
Callum Law
afca221d47 LibWeb: Parse @counter-style range descriptor 2026-02-03 09:58:47 +00:00
Callum Law
f1e8d54717 LibWeb: Parse @counter-style prefix and suffix descriptors 2026-02-03 09:58:47 +00:00
Callum Law
70c8d8746f LibWeb: Parse @counter-style negative descriptor 2026-02-03 09:58:47 +00:00
Callum Law
f60bfd9e9e LibWeb: Parse @counter-style system descriptor 2026-02-03 09:58:47 +00:00
Andrew Kaster
5cfb497e65 LibWeb: Reduce memory usage for GenerateWindowOrWorkerInterfaces
Before, we had inefficient Vector usage in this code generator that
caused a lot of heap churn while loading in all the IDL files. Given
that this file will load in hundreds of IDL files, we can do better by
mmapping the files directly instead of reading them into two separate
file contents string buffers and then copying them into a growing vector
2026-02-03 10:29:51 +01:00
Timothy Flynn
34466eeb2d IDLGenerators: Do not generate a plain type for default nullable values
Commit 1b8e81cd6f added a check to prevent
assigning a default value when the default value itself is null. But we
had previously generated an uninitialized type, expecting it to become
defaulted later on. So we would have generated code such as:

    bool value;

    if (!property.is_null() && !property.is_undefined())
        value = property.to_boolean();

    options.value = value;

This is undefined behavior.

We know use the same default value check to ensure we generate Optional
types instead. So the above `value` initializer becomes:

    Optional<bool> value;
2026-02-02 18:01:08 +01:00
Jonathan Gamble
4e48ba36bd LibWeb: Better handling of union types in IDL code generation
First check if a string is a member of the enum before attempting
numeric conversion. This generates correct code for fields like:

AudioContextOptions {
  latencyHint: AudioContextLatencyCategory | double;
}
2026-01-26 18:46:39 +01:00
Andreas Kling
35839af2d2 LibWeb: Optimize getComputedStyle() to avoid layout when possible
Previously, getComputedStyle() would always call update_layout() for
most properties. This was expensive since layout involves a full tree
traversal even when only style information is needed.

This change introduces a more granular approach:
- Properties needing layout computation (used values like width/height)
  still call update_layout()
- Properties needing a layout node for resolved value computation
  (colors, border widths, etc.) also call update_layout()
- All other properties now only call update_style()

The set of properties needing layout node for resolution is now defined
in Properties.json via the "needs-layout-node-for-resolved-value" flag,
rather than being hardcoded. This is generated into a new function
property_needs_layout_node_for_resolved_value().
2026-01-26 12:40:36 +01:00
Reimar
26181f2958 LibWeb: Implement External interface 2026-01-22 14:56:46 +01:00
Jelle Raaijmakers
e8cbddbeb8 Meta/IDLGenerators: Clean up is_platform_object()
Any type ending in "Event" or "Element" does not need to be added to the
manually curated list of platform objects in is_platform_object().
Additionally, "WindowProxy" was already part of that list, so no need to
check for it separately. No functional changes.
2026-01-20 07:28:32 -05:00
Jelle Raaijmakers
99923eac8d LibWeb: Add stubbed Speech API 2026-01-20 06:51:04 -05:00
Psychpsyo
52781cc2fd LibWeb: Add WebXR's XRSystem 2026-01-11 00:01:24 +01:00
Shannon Booth
f67c15b2ff LibWeb/Bindings: Ensure identity for [LegacyUnforgeable] attributes
The WebIDL spec requires that attributes marked [LegacyUnforgeable]
share the same getter and setter function objects across all instances
within the same Realm.

Previously, we were creating new JS::NativeFunction wrappers during
every instance initialization, which caused identity checks to fail.
This change moves these functions into Bindings::Intrinsics so they
are created once per Realm and reused.
2026-01-08 12:57:17 +01:00
Andreas Kling
2ac363dcba LibGC: Only call finalize() on types that override finalize()
This dramatically cuts down on time spent in the GC's finalizer pass,
since most types don't override finalize().
2026-01-07 20:51:17 +01:00
Shannon Booth
f9a996650b LibWeb/HTML: Implement the Origin interface
See: https://github.com/whatwg/html/commit/68909b2
2025-12-30 12:40:27 +01:00
Callum Law
cbd07b2153 LibWeb: Don't mark whether shorthand properties are inherited
Inheritance applies to longhands individually so whether a shorthand was
marked as inherit or not is irrelevant
2025-12-29 16:11:13 +01:00
Sam Atkins
2b2e5a1db3 LibWeb/CSS: Support legacy selector aliases for pseudo-classes
These are replaced with the pseudo-class they are an alias of, during
parsing.
2025-12-18 14:50:27 +01:00
Sam Atkins
7418d262ed IDLGenerators: Convert reflected attribute names to ASCII lowercase 2025-12-15 14:08:24 +00:00
Callum Law
3089f12609 Meta: Avoid outputting stray closing bracket in IDL code generation 2025-12-12 10:49:18 +00:00
Andreas Kling
cb23d65625 LibJS: Pass JS::Value directly to string formatting functions
We don't need to call .to_string_without_side_effects() when passing
a JS::Value in for string formatting. The Formatter will do it for us.
2025-12-09 21:44:13 -06:00
Callum Law
7110687155 LibWeb: Add method to get multiplicity of property 2025-12-08 11:41:13 +00:00
Sam Atkins
16c12c1485 LibWeb: Parse the ::part() pseudo-element selector
It doesn't yet do anything, but it helps a few tests that just check
serialization.
2025-12-08 09:44:32 +00:00
mikiubo
de4e3ef63a LibWeb: Honor LegacyNullToEmptyString in union string conversion
The IDL generator was passing 'false' to generate_to_cpp when converting
a union containing a string type.
This broke WebIDL's LegacyNullToEmptyString behavior.

Pass the actual legacy_null_to_empty_string flag instead.
Fixes some WPTs:

domparsing/outerhtml-02
trusted-types/block-string-assignment-to-Element-outerHTML
trusted-types/block-string-assignment-to-HTMLElement-generic
trusted-types/block-string-assignment-to-ShadowRoot-innerHTML
2025-12-07 07:45:45 +00:00
Callum Law
12e8f503aa LibWeb: Support non-fixed <random-value-sharing>
This works by generating random values using XorShift128PlusRNG at
compute time and then caching them on the document using the relevant
random-caching-key
2025-12-01 11:00:33 +00:00
Callum Law
86e6aa0291 LibWeb: Keep track of random function index within property value
Caching keys for 'auto' <random-value-sharing> rely on this value to
distinguish between two random functions in a single property
2025-12-01 11:00:33 +00:00