Skip to content

Move web views onto PureSwift/WebKit - #20

Merged
colemancda merged 5 commits into
masterfrom
feature/pureswift-webkit
Nov 23, 2026
Merged

colemancda merged 5 commits into
masterfrom
feature/pureswift-webkit

Conversation

@colemancda

@colemancda colemancda commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Moves web views onto PureSwift/WebKit: its WPEWebKit drives the engine, and its CacaoWebKit shows the pages. That's phase 1 of PureSwift/WebKit's plan.

Builds on PureSwift/WebKit#7 (WebView(content:)), now merged into WebKit's master, which this depends on.

LinuxWebKit

  • LinuxWebContent makes a WPEWebContent and relays its delegate to the guest's. The delegate methods and their numbers (WebNavigationKind, WebError.Code) are already the contract's.
  • It still refuses a load of what isn't a URL, or of a remote URL without network, before anything starts, with or without WPE. loadResource still loads from the bundle's resources/.
  • WPE.swift goes, along with the GError mapping, the policy decisions, the SHM backend and the event structs, which PureSwift/WebKit now has and tests.
  • The engine's loop: WPEEngine.onReady posts WPEEngine.pump() to the MainLoop, so nothing polls. The 8 ms GLib timer is gone. A guest's call schedules a pump for the loop's next turn, so the guest doesn't hear from a page while it's still calling it.
  • The engine logs through HostLog, and the app's network capability sets WPEEngine.isNetworkAllowed.

The player

HostWebView is now CacaoWebKit.WebView(content:) over the page its node names. Frames go to Cacao's ExternalSurface as BGRA, with one copy and no conversion to RGBA. The view's input replaces the drag gesture and the keysym table: the wheel, touch, every button, typed text with the keyboard's layout, and focus now reach the page.

Package

  • New dependency on PureSwift/WebKit: WPEWebKit for LinuxWebKit, and CacaoWebKit for the player on Linux.
  • WEBKIT_PATH points at a local checkout, and Scripts/docker.sh mounts it, as it does for APPRUNTIME_PATH and CACAO_PATH.

Docs

§8 of the plan describes the new layering and drops the wheel, touch and buttons from "Not yet". The readme's module table and its section on local checkouts are updated.

Testing

On aarch64 Debian 13, Swift 6.4.2, WPE 2.48.3 (the development image), with WEBKIT_PATH at PureSwift/WebKit#7's branch, as merged:

  • swift build --build-tests succeeds, and every test target passes.
  • WebContentTests (9 tests, all run in WPE) and the new RenderingTests.aWebViewNodeShowsItsPage passed three runs in a row.
  • New: a page found by its identifier draws its frames at the attached size and is gone once released. A WebView render node attaches the page it names at its size, and detaches it when the node goes, leaving the page alive.
  • Removed: the tests for GError codes, navigation kinds, the RGBA conversion and libwpe's event layouts. That code is now PureSwift/WebKit's, which tests it.
  • Not tested: x86_64, and ExampleWeb under Scripts/run-app.sh, including scrolling with the wheel. Bundling a guest needs the wasm Swift SDK, which the image doesn't have.

WPEWebKit for LinuxWebKit, CacaoWebKit for the player on Linux, and
WEBKIT_PATH for a local checkout, which Scripts/docker.sh mounts.
LinuxWebContent makes PureSwift/WebKit's page and relays its delegate to
the guest's. WPE.swift goes: the engine runs on the main loop when it
says its pages have work, after the guest's call returns.
Its input replaces the drag gesture and the keysym table: the wheel,
touches and every button now reach the page.
What moved there is tested there. Here: a page found by its identifier
draws, and a WebView node attaches the page it names and lets it go.
@colemancda
colemancda merged commit ae7437c into master Nov 23, 2026
2 checks passed
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