From ffc22e911f069e02c61d2cc48f43f10c038b6d94 Mon Sep 17 00:00:00 2001 From: astar76 Date: Fri, 13 Nov 2026 07:20:17 -0600 Subject: [PATCH] S047: page scripts, user style sheets, find and JS on WebKit User styles become WebKit user style sheets (script fallback for patterns WebKit can't express), the nacre message handler is registered before the view exists, find runs on FindController, and the Servo-only shims are gone from inject.rs. Co-Authored-By: Claude Opus 5.5 --- Plans/08 WebKit engine/S047-page-channel.md | 14 +- Plans/INDEX.md | 2 +- docs/PROGRESS.md | 8 + src/actions.rs | 89 +++++++++--- src/app.rs | 6 +- src/engine/host.rs | 45 ++++-- src/engine/mod.rs | 11 ++ src/engine/view.rs | 30 +++- src/inject.rs | 153 +++----------------- src/store/scripts.rs | 71 ++++++++- src/tabs.rs | 2 + tests/smoke/basics.txt | 6 +- tests/smoke/pages/probe-file.user.css | 5 + tests/smoke/stores-apps.txt | 12 ++ 14 files changed, 266 insertions(+), 188 deletions(-) create mode 100644 tests/smoke/pages/probe-file.user.css diff --git a/Plans/08 WebKit engine/S047-page-channel.md b/Plans/08 WebKit engine/S047-page-channel.md index e746ca3..504ba7b 100644 --- a/Plans/08 WebKit engine/S047-page-channel.md +++ b/Plans/08 WebKit engine/S047-page-channel.md @@ -13,13 +13,13 @@ cosmetic filters, autofill, media actions; Servo-only shims in `inject.rs` dropp - `src/inject.rs` (whole), `src/app.rs` `install_page_scripts` / `on_page_message` / `apply_cosmetic`. ## Steps -- [ ] `UserContentManager` per profile: `WebKitUserScript` (document start, all frames) for Nacre's scripts, `WebKitUserStyleSheet` for user styles; reinstall on settings change. -- [ ] Script message handler `nacre` → `inject::PageMessage` → `Event::PageMessage`; replace the Servo transport in `inject.rs`. -- [ ] `evaluate_javascript` wrapper returning `serde_json::Value` (JSCValue → JSON string); callers in actions/selftest. -- [ ] Find bar on `FindController` (count, next/prev, highlight, close). -- [ ] Drop/re-check the Servo shims listed in servo-removal §3.7 (UA cleanup, SVG colour, WebGL vendor, fonts check, compressor, caret workaround, seek-then-play, navigator fixes) — each removed or kept with a one-line reason. -- [ ] Smoke: `basics.txt` find steps, `dialogs.txt`, `stores-*`/`integ-*` that use page scripts (autofill, scripts store) green hidden. -- [ ] PROGRESS entry, INDEX line, tracker, commit `S047: …`, push. +- [x] `UserContentManager` per profile: `WebKitUserScript` (document start, all frames) for Nacre's scripts, `WebKitUserStyleSheet` for user styles; reinstall on settings change. +- [x] Script message handler `nacre` → `inject::PageMessage` → `Event::PageMessage`; replace the Servo transport in `inject.rs`. +- [x] `evaluate_javascript` wrapper returning `serde_json::Value` (JSCValue → JSON string); callers in actions/selftest. +- [x] Find bar on `FindController` (count, next/prev, highlight, close). +- [x] Drop/re-check the Servo shims listed in servo-removal §3.7 (UA cleanup, SVG colour, WebGL vendor, fonts check, compressor, caret workaround, seek-then-play, navigator fixes) — each removed or kept with a one-line reason. +- [x] Smoke: `basics.txt` find steps, `dialogs.txt`, `stores-*`/`integ-*` that use page scripts (autofill, scripts store) green hidden. +- [x] PROGRESS entry, INDEX line, tracker, commit `S047: …`, push. ## End criteria - `cargo test` green; the listed smokes exit 0 hidden; `grep -n "Servo" src/inject.rs` returns nothing. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index ffbead4..3e85db3 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -10,7 +10,7 @@ Engine switch to WebKit (D-032): new category `08 WebKit engine` comes first; Se - [x] [S044 — Engine seam: pure logic out of the Servo files](08%20WebKit%20engine/S044-engine-seam.md) · Opus medium - [x] [S045 — GTK 4 host with the egui overlay; WebKitGTK views; Servo out of the build](08%20WebKit%20engine/S045-gtk-host.md) · Opus high - [x] [S046 — Smoke harness and selftest on the GTK host (hidden nested niri)](08%20WebKit%20engine/S046-smoke-harness.md) · Opus medium -- [ ] [S047 — Page scripts, page messages, find and JS on WebKit](08%20WebKit%20engine/S047-page-channel.md) · Opus medium +- [x] [S047 — Page scripts, page messages, find and JS on WebKit](08%20WebKit%20engine/S047-page-channel.md) · Opus medium - [ ] [S048 — WebKit UI callbacks: pop-ups, dialogs, menus, permissions, full screen, inspector, PiP](08%20WebKit%20engine/S048-ui-callbacks.md) · Opus high - [ ] [S049 — Ad blocker on WebKit: content filters + web process extension](08%20WebKit%20engine/S049-adblock-webext.md) · Opus high - [ ] [S050 — Network bridge, HTTPS-only, certificates, error pages, privacy switches, downloads](08%20WebKit%20engine/S050-net-privacy-downloads.md) · Opus medium diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 7691ae2..a2767ef 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -373,6 +373,14 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor - Not done: no visible run. The user's niri config has no window rule for `dev.nacre.Nacre`, so a window would take focus; smoke.sh now refuses visible runs without the rule (D-044). Other smoke scripts not ported (each moves with its feature's plan). - Found: loopback http goes through the bridge and fails ("restarted too many times") → S050 box; use `NACRE_NO_BRIDGE=1` for loopback smokes until then. +## S047 — Page scripts, page messages, find and JS on WebKit (2026-11-13) +- Done: user styles are WebKit user style sheets (author level, all frames) via `Engine::set_page_content`; patterns WebKit can't say (`*` inside a host, a port) keep the `