Commit graph

1068 commits

Author SHA1 Message Date
Callum Law
0e82ab2966 LibWeb: Define <opacity-value> as a ValueType
Since `<opacity-value>` is used across multiple properties it makes
sense to have it defined as a value.
2025-10-17 11:10:05 +01:00
Sam Atkins
1e1752b33b LibWeb/CSS: Mark list-valued properties
Typed-OM requires us to have a generic way of asking "does property X
accept a list or a single value?" so this exists mainly for that.
Coordinating lists are annotated too - I'm not clear on exactly what
will be needed for those, but giving them a unique value now at the
worst will make them easier to find later.
2025-10-04 22:57:00 +02:00
Johannes Gustafsson
f04b866cb0 LibWeb: Implement stubs for XPathEvaluator 2025-10-03 13:16:11 +02:00
Sam Atkins
a8312bf571 LibWeb/CSS: Use FlyString const& for property name IDL parameters 2025-10-02 13:46:04 +01:00
Sam Atkins
c0ef7f09e4 LibWeb/CSS: Use PropertyNameAndID instead of old Variant 2025-10-02 13:46:04 +01:00
Aliaksandr Kalenik
ffc05a9ca9 LibWeb/WebGL: Define Uint32List exactly like in the spec
Same fix as d54cab60 but applied for Uint32List.
2025-09-30 18:35:32 +02:00
Aliaksandr Kalenik
c75a8fab3b LibWeb/WebGL: Define Int32List exactly like in the spec
Same fix as d54cab60 but applied for Int32List.
2025-09-30 17:57:46 +02:00
Aliaksandr Kalenik
22075c08e4 BindingsGenerator: Return the exact typed array member type for unions
Allows definition of:
`typedef (Float32Array or sequence<GLfloat>) Float32List;`

which did fail to compile before, because `GC::Root<JS::Object>` fails
to implicitly cast into
`AK::Variant<GC::Root<JS::Float32Array>, AK::Vector<float>>`.
2025-09-30 16:47:16 +02:00
Sam Atkins
a098b5fcc4 LibWeb/CSS: Remove PropertyID::Invalid 2025-09-30 15:21:09 +02:00
Tim Ledbetter
3299ea97c6 LibWeb: Treat word-wrap as an alias for overflow-wrap 2025-09-30 13:50:53 +01:00
Sam Atkins
a1db5e7789 LibWeb/CSS: Implement CSSMatrixComponent
Equivalent to the matrix() and matrix3d() transform functions.

+19 WPT subtests.
2025-09-24 12:27:05 +01:00
Sam Atkins
8e86bf2dd0 LibWeb/CSS: Implement CSSTransformComponent
This is a base type for the various transform functions.

CSSMatrixComponent's to_string() can throw exceptions, so to_string() is
implemented that way. https://github.com/w3c/fxtf-drafts/issues/611

+9 WPT subtests.
2025-09-24 12:27:05 +01:00
Callum Law
43dd0f2dda LibWeb: Properly clamp interpolated opacity values
Opacity values are unique in that the range which calculated and
interpolated values should be clamped to [0,1] is different from the
range of allowed values [-∞,∞].

This fixes 28 WPT tests that were regressed in #6112
2025-09-24 12:01:52 +01:00
Niccolo Antonelli Dziri
a72b0c29bb LibWeb: Add a simplified Notification constructor
This allows the Notification object to be created in javascript without
any additional functionalities.

It passes two wpt tests which require a call to the notification
constructor with no arguments.

https://wpt.live/notifications/constructor-basic.https.html

https://wpt.live/notifications/constructor-invalid.https.html
2025-09-24 11:53:14 +01:00
Pavel Shliak
a7f85e1349 Meta: Use StringView consistently in IDL types argument list 2025-09-24 08:45:26 +01:00
Aliaksandr Kalenik
451c947c3f LibJS: Fast-path own-property enumeration and reduce descriptor lookups
Before this change, PropertyNameIterator (used by for..in) and
`Object::enumerable_own_property_names()` (used by `Object.keys()`,
`Object.values()`, and `Object.entries()`) enumerated an object's own
enumerable properties exactly as the spec prescribes:
- Call `internal_own_property_keys()`, allocating a list of JS::Value
  keys.
- For each key, call internal_get_own_property() to obtain a
  descriptor and check `[[Enumerable]]`.

While that is required in the general case (e.g. for Proxy objects or
platform/exotic objects that override `[[OwnPropertyKeys]]`), it's
overkill for ordinary JS objects that store their own properties in the
shape table and indexed-properties storage.

This change introduces `for_each_own_property_with_enumerability()`,
which, for objects where
`eligible_for_own_property_enumeration_fast_path()` is `true`, lets us
read the enumerability directly from shape metadata (and from
indexed-properties storage) without a per-property descriptor lookup.
When we cannot avoid `internal_get_own_property()`, we still
benefit by skipping the temporary `Vector<Value>` of keys and avoiding
the unnecessary round-trip between PropertyKey and Value.
2025-09-21 15:06:32 +02:00
Tim Ledbetter
637724f8d9 LibWeb: Add the overflow-inline property 2025-09-19 13:41:27 +01:00
Tim Ledbetter
2e00ff80e5 LibWeb: Add the overflow-block property 2025-09-19 13:41:27 +01:00
Andreas Kling
59a28febc9 AK: Store hash with HashTable entry to avoid expensive equality checks
When T in HashTable<T> has a potentially slow equality check, it can be
very profitable to check for a matching hash before full equality.

This patch adds may_have_slow_equality_check() to AK::Traits and
defaults it to true. For trivial types (pointers, integers, etc) we
default it to false. This means we skip the hash check when the equality
check would be a single-CPU-word compare anyway.

This synergizes really well with things like HashMap<String, V> where
collisions previously meant we may have to churn through multiple O(n)
equality checks.
2025-09-18 22:37:18 +02:00
Sam Atkins
1b8e81cd6f IDLGenerators: Support null as a default value for dictionary types
Specifically, NotificationOptions has this:

```webidl
dictionary NotificationOptions {
    // ...
    boolean? silent = null;
    // ...
};
```
https://notifications.spec.whatwg.org/#dictdef-notificationoptions

Without this patch, we generate this code, which isn't valid:

```c++
silent_value_11 = static_cast<bool>(null);
```

Treating `null` the same as no default value seems like the best option,
as they're equivalent in our C++ types.
2025-09-18 13:59:46 +01:00
Aliaksandr Kalenik
a54215c07d LibJS: Make internal_define_own_property() save added property offset
...in `PropertyDescriptor`. This is required for the upcoming change
that needs to know offset of newly added properties to set up inline
caching.
2025-09-17 12:44:44 +02:00
Aliaksandr Kalenik
85e029b2e7 LibJS+LibWeb: Inline fast path for Value::to_object()
Adds inline implementation for the most common case when `Value` is
already an object.

1.47x improvement on the following benchmark:
```js
const o = {};
for (let i = 0; i < 10_000_000; i++) {
    o.a = 1;
    o.b = 2;
    o.c = 3;
}
```
2025-09-15 12:16:58 +02:00
Sam Atkins
050d3a58cf LibWeb/CSS: Generate canonical/compatible unit functions
These are used by `CSSNumericValue.to(unit)` which attempts to convert
to the provided unit.
2025-09-12 13:45:41 +02:00
Sam Atkins
995c19da56 LibWeb/CSS: Return unit names as FlyStrings
From the CSS token side, we already have these in FlyString form. From
the generated code side, we can easily return FlyStrings instead of
StringViews. So, let's do that, and save some work converting back and
forth.
2025-09-12 13:45:41 +02:00
Aliaksandr Kalenik
db5fd614ac LibWeb: Require layout update for less properties in getComputedStyle()
Some properties like `justify-items`, `grid`, or `display` do affect
layout, but their used values can be obtained without performing a
layout calculation.

This change introduces a new helper,
`property_needs_layout_for_getcomputedstyle()`, specifically for use by
`CSSStyleProperties::property()`. It returns true only for properties
such as `width`, `height`, `margin`, `padding`, `top`, and `left`, where
an up-to-date layout is required to return the correct used value.
2025-09-12 11:06:16 +02:00
Sam Atkins
82f5be871a LibWeb: Generate the "Numeric Factory" OM methods on the CSS namespace
Generating boilerplate is nice! This also has the bonus that we're more
correct: I included all the units listed in the spec before,
(see https://drafts.css-houdini.org/css-typed-om-1/#numeric-factory )
but we're supposed to exactly include ones for the units we support:

> If an implementation supports additional CSS units that do not have a
  corresponding method in the above list, but that do correspond to one
  of the existing CSSNumericType values, it must additionally support
  such a method, named after the unit in its defined canonical casing,
  using the generic behavior defined above.

> If an implementation does not support a given unit, it must not
  implement its corresponding method from the list above.

Now, our factory functions will exactly match the units we support.

The changed test result is partly the order being different, and partly
that the container-query units are no longer included as we don't
actually support them.
2025-09-11 17:06:44 +01:00
Sam Atkins
bda4f8cbe8 LibWeb/CSS: Use raw_value() to bounds-check all dimension types
This avoids constructing temporary objects to compare against, and
reduces the amount of code. Also, a few of these were actually wrong!
2025-09-11 17:06:44 +01:00
Sam Atkins
cbc019350b LibWeb/CSS: Generate code for CSS dimension units 2025-09-11 17:06:44 +01:00
Psychpsyo
fa3c45d0b4 LibWeb: Implement optional function IDL arguments
This allows us to run some more view transitions WPT tests, one of
which has been imported.
2025-09-10 09:49:14 -04:00
Psychpsyo
56739b4b16 LibWeb: Implement plumbing for view transitions
This implements large parts of the CSS view-transitions-1 spec.
2025-09-07 13:58:05 +01:00
Luke Wilde
74e0483ea5 LibWeb: Implement the Gamepad API with SDL3 2025-09-01 21:10:47 +02:00
Luke Wilde
36d5e814ef IDLGenerator: Use fully qualified type names for namespace conflicts 2025-09-01 21:10:47 +02:00
Sam Atkins
ffb236adbd IDLGenerators: Correctly treat optional enums as optional
Specifically, this makes enums in dictionaries not cause compile errors.
2025-08-29 11:57:10 +02:00
Sam Atkins
73d7d6b831 LibWeb: Generate a math_function_from_string() function
This will be used as a convenient way to see if a string is the name of
a math function.
2025-08-29 11:57:10 +02:00
Sam Atkins
a46c980629 LibWeb/CSS: Implement CSSNumericArray 2025-08-29 11:57:10 +02:00
Sam Atkins
ef8ca729cc IDLGenerators: Make 'operator' a reserved word
This is the name of an attribute of CSSMathValue.
2025-08-29 11:57:10 +02:00
Sam Atkins
4791f9e88f IDLGenerators: Make attribute names C++-safe 2025-08-29 11:57:10 +02:00
Sam Atkins
f93819eda2 LibWeb/CSS: Remove unused <an+b># code for pseudo-classes
This reverts e7890429aa and partly reverts
a59c15481f.

The one pseudo-class that accepted multiple of these was :heading(), and
since that got changed to take integers instead, there's no need to keep
this extra complexity (and memory usage) around.
2025-08-28 12:40:03 +02:00
Sam Atkins
d461e96f40 LibWeb/CSS: Make :heading() pseudo-class take integers not AN+B
Corresponds to 8eb3787e34
2025-08-28 12:40:03 +02:00
stelar7
752210aec1 LibWeb/IDB: Implement IDBRecord 2025-08-27 16:13:25 +02:00
stelar7
b1c1e33bae LibWeb/EME: Implement MediaKeySystemAccess 2025-08-27 09:58:00 +02:00
stelar7
7f2b431810 Meta/IDL: Ensure unique variable name when iterating dictionary members 2025-08-27 09:58:00 +02:00
stelar7
69c6b6df91 Meta/IDL: Correctly generate variable names when value contains a dot 2025-08-27 09:58:00 +02:00
Idan Horowitz
4c49ce5fe5 LibWeb: Add support for caching IDL attribute values
This lets us properly implement for [SameObject] for generated
constructs like FrozenArray<T>.
2025-08-26 06:28:10 -04:00
Callum Law
fba4187c8f LibWeb: Add a constant for the number of longhand properties
We use this in multiple places (and will in more places in the future)
so it's worth having as a constant from a clarity point of view
2025-08-26 12:17:55 +02:00
Jelle Raaijmakers
3522ff16c0 Meta: Reuse "define the operations" algorithm for generated namespaces
This is one step closer to the spec. No functional changes.
2025-08-26 10:14:22 +02:00
ayeteadoe
3df8e00d91 LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Sam Atkins
5384338788 LibWeb/CSS: Implement CSSUnitValue 2025-08-22 09:48:30 +01:00
Sam Atkins
6cb8e92bd4 LibWeb/CSS: Stub out CSSNumericValue
Most of the methods on this rely on its subclasses existing, so for now
it's very basic.
2025-08-22 09:48:30 +01:00
Sam Atkins
5bdc2981e3 LibWeb/CSS: Rename CSSNumericType to NumericType
The CSSNumericType defined in the spec is a simple dictionary which is
only used for OM purposes. This NumericType class is used internally
and matches the more abstract definition of a "type".
2025-08-22 09:48:30 +01:00