Commit graph

118 commits

Author SHA1 Message Date
Shannon Booth
8d0fb91450 Headless: Remove uneeded URL validity check
All of the URLs in the browser options must 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
Andrew Kaster
6ff0373556 UI: Pass parent WebView by non-const ref when creating children
We need to call non-const methods on this guy and access its members in
a non-const way.
2025-04-16 10:41:44 -06:00
Andrew Kaster
5c4b65996e UI/Qt: Store TVG Image Data in a RefPtr to const
We don't need to mutate this data after it's loaded.
2025-04-16 10:41:44 -06:00
Andrew Kaster
91b549f797 LibGfx+LibWebView+UI: Store Gfx::Bitmap in RefPtr to const 2025-04-16 10:41:44 -06:00
stasoid
a821fc03be Headless: Compile on Windows 2025-04-13 10:19:23 -06: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
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
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
c1fe912bf9 UI/AppKit: Implement an autocomplete view for the location bar 2025-04-02 08:52:45 -04:00
Timothy Flynn
60dd5cc4ef UI/Qt: Migrate to LibWebView's autocomplete engine
As a result, we now no longer depend on Qt::Network.
2025-04-02 08:52:45 -04:00
Timothy Flynn
a87c264088 UI/Qt: Add a couple of missing includes
These are currently being transitively included. This will no longer be
the case in a future patch.
2025-04-02 08:52:45 -04:00
Timothy Flynn
b23b21fa4a UI/AppKit: Restore custom cursor shown on link hover
This seems to have broken in some recent-ish AppKit update. When we add
the status label to the view hierarchy / change its visibility state,
the NSApp is resetting the cursor to the standard cursor. By overriding
the cursorUpdate method to do nothing, we prevent this from happening.
2025-04-01 23:10:14 +02: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
Jelle Raaijmakers
91d6902725 UI: Add Cmd+U as a shortcut for "View Source" to AppKit
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
This mirrors the shortcut we have in our Qt UI.
2025-03-25 17:08:42 -04:00
Timothy Flynn
9bdd22c6b1 UI/Qt: Add a menu item to open about:settings
This replaces the existing menu item that would open the Qt settings
dialog. That menu item still exists, but is no longer the default
settings action.
2025-03-22 17:27:45 +01:00
Timothy Flynn
7a5387b0ab UI/AppKit: Add a menu item to open about:settings 2025-03-22 17:27:45 +01: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
a69ecc3943 UI: Add a default CSS file for internal Ladybird pages
In order to maintain a consistent look and feel between internal about:
pages going forward, let's use a central CSS file to define Ladybird
colors and some common form control styles.
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
Jelle Raaijmakers
acc9499c5d UI: Show "Disable" title in DevTools disable button
The "disable DevTools" button looked like a "close this notification"
button to me, and although a tooltip was set, it only showed up
immediately on the AppKit UI and not the Qt version.

This makes the behavior of clicking the disable button a lot clearer by
showing a button with "Disable" as its title.
2025-03-20 17:44:07 -04:00
Timothy Flynn
9214322129 UI/Qt: Do not make assumptions about autocomplete response types
For example, we expect a JSON array from Google. Let's not crash if we
get a JSON object or some other unexpected type.
2025-03-20 10:50:24 +01:00
Timothy Flynn
8847079d8a UI/Qt: Invert check for DuckDuckGo autocomplete parse results 2025-03-20 10:50:24 +01:00
Timothy Flynn
86a93b9b47 UI/Qt: Prevent UAF while parsing autocomplete response data
JsonParser only holds a view into the provided string, the caller must
keep it alive. Though we can actually just use JsonValue::from_string
here instead.
2025-03-20 10:50:24 +01:00
Timothy Flynn
45d8cd5c9f UI/Qt: Replace the Task Manager window with about:processes 2025-03-19 10:03:17 -04:00
Timothy Flynn
67a1dd72db UI/AppKit: Replace the Task Manager window with about:processes 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
259d39cbad UI/Headless: Wait for "reftest-wait" class removal before screenshotting
Resolves https://github.com/LadybirdBrowser/ladybird/issues/3984
2025-03-18 20:09:46 +01: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
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
0065dde749 UI/Qt: Add UI components to enable DevTools at runtime 2025-03-15 19:09:40 +01:00
Timothy Flynn
28574e2812 UI/AppKit: Add UI components to enable DevTools at runtime 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
1c696e7893 UI/Qt: Remove the built-in Inspector widget 2025-03-15 19:09:40 +01:00
Timothy Flynn
03735cf11d UI/AppKit: Remove the built-in Inspector widget 2025-03-15 19:09:40 +01:00
SINF-KEN
96a5b97131 Base: Add new error page
This commit introduces a new error page.

Co-authored-by: NotNotNescap <nescap@tuta.com>
2025-03-12 11:56:15 -04:00
Gingeh
5838c73a72 LibWeb: Restrict weird about:foo URIs
This commit:
- Prevents path traversal via the about: scheme
- Prevents loading about:inspector
- Requires about: URIs to be opaque paths
- Prevents crashes with invalid percent encoded paths
2025-03-12 10:41:06 +00:00
rmg-x
41927ad9d1 UI/Qt: Use book title capitalization for "Clear All Cookies" menu item
This follows the human interface guidelines of Ladybird.
2025-03-10 12:30:21 +00:00
rmg-x
c361ea8916 WebContent+UI/Qt: Add debug option to toggle content filtering on/off
This was needed by @piruzzolo on Discord for debugging purposes and
seems pretty useful :^)
2025-03-10 12:30:21 +00:00
Timothy Flynn
5f76324af5 LibDevTools+LibWebView: Take advantage of IPC encoding improvements 2025-03-09 11:14:20 -04:00
Timothy Flynn
68947d55d9 LibIPC: Do not require constructing containers when sending IPC messages
For example, consider the following IPC message:

    do_something(u64 page_id, String string, Vector<Data> data) =|

We would previously generate the following C++ method to encode/transfer
this message:

    void do_something(u64 page_id, String string, Vector<Data> data);

This required the caller to either have to copy the non-trivial types or
`move` them in. In some places, this meant we had to construct temporary
vectors just to send an IPC.

This isn't necessary because we weren't holding onto these parameters
anyways. We would construct an IPC::Message subclass with them (which
does require owning types), but then immediate encode the message to
an IPC::MessageBuffer and send it.

We now generate code such that we don't need to construct a Message. We
can simply encode the parameters directly without needing ownership.
This allows us to take view-types to IPC parameters.

So the above example now becomes:

    void do_something(u64, StringView, ReadonlySpan<Data>);
2025-03-09 11:14:20 -04:00
Shannon Booth
3fb9c37783 UI/Qt: Do not rely on the URL implicit constructors 2025-03-04 16:24:19 -05:00
Shannon Booth
0f495421f1 UI/AppKit: Do not rely on the implicit URL constructors 2025-03-04 16:24:19 -05:00
Timothy Flynn
cf523137ad headless-browser: Do not log the inner text of crash tests
This re-implements 533c8e910a without
breaking the ability to dump layout trees.
2025-03-02 11:49:49 -05:00
Timothy Flynn
1aa009b0cf Revert "headless-browser: Do not log the inner text of crash tests"
This reverts commit 533c8e910a.

This broke the ability to dump layout trees using headless-browser.
2025-03-02 11:49:49 -05:00