Commit graph

135 commits

Author SHA1 Message Date
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
Timothy Flynn
920170f60a LibWebView+UI: Remove native do-not-track setting
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Build Dev Container Image / build (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, 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-04-02 14:16:18 -04:00
Timothy Flynn
1be3e7fd8a LibWebView: Add do-not-track setting to about:settings 2025-04-02 14:16:18 -04:00
Timothy Flynn
5d2e6ffe30 LibWebView: Add autocomplete settings to about:settings
This implements an autocomplete engine inside LibWebView, to replace the
engine currently used by Qt. Whereas Qt uses the Qt Network framework to
perform autocomplete requests, LibWebView uses RequestServer. This moves
downloading this untrusted data out of the browser process.

This patch only implements the persisted settings and their UI. It does
not integrate this engine into the browser UI.
2025-04-02 08:52:45 -04:00
Timothy Flynn
ed265b568d LibWebView+WebContent+UI: Migrate to the new autoplay settings
This removes the old autoplay allowlist file in favor of the new site
setting. We still support the command-line flag to enable autoplay
globally, as this is needed for WPT.
2025-03-30 16:18:57 +01:00
Timothy Flynn
223b04f087 LibWebView: Add autoplay settings to about:settings
The idea with the UI here is that it will serve as a generic component
for all site settings, such as autoplay, notifications, etc. When the
site settings dialog is opened, it is filled with the requested setting
data, and messages sent to the browser process are based on the setting.

This patch only implements the UI and persisted settings. It does not
apply autoplay changes to the WebContent process.
2025-03-30 16:18:57 +01:00
Timothy Flynn
f05b0bfd5f LibWeb+LibWebView+WebContent: Convert about:settings to a WebUI
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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-03-28 07:31:10 -04:00
Timothy Flynn
c75e40180c LibWeb+LibWebView+WebContent: Convert about:processes to a WebUI 2025-03-28 07:31:10 -04:00
Timothy Flynn
41aeb9e63a LibWeb+LibWebView+WebContent: Introduce a WebUI framework
When we build internal pages (e.g. about:settings), there is currently
quite a lot of boilerplate needed to communicate between the browser and
the page. This includes creating IDL for the page and the IPC for every
message sent between the processes.

These internal pages are also special in that they have privileged
access to and control over the browser process.

The framework introduced here serves to ease the setup of new internal
pages and to reduce the access that WebContent processes have to the
browser process. WebUI pages can send requests to the browser process
via a `ladybird.sendMessage` API. Responses from the browser are passed
through a WebUIMessage event. So, for example, an internal page may:

    ladybird.sendMessage("getDataFor", { id: 123 });

    document.addEventListener("WebUIMessage", event => {
        if (event.name === "gotData") {
            console.assert(event.data.id === 123);
        }
    });

To handle these messages, we set up a new IPC connection between the
browser and WebContent processes. This connection is torn down when
the user navigates away from the internal page.
2025-03-28 07:31:10 -04:00
Manuel Zahariev
9e7436a096 LibWebView: Better integration of sanitize_url with search
With search enabled:
- For a single word that does not look like a url: search (a
reported bug).
- If no suffix or a suffix that is not recognized: search.

In general:
- Respect the user's choice if they specified a scheme.
- Respect localhost and registered TLDs.
- As before, add file:// to filesystem files that exist.
2025-03-27 18:30:08 -04:00
Luke Wilde
42bc83a9d0 LibWebView+WebWorker: Attach an image decoder to worker instances
The createImageBitmap API can programmatically decode arbitrary images
from JS, and it's exposed in Workers, so they need an ImageDecoder
instance.
2025-03-27 17:47:27 +00:00
Timothy Flynn
9eca5febd1 LibDevTools+LibWebView+WebContent: Report exceptions to DevTools 2025-03-27 14:14:02 +00:00
Timothy Flynn
5d0fbc85e5 LibWebView+WebContent: Remove "styled" JS console IPC hooks
This was used by the built-in Inspector to send HTML-ified JS console
messages to the browser. It is no longer used.
2025-03-27 14:14:02 +00:00
SINF-KEN
32dbd6ab8f UI: Fix new error page 2025-03-27 08:34:38 +00:00
SINF-KEN
1a34676046 UI: Style the crash page and update error page image
- Modified the error page
- changed the error/crash page

Co-authored-by: notnotnescap <97590612+nescapp@users.noreply.github.com>
2025-03-26 19:39:24 +00:00
Timothy Flynn
8155377b5f LibWebView: Move stored settings to the system configuration directory
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, 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-03-24 22:55:35 +01:00
Sam Atkins
0ed2e71801 LibWeb/CSS: Move and rename PseudoElement types to prep for code gen
The upcoming generated types will match those for pseudo-classes: A
PseudoElementSelector type, that then holds a PseudoElement enum
defining what it is. That enum will be at the top level in the Web::CSS
namespace.

In order to keep the diffs clearer, this commit renames and moves the
types, and then a following one will replace the handwritten enum with
a generated one.
2025-03-24 09:49:50 +00:00
Timothy Flynn
b169a98495 LibWeb+LibWebView+WebContent: Introduce a basic about:settings page
This adds a basic settings page to manage persistent Ladybird settings.
As a first pass, this exposes settings for the new tab page URL and the
default search engine.

The way the search engine option works is that once search is enabled,
the user must choose their default search engine; we do not apply any
default automatically. Search remains disabled until this is done.

There are a couple of improvements that we should make here:

* Settings changes are not broadcasted to all open about:settings pages.
  So if two instances are open, and the user changes the search engine
  in one instance, the other instance will have a stale UI.

* Adding an IPC per setting is going to get annoying. It would be nice
  if we can come up with a smaller set of IPCs to send only the relevant
  changed settings.
2025-03-22 17:27:45 +01:00
Timothy Flynn
e084a86861 LibWebView+UI: Introduce a persistent settings object
This adds a WebView::Settings class to own persistent browser settings.
In this first pass, it now owns the new tab page URL and search engine
settings.

For simplicitly, we currently use a JSON format for these settings. They
are stored alongside the cookie database. As of this commit, the saved
JSON will have the form:

    {
        "newTabPageURL": "about:blank",
        "searchEngine": {
            "name": "Google"
        }
    }

(The search engine is an object to allow room for a future patch to
implement custom search engine URLs.)

For Qt, this replaces the management of these particular settings in the
Qt settings UI. We will have an internal browser page to control these
settings instead. In the future, we will want to port all settings to
this new class. We will also want to allow UI-specific settings (such as
whether the hamburger menu is displayed in Qt).
2025-03-22 17:27:45 +01:00
Timothy Flynn
b4fde1ef64 LibWebView: Remove non-generic search engines
It really doesn't make sense for GitHub to be the default search engine.
If some really wants this, we can eventually implement setting custom
search engine URLs.
2025-03-22 17:27:45 +01:00
Timothy Flynn
9b6ae962d0 LibWebView+UI: Handle DPR for select elements like other menus
The select dropdown was doing its own ad-hoc method of handling DPR. We
now handle it just like other context menus. Previously, the drop down
in the AppKit chrome was twice as large as it should be.
2025-03-22 17:27:45 +01:00
Timothy Flynn
daca9f5995 LibDevTools+LibWebView+WebContent: Selectively fetch DOM node properties
When we inspect a DOM node, we currently serialize many properties for
that node, including its layout, computed style, used fonts, etc. Now
that we aren't piggy-backing on the Inspector interface, we can instead
only serialize the specific information required by DevTools.
2025-03-20 09:01:26 +01:00
stasoid
2dd657f530 LibWebView: Port to Windows 2025-03-19 20:25:24 -06:00
Timothy Flynn
942f26a846 LibWebView: Remove now-unused ProcessManager HTML generator 2025-03-19 10:03:17 -04:00
Timothy Flynn
843209c6a9 LibWeb+LibWebView+WebContent: Add an about:processes page
The intent is that this will replace the separate Task Manager window.
This will allow us to more easily add features such as actual process
management, better rendering of the process table, etc. Included in this
page is the ability to sort table rows.

This also lays the ground work for more internal `about` pages, such as
about:config.
2025-03-19 10:03:17 -04:00
Aliaksandr Kalenik
394073f611 LibWeb: Rename internals.signalTextTestIsDone() to signalTestIsDone()
In upcoming change this function will be used for ref-tests as well.
2025-03-18 20:09:46 +01:00
Luke Wilde
61c1e4a855 LibWebView: Keep javascript URL navigations in the same process
JavaScript URLs run in the same document context the navigation was
started in, so they're not eligible to be moved to a new WebContent
process.

Fixes the "Login as demo user" link on https://demo.immich.app/
2025-03-16 10:59:41 -04:00
Timothy Flynn
3af63bc5a3 Everywhere: Replace miscellaneous references to the chrome process 2025-03-15 19:57:27 -04:00
Timothy Flynn
18eee7e3f0 LibWebView: Rename the Chrome process type to Browser 2025-03-15 19:57:27 -04:00
Timothy Flynn
e20d7be15f LibWeb+UI: Rename ChromeInputData to BrowserInputData 2025-03-15 19:57:27 -04:00
Timothy Flynn
47d6747945 LibWebView+UI: Rename ChromeProcess to BrowserProcess 2025-03-15 19:57:27 -04:00
Timothy Flynn
e00c0c176e LibWebView+UI: Rename ChromeOptions to BrowserOptions 2025-03-15 19:57:27 -04:00
Timothy Flynn
df7917d705 LibWebView: Change the DevTools server to be a runtime-enabled feature 2025-03-15 19:09:40 +01:00
Timothy Flynn
810d04b3f4 LibWeb+LibWebView+WebContent: Remove the built-in Inspector 2025-03-15 19:09:40 +01:00
Timothy Flynn
0a5f68eba6 LibWebView: Disable site isolation and spare processes when debugging
These features make it difficult to debug a single WebContent instance.
2025-03-14 18:53:50 +01:00