Commit graph

64 commits

Author SHA1 Message Date
Simon Farre
04d1e2bf3d LibWeb: Implement exitFullscreen algorithm
Exiting fullscreen from the UI will be added in future commits.
2026-02-23 18:44:26 +00:00
Jelle Raaijmakers
1cc29c669a WebContent: Combine viewport size and DPR into a single IPC message
The set_viewport_size and set_device_pixel_ratio IPC messages were sent
separately, potentially causing a race condition when the DPR changes
(e.g. moving a window between screens): the DPR message would arrive
and use a stale viewport size, computing a temporarily wrong CSS
viewport. Combine both into a single set_viewport IPC that updates the
device viewport size and DPR together.
2026-02-23 15:22:12 +01:00
Timothy Flynn
17a420cf97 test-web: Handle WebContent process changes during cross-site navigation
Commit 84db5d8c1c introduced the ability
to load tests over an http:// URL instead of a file:// URL. Each time
this happens, we switch to a new WebContent process due to site
isolation. Our WebContent output capture was not handling this.

For some reason, this was causing a wide array of test failures and
timeouts. Often, the failures were accompanied by the content of the
files loaded over HTTP being dumped to stdout. It's not quite clear
what was going on here.
2026-02-20 11:41:28 -05:00
Luke Wilde
0e958ca8d5 LibWebView+UI/AppKit: Present IOSurfaces directly
Instead of copying the Bitmap that wraps the IOSurface, we can just
present the IOSurface directly. This significantly reduces CPU usage in
the UI process, particularly at high refresh rates such as 120Hz where
it would saturate a full CPU core.

This is done by using CAMetalLayer and blitting the IOSurface to the
next drawable buffer, which handles triple buffering, locking the
IOSurface and vsync automatically. This also allows the Metal HUD to
work, but the only accurate stat is the frame intervals/FPS because
it's in the UI layer, not WebContent. However, that's still useful
to detect frame drops.
2026-02-16 14:57:17 +00:00
Luke Wilde
10b5ccc931 WebContent+LibWebView: Add endpoint to request top level closure
This will allow the UI to request WebContent to properly close the top
level traversable when closing a tab. For example, this allows the site
to ask if the user is sure they want to leave, closes WebSocket
connections and more.
2026-02-14 23:26:10 +00:00
Timothy Flynn
8d97389038 LibHTTP+Everywhere: Move the cookie implementation to LibHTTP
This will allow parsing cookies outside of LibWeb.

LibHTTP is basically becoming the home of HTTP WG specs.
2026-02-10 12:21:20 +01:00
Timothy Flynn
0482b6bb57 LibWeb+LibWebView+WebContent: Implement versioning for document cookies
This patch introduces a cookie cache in the WebContent process to reduce
blocking IPC calls when JS accesses document.cookie. The UI process now
maintains a cookie version counter per-domain in shared memory. When JS
reads document.cookie, we check whether we have a valid cached cookie by
comparing the current shared version to the last used version. If they
match, the cached cookie is returned without IPC.

This optimization is based on Chromium's shared versioning, in which it
was observed that 87% of document.cookie accesses were redundant. See:
https://blog.chromium.org/2024/06/introducing-shared-memory-versioning-to.html

Note that this cache only supports document.cookie, not HTTP Cookie
headers. HTTP cookies are attached to requests with varying URLs and
paths. The cookies that match the document URL might not match the
request URL, which we wouldn't know from WebContent. So attaching the
cached document cookie would be incorrect.

On https://twinings.co.uk, we see approximately 600 document.cookie
requests while the page loads. This patch reduces the time spent in
the document.cookie getter from ~45ms to 2-3ms.
2026-02-05 07:28:07 -05:00
Timothy Flynn
f322e8a29c LibWebView+UI: Add a context menu item to download images
This introduces a simple FileDownloader to download files in the UI
process from RequestServer. We use this to download the context menu
image - this download is likely to hit the disk cache.
2026-02-05 07:27:34 -05:00
Andreas Kling
64d033b31a LibWebView+test-web: Print heap explorer URL after dumping GC graph
When dumping a GC graph, we now write the output as a .js file
containing `var GC_GRAPH_DUMP = <json>;` instead of raw JSON.
This allows gc-heap-explorer.html to load the dump via a
dynamically created <script> element, avoiding CORS restrictions
that prevent file:// pages from fetching other file:// URLs.

After dumping, both the browser and test-web print a clickable
file:// URL that opens the heap explorer with the dump pre-loaded.

The heap explorer's drag-and-drop file picker also accepts both
the new .js format and plain .json files.
2026-02-01 22:46:09 +01:00
Andreas Kling
34ae80d602 WebContent+LibWebView: Send GC graphs etc over IPC as shared memory
These can get very large, exceeding the new IPC message size limits.
Instead of serializing them into messages (which was silly anyway)
we now send them as Core::AnonymousBuffer which uses shared memory.
2026-02-01 22:46:09 +01:00
Timothy Flynn
76eb5b2fa6 LibWeb+LibWebView+WebContent: Perform cookie URL filtering in the UI
When cookies change or expire, we currently send a list of all changed
cookies to all WebContent processes. We then filter that list in the
WebContent process for cookies that match the page's URL before sending
out cookie change events to JS.

We now perform this filtering in the UI process, so each WebContent
process only receives the cookies it would be interested in, if any.
This serves two purposes:

1. Less IPC chatter.
2. This will let each ViewImplementation know that its cookie value has
   actually changed.

(2) is for an upcoming change that will introduce a cookie cache, and
will allow each view to know it should bust that cache.

Note that for this filtering to work, we must iterate ViewImplementation
instances rather than WebContentClient in order to have the view's URL.
We must then associate the IPC with the view's page ID.

No changes to the /cookiestore WPT subtests.
2026-02-01 08:31:58 -05:00
Jelle Raaijmakers
ffc61e2042 LibWebView: Unregister view before creating a new WebContent process
If a did_paint message is in-flight and we create a new process when
navigating to another website, we would still have the view registered
with the client when eventually the stale did_paint message is handled.
In server_did_paint, we retrieve the client which points to the new
process, not the original process the view was registered for.

At that point, there might not be any queued rasterization tasks in the
RenderingThread for the new process, causing a crash because of:

  VERIFY(m_queued_rasterization_tasks >= 1 && ..);

Fix this by unregistering the view before proceeding with a new
WebContent process.
2026-01-30 12:41:55 +01:00
Andreas Kling
770811e343 LibDevTools: Only send network response bodies when DevTools connected
To avoid unnecessary IPC traffic, we now only send network response
bodies when a DevTools client is connected.

This requires tracking DevTools connection state in ViewImplementation
so we can propagate it to new WebContent processes created during
cross-site navigation.
2026-01-15 20:10:19 +01:00
Andreas Kling
cd8778f662 LibDevTools: Stream console messages instead of polling by index
Previously, console messages were sent using an index-based system where
DevTools would be notified of new message indices and then request them
in batches. This created synchronization issues during page navigation
when the WebContent process resets while DevTools still has stale index
state.

This changes to a push-based model where console messages are sent
immediately as resources when they are logged, matching how Firefox
DevTools handles console messages. Each message is pushed through IPC
and forwarded to DevTools as a "console-message" or "error-message"
resource.

This eliminates the need for index tracking in FrameActor and simplifies
the entire console message pipeline from WebContent through to DevTools.
2026-01-15 20:10:19 +01:00
Andreas Kling
9b8e822390 LibDevTools: Send navigation events to Firefox DevTools
When a page navigates, send document-event resources with
"will-navigate" and tabNavigated messages so Firefox DevTools
can follow along and clear the Network panel appropriately.
2026-01-15 20:10:19 +01:00
Andreas Kling
419afa544c LibWebView: Notify all views when shared WebContent crashes
When multiple views share a WebContent process (e.g. parent and child
views created via window.open()), we need to notify ALL of them when
the process crashes, not just one.

Previously, each view would overwrite the single crash callback on
WebContentClient, so only the last view to initialize would be notified.

This adds WebContentClient::notify_all_views_of_crash() which iterates
over all registered views and notifies each one. Child views also now
propagate crashes to their parent, and can be disconnected between
tests to prevent stale crashes from affecting subsequent tests.
2026-01-13 23:57:46 +01:00
Andreas Kling
7f40f549e1 LibWebView: Improve WebContent crash handling in headless mode
This commit makes several improvements to crash handling for headless
mode (used by test-web and other automated tools):

1. Always respawn WebContent after crashes, ignoring the crash count
   limit. The limit is meant for interactive use to prevent infinite
   crash loops; in headless mode, each test needs a working WebContent.

2. Skip the error page when respawning, as there's no UI to display it.

3. Suppress crash log messages that would corrupt live terminal output.

These changes allow test-web to properly recover from WebContent crashes
and continue running subsequent tests.
2026-01-13 21:05:58 +01:00
Jonathan Gamble
fc22c9ea38 LibWeb+WebContent: Allow WebContent to disentangle zoom from css pixels
So Ladybird can paint scrollbar & resizer chrome at the same size
regardless of zoom level while still respecting device pixel ratio
2026-01-12 11:00:14 +00:00
Aliaksandr Kalenik
835081d66e LibWeb+LibWebView+WebContent: Reset pinch-to-zoom state on Ctrl/Cmd+0 2025-10-10 15:37:45 +02:00
Aliaksandr Kalenik
c630de17ab LibWeb+UI+WebContent: Pipe pinch events from AppKit UI to WebContent 2025-10-10 15:37:45 +02:00
Timothy Flynn
ca082d6d73 LibWebView+UI: Move clipboard handling from the WebView to the App
Clipboard handling largely has nothing to do with the individual web
views. Rather, we interact with the system clipboard at the application
level. So let's move these implementations to the Application.
2025-09-19 06:38:52 -04:00
Timothy Flynn
ce331cbcd5 LibWebView+UI: Add an Application method to open a URL in a new tab
This lets us avoid each UI needing to handle link clicks directly, and
lets actions stored in LibWebView avoid awkwardly going through the link
click callbacks to open URLs.
2025-09-18 07:27:24 -04:00
Timothy Flynn
ede6314cb6 LibWebView+UI/AppKit: Display icons in the macOS UI on Tahoe
On macOS Tahoe, it is now recommended to show menu item icons. We use
system symbols for this now. Symbols do not have constant variable names
and must be found via the SF Symbols app.

The symbols chosen here were to match Safari as close as possible.
2025-09-17 11:29:01 +01:00
Timothy Flynn
b4df857a57 LibWeb+LibWebView+WebContent: Replace DNT with GPC
Global Privacy Control aims to be a replacement for Do Not Track. DNT
ended up not being a great solution, as it wasn't enforced by law. This
actually resulted in the DNT header serving as an extra fingerprinting
data point.

GPC is becoming enforced by law in USA states such as California and
Colorado. CA is further working on a bill which requires that browsers
implement such an opt-out preference signal (OOPS):

https://cppa.ca.gov/announcements/2025/20250911.html

This patch replaces DNT with GPC and hooks up the associated settings.
2025-09-16 10:38:20 +02:00
Timothy Flynn
9684e6dbc5 LibWebView+UI: Generate the zoom menu 2025-09-11 14:23:45 -04:00
Timothy Flynn
9c99c48f47 LibWebView+UI: Generate the application debug menu
By migrating the debug menu to LibWebView, the AppKit and Qt UIs are now
in sync - the AppKit UI was previously missing some actions.

Further, this inadvertently fixes bugs around applying debug settings to
new web views, especially across site-isolated processes. We were
previously not applying settings appropriately; this now "just works" in
the LibWebView infra.
2025-09-11 14:23:45 -04:00
Timothy Flynn
5d8d9b337a LibWebView+UI: Generate application context menus
This migrates all duplicated context menus from the UIs to LibWebView.
The context menu actions are now largely handled directly in LibWebView,
with some UI-specific callbacks added to display e.g. confirmation
dialogs.

Actions that only ever apply to a specific web view are stored on the
ViewImplementation itself. Actions that need to be dynamically applied
to the active web view are stored on the Application.
2025-09-11 14:23:45 -04:00
InvalidUsernameException
08162fb9af LibWebView+Base: Remove unnecessary scrollbar from error pages
I've been looking at the crash-page too much recently and the slight
scrollbar caused by the padding has been annoying me.
2025-09-08 12:02:44 +01:00
rmg-x
333164ecf9 LibWebView: Add defaultZoomLevelFactor setting and necessary plumbing 2025-08-26 06:31:22 -04:00
Luke Wilde
c93c30d596 LibWebView+WebContent: Make it possible to change the painting interval
This allows us to paint at the refresh rate of the screen. The default
is 60, as before, in case it never gets set by anything.
2025-07-26 10:09:12 -04: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
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
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
Viktor Szépe
5cc371d54c LibWeb: Fix typos - act II 2025-04-09 15:05:20 +01:00
Timothy Flynn
a3ea4881e7 LibWeb+LibWebView+UI: Migrate to LibWebView's language settings 2025-04-04 10:16:32 +02:00
Timothy Flynn
920170f60a LibWebView+UI: Remove native do-not-track setting 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
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
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
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
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
Timothy Flynn
e20d7be15f LibWeb+UI: Rename ChromeInputData to BrowserInputData 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
810d04b3f4 LibWeb+LibWebView+WebContent: Remove the built-in Inspector 2025-03-15 19:09:40 +01:00
Timothy Flynn
cbefa797d4 LibDevTools+LibWebView+WebContent: Implement moving DOM nodes
This allows for click-and-dragging DOM nodes in DevTools to move them.
2025-03-11 09:50:51 -04:00
Timothy Flynn
01c44a5c66 LibDevTools+LibWebView+WebContent: Implement getting DOM node inner HTML
This is used by DevTools to copy the inner HTML to the clipboard.
2025-03-11 09:50:51 -04:00
Timothy Flynn
d75eadc3c4 LibDevTools+LibWebView+WebContent: Implement editing DOM node HTML
These commands are used for the "Edit As HTML" feature in DevTools. This
renames our existing HTML getter IPC to indicate that it is for outer
HTML. DevTools will need a separate inner HTML getter.
2025-03-11 09:50:51 -04:00
Timothy Flynn
aca4385daf LibWebView: Create a spare WebContent process
Since cross-site navigation is a pretty frequent task, creating a spare
process is commonplace in other browsers to reduce the overhead of
directing the target site to a new process.

We store this process on the WebView application. If it is unavailable,
we queue a task to create it later.
2025-03-11 12:10:42 +01:00
Timothy Flynn
5810c8073e LibWeb+LibWebView+WebContent: Begin implementing simple site islotation
Site isolation is a common technique to reduce the chance that malicious
sites can access data from other sites. When the user navigates, we now
check if the target site is the same as the current site. If not, we
instruct the UI to perform the navigation in a new WebContent process.

The phrase "site" here is defined as the public suffix of the URL plus
one level. This means that navigating from "www.example.com" to
"sub.example.com" remains in the same process.

There's plenty of room for optimization around this. For example, we can
create a spare WebContent process ahead of time to hot-swap the target
site. We can also create a policy to keep the navigated-from process
around, in case the user quickly navigates back.
2025-03-11 12:10:42 +01:00