S006: R1-13 inline SVG icons take the page's colour

Servo 0.7 paints inline <svg> from its own markup, so currentColor fell back
to black (DuckDuckGo's icons in dark mode). SVG_COLOR_JS copies each SVG's
computed colour into its color attribute; basics.txt checks it. Engine limits
(MSE, mask-image, SVG colour) in DESIGN.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-12 09:14:57 -06:00
commit 27b89a6f12
6 changed files with 28 additions and 4 deletions

View file

@ -20,7 +20,7 @@ Check every row of FEATURES.md "Browser basics" works in the real app, fix what
- [ ] Mark each row in FEATURES.md `verified` or `broken: <why>` (with a PROGRESS 'Later' line for broken ones)
- [x] R1-03/R1-12 YouTube: find why https://www.youtube.com/ fails with `client error (SendRequest)` (start in `src/net/` fetch/bridge path, not page JS), fix, regression test where pure
- [x] R1-14 user agent: set a mainstream Firefox/Chrome-like UA through Servo prefs, check per-site overrides
- [ ] R1-13 DuckDuckGo dark mode icons: check site `prefers-color-scheme`/`color-scheme` handling vs Nacre chrome icon colours, fix the side that's wrong
- [x] R1-13 DuckDuckGo dark mode icons: check site `prefers-color-scheme`/`color-scheme` handling vs Nacre chrome icon colours, fix the side that's wrong
- [ ] R1-04/R1-14 site doctor checklist (no Tor/proxies): YouTube, Google sign-in page, captchas, DuckDuckGo, Reddit, GitHub, HTTP caching; fix in place or log as Servo limit; result list in PROGRESS
- [x] R4-07 heavy-web smoke `tests/smoke/heavy-web.txt` (needs internet, never Tor/proxy, VPN off): YouTube, Wikipedia, DuckDuckGo load, click, scroll, type, play; fails on a broken page; note R4-08 "Settings updated" popup source if seen
- [ ] Mark R1-03, R1-04, R1-12, R1-13, R1-14 fixed/open in `docs/review/phase1.md`, R4-03/05/07 (and R4-08 if found) in `docs/review/phase4.md`

View file

@ -139,6 +139,11 @@ picture-in-picture, extensions, password capture, printing.
- Chrome extensions: not possible. Replaced by user scripts and user styles (Apps -> Scripts).
- Hardware acceleration switch: Servo needs GL; "Off" selects software GL (LIBGL_ALWAYS_SOFTWARE) on next start.
- Printing: "Save page as PDF/PNG" through a full-page screenshot.
- Media Source Extensions: Servo 0.7 has no `MediaSource`, so YouTube's player says "Your browser can't play this
video" (and PiP finds no video). Plain `<video>` files (WebM, MP4 through GStreamer) play.
- Inline `<svg>` is painted from its own markup, so `currentColor` misses the CSS colour; `SVG_COLOR_JS`
(`inject.rs`) copies each icon's computed colour into its `color` attribute (hover colours not followed).
- CSS `mask-image` icons (e.g. Wikipedia's) paint as solid squares. HTTP/2 header limit: see D-012.
## UI system (S015)

View file

@ -39,7 +39,7 @@ State tags: `[open]`, `[fixed <commit>]`, `[wontfix: reason]`. Severity: high /
- R1-11 [fixed f99500f] Colours can't be changed after the welcome setup: once the user finished nacre://welcome, changing the browser colours (Settings → Appearance colour source / palette / custom) had no visible effect. Reproduce: fresh profile, finish the welcome flow, then change colours in Settings. Severity: high. (user, after S020) → first fix before S021 if quick, else S012. Cause found: an internal page typed into a web tab kept that site's theme-color, which won over palette picks under the Website source; the user's exact welcome path didn't reproduce (welcome + every Appearance control works in smoke).
- R1-11 detail [fixed S016 follow-up] "System accent" differed from the desktop on niri + caelestia-niri: Nacre read kdeglobals `AccentColor` (none there), then GNOME `accent-color` (`'red'`, also what the portal reports: #E62D42), which Caelestia never updates. The desktop's real colours are in `~/.local/state/caelestia/scheme.json` (primary `#e6b6f1`). Nacre now reads that file's `colours.primary` first. Nothing missing on the desktop side; optional: set the GNOME/portal accent too for other apps. Still read once at start: a new wallpaper needs a Nacre restart (Later).
- R1-12 [fixed S006] YouTube still doesn't open (same as R1-03; reconfirmed after the redesign). Severity: high. → S006.
- R1-13 [open] Dark mode: icons on DuckDuckGo (the page opened in the user's test) don't use the right colours. Unclear whether it's the site's own icons under dark mode (prefers-color-scheme / colour-scheme handling) or Nacre's chrome icons; check both. Severity: medium. (user) → S006.
- R1-13 [fixed S006] Dark mode: icons on DuckDuckGo (the page opened in the user's test) don't use the right colours. Unclear whether it's the site's own icons under dark mode (prefers-color-scheme / colour-scheme handling) or Nacre's chrome icons; check both. Severity: medium. (user) → S006. Fixed (S006): Nacre's chrome icons and the site's dark scheme were right (`prefers-color-scheme: dark` matches); Servo paints inline SVG from its own markup, so DuckDuckGo's `fill="currentColor"` icons fell back to black. `SVG_COLOR_JS` (inject.rs) sets each SVG's computed colour as its `color` attribute; `basics.txt` checks it. Not followed: hover colour changes.
- R1-14 [open] Site compatibility pass: "more things for sites to actually work right": a proper user agent (Servo 0.7 can set the UA through its preferences even though it can't add request headers; pick a mainstream Firefox/Chrome-like UA string, check per-site overrides), JavaScript features sites expect, and a general "doctor" pass over common sites (YouTube, Google sign-in, captchas, DuckDuckGo, Reddit, GitHub). Severity: high. (user) → S006/S007; extend S006 with a site-doctor checklist.
- R1-12 detail: the YouTube error page shows `client error (SendRequest)` for https://www.youtube.com/ (the request fails in Nacre's fetch/bridge path, not in page JS); start there.
- R1-15 [fixed 7e6c701] One shield flyout for protection: the shield button's flyout holds Ad blocker, Privacy mode and VPN as clearly separated sections (today: ad blocker only, `docs/ui-reference/current-shield-flyout.png`; the VPN has its own button). Severity: medium. (user) → chrome follow-up.

View file

@ -51,7 +51,7 @@ pub struct Options<'a> {
/// Nacre's own scripts run inside one closure with the private `__send`, so pages can call the
/// functions on `window.__nacre` (find, media controls, ...) but can never send a message as Nacre.
pub fn page_scripts(o: &Options) -> Vec<String> {
let mut modules: Vec<String> = vec![MEDIA_JS.to_owned(), FIND_JS.to_owned(), PIP_JS.to_owned(), META_JS.to_owned()];
let mut modules: Vec<String> = vec![MEDIA_JS.to_owned(), FIND_JS.to_owned(), PIP_JS.to_owned(), META_JS.to_owned(), SVG_COLOR_JS.to_owned()];
if o.dnt {
modules.push(DNT_JS.to_owned());
}
@ -370,6 +370,18 @@ const PRIVACY_JS: &str = r#"(() => { if (window.__nacrePriv) return; window.__na
})();"#;
/// Dark pages for sites that have no dark style of their own.
/// Servo 0.7 paints an inline <svg> as a separate image from its own markup, so `currentColor` doesn't see the
/// colour CSS gives the element and falls back to black (dark icons on dark sites, R1-13). Each new <svg> gets its
/// computed colour as its `color` attribute; a colour scheme change redoes them all. Hover colours aren't followed.
const SVG_COLOR_JS: &str = r#"(() => { if (window.__nacreSvg) return; window.__nacreSvg = 1;
let queued = false, all = false;
const run = () => { queued = false; const list = document.querySelectorAll(all ? 'svg' : 'svg:not([data-nacre-color])'); all = false;
for (const svg of list) { const c = getComputedStyle(svg).color; if (svg.getAttribute('data-nacre-color') !== c) { svg.setAttribute('data-nacre-color', c); svg.setAttribute('color', c); } } };
const queue = (everything) => { all = all || everything === true; if (!queued) { queued = true; requestAnimationFrame(run); } };
const start = () => { queue(true); new MutationObserver(() => queue()).observe(document.documentElement, { childList: true, subtree: true }); };
try { matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => queue(true)); } catch (e) {}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true }); else start(); })();"#;
const FORCE_DARK_JS: &str = r#"(() => { const add = () => { if (document.getElementById('__nacre_dark')) return;
const dark = matchMedia && matchMedia('(prefers-color-scheme: dark)').matches;
let bg = 'rgb(255, 255, 255)'; try { bg = getComputedStyle(document.body || document.documentElement).backgroundColor; } catch (e) {}

View file

@ -12,6 +12,9 @@ expect /tab_count 2
open @PAGES@/basics.html
waitload
expect /active/title "Basics"
# Inline SVG takes its colour from CSS (inject.rs SVG_COLOR_JS, R1-13): the icon is green, not black.
waitfor 5 document.getElementById("icon").getAttribute("color") === "rgb(0, 160, 0)"
shot svg-colour
do duplicate_tab
wait 1
expect /tab_count 3
@ -81,7 +84,9 @@ cmd navigate @PAGES@/hello.html
waitload
expect /active/title "Smoke page"
cmd navigate nacre smoke words
waitload 30
wait 1
expect /active/url "https://duckduckgo.com/?q=nacre+smoke+words"
status search
# Find in page: 3 matches, 2 with match case is the bar's job (count only here).
open @PAGES@/basics.html

View file

@ -1,6 +1,7 @@
<!doctype html>
<html>
<!-- Browser basics (S006): find text, a target=_blank link, a window.open pop-up, page full screen. -->
<!-- Browser basics (S006): find text, a target=_blank link, a window.open pop-up, page full screen, an
inline SVG icon drawn in currentColor (green from its parent's CSS). -->
<head><meta charset="utf-8"><title>Basics</title>
<style>body { margin: 0; padding: 20px; font: 16px sans-serif } a, button { display: block; margin: 0 0 20px; height: 30px; width: 300px; font-size: 16px }</style></head>
<body>
@ -8,5 +9,6 @@
<button id="popup" onclick="window.open('hello.html', 'pop', 'width=400,height=300')">Pop-up</button>
<button id="full" onclick="document.documentElement.requestFullscreen()">Full screen</button>
<p>needle one, needle two, Needle three.</p>
<div style="color: rgb(0, 160, 0)"><svg id="icon" viewBox="0 0 16 16" width="32" height="32"><circle cx="8" cy="8" r="7" fill="currentColor"/></svg></div>
</body>
</html>