The clang-format version released with llvm 19 will format many files
differently than clang-format-18.
This change presents the existing warning shown for incorrect
clang-format versions to those with versions greater than 18.
Fixes issue #1750
CSS Syntax 3 (https://drafts.csswg.org/css-syntax) has changed
significantly since we implemented it a couple of years ago. Just about
every parsing algorithm has been rewritten in terms of the new token
stream concept, and to support nested styles. As all of those
algorithms call into each other, this is an unfortunately chonky diff.
As part of this, the transitory types (Declaration, Function, AtRule...)
have been rewritten. That's both because we have new requirements of
what they should be and contain, and also because the spec asks us to
create and then gradually modify them in place, which is easier if they
are plain structs.
Prior to this change, running ./Meta/ladybird.sh rebuild would not
remove the user-variables.cmake file that was generated by the build
script. This caused errors when testing out the .devcontainer on my
Mac because the pkg-config binary lived in different dirs in the
container vs host.debug
There was no need to use FlyString for error messages, and it just
caused a bunch of churn since these strings typically only existed
during the lifetime of the error.
DedicatedWorkerGlobalScope is an object with a Global extended
attribute, but does not define any named property getters. This needs to
be handled by setting the prototype chain to:
DedicatedWorkerGlobalScope
^ DedicatedWorkerGlobalScopePrototype
^ WorkerGlobalScopePrototype
(This is different from something like Window, where there is an
intermediate WindowProperties object for named properties.)
Previously, we treated the GlobalMixin object as if it was a simple
prototype object, accidentally setting DedicatedWorkerGlobalScope's
prototype to WorkerGlobalScopePrototype. This caused the expression
self instanceof DedicatedWorkerGlobalScope
to return false inside workers.
This makes us pass many more of the "/xhr/idlharness.any.worker" WPT
tests than before, rather than failing early.
Disable some non-supported flags on windows platforms, and
pull in some flags from the other windows support branches.
Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
When the TokenStream code was originally written, there was no such
concept in the CSS Syntax spec. But since then, it's been officially
added, (https://drafts.csswg.org/css-syntax/#css-token-stream) and the
parsing algorithms are described in terms of it. This patch brings our
implementation in line with the spec. A few deprecated TokenStream
methods are left around until their users are also updated to match the
newer spec.
There are a few differences:
- They name things differently. The main confusing one is we had
`next_token()` which consumed a token and returned it, but the spec
has a `next_token()` which peeks the next token. The spec names are
honestly better than what I'd come up with. (`discard_a_token()` is a
nice addition too!)
- We used to store the index of the token that was just consumed, and
they instead store the index of the token that will be consumed next.
This is a perfect breeding ground for off-by-one errors, so I've
finally added a test suite for TokenStream itself.
- We use a transaction system for rewinding, and the spec uses a stack
of "marks", which can be manually rewound to. These should be able to
coexist as long as we stick with marks in the parser spec algorithms,
and stick with transactions elsewhere.
Between WPT.sh and ladybird.sh.
This is useful to me as I set my default build configuration to Debug,
and have been hacking around with the WPT script to align with this
configuration.
ladybird.sh allows the source directory to be overriden to point to
another source directory. I am not sure if anyone is actually using this
behaviour in practise, but let's make the behaviour at least common
between the two scripts with a helper function.
These were used to provide a layer of abstraction between ResourceLoader
and the networking backend. Now that we only have RequestServer, we can
remove these adapters to make the code a bit easier to follow.
Now that we use libcurl, there's no reason to keep Qt networking around.
Further, it doesn't support all features we need anyways, such as non-
buffered request handling for SSE.
https://www.w3.org/TR/event-timing/#sec-performance-event-timing
Add idl, header and stubs for PerformanceEventTiming interface.
Two missing `PerformanceEntry` types that have come up in issues
are the `first-input` and the `event` entryTypes. Those are both
this.
Also, because both of those are this same interface, the static
methods from the parent class are difficult to implement because
of instance-specific details. Might either need subclasses or to
edit the parent and also everything that inherits from it :/
While Origin is defined in the HTML spec - this leaves us with quite an
awkward relationship as the URL spec makes use of AO's from what is
defined in the HTML spec.
To simplify this factoring, relocate Origin into LibURL.
Now we can register jobs and they will be executed on the event loop
"later". This doesn't feel like the right place to execute them, but
the spec needs some updates in this regard anyway.
There is an issue where gifs with many frames cannot be loaded, as each
bitmap is sent over IPC using a separate file descriptor, and there is
limit on the maximum number of descriptors per IPC message. Thus, trying
to load gifs with more than 64 frames (the current limit) causes the
image decoder process to die.
This commit introduces the BitmapSequence class, which is a thin wrapper
around the type Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>> and
provides an IPC encode/decode routine that collates all bitmap data into
a single buffer so that only a single file descriptor is required per
IPC transfer, even if multiple frames are being sent.
This is a special form of `<string>` so doesn't need its own style value
type. It's used in a couple of font-related properties. For completeness
it's included in ValueType.
swift-format is available in the Xcode 16 Beta and homebrew.
We will need some extra docs to tell Linux developers how to get it on
their distribution.
This also makes use of the fact that you can pass git diff a colon
delimited pattern to include ':*pattern' or exclude ':!*pattern'
matching files, which is pretty neat.
We had numerous NiH-based implementations of audio formats and metadata
that we now no longer need because we either don't make use of the code,
or we replaced its implementation by FFmpeg.
This loader supports whatever format libavformat and libavcodec can
handle. Currently only seekable streams are supported, and we still have
some limitations as to the number of channels and sample format.
Plays all non-streaming audio files at:
https://tools.woolyss.com/html5-audio-video-tester/
When a property is a "legacy name alias", any time it is used in CSS or
via the CSSOM its aliased name is used instead.
(See https://drafts.csswg.org/css-cascade-5/#legacy-name-alias)
This means we only care about the alias when parsing a string as a
PropertyID - and we can just return the PropertyID it is an alias for.
No need for a distinct PropertyID for it, and no need for LibWeb to
care about it at all.
Previously, we had a bunch of these properties, which misused our code
for "logical aliases", some of which I've discovered were not even
fully implemented. But with this change, all that code can go away, and
making a legacy alias is just a case of putting it in the JSON. This
also shrinks `StyleProperties` as it doesn't need to contain data for
these aliases, and removes a whole load of `-webkit-*` spam from the
style inspector.
The vcpkg install is handled through an action to run vcpkg install with
the private --x-install-root flag that their CMake toolchain file uses
to install dependencies into a build-time directory.
Rather than checking the avcodec version in CMake, check it using the
avcodec version macros in the only source file that needs to know about
the AVFrame API/ABI change in version 59.24.100. This is friendlier to
other build systems that would rather avoid configure time checks.
The build assumed QT or AppKit are the only build UI frameworks. This
extends the default assumption away from that to start experimenting
with building on other platforms.
The `gn` build did not generate the CMake configuration file for the
backtrace module. Update the rules to configure the generated macros
mirroring the CMake build.
The file is not committed to disk until the close which occurs at the
termination of the scope. Extract the `rename` to outside the scope
allowing this to work on Windows. The `download_file` utility downloads
a file in the `gn` build.
Previously, using `ladybird.sh run` with any target that was part of the
MacOS app bundle would try to run the given executable from the wrong
directory.
This confirmed works on Xcode 16, and Xcode 16.1 Beta 2, with CMake 3.28
or higher.
On linux, the 6.0.0 release from swiftly is still missing my libstdc++
workaround, so it needs a snapshot to work.
When the detected SDK for CMAKE_OSX_SYSROOT and friends has the same
version as your current macOS system version, CMake helpfully doesn't
set CMAKE_OSX_DEPLOYMENT_TARGET. Unfortunately, in this case, swiftc
will default to macOS 10.4, which is absolutely ancient. Grab the target
triple from the -print-target-info JSON when CMAKE_OSX_DEPLOYMENT_TARGET
is not provided at configure time.
The IPCs to request a page's text, layout tree, etc. are currently all
synchronous. This can result in a deadlock when WebContent also makes
a synchronous IPC call, as both ends will be waiting on each other.
This replaces the page info IPCs with a single, asynchronous IPC. This
new IPC is promise-based, much like our screenshot IPC.
This change allows the user to specify the format of the log file to be
generated by the `WPT.sh` script. Multiple logging arguments may now be
specified.
The supported logging arguments are: `--log-raw`, `--log-unittest`,
`--log-xunit`, `--log-html`, `--log-mach`, `--log-tbpl`,
`--log-grouped`, `--log-chromium`, `--log-wptreport` and
`--log-wptscreenshot`. These arguments act the same as the equivalent
arguments supported by `wpt run`.
The short `--log` argument may also be used as an alias for `--log-raw`.
UI event handlers currently return a boolean where false means the event
was cancelled by a script on the page, or otherwise dropped. It has been
a point of confusion for some time now, as it's not particularly clear
what should be returned in some special cases, or how the UI process
should handle the response.
This adds an enumeration with a few states that indicate exactly how the
WebContent process handled the event. This should remove all ambiguity,
and let us properly handle these states going forward.
There should be no behavior change with this patch. It's meant to only
introduce the enum, not change any of our decisions based on the result.
This adds a new script for linting WebIDL files, and adds it to the set
of scripts Meta/lint-ci.sh runs. Initially, this script does just one
thing: normalizes IDL definition lines so they start with four spaces.
This script only checks Tests/AK, and verifies that all source files
that match Tests/AK/*.cpp are listed in the CMakeLists.txt.
This is a bit excessive. We don't have this check for any other test
files. This sort of error will definitely ™️ be caught in review.
CMake reads CMakePresets.json, which is before it reads CMakeLists.txt.
This causes CMake Error: Unrecognized "version" field if the version of
CMake is older than support for presets, or the version field of
presets.
The fix is to check CMake version in ladybird.sh before trying to create
the build directory.
Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
You can now build with STYLE_INVALIDATION_DEBUG and get a debug stream
of reasons why style invalidations are happening and where.
I've rewritten this code many times, so instead of throwing it away once
again, I figured we should at least have it behind a flag.
Instead of switching on the PropertyID and doing a boatload of
comparisons, we reorder the PropertyID enum so that all inherited
properties are in two contiguous ranges (one for shorthands,
one for longhands).
This replaces the switch statement with two simple range checks.
Note that the property order change is observable via
window.getComputedStyle(), but the order of those properties is
implementation defined anyway.
Removes a 1.5% item from the profile when loading https://hemnet.se/
This header held a bunch of utility functions shared across several code
generators. The only user of any of these utilities now is the public
suffix generator. Move the one used function to that generator, and
remove the common header.
Depending on usage, `@layer` has two forms, with two different CSSOM
types. One simply lists layer names and the other defines a layer with
its contained rules.
This change should move us forward toward emoji support, as we are no
longer limited by our own OpenType implementation, which was failing
to parse the TrueType Collection format used to store emoji fonts
(at least on macOS).
This is only used for CSS style sheets. One case wants it as a String,
and the others don't care, but will in future also want to have the
source as a String.
When trying to use pkgconfig for finding libjxl, the build fails
trying to link the cross-compiler's libc++.
Using this way libjxl also requires hwy library.
Findlibjxl.cmake was taken from SDL_image and altered to include its license.
This project is a part of the Xcode-shipped toolchain on macOS, but
needs built from source on other platforms. However, using the Xcode
version of the framework leads to a bunch of rpath confusion when
trying to link it the expected way. I suspect that there will be a
more intuitive way to link this library from the toolchain when it
stabilizes. So we'll build it everywhere :)
Instead of using a global setting, let's set this per-target. This
prevents conflicts when importing third-party dependencies that do
not tolerate the mode being "default".
At the same time, simplify CMakeLists magic for libraries that want to
include Swift code in the library. The Lib-less name of the library is
now always the module name for the library with any Swift additions,
extensions, etc. All vfs overlays now live in a common location to make
finding them easier from CMake functions. A new pattern is needed for
the Lib-less modules to re-export their Cxx counterparts.
We don't actually generate any such events ourselves. But Google Lens
will create one with the DataTransfer attribute set to that of any drop
event we send it.
Instead of CSSColorValue holding a Gfx::Color, make it an abstract class
with subclasses for each different color function, to match the Typed-OM
spec. This means moving the color calculations from the parsing code to
the `to_color()` method on the style value.
This lets us have calc() inside a color function, instead of having to
fully resolve the color at parse time. The canvas fillStyle tests have
been updated to reflect this.
The other test change is Screenshot/css-color-functions.html: previously
we produced slightly different colors for an alpha of 0.5 and one of
50%, and this incorrect behavior was baked into the test. So now it's
more correct. :^)
The identifier "Protocol" is claimed by Objective-C and Swift for use
by the language's built-in protocol conformance feature, which is
similar to Rust traits or Java interfaces.
Rename LibProtocol -> LibRequests, and its namespace from Protocol to
Requests to accomodate this.
USVString attributes Now replace any surrogates with the replacement
character U+FFFD and resolve any relative URLs to an absolute URL. This
brings our implementation in line with the specification.
The Web Platform Tests runner requires that some hostnames point to
localhost when running the tests locally. We now append these hostnames
to `/etc/hosts` if they aren't already present.
For a long time, we've used two terms, inconsistently:
- "Identifier" is a spec term, but refers to a sequence of alphanumeric
characters, which may or may not be a keyword. (Keywords are a
subset of all identifiers.)
- "ValueID" is entirely non-spec, and is directly called a "keyword" in
the CSS specs.
So to avoid confusion as much as possible, let's align with the spec
terminology. I've attempted to change variable names as well, but
obviously we use Keywords in a lot of places in LibWeb and so I may
have missed some.
One exception is that I've not renamed "valid-identifiers" in
Properties.json... I'd like to combine that and the "valid-types" array
together eventually, so there's no benefit to doing an extra rename
now.
Commit 35392d4d28 moved the
target_*_directories() calls (or rather their include()) before the
target declaration, so they fail because of the undefined target.
We can fix the problem by using global *_directories() instead.
Implements the corresponding encoders, selects the appropriate one when
encoding URL search params. If an encoder for the given encoding could
not be found, fallback to utf-8.
USVString is defined in the IDL spec as:
> The USVString type corresponds to scalar value strings. Depending on
> the context, these can be treated as sequences of either 16-bit
> unsigned integer code units or scalar values.
This means we need to account for surrogate code points by using the
replacement character.
This fixes the last test in https://wpt.live/url/url-constructor.any.html
In theory the clang module map should not have absolute paths for the
headers. Other Swift projects seem to use the -ivfsoverlay feature of
clang to work around this, but it seems difficult to get to work.
And modernize the cmake_parse_arguments() call at the top.
Ideally, we would pull these flags from the target we're generating
for, but the current CMake setup makes that prohibitively infeasible.
This ensures that we can get all the proper warnings on/off to get the
same diagnostics and other options when loading C++ headers into the
Swift frontend.
Add a simple shell script to update the local clangd configuration
according to the type of build selected by the user. Include
documentation on where the script might be useful when building
under different configurations.
For the SVG <use> element, we want to support loading HTML documents
that have a SVG element inside of it pointed to by the URL fragment.
In this situation we would need to fetch and parse the entire document
in SharedImageRequest (so that we can still cache the SVGs). Rename
SharedImageRequest to SharedResourceRequest to make the class a little
more generic for future usecases.
Previously we were assuming that the attribute return value was never
nullable and going to be returned in an Optional<IntegralType>, causing
complile errors for something such as: `attribute unsigned long?`.
Mirroring the pre-existing `generate_from_integral` function. This will
allow us to fix a bug that all of these if statements have in common -
no handling of nullable types.
This also adjusts the type casted for each integral to fully match that
stated by the spec.