From ccc85d0eca1c4dfce958d3e26681735733d49586 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 23 Nov 2026 02:05:14 -0500 Subject: [PATCH 1/2] Tested that the wheel scrolls a WebView(content:) page A notch through Cacao's view graph moves the page by a notch's points, and one the other way brings it back. --- Tests/CacaoWebKitTests/WebViewTests.swift | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Tests/CacaoWebKitTests/WebViewTests.swift b/Tests/CacaoWebKitTests/WebViewTests.swift index 0743f33..24b5271 100644 --- a/Tests/CacaoWebKitTests/WebViewTests.swift +++ b/Tests/CacaoWebKitTests/WebViewTests.swift @@ -80,4 +80,31 @@ struct WebViewTests { try wait(for: "the script") { host.scripts[1] != nil } #expect(host.scripts[1] == #""Clicked""#) } + + @Test func scrollsThePageWithTheWheel() throws { + let host = Host() + let content = try #require(WPEWebContent(delegate: host)) + content.loadHTML("
", baseURL: nil) + try wait(for: "the load") { host.finished } + let graph = ViewGraph(rootView: Root(content: content, shown: true)) + graph.layout(in: CGSize(width: 200, height: 100)) + _ = graph.displayList() + try wait(for: "a frame") { content.surface.pixelSize == CGSize(width: 200, height: 100) } + + var request: Int32 = 0 + func scrollY() -> String? { + request += 1 + let asked = request + content.evaluateJavaScript("window.scrollY", request: asked) + _ = WPEEngine.dispatch(for: 5) { host.scripts[asked] != nil } + return host.scripts[asked] ?? nil + } + #expect(scrollY() == "0") + let point = CGPoint(x: 100, y: 50) + // A notch toward the user moves down the page by one notch's points. + #expect(graph.externalScroll(x: 0, y: -1, at: point)) + try wait(for: "the scroll down") { scrollY() == "\(Int(WebInput.notch))" } + #expect(graph.externalScroll(x: 0, y: 1, at: point)) + try wait(for: "the scroll back") { scrollY() == "0" } + } } From c1359fa47de4c431052185a93be58bd62ca184af Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 23 Nov 2026 02:05:14 -0500 Subject: [PATCH 2/2] Marked phase 1 done in the plan ExampleWeb runs in linux-app-host over this package, and the wheel scrolls. --- Documentation/Plan.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/Plan.md b/Documentation/Plan.md index 14ad3f6..b0c5daa 100644 --- a/Documentation/Plan.md +++ b/Documentation/Plan.md @@ -1,10 +1,9 @@ # WebKit — Plan -**Status:** a draft for review. Phases 2 to 4, URL schemes and replies -to script messages in `WPEWebKit` and `CacaoWebKit`'s API, are merged (#3, -#4, #5). Phase 1 is implemented: `WebView(content:)` here, on -`feature/web-view-content`, and LinuxAppRuntime over this package on its -`feature/pureswift-webkit`. Phase 5 is what's left. +**Status:** a draft for review. Phases 1 to 4 are merged: URL schemes +and replies to script messages in `WPEWebKit` (#3, #4), `CacaoWebKit`'s API +(#5), and LinuxAppRuntime on this package, with `WebView(content:)` here +(#7, PureSwift/LinuxAppRuntime#20). Phase 5 is what's left. This package has WPE WebKit pages drawn into Cacao's external surfaces (`WPEWebKit`) and SwiftUI's `WebView` and `WebPage` on Cacao @@ -272,7 +271,10 @@ func stopURLSchemeTask(_ content: WebContent, task: Int32) drag gesture. Done when `ExampleWeb` runs as before under `Scripts/run-app.sh`, and scrolls with the wheel. `CacaoWebKit` needs `WebView(content:)`, or `WebPage(content:)`, for a page it didn't make. - Implemented: `WebView(content:)` shows a `WPEWebContent` a host made, + Done: `ExampleWeb` runs in `linux-app-host` as before, loading + swift.org through the guest's `WebPage`, and a wheel notch through + Cacao's view graph scrolls a `WebView(content:)` page by the notch and + back (`WebViewTests`). `WebView(content:)` shows a `WPEWebContent` a host made, attached while on screen, with the view's input; the page's delegate stays the host's, so `WebPage(content:)`, which would need it, isn't needed. A host that set `WPEEngine.onReady` runs the engine's loop, and