Commit graph

70037 commits

Author SHA1 Message Date
Jelle Raaijmakers
408165d2f4 AK: Return early in utf8_to_utf16() for empty strings
No need to validate an empty string.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
6f926e6977 AK: Add Utf8View::code_point_offset_of() 2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
cea9012b5b LibWeb: Simplify Selection::cursor_position()
No functional changes.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
2d6da6e112 AK: Remove superfluous check from Utf16View::subtring_view()
The `Span::slice()` operation just below it performs the exact same
check.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
0d543b604b AK: Make more use of lazily calculated code point count in Utf16View
In 0c93a07fb1, a lazily calculated code
point count was introduced but was not used in all places where we need
that count. No functional changes.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
9126507dc6 LibWeb: Make fragment start/length size_t instead of int
These must always be unsigned. No functional changes.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
b42c2c5e8f LibWeb: Use code unit offsets in Document::find_matching_text()
We were passing in byte offsets instead of UTF-16 code unit offsets,
which could lead to crashes if the offsets found exceeded the number of
code units in text fragments on the page.

Fixes #4908.

Co-authored-by: Tim Ledbetter <tim.ledbetter@ladybird.org>
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
cc0a28ee7d AK: Add Utf16View::find_code_unit_offset(_ignoring_case) 2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
7d7f6fa494 AK: Remove superfluous check from Utf16View::equals_ignoring_case()
Returning true if both lengths are 0 is already handled by the default
case.
2025-06-13 15:08:26 +02:00
Jelle Raaijmakers
b558b4dba6 AK: Add Span<T>::index_of(ReadonlySpan)
This will be used for case-sensitive substring index matches in a later
commit.
2025-06-13 15:08:26 +02:00
rmg-x
5e9ceac16c LibDNS: Add debug messages for error response codes in resolver 2025-06-13 11:42:01 +02:00
Timothy Flynn
de34143a4e LibWeb: Do not spin the event loop awaiting text track state changes
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The text track processing model would previously spin forever waiting
for the track URL to change. It would then recursively invoke itself
to handle the new URL, again entering the spin loop. This meant that
tracks could easily cause event loop hangs.

We now have an observer system to be notified when the track state
changes instead. This lets us exit the processing model and move on.
2025-06-12 12:25:23 -04:00
Timothy Flynn
24ac860998 LibWeb: Set the "loading" flag for HTMLTrackElement sooner
We don't want to wait for the queued task to run to indicate that the
processing model is in progress.
2025-06-12 12:25:23 -04:00
Timothy Flynn
8da6731048 LibWeb: Do not capture local lambda by reference in HTMLTrackElement
This is UAF. It will cause a crash in an upcoming commit.
2025-06-12 12:25:23 -04:00
Timothy Flynn
c6a94fe513 LibWeb: Do not return a GC::Root from HTMLTrackElement's track getter
There's no need to create a root each time the getter is called. We
should also allocate it in the `initialize` overload rather than the
constructor.
2025-06-12 12:25:23 -04:00
Aliaksandr Kalenik
642dd751cf test-web: Disable SQL database usage
We have a test for localStorage that repeatedly adds new items until the
quota is exceeded:
`webstorage/storage_local_setitem_quotaexceedederr.window.html`.

This test becomes significantly slower when localStorage is backed by
SQL database. Let's disable database usage in test mode for now, as this
test is likely to be flaky on CI due to timeouts.
2025-06-12 17:04:35 +02:00
Aliaksandr Kalenik
84b9224121 Everywhere: Implement persistence of localStorage using sqlite
This change follows the pattern of our cookies persistence
implementation: the "browser" process is responsible for interacting
with the sqlite database, and WebContent communicates all storage
operations via IPC.

The new database table uses (storage_endpoint, storage_key, bottle_key)
as the primary key. This design follows concepts from the
https://storage.spec.whatwg.org/ and is intended to support reuse of the
persistence layer for other APIs (e.g., CacheStorage, IndexedDB). For
now, `storage_endpoint` is always "localStorage", `storage_key` is the
website's origin, and `bottle_key` is the name of the localStorage key.
2025-06-12 17:04:35 +02:00
Aliaksandr Kalenik
f53559cb55 LibWeb: Change Storage{Bottle,Bucket,Shelf} to be GC-allocated
In upcoming changes StorageBottle will own pointers to GC-allocated
objects, so it needs to be a GC-allocated object itself to avoid
introducing more GC roots.
2025-06-12 17:04:35 +02:00
Aliaksandr Kalenik
70a29f36c6 WebContent: Delete unused get_local{session}_storage_entries() IPC calls 2025-06-12 17:04:35 +02:00
Callum Law
d31a58a7d6 LibWeb: Add support for the 'all' CSS property
The "longhands" array is populated in the code generator to avoid the
overhead of manually maintaining the list in Properties.json

There is one subtest that still fails in
'cssstyledeclaration-csstext-all-shorthand', this is related to
us not maintaining the relative order of CSS declarations for custom vs
non-custom properties.
2025-06-12 15:25:35 +01:00
Jelle Raaijmakers
0762d57f65 LibWeb: Remove accidentally added test expectation
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This was added in 4b6489917b.
2025-06-12 13:09:26 +02:00
Jelle Raaijmakers
4b6489917b LibGfx: Disable tech(variations) font support for now
We apparently don't support it in the right way, since it causes the
wrong font to display on https://ladybird.org.
2025-06-12 11:04:37 +01:00
Andrew Kaster
aab0f3c23f CMake: Re-enable SIL verification for swift source files
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The associated Swift bug has been fixed on main.
2025-06-11 11:54:52 -06:00
Andrew Kaster
b6d0069015 Documentation: Update swift preset documentation 2025-06-11 11:54:52 -06:00
Andrew Kaster
ab661467e7 Meta: Support Swift_Release preset in ladybird.py 2025-06-11 11:54:52 -06:00
Andrew Kaster
a0173b342f CMake: Add preset with swift interop enabled 2025-06-11 11:54:52 -06:00
Andrew Kaster
0b7a6ef4c9 Meta: Record desired swift toolchain version in .swift-version
This makes it easier to ensure everyone is using the same version of
Swift when building the project, especially for CI environments.

`swiftly install` will automatically read this file and install the
specified version if it is not already installed. It also tells swiftly
what version to use for the project, independent of the global default
version.
2025-06-11 11:54:52 -06:00
Andrew Kaster
3b9756d9b1 Meta: Add optional cwd argument to run_command helper
This just passes it through to subprocess.Popen, so it can be used to
run commands in a specific directory if needed.
2025-06-11 11:54:52 -06:00
Andrew Kaster
a267743095 LibGfx: Avoid importing FilterImpl into swift
This header uses skia directly, and is not needed in swift.
2025-06-11 11:54:52 -06:00
Ali Mohammad Pur
4b5664f867 LibWebView+RequestSever: Wire up a validate-DNSSEC setting option to RS 2025-06-11 18:16:29 +02:00
Ali Mohammad Pur
b24fb0a836 LibDNS: Add support for local DNSSEC validation 2025-06-11 18:16:29 +02:00
Ali Mohammad Pur
59b6293182 LibCore: Add a Promise::after(promises) API
This is equivalent to Promise.all() in js, more or less.
2025-06-11 18:16:29 +02:00
Ali Mohammad Pur
6c312188dc AK: Let CountingStream take an initial value for the counter 2025-06-11 18:16:29 +02:00
Ali Mohammad Pur
3dd246a8e1 LibCrypto: Add support for raw EC keys and SECPxxxr1 signatures 2025-06-11 18:16:29 +02:00
Ali Mohammad Pur
b374322e38 LibTLS: Make TLSv12::can_read_without_blocking() respect the timeout arg
Previously this function's return value was not reliable, as available
data on the underlying socket did not necessarily translate to available
application data on the TLS socket.
2025-06-11 18:16:29 +02:00
Sam Atkins
00f76ccbf4 LibWeb/CSS: Add alternative src() syntax for URLs
url() has some limitations because of allowing unquoted URLs as its
contents. For example, it can't use `var()`. To get around this, there's
an alternative `src()` function which behaves the same as `url()` except
that it is parsed as a regular function, which makes `var()` and friends
work properly.

There's no WPT test for this as far as I can tell, so I added our own.
2025-06-11 16:26:23 +02:00
Andreas Kling
ea0bfda1b9 LibWeb: Cache the font in StyleComputer::initial_font()
This function is bogus, but it's still getting called a lot during media
query evaluation, so let's at least cache the font instead of recreating
it every single time.
2025-06-11 16:25:42 +02:00
Andreas Kling
07ff75bbec LibWeb: Don't traverse entire layout tree in every HTML::EventLoop tick
Instead, collect a list of all the elements with content-visibility:auto
after layout.

This way we can skip the tree traversal when updating the rendering.

This was previously eating up ~300 µs of the 60fps frame budget on
our GitHub repo pages (and even more on large pages).
2025-06-11 16:25:42 +02:00
Timothy Flynn
df0dc32006 LibWebView: Defer creating services until after application init
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
In particular, we need to defer creating the process manager until after
we have decided whether or not to create a UI-specific event loop. If we
create the process manager sooner, its event loop signal registration
does not work, and we don't handle child processes exiting.
2025-06-11 08:26:29 -04:00
Timothy Flynn
39da2d9a2f LibWebView+UI: Migrate some UI process init to LibWebView
No need to do this setup in every UI's main().
2025-06-11 07:26:32 -04:00
Timothy Flynn
6430b215af LibWebView: Make WEB_VIEW_APPLICATION switch back to a private section
Let's not leave everything after the WEB_VIEW_APPLICATION invocation
public.
2025-06-11 07:26:32 -04:00
Timothy Flynn
b425ce93b1 LibWebView+UI: Don't declare a magic ctor for Application subclasses
You would have to just know that you need to define the constructor with
this declaration. Let's allow subclasses to define constructors as they
see fit.
2025-06-11 07:26:32 -04:00
Timothy Flynn
3a4f2faf2e Meta: Use Optional[str] instead of str | None for python 3.9 compat
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
2025-06-10 18:59:01 -04:00
Timothy Flynn
fa164083fd LibWebView+UI: Do not create a QApplication in headless mode
This is causing errors on the WPT runner, which does not have a display
output. To do this requires shuffling around the Main::Arguments struct,
as we now need access to it from overridden WebView::Application methods
after construction.
2025-06-10 23:10:48 +01:00
Timothy Flynn
f66cac3417 LibWebView+UI: Define concrete Application::the accessor automatically
This avoids assuming that the Qt Application is a QApplication, which
will not be the case in an upcoming commit.
2025-06-10 23:10:48 +01:00
ayeteadoe
f2a10bda32 CMake: Simplify preset structure for Windows
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
As we now are only officially supporting the Ninja generator for
Windows, the old preset structure can now be simplified. Also, we
now follow the naming conventions of the non-hidden presets.
2025-06-10 11:29:29 -06:00
Timothy Flynn
9a5b31ccd1 LibWebView+Tests+UI: Migrate headless-browser to test-web
Now that headless mode is built into the main Ladybird executable, the
headless-browser's only purpose is to run tests. So let's move it to the
testing directory and rename it to test-web (a la test-js / test-wasm).
2025-06-10 12:04:59 -04:00
Timothy Flynn
c011dc766f LibWebView+WebDriver+UI: Migrate headless browsing to main Ladybird exe
We currently create a separate headless-browser application to serve two
purposes:

1. Allow headless browsing to take a screenshot of a page or print its
   layout tree / internal text.
2. Run the LibWeb test framework.

This patch migrates (1) to the main Ladybird executable. The --headless
flag enables this mode. This matches the behavior of other browsers, and
means we have one less executable to ship at distribution time.

We want to avoid creating too many AppKit / Qt facilities in headless
mode. So this involves some shuffling of application init to ensure we
don't create them until after we've parsed the command line arguments.
Namely, we avoid creating the NSApp in AppKit and QCoreApplication in
Qt. Doing so also requires that we don't create the application event
loop until we've parsed the command line as well, because the loop we
create depends on whether we're creating those UI facilities.
2025-06-10 12:04:59 -04:00
Timothy Flynn
3894d8efec headless-browser: Don't go through Application to create web views
We currently create web views through the headless Application, so that
the Application can store the views for easy iteration/management. We
would like to move HeadlessWebView into LibWebView to make headlessness
a feature of the primary Ladybird binaries. In order to do so, we need
to remove this indirection, as we won't have this test-only Application
class in Ladybird.
2025-06-10 12:04:59 -04:00
Timothy Flynn
0416961133 LibWebView: Forward declare WebView option structures 2025-06-10 12:04:59 -04:00