Skip to content

LibWebView: Run browser-UI traversals as queued history operations - #11101

Draft
shannonbooth wants to merge 3 commits into
LadybirdBrowser:masterfrom
shannonbooth:site-isolation-part-20
Draft

LibWebView: Run browser-UI traversals as queued history operations#11101
shannonbooth wants to merge 3 commits into
LadybirdBrowser:masterfrom
shannonbooth:site-isolation-part-20

Conversation

@shannonbooth

Copy link
Copy Markdown
Member

This simplifies browser-UI back and forward now that the UI process
owns session history, and fixes (some specific cases of) rapid traversals.

The traversable starts its traversal operation directly where it
decides what to do, instead of returning a HistoryTraversalDecision for
ViewImplementation to interpret, and each traversal reports a single
completion. Targets now resolve at the traversal's queue position as
the specification describes, which fixes two rapid Forward presses
moving by only one entry.

Keyboard back and forward move out of WebContent and become UI
accelerators that fire when WebContent reports the keys unhandled.
Pages keep their first shot at the keys, and WebContent's dedicated
traversal IPC message is deleted. A new integration test drives both
the rapid-traversal fix and the keys through a live WebContent process.

This leaves less machinery to carry when traversal operations learn to
survive WebContent process swaps.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 58a3bcd7-23f6-4841-bfc6-6869cd7f6268

📥 Commits

Reviewing files that changed from the base of the PR and between 6c29e9b and 0b311a6.

📒 Files selected for processing (21)
  • Libraries/LibWeb/HTML/HistoryOperation.h
  • Libraries/LibWeb/Page/EventHandler.cpp
  • Libraries/LibWeb/Page/Page.cpp
  • Libraries/LibWeb/Page/Page.h
  • Libraries/LibWebView/Application.cpp
  • Libraries/LibWebView/CanonicalTraversable.cpp
  • Libraries/LibWebView/CanonicalTraversable.h
  • Libraries/LibWebView/ViewImplementation.cpp
  • Libraries/LibWebView/ViewImplementation.h
  • Libraries/LibWebView/WebContentClient.cpp
  • Libraries/LibWebView/WebContentClient.h
  • Services/WebContent/PageClient.cpp
  • Services/WebContent/PageClient.h
  • Services/WebContent/WebContentClient.ipc
  • Tests/LibWeb/CMakeLists.txt
  • Tests/LibWeb/TestPage.cpp
  • Tests/LibWebView/CMakeLists.txt
  • Tests/LibWebView/TestBrowserHistoryTraversal.cpp
  • Tests/LibWebView/test-webdriver-session-history.py
  • UI/Qt/Menu.cpp
  • UI/Qt/WebContentView.cpp
💤 Files with no reviewable changes (9)
  • Libraries/LibWebView/WebContentClient.h
  • Services/WebContent/PageClient.h
  • Services/WebContent/WebContentClient.ipc
  • Libraries/LibWeb/HTML/HistoryOperation.h
  • Tests/LibWeb/TestPage.cpp
  • Tests/LibWeb/CMakeLists.txt
  • Libraries/LibWeb/Page/Page.cpp
  • Libraries/LibWeb/Page/Page.h
  • Services/WebContent/PageClient.cpp
🚧 Files skipped from review as they are similar to previous changes (12)
  • UI/Qt/WebContentView.cpp
  • Libraries/LibWeb/Page/EventHandler.cpp
  • Libraries/LibWebView/WebContentClient.cpp
  • Libraries/LibWebView/Application.cpp
  • UI/Qt/Menu.cpp
  • Libraries/LibWebView/ViewImplementation.h
  • Tests/LibWebView/CMakeLists.txt
  • Tests/LibWebView/TestBrowserHistoryTraversal.cpp
  • Libraries/LibWebView/CanonicalTraversable.cpp
  • Libraries/LibWebView/CanonicalTraversable.h
  • Libraries/LibWebView/ViewImplementation.cpp
  • Tests/LibWebView/test-webdriver-session-history.py

📝 Walkthrough

Walkthrough

History traversal APIs now complete asynchronously through queued operations. Legacy page, client, IPC, and precheck interfaces were removed. Modified arrow keys no longer trigger history traversal from EventHandler; platform history modifiers are handled by ViewImplementation. WebDriver traversal now uses UI deltas and completion callbacks. A standalone headless test validates queued traversal, boundary behavior, and page-consumed keys.

Sequence Diagram(s)

sequenceDiagram
  participant ViewImplementation
  participant CanonicalTraversable
  participant HistoryOperationQueue
  ViewImplementation->>CanonicalTraversable: request history traversal
  CanonicalTraversable->>HistoryOperationQueue: enqueue browser history operation
  HistoryOperationQueue-->>CanonicalTraversable: complete traversal operation
  CanonicalTraversable-->>ViewImplementation: invoke completion callback
Loading

Possibly related PRs

Suggested reviewers: trflynn89

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly explains the history traversal, keyboard handling, IPC removal, rapid traversal fix, and integration test changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Libraries/LibWebView/CanonicalTraversable.cpp (1)

810-810: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse traversal_requires_process_replacement for the process-swap prediction.

traversal_requires_process_replacement at line 759 already wraps this exact call. ViewImplementation::start_requested_history_traversal uses it. Calling it here keeps one definition of the rule.

♻️ Proposed refactor
-    auto will_replace_web_content_process = SiteIsolationManager::the().navigation_requires_process_swap(view->url(), target.target_top_level_entry->url);
+    auto will_replace_web_content_process = traversal_requires_process_replacement(target, view->url());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Libraries/LibWebView/CanonicalTraversable.cpp` at line 810, In the
process-swap prediction within the relevant history traversal flow, replace the
direct SiteIsolationManager::the().navigation_requires_process_swap call with
the existing traversal_requires_process_replacement helper. Reuse that helper
consistently with ViewImplementation::start_requested_history_traversal and
remove the duplicate rule invocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Libraries/LibWebView/CanonicalTraversable.cpp`:
- Line 810: In the process-swap prediction within the relevant history traversal
flow, replace the direct
SiteIsolationManager::the().navigation_requires_process_swap call with the
existing traversal_requires_process_replacement helper. Reuse that helper
consistently with ViewImplementation::start_requested_history_traversal and
remove the duplicate rule invocation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c1f8c7c-c4a7-4a02-860f-1498e3b1fb07

📥 Commits

Reviewing files that changed from the base of the PR and between fdf8a47 and 3c1faa9.

📒 Files selected for processing (21)
  • Libraries/LibWeb/HTML/HistoryOperation.h
  • Libraries/LibWeb/Page/EventHandler.cpp
  • Libraries/LibWeb/Page/Page.cpp
  • Libraries/LibWeb/Page/Page.h
  • Libraries/LibWebView/Application.cpp
  • Libraries/LibWebView/CanonicalTraversable.cpp
  • Libraries/LibWebView/CanonicalTraversable.h
  • Libraries/LibWebView/ViewImplementation.cpp
  • Libraries/LibWebView/ViewImplementation.h
  • Libraries/LibWebView/WebContentClient.cpp
  • Libraries/LibWebView/WebContentClient.h
  • Services/WebContent/PageClient.cpp
  • Services/WebContent/PageClient.h
  • Services/WebContent/WebContentClient.ipc
  • Tests/LibWeb/CMakeLists.txt
  • Tests/LibWeb/TestPage.cpp
  • Tests/LibWebView/CMakeLists.txt
  • Tests/LibWebView/TestBrowserHistoryTraversal.cpp
  • Tests/LibWebView/test-webdriver-session-history.py
  • UI/Qt/Menu.cpp
  • UI/Qt/WebContentView.cpp
💤 Files with no reviewable changes (9)
  • Services/WebContent/PageClient.h
  • Libraries/LibWeb/HTML/HistoryOperation.h
  • Tests/LibWeb/CMakeLists.txt
  • Libraries/LibWeb/Page/Page.cpp
  • Services/WebContent/WebContentClient.ipc
  • Libraries/LibWebView/WebContentClient.h
  • Libraries/LibWeb/Page/Page.h
  • Services/WebContent/PageClient.cpp
  • Tests/LibWeb/TestPage.cpp

@shannonbooth
shannonbooth force-pushed the site-isolation-part-20 branch from 3c1faa9 to c00eed4 Compare August 11, 2026 19:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Services/WebContent/WebDriverConnection.cpp`:
- Around line 626-630: Update the validation before
request_webdriver_press_history_traversal_key in the current WebDriver command
handler to accept only delta values of -1 or 1; return InvalidArgument for 0 and
values whose absolute value exceeds 1. Add endpoint tests covering zero and
out-of-range positive and negative values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3021142d-e762-487e-a14c-799308642368

📥 Commits

Reviewing files that changed from the base of the PR and between 3c1faa9 and c00eed4.

📒 Files selected for processing (13)
  • Libraries/LibWeb/WebDriver/Client.cpp
  • Libraries/LibWeb/WebDriver/Client.h
  • Libraries/LibWebView/WebContentClient.cpp
  • Libraries/LibWebView/WebContentClient.h
  • Services/WebContent/PageClient.cpp
  • Services/WebContent/PageClient.h
  • Services/WebContent/WebContentClient.ipc
  • Services/WebContent/WebDriverClient.ipc
  • Services/WebContent/WebDriverConnection.cpp
  • Services/WebContent/WebDriverConnection.h
  • Services/WebDriver/Client.cpp
  • Services/WebDriver/Client.h
  • Tests/LibWebView/test-webdriver-session-history.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • Libraries/LibWebView/WebContentClient.h
  • Services/WebContent/WebContentClient.ipc
  • Services/WebContent/PageClient.h

Comment thread Services/WebContent/WebDriverConnection.cpp Outdated
@shannonbooth
shannonbooth marked this pull request as draft August 11, 2026 19:24
@shannonbooth
shannonbooth force-pushed the site-isolation-part-20 branch 3 times, most recently from cf31cbf to d07cef9 Compare August 11, 2026 20:37
@shannonbooth
shannonbooth marked this pull request as ready for review August 11, 2026 20:49
@github-actions github-actions Bot added the conflicts Pull request has merge conflicts that need resolution label Aug 12, 2026
@github-actions

Copy link
Copy Markdown

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

Previously, browser-UI history traversal was split between
CanonicalTraversable and ViewImplementation. CanonicalTraversable
computed a HistoryTraversalDecision, then ViewImplementation interpreted
it and queued the operation back onto the same traversable. The decision
also carried UI updates and the traversal result. The result could be
reported either synchronously or through the cancellation callback. This
made WebDriver construct the same completion twice.

Now, CanonicalTraversable starts the traversal as soon as it has
computed the decision and reports a single completion. It invokes view
methods directly for UI updates. New traversal flows no longer require
additional decision fields or switch cases.

The fallback path now uses the shared UI-process traversal loader. This
also ensures that, when Back wins a cross-site race, a provisional
WebContent process is replaced instead of being reused for the load.
Previously, browser traversal targets were resolved before the traversal
entered the queue. If a second Forward was pressed while the first
traversal was pending, it saw the session history from before that
traversal and selected the same entry again.

Now, the traversal is queued first. Its target is resolved when its
queue slot starts, after earlier traversals have updated the session
history. Each request sees the results of the requests ahead of it. This
matches the specification's queued traversal steps. To-step traversals
use the same path.
WebContent's EventHandler turned alt+arrow into a history traversal
through a dedicated IPC message with its own precheck enum, a leftover
from when the page and the browser chrome lived in one process. The
requesting page can also host only a subframe of its traversable, which
is why that message could not reuse the typed history-operation request.

Match the back and forward keys in ViewImplementation once WebContent
reports them unhandled instead. Pages keep their first shot at the
keys, and Page::traverse_the_history_by_delta, the separate IPC
message, and HistoryTraversalPrecheck all disappear.

WebDriver key actions dispatch into the page and never reach a browser
accelerator, so the session-history suite now drives its browser
traversal scenarios through the from-UI test hook. The key path itself
is covered by the browser history traversal test.
@shannonbooth
shannonbooth force-pushed the site-isolation-part-20 branch from d07cef9 to 0b311a6 Compare August 12, 2026 16:10
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@github-actions github-actions Bot removed the conflicts Pull request has merge conflicts that need resolution label Aug 12, 2026
@shannonbooth
shannonbooth marked this pull request as draft August 12, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant