Commit graph

169 commits

Author SHA1 Message Date
Trey Shaffer
e7f0126c2e LibWebView: Don't provide autocomplete suggestions for file:// URLs 2025-07-18 10:58:07 +01:00
Jelle Raaijmakers
e4b2253b63 Tests: Replace load-reference-page debug action with internals method
WPT reference tests can add metadata to tests to instruct the test
runner how to interpret the results. Because of this, it is not enough
to have an action that starts loading the (mis)match reference: we need
the test runner to receive the metadata so it can act accordingly.

This sets our test runner up for potentially supporting multiple
(mis)match references, and fuzzy rendering matches - the latter will be
implemented in the following commit.
2025-07-17 12:59:11 +01:00
Andreas Kling
dab1fd265d test-web: Dump stacking context tree in layout test output
This will allow us to test (and catch regressions in) stacking context
tree construction and updates, etc.
2025-07-09 14:36:08 +02:00
Jelle Raaijmakers
e96fd53eda Revert "LibWebView: Add Arial Unicode MS to the list of Sans Serif (...)
(...) fallbacks"

This reverts commit 9e7b40747f. This
caused most bold headings to display as regular headings, since Arial
Unicode MS does not support other styles (as opposed to Arial).

We need a better font selection algorithm to properly support selecting
fonts for specific glyphs. Issue #2332 exists to keep track of
supporting less frequently used glyphs.
2025-07-08 09:17:32 -04:00
Andrew Kaster
62c5f4b822 CMake: Remove unconditional Qt linkage from WebContent and WebWorker
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, arm64 (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
WebContent only needs it when using QtMultimedia for audio playback, and
WebWorker never needs it.
2025-07-07 15:53:15 -06:00
Andrew Kaster
1a6b4aaa49 RequestServer: Remove serenity_resource_root argument from main
We don't need it now that we're not trying to load the cacert.pem file.
Clean up includes while we're here.
2025-07-07 09:10:05 +02:00
ayeteadoe
25f5936dee CMake: Rename serenity_* helper functions/macros to ladybird_* 2025-07-03 23:19:41 +02:00
Timothy Flynn
b55d2909f6 LibWebView+UI: Launch the DevTools server if --devtools is specified
This replaces the --devtools-port flag with a --devtools flag, which
optionally accepts a port. If the --devtools flag is set, we will now
automatically launch the DevTools server.
2025-07-02 15:27:54 -04:00
Shannon Booth
a2b523eeb8 LibURL: Replace use of URL::get_public_suffix
It is confusing to have both URL::Host::public_suffix and
URL:get_public_suffix, both with slightly different semantics.

Instead, use PublicSuffixData for cases that just want a direct
match against the list, and URL::Host::public_suffix in LibWeb
land as the URL spec defined AO.
2025-06-29 12:47:57 +01:00
Semyon Danilov
9e7b40747f LibWebView: Add Arial Unicode MS to the list of Sans Serif fallbacks
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, arm64 (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-28 12:10:35 +01:00
Tomasz Strejczek
6fb2be96bf Everywhere: Replace DateTime::to_string() with UnixDateTime::to_string()
Replace LibCore::DateTime::to_string() with
AK::UnixDateTime::to_string().
Remove unncessary #include <LibCore/DateTime.h>.
2025-06-19 18:42:45 -06: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
Ali Mohammad Pur
4b5664f867 LibWebView+RequestSever: Wire up a validate-DNSSEC setting option to RS 2025-06-11 18:16:29 +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
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
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
0416961133 LibWebView: Forward declare WebView option structures 2025-06-10 12:04:59 -04:00
Timothy Flynn
23855bd412 LibWebView: Do not make the client bitmap shareable for screenshots
Not sure what the issue is here, but it seems to cause very incorrect
screenshots on macOS. In any case, it's wasted computation.
2025-05-29 16:24:08 -04:00
blukai
e356a4bd01 LibGfx: Rely on fontconfig(if enabled) for font directory resolution
this commit also introduces GlobalFontConfig class that is now
responsible for fontconfig initialization. it seems sane, even thought
FcInit's docs state that if the default configuration has already been
loaded, this routine does nothing.
2025-05-26 12:14:29 -06:00
blukai
4b3691ff39 LibCore+LibGfx: Move font_directories from LibCore to LibGfx
the goal is to rely on fontconfig for font directory resolution. it
doesn't seem like it would be appropritate to call to fontconfig funcs
from within the LibCore.

i'm not 100% confident that FontDatabase is the correct place.. seems
okay?
2025-05-26 12:14:29 -06:00
Timothy Flynn
7280ed6312 Meta: Enforce newlines around namespaces
This has come up several times during code review, so let's just enforce
it using a new clang-format 20 option.
2025-05-14 02:01:59 -06:00
Timothy Flynn
1a9e78a774 LibWebView: Disable autocomplete when search is disabled
Search suggestions don't make much sense when search itself is disabled.
We now auto-disable autocomplete when search is disabled.
2025-05-11 11:48:02 -04:00
Timothy Flynn
5eb4c3dc2f LibWebView: Disable spare WebContent processes when profiling WebContent
Each WebContent process will create a callgrind log file. Let's not log
processes we are not interested in.
2025-05-08 10:02:41 -04:00
Timothy Flynn
4916ae6d67 LibWebView: Paint callgrind instructions a bit less aggressively
On my terminal, the colors chosen before were very hard to read.
2025-05-08 10:02:41 -04:00
Timothy Flynn
61c0f67c8c LibWeb+LibWebVew+WebContent+UI: Add IPC to retrieve the system clipboard
We currently have a single IPC to set clipboard data. We will also need
an IPC to retrieve that data from the UI. This defines system clipboard
data in LibWeb to handle this transfer, and adds the IPC to provide it.
2025-05-02 17:46:16 -04:00
Andrew Kaster
b50d03f42e LibCore+LibWebView: Restore was_exit_requested to EventLoop
This method was removed in e015a43b51

However, it was not exactly *unused* as the commit message would say.
This method was the only thing that allowed spin_until to exit when
the event loop was cancelled. This happens normally when IPC connections
are closed, but also when the process is killed.

The logic to properly handle process exit from event loop spins needs to
actually notify the caller that their goal condition was not met though.
That will be handled in a later commit.
2025-04-30 11:12:23 -04:00
Shannon Booth
a2cca59516 LibWeb+LibWebView+Services: Add IPC for starting WebWorker of a type
The provides some of the plumbing for a WebContent process to spin
up a WebWorker that is not just a dedicated worker.
2025-04-25 14:07:51 +02:00
Timothy Flynn
6a6c56aabe LibWebView: Create a dedicated settings observer for the Application
We had a bit of an awkward setup where we want the Application to be a
SettingsObserver, but neither the Settings object nor the Application
itself was fully initialized by the time the observer was created. So
we invented a deferred observer initializer specifically for the
Application.

Instead, let's just create a dedicated observer subclass that is owned
by the Application. We can then create it once we have the singleton
Application appropriately set up.
2025-04-23 19:58:58 -04:00
Ali Mohammad Pur
2c13504bfc LibWebView+RequestServer: Add some UI for DNS settings 2025-04-22 18:05:07 -04:00
Shannon Booth
8794bf568a LibWebView: Remove uneeded URL valdity check in CookieJar
The URL given will always be valid.
2025-04-19 07:18:43 -04:00
Shannon Booth
00bbb2105b LibURL: Port create_with_file_scheme to Optional
Removing one of the main remaining users of URL valid state.
2025-04-19 07:18:43 -04:00
Shannon Booth
2072eee83d LibURL: Implement create_with_file_scheme using URL Parser
Creating a URL should almost always go through the URLParser to
handle all of the small edge cases involved. This reduces the
need for URL valid state.
2025-04-19 07:18:43 -04:00
Timothy Flynn
5e9a11b13d LibWebView: Respect autocomplete response Content-Encoding headers
For example, Google uses ISO-8859-1 encoding. This patch allows us to
decode such responses, falling back to UTF-8 if a Content-Type was not
specified or could not be parsed. We should also now handle if decoding
fails, rather than crashing inside JsonParser.
2025-04-17 07:51:43 -04:00
Andrew Kaster
91b549f797 LibGfx+LibWebView+UI: Store Gfx::Bitmap in RefPtr to const 2025-04-16 10:41:44 -06:00
Viktor Szépe
5cc371d54c LibWeb: Fix typos - act II 2025-04-09 15:05:20 +01:00
Aliaksandr Kalenik
db8c443392 Everywhere: Make TransportSocket non-movable
Instead of wrapping all non-movable members of TransportSocket in OwnPtr
to keep it movable, make TransportSocket itself non-movable and wrap it
in OwnPtr.
2025-04-09 15:27:52 +02:00
Timothy Flynn
ee6b2db009 AK+LibURL+LibWeb: Use simdutf to validate ASCII strings
simdutf provides a vectorized ASCII validator, so let's use that instead
of looping over strings manually.
2025-04-06 11:05:58 -04:00
Timothy Flynn
2810071a9c LibWebView: Support custom search engines
This allows the user to store custom search engines via about:settings.
Custom engines will be displayed below the builtin engines in the drop-
down to select the default engine.

A couple of edge cases here:

1. We currently reject a custom engine if one with the same name already
   exists. In the future, we should allow editing custom engines.

2. If a custom engine which was the default engine is removed, we will
   disable search rather than falling back to any other engine.
2025-04-06 13:45:10 +02:00
Timothy Flynn
dbf4b189a4 LibWebView: Do not use AK::format to format search engine URLs
This is to prepare for custom search engines. If we use AK::format, it
would be trivial for a user (or bad actor) to come up with a template
search engine URL that ultimately crashes the browser due to internal
assertions in AK::format. For example:

    https://example.com/crash={1}

Rather than coming up with a complicated pre-format validator, let's
just not use AK::format. Custom URLs will signify their template query
parameters with "%s". So we can do the same with our built-in engines.
When it comes time to format the URL, we will do a simple string
replacement.
2025-04-06 13:45:10 +02:00
Timothy Flynn
cbee476dac LibWebView: Store search engine names/URLs as String
In order to support custom search engines, we will need to store the
engine properties as String to hold user-provided data.

This also caused a compile error trying to assign Optional<SearchEngine>
to Optional<SearchEngine const&>, so there's a bit of extra churn here.
2025-04-06 13:45:10 +02:00
Timothy Flynn
7f37a8f60f AK: Add an AK::find helper to return a reference to the found value
This is often more convenient than dealing with iterators.

This commit includes a couple conversions to find_value as examples.
2025-04-06 13:45:10 +02:00
Timothy Flynn
f1f7f68f36 LibWebView: Highlight about: and data: URL schemes 2025-04-06 00:32:14 +02:00
Timothy Flynn
a3ea4881e7 LibWeb+LibWebView+UI: Migrate to LibWebView's language settings 2025-04-04 10:16:32 +02:00
Timothy Flynn
f242920cc9 LibWebView: Add language settings to about:settings
This implements a setting to change the languages provided to websites
from `navigator.language(s)` and the `Accept-Language` header. Whereas
the existing Qt settings dialog allows users to type their language of
choice, this setting allows users to select from a predefined list of
languages. They may choose any number of languages and their preferred
order.

This patch only implements the persisted settings and their UI. It does
not integrate the choses languages into the WebContent process.
2025-04-04 10:16:32 +02:00
Timothy Flynn
26ec01068f LibWebView: Fire all observers when settings are restored to default
Otherwise the change is not propagated to the WebContent process for
some of these.
2025-04-04 10:16:32 +02:00