Commit Graph

4447 Commits

Author SHA1 Message Date
Timothy Flynn
2df4835025 LibWeb: Place HTTP cache logging behind a debug flag
It's quite verbose to have logging on by default here.
2025-09-19 13:52:07 +02: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
Jelle Raaijmakers
49817a1c6a CI+Meta: Add option to enable baseline CPU target for CI
We currently have the issue that our macOS builds are being hosted by
both Apple M1 and M4 runners. By default, these target `-mcpu=apple-m1`
and `-mcpu=apple-m3` respectively, causing their ccache artifacts to be
incompatible and effectively thrashing each other's ccache cache on each
run.

Add a new CMake option `ENABLE_CI_BASELINE_CPU` that toggles a baseline
`-mcpu/-march` compile option for each of the supported build platforms.
When disabled (the default), we now default to `-march=native` which on
Linux could theoretically lead to better performance.

The new CPU baseline is used by the `lagom-template.yml` and
`js-and-wasm-artifacts.yml` workflows, since they both produce artifacts
or caches that might be picked up by other runners. We also enable it
for Flatpak builds, so they target a fixed architecture instead of
whatever architecture the action runner that picked up the job has.
2025-09-16 10:53:15 -04: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
Tim Ledbetter
21082f5002 Meta: Only update hosts file when necessary in WPT.sh
Previously, the hosts file was updated at the same time the WPT repo
was cloned, but updating the hosts file is only necessary for commands
that start the WPT test runner.
2025-09-07 08:14:42 -04:00
Luke Wilde
74e0483ea5 LibWeb: Implement the Gamepad API with SDL3 2025-09-01 21:10:47 +02:00
Luke Wilde
50dcd8fc85 Meta+WebContent+LibWeb: Add, link and initialize 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
Erik Kurzinger
21ff66c6cb LibWeb/SVG: Parse comma-separated SVG viewBox
From the SVG spec

The value of the ‘viewBox’ attribute is a list of four numbers <min-x>,
<min-y>, <width> and <height>, separated by whitespace and/or a comma...

Currently try_parse_view_box will fail to parse the attribute if the
values are separated by commas.

This change replaces try_parse_view_box with a more correct
implementation. It will reside in the AttributeParser.cpp. This new
implementation correctly handles comma-separated viewBox values, and is
also more robust against invalid inputs.

Additionally, it adds a new test case to ensure viewBox values with
various syntax are parsed correctly and invalid values are rejected.
2025-08-30 15:49:11 +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
sayhan
02abd3e373 Meta: Fixed variable typo switfc -> swiftc 2025-08-25 11:02:04 +02:00
ayeteadoe
9ec1643d88 CMake: Add helper to ensure vcpkg DLLs are copied to the output dir
The BUILD_RPATH/INSTALL_RPATH CMake infrastructure is not supported
on Windows, but we want to ensure Ladybird executables are runnable
after the build phase so there can be an efficient dev loop.
lagom_copy_runtime_dlls() can be used by executable targets so all
their dependent dlls are copied to their output directory in their
post build step.
2025-08-23 16:04:36 -06:00
ayeteadoe
3df8e00d91 LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
ayeteadoe
ee3c033de2 LibWebView: Enable in Windows CI 2025-08-23 16:04:36 -06:00
Idan Horowitz
bcb8b06a74 ClangPlugins: Make sure forward declared fields are visited as well
Instead of ignoring fields using forward-delcared types, always assume
they inherit from GC::Cell. This improves the worst case from a missed
unvisited field, to a slightly wrong error message.

Fixes #5959.
2025-08-23 21:21:04 +02:00
Idan Horowitz
1eed5bdef7 ClangPlugins: Check for unvisited JS::Value members
JS:Value members might hold a JS::Cell inside, so they must be visited
in ::visit_edges implementations as well.

Fixes #5958.
2025-08-23 21:21:04 +02: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
Sam Atkins
6428c9990d LibWeb/CSS: Implement CSSUnparsedValue and CSSVariableReferenceValue
We don't serialize these the way WPT expects, because we don't implement
the comment-insertion rules from CSS-Syntax. We don't implement that
for regular serialization either, so it's something we can worry about
later.
2025-08-21 10:21:54 +01:00
Sam Atkins
a93c6a347f LibWeb/CSS: Implement CSSKeywordValue
CSSStyleValue is adjusted to allow for subclasses. Serialization for
CSSKeywordValue is implemented differently than the spec says because
of a spec bug: https://github.com/w3c/csswg-drafts/issues/12545
2025-08-21 10:21:54 +01:00
Tete17
658477620a LibWeb/LibURL/LibIPC: Extend createObjectURL to also accept MediaSources
This required some changes in LibURL & LibIPC since it has its own
definition of an BlobURLEntry. For now, we don't have a concrete usage
of MediaSource in LibURL so it is defined as an empty struct.

This removes one FIXME in an idl file.
2025-08-19 23:50:38 +02:00
Luke Wilde
a04f2d0796 Meta: Remove curl overlay port
The http3 feature is now upstream, so we no longer need an overlay port
to use it.
2025-08-19 22:08:55 +02:00
Abhinav
be5c52bfef Meta: Detect urls to import from Worker 2025-08-18 11:27:12 +01:00
Timothy Flynn
f8d414ec37 Meta: Pass ladybird.py extra arguments to the target process
Let's behave a bit more like the run command here. This allows us to run
`ladybird.py profile js zlib.js`, for example.
2025-08-18 01:43:45 +02:00
Sam Atkins
80a6dc4da0 LibIDL: Make ExposedTo an enum class 2025-08-15 09:21:28 +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
Sam Atkins
882288bf86 LibWeb/CSS: Stub out CSSStyleValue 2025-08-13 09:47:50 +01:00
Sam Atkins
b447dc63c4 IDLGenerators: Include JS::Array in constructor implementations
Will be required by CSSStyleValue.
2025-08-13 09:47:50 +01:00
Sam Atkins
e7890429aa LibWeb/CSS: Add support for pseudo-classes taking <an+b># 2025-08-13 09:47:28 +01:00
Callum Law
6025805f19 LibWeb/Meta: Compute the accepted value range for CalculationContexts
This currently only applies to property-level calculation contexts, more
work to be done to generate accepted ranges for other calculation
contexts (e.g. within transformation functions, color functions, etc)
2025-08-11 17:10:04 +01:00
Callum Law
2af7016a77 LibWeb: Rename ValueType::OpenTypeTag to ValueType::OpentypeTag
This is the correct capitalization in line with what it is called in the
spec "opentype-tag".
2025-08-11 17:10:04 +01:00
Tete17
adaad653ca LibWeb: Implement TrustedScriptURL class 2025-08-11 12:21:31 +01:00
Tete17
56cab6955a LibWeb: Implement TrustedScript type
This turns out to be very similar to TrustedHTML.
2025-08-11 12:21:31 +01:00
Tete17
90bcc16a7b LibWeb: Add TrustedTypePolicy class
It is mostly a skeleton with no actual implementation.
2025-08-11 12:21:31 +01:00
Tete17
0a147aa9a1 LibWeb: Implement TrustedHTML class
The TrustedHTML interface represents a string that a developer can
confidently insert into an injection sink that will render it as HTML.

These objects are immutable wrappers around a string, constructed via a
TrustedTypePolicy’s createHTML method.
2025-08-11 12:21:31 +01:00
Idan Horowitz
70efa8c1c5 LibWeb: Implement CookieChangeEvent 2025-08-08 13:09:58 -04:00
Idan Horowitz
dc1b7b1925 IDLGenerators: Support generating dictionary to value converter helpers
This is useful when returning dictionaries as a Promise.
2025-08-08 13:09:58 -04:00
Idan Horowitz
d6c2893663 LibWeb: Add initial CookieStore support 2025-08-08 13:09:58 -04:00
Sam Atkins
7c29db6ab0 Meta: Exclude crash and screenshot tests from newline-at-eof requirement 2025-08-08 15:59:24 +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
Ali Mohammad Pur
0d8ad0a9fe Meta: Bump minimum compiler versions for deducing this 2025-08-08 12:54:06 +02:00
Edwin Hoksberg
1be31c103f LibWeb: Stub WebSerial API 2025-08-08 10:23:17 +02:00
Sam Atkins
7b30c94fcf LibWeb+CodeGenerators: Generate EnvironmentVariable enum and functions 2025-08-07 16:38:29 +02:00
Timothy Flynn
f3c3213b06 Meta: Add a ladybird.py command to profile a process
Works basically the same as the debug command. This command uses
callgrind for now, which matches LibWebView/HelperProcess.cpp.
2025-08-07 06:57:26 -04:00
Timothy Flynn
11f4b9c6ae Meta: Resolve pyright warnings in ladybird.py and helpers 2025-08-07 06:57:26 -04:00
InvalidUsernameException
add3a095d8 LibWeb/CSS: Rename background-repeat related symbols to align with spec
These will be used for the mask-repeat property as well in an upcoming
commit, hence the more generic names. Also, this more closely matches
the names used in the spec.
2025-08-06 23:09:07 +01:00
Edwin Hoksberg
6d954b73f1 LibWeb: Fix IDL codegen for dictionary return type with optional members 2025-08-06 16:34:44 -04:00
Bernard Niset
02b5ab385a Meta: Generate correct format for user-variables.cmake 2025-08-06 16:32:15 -04: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
Sam Atkins
cebdcd9f69 LibWeb/CSS: Use ErrorReporter for value-parsing errors
Also remove some redundant reporting for `<urange>` parsing errors.
2025-08-04 10:50:09 +01:00
Tim Ledbetter
1d9e4a6f62 LibWeb: Parse anchor() function for inset properties 2025-08-03 22:09:31 +02:00
Glenn Skrzypczak
c5fc4a5ac2 Meta: Download resources referenced in action attributes of forms
Resources referenced in the action attribute of forms now also get
downloaded by the WPT import script.
2025-08-02 18:27:35 +01:00
Timothy Flynn
13ed6aba71 AK+LibIPC: Implement an encoder/decoder for UTF-16 strings 2025-08-02 10:10:14 -07:00
Tim Ledbetter
138eabcf0d Meta: Ensure WPT repository exists before attempting to import tests
Previously, importing tests would fail if the WPT repository wasn't
already cloned.
2025-07-30 22:47:04 +02:00
Tete17
8fdd9b68dc LibWeb: First implementation of the TrustedTypePolicyFactory
Most of the functions are either not implemented of filled with dummy
values.
2025-07-30 15:51:35 +01:00
Tete17
223b1cc704 LibWeb: Add barebones SVGAnimationElement class
Many wpt test on trusted-types relay on this class being defined to even
begin the test as it declares some event handlers.

This is not really an implementation but the most basic setup needed to
run the tests.
2025-07-30 15:51:35 +01:00
Jan Koudijs
1b1eae4409 Meta: Add a freedesktop appstream/metainfo manifest 2025-07-28 19:37:48 -06:00
Andrew Kaster
64f1a76636 CMake: Ignore invalid offset of when generating Swift interop header 2025-07-26 23:33:58 +02:00
Timothy Flynn
49467d0583 LibIDL+LibWeb: Support UTF-16 USVString 2025-07-26 00:40:06 +02:00
Jelle Raaijmakers
acc7c2f7f3 LibWeb: Do not use namespace in interface names
Gives us 20 additional WPT subtest passes in `wasm/jsapi`.
2025-07-25 16:50:45 +02:00
Luke Wilde
da5fca15ee LibWeb: Only expose performance.{timing,navigation} on Window
They are only valid in a Window context, and the spec only exposes them
in Window contexts.

Fixes workers crashing on:
- https://web.whatsapp.com/
- https://pro.kraken.com/app/trade/btc-usd
2025-07-25 11:46:58 +02:00
Timothy Flynn
cb85eac3d8 LibIDL+IDLGenerators: Begin supporting UTF-16 strings in IDL
This adds a new IDL type, Utf16DOMString. This is the same as DOMString,
except it is UTF-16. This type is temporary - we will want DOMString to
be UTF-16 by default once we've ported enough of LibWeb.

To make this support easier, some string IDL generator handling is moved
directly into `generate_to_string` from the call sites.
2025-07-24 19:00:20 +02:00
Andrew Kaster
85baf71d48 Meta: Use clang to build ladybird module in flatpak 2025-07-23 15:12:00 -06:00
Jan Koudijs
0c89b2e690 Meta: Add offline build for ANGLE flatpak module
At the same time, build with gcc instead of bundled clang.

Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
2025-07-23 15:12:00 -06:00
Andrew Kaster
7d458103a8 Meta: Move skia and angle flatpak build scripts to their own directories 2025-07-23 15:12:00 -06:00
Andrew Kaster
35f65b8dab Meta: Bump version of gn flatpak source module to rev 2255 2025-07-23 15:12:00 -06:00
Andrew Kaster
738c81877c Meta: Move build of gn module in flatpak build before angle 2025-07-23 15:12:00 -06:00
Andrew Kaster
08221c2534 Meta: Skip build directories when building Ladybird module in flatpak
flatpak-builder doesn't respect .gitignore when creating its local build
directory, so we need to explicitly skip potentially large ignored
directories to avoid bloating the flatpak build directory during builds.
2025-07-23 15:12:00 -06:00
Sam Atkins
943cc0e32a LibWeb/CSS: Implement "legacy value aliases" in generated code
This uses a `foo>bar` notation in the `valid-identifiers` field of
Properties.json, to say "replace `foo` with `bar`".

The motivation here is to avoid calling `parse_css_value_for_property()`
inside the per-property switch in `parse_css_value()`. Eventually we'll
need to be able to call that switch from
`parse_css_value_for_properties()` so that shorthands can make use of
any bespoke parsing code to parse their longhands.
2025-07-23 12:50:42 +01:00
Jelle Raaijmakers
526615bc10 LibWeb: Stub Navigator.getGamepads() 2025-07-22 11:55:29 -04:00
Jelle Raaijmakers
cdb736bea5 LibWeb: Remove WrappingReference from IDLGenerators
We have no cases where WrappingReferences::No does not result in the
right wrapper expression, so let's remove the enum.
2025-07-22 11:55:29 -04:00
Jelle Raaijmakers
529ab9d88a Meta: Allow partial interface when formatting IDL files 2025-07-22 13:07:06 +01:00
Luke Wilde
0faf96fa1b Meta/curl: Update to 8.15.0
This includes the patch for issue 17917, so we can remove our custom
patch :^)
2025-07-21 15:09:35 +02:00
Sam Atkins
16ef883e44 IDLGenerators: Update spec steps for "internally create a new object..."
Also wrap these in {} so it's clearer which steps are from this, and
which are from the HTML algorithm.
2025-07-21 10:05:32 +01:00
Sam Atkins
3ca879776f IDLGenerators: Allow initialize() as an IDL member name
While not a C++ keyword, we already define a `Foo::initialize()` method
on every generated binding type, so we need to avoid clashing with that.
2025-07-21 10:05:32 +01:00
Sam Atkins
ef252d63c8 IDLGenerators: Add support for default values on bool dictionary members 2025-07-21 10:05:32 +01:00