From 5417cbb09f8aa8d568887714735eb4456c853ff8 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Sun, 15 Nov 2026 04:21:54 +0900 Subject: [PATCH 1/4] Feat: Take the developer bar commands from Chromium's public command ids IDC_DEV_TOOLS_INSPECT and IDC_DEV_TOOLS_CONSOLE are read from chrome/app/chrome_command_ids.h at each milestone's branch (150 to 159), so they are no longer row values. The runtime takes them by the build's milestone, and the row generator writes them from the same table for older runtimes instead of carrying them over unchecked. --- rivet/platform/windows/src/command_ids.rs | 55 +++++++++++++++ rivet/platform/windows/src/lib.rs | 1 + rivet/platform/windows/src/row_port.rs | 69 +++++++++++++++++++ rivet/platform/windows/src/row_recipe.rs | 7 +- .../windows/src/browsers/chromium/commands.rs | 19 +++++ rivet/runtime/windows/src/builds/chrome.rs | 2 - rivet/runtime/windows/src/builds/mod.rs | 9 +-- rivet/runtime/windows/src/builds/tests.rs | 11 ++- .../runtime/windows/src/features/dev_page.rs | 16 ++++- 9 files changed, 171 insertions(+), 18 deletions(-) create mode 100644 rivet/platform/windows/src/command_ids.rs diff --git a/rivet/platform/windows/src/command_ids.rs b/rivet/platform/windows/src/command_ids.rs new file mode 100644 index 0000000..fe805cb --- /dev/null +++ b/rivet/platform/windows/src/command_ids.rs @@ -0,0 +1,55 @@ +//! Chromium's browser command ids that Rivet runs, per Chromium milestone. +//! +//! A browser window runs these ids from its own `WM_COMMAND`, as its own menu and keys do, so they +//! need no address or member of the build. They are defined in `chrome/app/chrome_command_ids.h`, +//! and each value below was read from that header at the milestone's branch on +//! chromium.googlesource.com (`refs/branch-heads//chrome/app/chrome_command_ids.h`). They +//! are public and stable, so they are not values of a build row: the row generator and the +//! runtime both take them from here. A milestone without a read value has no id, and what needs it +//! stays off, because a wrong id runs another command. + +/// `IDC_DEV_TOOLS_INSPECT` and `IDC_DEV_TOOLS_CONSOLE` per Chromium milestone, with the branch the +/// header was read at. They are the commands of the Ctrl+Shift+C and Ctrl+Shift+J keys. +pub const DEV_TOOLS: &[(u16, u16, u32, u32)] = &[ + (150, 7871, 40023, 40005), + (151, 7922, 40023, 40005), + (152, 7977, 40023, 40005), + (153, 8010, 40023, 40005), + (154, 8037, 40023, 40005), + (155, 8059, 40023, 40005), + (156, 8078, 40023, 40005), + (157, 8103, 40023, 40005), + (158, 8127, 40023, 40005), + (159, 8154, 40023, 40005), +]; + +/// The paths of a row's values that are these command ids. A row generator never carries them: +/// it writes the value this table gives, or zero for a milestone it does not know. +pub const ROW_PATHS: &[&str] = &["toolbar.dev.inspect", "toolbar.dev.console"]; + +/// The inspect and console command ids of a Chromium milestone. +pub fn dev_tools(milestone: u16) -> Option<(u32, u32)> { + DEV_TOOLS + .iter() + .find(|(known, _, _, _)| *known == milestone) + .map(|(_, _, inspect, console)| (*inspect, *console)) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn fr11_developer_commands_come_from_chromium_command_ids() { + for milestone in 150..=159u16 { + assert_eq!(dev_tools(milestone), Some((40023, 40005)), "{milestone}"); + } + // An unread milestone never borrows a neighbour's value. + assert_eq!(dev_tools(149), None); + assert_eq!(dev_tools(160), None); + // Each milestone appears once, in branch order. + assert!(DEV_TOOLS + .windows(2) + .all(|pair| pair[0].0 + 1 == pair[1].0 && pair[0].1 < pair[1].1)); + } +} diff --git a/rivet/platform/windows/src/lib.rs b/rivet/platform/windows/src/lib.rs index 88c1962..90ec921 100644 --- a/rivet/platform/windows/src/lib.rs +++ b/rivet/platform/windows/src/lib.rs @@ -6,6 +6,7 @@ pub mod background; pub mod chrome_build; +pub mod command_ids; pub mod control; pub mod focus; pub mod hold; diff --git a/rivet/platform/windows/src/row_port.rs b/rivet/platform/windows/src/row_port.rs index 79487ee..1e17cb4 100644 --- a/rivet/platform/windows/src/row_port.rs +++ b/rivet/platform/windows/src/row_port.rs @@ -1020,6 +1020,7 @@ fn begin_row(prior: &Value, version: &str, carries: bool) -> (Value, PortReport) .review .push(format!("{} is not a four part version", version)); } + write_command_ids(&mut row, version, &mut report); report.carried = crate::row_recipe::without_recipe(&prior["build"]); report.settings = crate::row_recipe::settings(&prior["build"]); if carries && prior_version.split('.').next() != version.split('.').next() { @@ -1037,6 +1038,42 @@ fn begin_row(prior: &Value, version: &str, carries: bool) -> (Value, PortReport) (row, report) } +/// Writes Chromium's public command ids into a row from the table read from Chromium's source, +/// for runtimes that still read them from the row. They are never carried from the prior row: a +/// milestone the table does not know gets zero, which offers no command. A prior row with zero +/// never had the developer bar checked, so it keeps zero. +fn write_command_ids(row: &mut Value, version: &str, report: &mut PortReport) { + let browser = row["build"]["browser"].as_str().unwrap_or_default(); + // Chrome, Edge and Brave carry their Chromium milestone as the first part of their version. + let milestone = matches!(browser, "Google Chrome" | "Microsoft Edge" | "Brave") + .then(|| version.split('.').next()?.parse::().ok()) + .flatten(); + let ids = milestone.and_then(crate::command_ids::dev_tools); + let Some(dev) = row["build"]["toolbar"]["dev"].as_object_mut() else { + return; + }; + for (key, id) in [ + ("inspect", ids.map(|ids| ids.0)), + ("console", ids.map(|ids| ids.1)), + ] { + let Some(prior) = dev.get(key).and_then(Value::as_u64) else { + continue; + }; + let value = if prior == 0 { 0 } else { id.unwrap_or(0) }; + dev.insert(key.to_owned(), json!(value)); + report.derived.push(match (prior == 0, id) { + (true, _) => format!("toolbar.dev.{key}: 0, the prior row offers no developer bar"), + (false, Some(id)) => format!( + "toolbar.dev.{key}: {id}, from chrome_command_ids.h at Chromium {}", + milestone.unwrap_or_default() + ), + (false, None) => format!( + "toolbar.dev.{key}: 0, no command id is read for this build's Chromium milestone" + ), + }); + } +} + /// Finds each address of a row through the public names of both builds. fn port_by_name( prior: &Value, @@ -2123,6 +2160,38 @@ mod tests { ); } + #[test] + fn nfr6_a_command_id_is_not_a_row_value() { + let mut prior = prior(); + prior["build"]["browser"] = json!("Google Chrome"); + prior["frame"]["version"] = json!("157.0.8103.39"); + // A wrong prior value shows that the new row does not copy it. + prior["build"]["toolbar"]["dev"] = json!({"inspect": 1, "console": 2, "colours": []}); + let code = new_code(); + let (row, report) = port(&prior, NEW_SYMBOLS, &code_refs(&code), "158.0.8127.36"); + assert_eq!(row["build"]["toolbar"]["dev"]["inspect"], 40023); + assert_eq!(row["build"]["toolbar"]["dev"]["console"], 40005); + assert!( + !report.carried.iter().any(|path| path.starts_with("toolbar.dev.inspect") + || path.starts_with("toolbar.dev.console")), + "{:?}", + report.carried + ); + let milestone = report + .review + .iter() + .find(|line| line.contains("milestone")) + .expect("the other values still cross the milestone"); + assert!(!milestone.contains("toolbar.dev.console"), "{milestone}"); + // A milestone whose header was not read offers no command rather than the prior one. + let (row, _) = port(&prior, NEW_SYMBOLS, &code_refs(&code), "199.0.1.1"); + assert_eq!(row["build"]["toolbar"]["dev"]["inspect"], 0); + // A row that never offered the developer bar keeps offering none. + prior["build"]["toolbar"]["dev"] = json!({"inspect": 0, "console": 0, "colours": []}); + let (row, _) = port(&prior, NEW_SYMBOLS, &code_refs(&code), "158.0.8127.36"); + assert_eq!(row["build"]["toolbar"]["dev"]["console"], 0); + } + #[test] fn nfr3_a_row_that_crosses_a_milestone_stops_for_review() { let code = new_code(); diff --git a/rivet/platform/windows/src/row_recipe.rs b/rivet/platform/windows/src/row_recipe.rs index a14d276..0faba0f 100644 --- a/rivet/platform/windows/src/row_recipe.rs +++ b/rivet/platform/windows/src/row_recipe.rs @@ -438,7 +438,8 @@ pub fn settings(build: &Value) -> Vec { } /// Every number of a row below the address range that no recipe reads: member offsets, slots, -/// sizes, ids and constants that a port can only carry over. Rivet's own settings are not listed. +/// sizes, ids and constants that a port can only carry over. Rivet's own settings and Chromium's +/// public command ids are not listed. pub fn without_recipe(build: &Value) -> Vec { fn walk(path: &str, value: &Value, out: &mut Vec) { match value { @@ -492,6 +493,7 @@ pub fn without_recipe(build: &Value) -> Vec { && !path.starts_with("version[") && !FIELDS.iter().any(|field| field.path == path) && !SETTINGS.contains(&path.as_str()) + && !crate::command_ids::ROW_PATHS.contains(&path.as_str()) }); out } @@ -682,8 +684,7 @@ mod tests { vec![ "tabs.tab_contents", "toolbar.dev.colours[0][0]", - "toolbar.dev.colours[1][0]", - "toolbar.dev.console" + "toolbar.dev.colours[1][0]" ] ); assert_eq!( diff --git a/rivet/runtime/windows/src/browsers/chromium/commands.rs b/rivet/runtime/windows/src/browsers/chromium/commands.rs index 05041b7..4ada104 100644 --- a/rivet/runtime/windows/src/browsers/chromium/commands.rs +++ b/rivet/runtime/windows/src/browsers/chromium/commands.rs @@ -36,6 +36,15 @@ pub(crate) fn chromium_milestone(browser: &str, version: [u16; 4]) -> Option (u32, u32) { + chromium_milestone(browser, version) + .and_then(rivet_platform_windows::command_ids::dev_tools) + .unwrap_or((0, 0)) +} + /// Whether a browser keeps Chromium's command ids without public source to confirm it. Brave /// publishes its changes and adds its own ids only from 56000, so it keeps Chromium's. Edge, Whale /// and Samsung Internet take the value of their Chromium milestone, which needs a regression check @@ -150,6 +159,16 @@ mod tests { assert!(move_tab_to_new_window("Opera", [130, 0, 1, 1]).is_err()); } + #[test] + fn nfr6_a_command_id_is_not_a_row_value() { + // The developer commands follow the build's Chromium milestone, whatever its row holds. + assert_eq!(dev_tools("Google Chrome", [159, 0, 8154, 6]), (40023, 40005)); + assert_eq!(dev_tools("Microsoft Edge", [157, 0, 4341, 46]), (40023, 40005)); + // A milestone whose header was not read offers no command. + assert_eq!(dev_tools("Google Chrome", [149, 0, 1, 1]), (0, 0)); + assert_eq!(dev_tools("Samsung Internet", [30, 0, 4, 29]), (0, 0)); + } + #[test] fn fr9_browsers_without_public_command_ids_need_a_regression_check() { assert!(!needs_regression_check("Google Chrome")); diff --git a/rivet/runtime/windows/src/builds/chrome.rs b/rivet/runtime/windows/src/builds/chrome.rs index 81e0e5d..74fcc3c 100644 --- a/rivet/runtime/windows/src/builds/chrome.rs +++ b/rivet/runtime/windows/src/builds/chrome.rs @@ -3,8 +3,6 @@ use super::*; pub(super) const DEV_CHROME_156: DevMode = DevMode { - inspect: 40023, - console: 40005, colours: &[ (0x13C, DEV_GROUND), (1590, DEV_GROUND), diff --git a/rivet/runtime/windows/src/builds/mod.rs b/rivet/runtime/windows/src/builds/mod.rs index b5335aa..9ca0fd3 100644 --- a/rivet/runtime/windows/src/builds/mod.rs +++ b/rivet/runtime/windows/src/builds/mod.rs @@ -618,13 +618,10 @@ pub struct Layout { row_struct! { /// What a build needs to show a page in developer mode. pub struct DevMode { - /// The browser's own commands the developer bar runs, as `WM_COMMAND` ids, or zero when the build - /// has none. They are the commands of the Ctrl+Shift+C and Ctrl+Shift+J keys, read from the - /// browser's accelerator table. - pub inspect: u32, - pub console: u32, /// Colour ids of this build and the colours the row takes in developer mode, as `0xAARRGGBB`. /// An id that `colours` does not hold is asked of the provider first, like the ones that it does. + /// A build with no colours has no developer bar. The bar's browser commands are Chromium's + /// public command ids, which come from `browsers::chromium::commands`, not from the row. pub colours: &'static [(i32, u32)], /// `gfx::Font::Font(this, &name, size)` and `gfx::FontList::FontList(this, &font)`, which build /// the monospace font of the address. A build without them keeps the address in its own font. @@ -636,8 +633,6 @@ pub struct DevMode { } const UNCHECKED_DEV: DevMode = DevMode { - inspect: 0, - console: 0, colours: &[], font_new: ABSENT, font_new_prologue: &[0], diff --git a/rivet/runtime/windows/src/builds/tests.rs b/rivet/runtime/windows/src/builds/tests.rs index d1d3757..bfc4eac 100644 --- a/rivet/runtime/windows/src/builds/tests.rs +++ b/rivet/runtime/windows/src/builds/tests.rs @@ -633,11 +633,16 @@ fn fr3_a_build_with_tabs_checks_only_functions_it_has() { #[test] fn fr11_developer_commands_are_those_of_the_devtools_keys() { for build in [&CHROME, &EDGE, &BRAVE, &BRAVE_63] { - let dev = &build.toolbar.dev; - assert_eq!((dev.console, dev.inspect), (40005, 40023)); + assert!(!build.toolbar.dev.colours.is_empty()); + assert_eq!( + crate::features::dev_page::dev_commands(build), + (40023, 40005) + ); } // A build that was never checked offers no command and no bar. - assert_eq!(UNCHECKED_TOOLBAR.dev.inspect, 0); + for build in [&WHALE, &SAMSUNG, &CHROME_150] { + assert_eq!(crate::features::dev_page::dev_commands(build), (0, 0)); + } } #[test] diff --git a/rivet/runtime/windows/src/features/dev_page.rs b/rivet/runtime/windows/src/features/dev_page.rs index 54c12c1..084df23 100644 --- a/rivet/runtime/windows/src/features/dev_page.rs +++ b/rivet/runtime/windows/src/features/dev_page.rs @@ -47,18 +47,28 @@ pub(crate) unsafe fn toggle_dev_mode(window: HWND) -> bool { /// The buttons the developer bar of this build offers, with the command each runs. pub(crate) fn dev_actions() -> Vec<(Action, u32)> { - let dev = &crate::builds::get().toolbar.dev; + let (inspect, console) = dev_commands(crate::builds::get()); // Chromium has no browser command that opens DevTools on its Network or Performance panel. // Rivet opens them itself through Chromium's DevTools functions where the build records them. let panels = panel_buttons(crate::features::dev_tools::available()); crate::dev_mode::bar_buttons(&[ - (Action::Inspect, dev.inspect), - (Action::Console, dev.console), + (Action::Inspect, inspect), + (Action::Console, console), (Action::Network, panels), (Action::Performance, panels), ]) } +/// The inspect and console commands the developer bar of `build` runs, or zero for each. They are +/// Chromium's public command ids for the build's milestone. Only a build whose developer colours +/// were checked has the bar at all. +pub(crate) fn dev_commands(build: &crate::builds::Build) -> (u32, u32) { + if build.toolbar.dev.colours.is_empty() { + return (0, 0); + } + crate::browsers::chromium::commands::dev_tools(build.browser, build.version) +} + /// The marker the Network and Performance buttons carry when Rivet can open their panels. Rivet /// runs them itself, so it is never sent to the browser as a command. pub(crate) const PANEL_BUTTON: u32 = u32::MAX; From 571187816b5f83cceb4894b629e37c2b6f4cbc09 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Sun, 15 Nov 2026 04:30:25 +0900 Subject: [PATCH 2/4] Feat: Turn off only the features whose row values could not be read A row that crosses a milestone no longer goes to review as a whole for its carried values. Each carried value that only one feature reads (split view, vertical tabs, the Sidebar, the app window, address suggestions, the developer colours, the frame colour) turns that feature off with the switch the runtime already obeys, and is cleared, so no value of the prior build reaches a browser. A value the runtime does not read in this row is written as zero. A value of the frame or the page area layout still stops the row. The row names its switched-off features, and the feature gate does not require their checks, so the rest of the row ships once its checks pass. --- .github/workflows/browser-rows.yml | 8 +- .../platform/windows/src/bin/chrome-builds.rs | 14 +- rivet/platform/windows/src/lib.rs | 1 + rivet/platform/windows/src/row_features.rs | 348 ++++++++++++++++++ rivet/platform/windows/src/row_port.rs | 187 +++++++++- rivet/platform/windows/src/row_watch.rs | 36 ++ 6 files changed, 574 insertions(+), 20 deletions(-) create mode 100644 rivet/platform/windows/src/row_features.rs diff --git a/.github/workflows/browser-rows.yml b/.github/workflows/browser-rows.yml index d99737e..d0c5a42 100644 --- a/.github/workflows/browser-rows.yml +++ b/.github/workflows/browser-rows.yml @@ -431,7 +431,9 @@ jobs: # The harness builds Rivet itself, with the test flags that keep sync and sign-in off. ./scripts/tests/windows-features.ps1 -Browsers $name ` -Executable "${{ steps.build.outputs.executable }}" -OutDir $features - ./tools/chrome-builds.exe gate (Join-Path $features "results.json") $name + # A check of a feature the row turns off for this build is not required; the row ships with + # that feature off, and the gate prints a note for it. + ./tools/chrome-builds.exe gate (Join-Path $features "results.json") $name "$temp/row.json" if ($LASTEXITCODE -ne 0) { throw "a feature check failed or could not run; results.json lists which" } Set-Content (Join-Path $temp "session/features-passed") "${{ matrix.build.version }}" @@ -538,6 +540,10 @@ jobs: $body += "The symbol server had no PDB for this build, so the row was made from the fingerprints of the $($report.prior_version) row: $($report.fingerprinted.Count) of $($report.addresses) addresses matched exactly one place. When the PDB appears, the row job makes the row again from it and compares the two.`n`n" } $body += (($report.review | ForEach-Object { "- $_" }) -join "`n") + if ($report.switched_off.Count -gt 0) { + $body += "`n`nThese features are off in this row, because a value they need could not be read from this build:`n`n" + $body += (($report.switched_off | ForEach-Object { "- $_" }) -join "`n") + } gh pr create --draft --base develop --head $branch --title "Feat: Propose a row for ${{ matrix.build.browser }} ${{ matrix.build.version }}" --body $body gh workflow run test.yml --ref $branch diff --git a/rivet/platform/windows/src/bin/chrome-builds.rs b/rivet/platform/windows/src/bin/chrome-builds.rs index f3fb64b..e37dac5 100644 --- a/rivet/platform/windows/src/bin/chrome-builds.rs +++ b/rivet/platform/windows/src/bin/chrome-builds.rs @@ -105,7 +105,8 @@ fn main() -> ExitCode { ["pending", stable, beta, edge, brave, known] => { pending(Path::new(stable), Path::new(beta), Path::new(edge), Path::new(brave), Path::new(known)) } - ["gate", results, browser] => gate(Path::new(results), browser), + ["gate", results, browser] => gate(Path::new(results), browser, None), + ["gate", results, browser, row] => gate(Path::new(results), browser, Some(Path::new(row))), ["fingerprint", row, module, out] => fingerprint(Path::new(row), Path::new(module), Path::new(out)), ["release-sign", version, signed, files @ ..] => release_sign(version, Path::new(signed), files), ["release-check", signed, file] => release_check(Path::new(signed), Path::new(file)), @@ -123,7 +124,7 @@ fn main() -> ExitCode { ["table-withdraw", published, signed, builds @ ..] if !builds.is_empty() => { table_withdraw(Path::new(published), Path::new(signed), builds) } - _ => Err("usage: chrome-builds pdb-key | extract [frame-class] | port | find | pdb-check | pending | gate | fingerprint | release-sign ... | release-check | table-key | table-add | table-read | table-merge ... | table-sign [published-file] | table-withdraw ...".into()), + _ => Err("usage: chrome-builds pdb-key | extract
[frame-class] | port | find | pdb-check | pending | gate [row.json] | fingerprint | release-sign ... | release-check | table-key | table-add | table-read | table-merge ... | table-sign [published-file] | table-withdraw ...".into()), }; match result { Ok(()) => ExitCode::SUCCESS, @@ -878,13 +879,18 @@ mod symbols { } /// Refuses a browser that did not pass every feature check, so it is never listed as supported. -fn gate(results: &Path, browser: &str) -> Result<(), String> { +/// The row is the one being published: a check of a feature it turns off is not required. +fn gate(results: &Path, browser: &str, row: Option<&Path>) -> Result<(), String> { + let row = match row { + Some(path) => json_file(path)?, + None => serde_json::Value::Null, + }; let text = String::from_utf8(read(results)?) .map_err(|error| format!("the feature results are not text: {error}"))?; // PowerShell writes UTF-8 with a byte order mark. let results: serde_json::Value = serde_json::from_str(text.trim_start_matches('\u{feff}')) .map_err(|error| format!("the feature results are not JSON: {error}"))?; - let notes = row_watch::publish_gate(&results, browser) + let notes = row_watch::publish_gate_for_row(&results, browser, &row) .map_err(|reasons| format!("{browser} is not supported: {}", reasons.join("; ")))?; for note in notes { println!("note: {note}"); diff --git a/rivet/platform/windows/src/lib.rs b/rivet/platform/windows/src/lib.rs index 90ec921..81c550f 100644 --- a/rivet/platform/windows/src/lib.rs +++ b/rivet/platform/windows/src/lib.rs @@ -10,6 +10,7 @@ pub mod command_ids; pub mod control; pub mod focus; pub mod hold; +pub mod row_features; pub mod row_port; pub mod row_recipe; pub mod row_resolve; diff --git a/rivet/platform/windows/src/row_features.rs b/rivet/platform/windows/src/row_features.rs new file mode 100644 index 0000000..ede4daa --- /dev/null +++ b/rivet/platform/windows/src/row_features.rs @@ -0,0 +1,348 @@ +//! Which feature of a row each value belongs to, and how a row turns that feature off. +//! +//! A row value that could not be read from its own build must never reach a browser. When it +//! belongs to a feature the runtime can do without, the row turns that feature off and clears the +//! value, and the rest of the row can still ship once its checks pass. A value of a part the +//! window cannot do without (the frame and the page area layout) has no switch here, so it still +//! stops the row and the browser opens with Rivet's held build. +//! +//! The switches are the ones the runtime already obeys: a section's `supported` flag, an optional +//! part left `null`, an empty list of colour ids, and the frame colour's `provider_verified`. Each +//! one was checked against every reader of the values it covers, so a feature that is off reads +//! none of them. The same switches work in older runtimes, which read the same row fields. + +use serde_json::{json, Value}; + +/// The address a build records for what it does not have. +const ABSENT: &str = "0x7fff0000"; + +/// What turns a feature off in a row. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Off { + /// A `supported` or `provider_verified` flag set to false. + Flag(&'static str), + /// An optional part set to `null`. + Part(&'static str), +} + +/// What a value of a feature that is off becomes, so the row holds nothing of another build. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Clear { + /// Every number in it becomes zero, in the form it was written. + Zero, + /// The address the build does not have, which a reader takes as nothing there. + Absent, + /// An empty list. + Empty, +} + +/// A feature of a row and the values only it reads. +pub struct RowFeature { + /// The feature's name, as the runtime and the report give it. + pub name: &'static str, + /// Row paths of its values. A path that ends with `.` covers the whole section. + pub paths: &'static [&'static str], + pub off: &'static [Off], + pub clear: Clear, + /// The checks of `scripts/tests/windows-features.ps1` that need the feature. A row that has the + /// feature off is not expected to pass them. A prefix ending with `-` covers its family. + pub checks: &'static [&'static str], +} + +pub const ROW_FEATURES: &[RowFeature] = &[ + RowFeature { + name: "split view", + paths: &["split."], + off: &[Off::Flag("split.supported")], + clear: Clear::Zero, + checks: &["split", "split-"], + }, + RowFeature { + name: "vertical tabs", + paths: &[ + "vertical.update_collapse_action", + "vertical.browser_offset", + "vertical.mode_offset", + "vertical.width_offset", + ], + off: &[Off::Flag("vertical.supported")], + clear: Clear::Zero, + checks: &[], + }, + RowFeature { + name: "sidebar", + paths: &[ + "side_panel.color_source", + "side_panel.source_in_widget", + "side_panel.entry_count", + "side_panel.extension_entry", + "side_panel.features_coordinator", + "side_panel.features_offset", + ], + off: &[Off::Flag("side_panel.supported")], + clear: Clear::Zero, + checks: &["sidebar", "sidebar-", "fullscreen-sidebar"], + }, + RowFeature { + name: "sidebar", + paths: &["side_panel.hidden_entries"], + off: &[Off::Flag("side_panel.supported")], + clear: Clear::Empty, + checks: &["sidebar", "sidebar-", "fullscreen-sidebar"], + }, + RowFeature { + // Fields of the browser's layout object that only the Sidebar's part of the layout reads. + // The layout reads an absent field as no view. + name: "sidebar", + paths: &[ + "side_panel.side_panel", + "side_panel.side_panel_animation", + "side_panel.contents_outline", + "side_panel.vertical_tabs", + ], + off: &[Off::Flag("side_panel.supported")], + clear: Clear::Absent, + checks: &["sidebar", "sidebar-", "fullscreen-sidebar"], + }, + RowFeature { + name: "app window", + paths: &["app_window."], + off: &[Off::Part("app_window")], + clear: Clear::Zero, + checks: &["mini-", "tab-moves"], + }, + RowFeature { + name: "address suggestions", + paths: &["omnibox."], + off: &[Off::Part("omnibox")], + clear: Clear::Zero, + checks: &["address-suggest", "security-chip"], + }, + RowFeature { + // An empty list is a build without developer colours, whose page keeps the browser's own. + name: "developer colours", + paths: &["toolbar.dev.colours"], + off: &[], + clear: Clear::Empty, + checks: &["dev-row"], + }, + RowFeature { + name: "frame colour", + paths: &["layout.frame_ids", "layout.caption_ink_ids"], + off: &[Off::Flag("layout.provider_verified")], + clear: Clear::Empty, + checks: &[], + }, +]; + +/// Values the runtime does not read while another value of the row says so: then they are not +/// values of the build at all, and a row holds zero for them. +pub struct UnusedWhen { + pub paths: &'static [&'static str], + /// The address that decides it. + pub address: &'static str, + /// Unused while that address is recorded, or while it is absent. + pub while_recorded: bool, + pub why: &'static str, +} + +pub const UNUSED_WHEN: &[UnusedWhen] = &[ + UnusedWhen { + paths: &["tabs.tab_collection", "tabs.tab_contents"], + address: "tabs.tab_at", + while_recorded: true, + why: "the build has its own GetWebContentsAt", + }, + UnusedWhen { + paths: &[ + "vertical.window_feature_tab_strip", + "vertical.window_feature_callers", + "vertical.toolbar_in_view", + "vertical.toolbar_leading", + ], + address: "vertical.window_feature", + while_recorded: false, + why: "the tab strip is left out through ShouldDrawTabStrip, not the window feature", + }, +]; + +/// The field a value path names: `layout.frame_ids[2]` names `layout.frame_ids`. +pub fn field_of(path: &str) -> &str { + path.split('[').next().unwrap_or(path) +} + +fn covers(rule: &str, path: &str) -> bool { + let field = field_of(path); + if rule.ends_with('.') { + field.starts_with(rule) + } else { + field == rule + } +} + +/// The feature a value belongs to, when the row can turn it off. +pub fn feature_of(path: &str) -> Option<&'static RowFeature> { + ROW_FEATURES + .iter() + .find(|feature| feature.paths.iter().any(|rule| covers(rule, path))) +} + +fn at<'a>(build: &'a Value, path: &str) -> Option<&'a Value> { + path.split('.').try_fold(build, |value, key| value.get(key)) +} + +fn at_mut<'a>(build: &'a mut Value, path: &str) -> Option<&'a mut Value> { + path.split('.').try_fold(build, |value, key| value.get_mut(key)) +} + +fn is_recorded(value: &Value) -> bool { + crate::row_recipe::number(value) + .is_some_and(|value| (0x10_0000..0x7FFF_0000).contains(&value)) +} + +/// Why the runtime does not read a value in this row, or `None` when it does. +pub fn unused(build: &Value, path: &str) -> Option<&'static str> { + UNUSED_WHEN + .iter() + .find(|rule| { + rule.paths.iter().any(|each| covers(each, path)) + && at(build, rule.address) + .is_some_and(|value| is_recorded(value) == rule.while_recorded) + }) + .map(|rule| rule.why) +} + +fn zero(value: &mut Value) { + if let Value::Array(items) = value { + items.iter_mut().for_each(zero); + return; + } + let cleared = match &*value { + Value::String(text) if text.starts_with("0x") => json!("0x0"), + Value::Number(_) => json!(0), + _ => return, + }; + *value = cleared; +} + +/// Clears the field a value path names, as `clear` says. +pub fn clear(build: &mut Value, path: &str, how: Clear) { + let Some(value) = at_mut(build, field_of(path)) else { + return; + }; + match how { + Clear::Zero => zero(value), + Clear::Absent => *value = json!(ABSENT), + Clear::Empty => *value = json!([]), + } +} + +/// Turns a feature off in a row's build part. +pub fn switch_off(build: &mut Value, feature: &RowFeature) { + for off in feature.off { + match *off { + Off::Flag(path) => { + if let Some(flag) = at_mut(build, path) { + *flag = json!(false); + } + } + Off::Part(name) => build[name] = Value::Null, + } + } +} + +/// The key of a row that names the features it has off and the values that turned them off. The +/// runtime reads only `frame` and `build`, so it changes nothing in a browser; the feature gate +/// reads it. +pub const SWITCHED_OFF: &str = "switched_off"; + +/// The feature checks a row's switched-off features excuse, by the names the row gives. +pub fn excused_checks(row: &Value) -> Vec<(&'static str, &'static str)> { + let names: Vec<&str> = row[SWITCHED_OFF] + .as_array() + .map_or(&[][..], Vec::as_slice) + .iter() + .filter_map(|entry| entry["feature"].as_str()) + .collect(); + let mut out = Vec::new(); + for feature in ROW_FEATURES + .iter() + .filter(|feature| names.contains(&feature.name)) + { + for check in feature.checks { + if !out.contains(&(feature.name, *check)) { + out.push((feature.name, *check)); + } + } + } + out +} + +/// The switched-off feature that excuses a feature check, if one does. +pub fn excuses(excused: &[(&'static str, &'static str)], check: &str) -> Option<&'static str> { + excused + .iter() + .find(|(_, rule)| { + if rule.ends_with('-') { + check.starts_with(rule) + } else { + check == *rule + } + }) + .map(|(name, _)| *name) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn nfr6_every_row_value_of_a_feature_has_one_switch() { + assert_eq!(feature_of("split.view_size").unwrap().name, "split view"); + assert_eq!(feature_of("toolbar.dev.colours[3][0]").unwrap().name, "developer colours"); + assert_eq!(feature_of("layout.frame_ids[1]").unwrap().name, "frame colour"); + assert_eq!(feature_of("omnibox.match_size").unwrap().name, "address suggestions"); + // The frame and the page area layout have no switch: the window cannot do without them. + for core in [ + "layout.view_bounds_offset", + "layout.frame_browser_window_offset", + "side_panel.page_area", + "side_panel.host_view", + "side_panel.contents_container", + "side_panel.toolbar", + "toolbar.get_widget_slot", + ] { + assert!(feature_of(core).is_none(), "{core}"); + } + // A value that only looks like a section's name is not in it. + assert!(feature_of("splitter.width").is_none()); + } + + #[test] + fn nfr6_a_value_the_runtime_does_not_read_is_not_a_value_of_the_build() { + let build = json!({ + "tabs": {"tab_at": "0x326a00", "tab_collection": "0x30"}, + "vertical": {"window_feature": "0x7fff0000", "window_feature_callers": ["0x0", "0x0"]}, + }); + assert!(unused(&build, "tabs.tab_collection").is_some()); + assert!(unused(&build, "vertical.window_feature_callers[1]").is_some()); + let build = json!({ + "tabs": {"tab_at": "0x7fff0000"}, + "vertical": {"window_feature": "0x1234560"}, + }); + assert!(unused(&build, "tabs.tab_collection").is_none()); + assert!(unused(&build, "vertical.toolbar_in_view").is_none()); + } + + #[test] + fn nfr6_a_switched_off_feature_excuses_only_its_own_checks() { + let row = json!({"switched_off": [{"feature": "split view"}, {"feature": "developer colours"}]}); + let excused = excused_checks(&row); + assert_eq!(excuses(&excused, "split-grid-4"), Some("split view")); + assert_eq!(excuses(&excused, "split"), Some("split view")); + assert_eq!(excuses(&excused, "dev-row"), Some("developer colours")); + assert_eq!(excuses(&excused, "sidebar"), None); + assert_eq!(excuses(&excused, "bar-layout"), None); + assert!(excused_checks(&json!({})).is_empty()); + } +} diff --git a/rivet/platform/windows/src/row_port.rs b/rivet/platform/windows/src/row_port.rs index 1e17cb4..d9e40a7 100644 --- a/rivet/platform/windows/src/row_port.rs +++ b/rivet/platform/windows/src/row_port.rs @@ -71,6 +71,20 @@ pub struct PortReport { pub fingerprinted: Vec, /// Values that are Rivet's settings rather than facts about the build, kept from the prior row. pub settings: Vec, + /// Features this row turns off, each with the values that could not be read for it. The row + /// clears those values, so none of the prior build reaches a browser. + pub switched_off: Vec, + /// Values the runtime does not read in this row, written as zero, with the reason. + pub unused: Vec, + /// Whether every carried value must be settled: the milestone changed, or values were read. + #[serde(skip)] + must_check: bool, + /// The milestone change, when there is one and nothing read the carried values. + #[serde(skip)] + milestone: Option, + /// Why each value that was tried could not be read. + #[serde(skip)] + unread: BTreeMap, } fn is_address(value: u64) -> bool { @@ -986,7 +1000,75 @@ pub fn port_row( let targets = addresses_of(&row); report.addresses = targets.len(); port_by_name(prior, &row, named, new, &targets, &mut moved, &mut report); - finish_row(row, &moved, new.pe, report) + let (mut row, mut report) = finish_row(row, &moved, new.pe, report); + settle_carried(&mut row, &mut report); + (row, report) +} + +/// Settles each value no recipe or instruction read from the new build. A value the runtime does +/// not read in this row is written as zero. A value of a feature the runtime can do without turns +/// that feature off for this build and is cleared, so the rest of the row is not held back by it. +/// Any other value stops the row with its reason, since no feature may run on a value of another +/// build. +fn settle_carried(row: &mut Value, report: &mut PortReport) { + use crate::row_features::{self, Clear, RowFeature}; + if !report.must_check { + return; + } + let mut left = Vec::new(); + let mut off: BTreeMap<&'static str, (&'static RowFeature, Vec)> = BTreeMap::new(); + for path in std::mem::take(&mut report.carried) { + if let Some(why) = row_features::unused(&row["build"], &path) { + row_features::clear(&mut row["build"], &path, Clear::Zero); + report.unused.push(format!("{path}: {why}")); + report.unread.remove(&path); + } else if let Some(feature) = row_features::feature_of(&path) { + row_features::clear(&mut row["build"], &path, feature.clear); + off.entry(feature.name) + .or_insert((feature, Vec::new())) + .1 + .push(path); + } else { + left.push(path); + } + } + let mut entries = Vec::new(); + for (name, (feature, paths)) in off { + row_features::switch_off(&mut row["build"], feature); + let reasons: Vec = paths + .iter() + .map(|path| match report.unread.remove(path) { + Some(reason) => format!("{path} {reason}"), + None => format!("{path} has no recipe"), + }) + .collect(); + report + .switched_off + .push(format!("{name} is off: {}", reasons.join("; "))); + entries.push(json!({"feature": name, "values": paths})); + } + if !entries.is_empty() { + row[row_features::SWITCHED_OFF] = json!(entries); + } + let mut unchecked = Vec::new(); + for path in &left { + match report.unread.remove(path) { + Some(reason) => report.review.push(format!("{path} {reason}")), + None => unchecked.push(path.clone()), + } + } + if !unchecked.is_empty() { + let head = report + .milestone + .clone() + .unwrap_or_else(|| "values were not read".to_owned()); + report.review.push(format!( + "{head}: {} values have no recipe and were carried over unchecked: {}", + unchecked.len(), + unchecked.join(", ") + )); + } + report.carried = left; } /// A copy of the prior row with the new version, and frame addresses in the `0x` form. `carries` @@ -1023,11 +1105,11 @@ fn begin_row(prior: &Value, version: &str, carries: bool) -> (Value, PortReport) write_command_ids(&mut row, version, &mut report); report.carried = crate::row_recipe::without_recipe(&prior["build"]); report.settings = crate::row_recipe::settings(&prior["build"]); - if carries && prior_version.split('.').next() != version.split('.').next() { - report.review.push(format!( - "the milestone changed from {prior_version} to {version}: {} values have no recipe and were carried over unchecked: {}", - report.carried.len(), - report.carried.join(", ") + let milestone_changed = prior_version.split('.').next() != version.split('.').next(); + report.must_check = !carries || milestone_changed; + if carries && milestone_changed { + report.milestone = Some(format!( + "the milestone changed from {prior_version} to {version}" )); } row["build"]["version"] = json!(parts); @@ -1559,6 +1641,7 @@ pub fn find_candidate( if let Some(prior_pe) = prior_pe { read_carried(prior, &mut row, &moved, &followed, prior_pe, pe, &mut report); } + settle_carried(&mut row, &mut report); (row, report) } @@ -1589,8 +1672,8 @@ fn value_at_mut<'a>(value: &'a mut Value, path: &str) -> Option<&'a mut Value> { /// Reads each value the recipes leave, a member offset, slot, size or id, from the instructions /// that use it in the prior build's functions and the same instructions in the new build. A value -/// that cannot be read keeps a review line with the reason and stays listed as carried, so the row -/// is never published with a value of the prior build. +/// that cannot be read keeps its reason and stays listed as carried, and `settle_carried` decides +/// what it does to the row, so the row is never published with a value of the prior build. fn read_carried( prior: &Value, row: &mut Value, @@ -1658,18 +1741,19 @@ fn read_carried( }); } Err(reason) => { - report.review.push(format!( - "{} was not read from the new build: {reason}", - reading.path - )); + report.unread.insert( + reading.path.clone(), + format!("was not read from the new build: {reason}"), + ); report.carried.push(reading.path); } } } for path in unreadable { - report - .review - .push(format!("{path} is not a number this generator can read")); + report.unread.insert( + path.clone(), + "is not a number this generator can read".to_owned(), + ); report.carried.push(path); } } @@ -2192,6 +2276,79 @@ mod tests { assert_eq!(row["build"]["toolbar"]["dev"]["console"], 0); } + /// A prior row whose values that are not addresses all belong to features the runtime can do + /// without, or are not read in this row. + fn prior_with_features() -> Value { + let mut prior = prior(); + let toolbar = prior["build"]["toolbar"].as_object_mut().unwrap(); + toolbar.remove("view_layer"); + toolbar.remove("colours"); + toolbar.insert( + "dev".to_owned(), + json!({"colours": [[321, 4280953905u32], [1597, 0]]}), + ); + prior["build"]["split"] = json!({"supported": true, "outline_member": "0x40"}); + prior["build"]["omnibox"] = json!({"match_size": "0x820"}); + prior["build"]["tabs"]["tab_at"] = json!("0x200300"); + prior["build"]["tabs"]["tab_collection"] = json!("0x30"); + prior + } + + #[test] + fn nfr6_a_feature_with_an_unread_value_is_off_for_that_build() { + let code = new_code(); + let (row, report) = port(&prior_with_features(), NEW_SYMBOLS, &code_refs(&code), "2.0.0.1"); + // Nothing holds the rest of the row back. + assert_eq!(report.review, Vec::::new()); + assert!(report.carried.is_empty(), "{:?}", report.carried); + let build = &row["build"]; + // Each feature with a value of the prior build is off, and the value is gone. + assert_eq!(build["split"]["supported"], false); + assert_eq!(build["split"]["outline_member"], "0x0"); + assert!(build["omnibox"].is_null()); + assert_eq!(build["toolbar"]["dev"]["colours"], json!([])); + let off: Vec<&str> = row[crate::row_features::SWITCHED_OFF] + .as_array() + .unwrap() + .iter() + .map(|entry| entry["feature"].as_str().unwrap()) + .collect(); + assert_eq!(off, ["address suggestions", "developer colours", "split view"]); + assert_eq!(report.switched_off.len(), 3, "{:?}", report.switched_off); + // A value this build does not use is written as zero, and no feature goes off for it. + assert_eq!(build["tabs"]["tab_collection"], "0x0"); + assert_eq!(report.unused.len(), 1, "{:?}", report.unused); + // The addresses of the row still move to the new build. + assert_eq!(build["tabs"]["tab_at"], "0x101300"); + } + + #[test] + fn nfr6_a_value_the_window_cannot_do_without_still_stops_the_row() { + let mut prior = prior_with_features(); + prior["build"]["layout"] = json!({"view_bounds_offset": "0x1c8"}); + let code = new_code(); + let (row, report) = port(&prior, NEW_SYMBOLS, &code_refs(&code), "2.0.0.1"); + assert_eq!(report.carried, ["layout.view_bounds_offset"]); + assert!( + report.review.iter().any(|line| line.contains("milestone") + && line.ends_with("carried over unchecked: layout.view_bounds_offset")), + "{:?}", + report.review + ); + // The features it could do without are still off. + assert_eq!(row["build"]["split"]["supported"], false); + } + + #[test] + fn nfr6_a_row_within_its_milestone_turns_nothing_off() { + let code = new_code(); + let (row, report) = port(&prior_with_features(), NEW_SYMBOLS, &code_refs(&code), "1.0.0.2"); + assert_eq!(report.review, Vec::::new()); + assert!(report.switched_off.is_empty()); + assert_eq!(row["build"]["split"]["supported"], true); + assert!(row.get(crate::row_features::SWITCHED_OFF).is_none()); + } + #[test] fn nfr3_a_row_that_crosses_a_milestone_stops_for_review() { let code = new_code(); diff --git a/rivet/platform/windows/src/row_watch.rs b/rivet/platform/windows/src/row_watch.rs index c960533..842f084 100644 --- a/rivet/platform/windows/src/row_watch.rs +++ b/rivet/platform/windows/src/row_watch.rs @@ -299,6 +299,18 @@ pub fn test_desktop_limits(browser: &str) -> Vec<(String, String)> { /// notes name each feature left undriven by the test desktop, and a listed feature that now /// passes, so the list is looked at again. pub fn publish_gate(results: &Value, browser: &str) -> Result, Vec> { + publish_gate_for_row(results, browser, &Value::Null) +} + +/// `publish_gate` for the row being published. A check of a feature the row turns off for its +/// build is not expected to pass: the row ships with that feature off, and a note names it. Every +/// other check must still pass. +pub fn publish_gate_for_row( + results: &Value, + browser: &str, + row: &Value, +) -> Result, Vec> { + let excused = crate::row_features::excused_checks(row); let rows: Vec<&Value> = match results { Value::Array(rows) => rows.iter().collect(), // ConvertTo-Json writes a single row as an object. @@ -326,6 +338,10 @@ pub fn publish_gate(results: &Value, browser: &str) -> Result, Vec reasons.push(format!("{feature}: not run")), @@ -531,6 +547,26 @@ mod tests { .collect() } + #[test] + fn nfr6_a_feature_off_in_the_row_does_not_hold_back_the_rest() { + let mut rows = all_pass("chrome"); + for row in rows.iter_mut().filter(|row| row.1.starts_with("split")) { + row.2 = "FAIL"; + } + // Without the row, the failed split checks keep the browser off the list. + assert!(publish_gate(&results(&rows), "chrome").is_err()); + let row = json!({"switched_off": [{"feature": "split view", "values": ["split.outline_member"]}]}); + let notes = publish_gate_for_row(&results(&rows), "chrome", &row).unwrap(); + assert!(notes + .iter() + .any(|note| note == "split-grid-4: split view is off in this build's row")); + // Another feature that fails still keeps it off. + let sidebar = rows.iter().position(|row| row.1 == "sidebar").unwrap(); + rows[sidebar].2 = "FAIL"; + let reasons = publish_gate_for_row(&results(&rows), "chrome", &row).unwrap_err(); + assert_eq!(reasons, ["sidebar: FAIL"]); + } + #[test] fn nfr3_a_browser_that_passed_every_feature_is_published() { assert!(publish_gate(&results(&all_pass("chrome")), "Chrome").is_ok()); From 0a3f69103b1a23eb2de0aa7365240ebd096df3a9 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Sun, 15 Nov 2026 04:31:47 +0900 Subject: [PATCH 3/4] Feat: Take a view's parent and children fields from its bounds offset ui/views/view.h declares parent_, then children_, and bounds_ 0x30 bytes after parent_. Every row that recorded the two fields by hand agrees, and the view walk in reflect.rs finds the same pair at run time. The runtime now takes them from the layout's bounds offset, and the row generator writes them from it instead of carrying them over. --- rivet/platform/windows/src/row_port.rs | 3 ++ rivet/platform/windows/src/row_recipe.rs | 54 +++++++++++++++++++ rivet/runtime/windows/src/builds/mod.rs | 4 +- rivet/runtime/windows/src/builds/tests.rs | 31 ++++++++++- rivet/runtime/windows/src/chromium/view.rs | 7 +++ .../windows/src/features/app_window.rs | 19 +++++-- 6 files changed, 112 insertions(+), 6 deletions(-) diff --git a/rivet/platform/windows/src/row_port.rs b/rivet/platform/windows/src/row_port.rs index d9e40a7..c458378 100644 --- a/rivet/platform/windows/src/row_port.rs +++ b/rivet/platform/windows/src/row_port.rs @@ -1012,6 +1012,9 @@ pub fn port_row( /// build. fn settle_carried(row: &mut Value, report: &mut PortReport) { use crate::row_features::{self, Clear, RowFeature}; + report + .derived + .extend(crate::row_recipe::follow(&mut row["build"])); if !report.must_check { return; } diff --git a/rivet/platform/windows/src/row_recipe.rs b/rivet/platform/windows/src/row_recipe.rs index 0faba0f..83630c9 100644 --- a/rivet/platform/windows/src/row_recipe.rs +++ b/rivet/platform/windows/src/row_recipe.rs @@ -415,6 +415,42 @@ pub fn derive_row(build: &mut Value, pe: &PeFile) -> Derived { derived } +/// Values that follow from another value of the row by the member order of a public Chromium +/// class, as (path, the value it follows, the distance). `ui/views/view.h` declares `parent_`, +/// then `children_`, then the members up to `bounds_`, 0x30 bytes after `parent_`. The runtime +/// takes them the same way, so they are written from the value they follow and never carried. +pub const FOLLOWS: &[(&str, &str, i64)] = &[ + ("app_window.view_parent", "layout.view_bounds_offset", -0x30), + ("app_window.view_children", "layout.view_bounds_offset", -0x28), +]; + +/// Writes each value of `FOLLOWS` the row has from the value it follows. +pub fn follow(build: &mut Value) -> Vec { + let mut read = Vec::new(); + for (path, from, by) in FOLLOWS { + let Some(base) = number(at_path(build, from)).filter(|base| *base >= 0x30) else { + continue; + }; + let (parent, key) = path.split_once('.').expect("a path has a parent"); + let Some(old) = number(&build[parent][key]) else { + continue; + }; + let value = (base as i64 + by) as u64; + let is_string = build[parent][key].is_string(); + build[parent][key] = if is_string { + Value::String(format!("{value:#x}")) + } else { + json!(value) + }; + read.push(if old == value { + format!("{path}: {value:#x}, from {from}") + } else { + format!("{path}: {old:#x} -> {value:#x}, from {from}") + }); + } + read +} + /// Values Rivet chooses rather than reads from a build, such as how long it waits before it opens /// a new tab. The row carries them for the runtime, so they are kept from the prior row. pub const SETTINGS: &[&str] = &["tabs.new_tab_delay_ms"]; @@ -494,6 +530,7 @@ pub fn without_recipe(build: &Value) -> Vec { && !FIELDS.iter().any(|field| field.path == path) && !SETTINGS.contains(&path.as_str()) && !crate::command_ids::ROW_PATHS.contains(&path.as_str()) + && !FOLLOWS.iter().any(|(follows, _, _)| follows == path) }); out } @@ -673,6 +710,23 @@ mod tests { ); } + #[test] + fn nfr6_a_views_parent_and_children_follow_its_bounds() { + let mut build = json!({ + "layout": {"view_bounds_offset": "0x1c0"}, + "app_window": {"view_parent": "0x198", "view_children": "0x1a0"}, + }); + assert_eq!(without_recipe(&build), vec!["layout.view_bounds_offset"]); + let read = follow(&mut build); + assert_eq!(build["app_window"]["view_parent"], "0x190"); + assert_eq!(build["app_window"]["view_children"], "0x198"); + assert_eq!(read.len(), 2, "{read:?}"); + // A row without the app window part gets none. + let mut bare = json!({"layout": {"view_bounds_offset": "0x1c8"}, "app_window": null}); + assert!(follow(&mut bare).is_empty()); + assert!(bare["app_window"].is_null()); + } + #[test] fn nfr6_rivet_settings_are_not_values_of_the_build() { let build = json!({ diff --git a/rivet/runtime/windows/src/builds/mod.rs b/rivet/runtime/windows/src/builds/mod.rs index 9ca0fd3..a96bcb5 100644 --- a/rivet/runtime/windows/src/builds/mod.rs +++ b/rivet/runtime/windows/src/builds/mod.rs @@ -139,7 +139,9 @@ pub struct AppWindow { pub detach_prologue: &'static [u8], pub insert: Option, pub insert_prologue: &'static [u8], - /// A `views::View` keeps its parent at this offset and its children vector right after it. + /// A `views::View` keeps its parent at this offset and its children vector right after it. Kept + /// for runtimes that read them from the row; this runtime takes both from the layout's bounds + /// offset, by the member order of `views::View`. pub view_parent: usize, pub view_children: usize, /// `operator new(size)`, `views::WebView::WebView(this, context)` and the object's size. diff --git a/rivet/runtime/windows/src/builds/tests.rs b/rivet/runtime/windows/src/builds/tests.rs index bfc4eac..e84ce43 100644 --- a/rivet/runtime/windows/src/builds/tests.rs +++ b/rivet/runtime/windows/src/builds/tests.rs @@ -916,8 +916,6 @@ fn fr13_every_build_that_shows_a_second_view_records_the_same_chromium_functions "size", "add_child", "set_contents", - "vparent", - "vchildren", "dtor_slot", ] { assert!( @@ -1637,3 +1635,32 @@ fn nfr6_a_table_row_carries_the_page_tools_and_bubble_anchor_of_its_prior_row() )) ); } + +/// The parent and children of a view follow from its bounds by the member order of `views::View`. +/// Every row that recorded them by hand agrees, so the rule replaces them. +#[test] +fn nfr6_a_views_parent_and_children_are_not_row_values() { + let mut seen = 0; + for build in compiled() { + let Some(row) = build.app_window.as_ref() else { + continue; + }; + assert_eq!( + crate::features::app_window::view_fields(build), + Some((row.view_parent, row.view_children)), + "{} {:?}", + build.browser, + build.version + ); + seen += 1; + } + assert!(seen >= 5, "{seen}"); + // A row the bounds offset of which moves gives the parent and children of that build. + let mut moved = crate::row_data::RowValue::to_row(&CHROME_157_38); + moved["layout"]["view_bounds_offset"] = serde_json::json!("0x1d0"); + let moved = ::from_row(&moved).unwrap(); + assert_eq!( + crate::features::app_window::view_fields(&moved), + Some((0x1A0, 0x1A8)) + ); +} diff --git a/rivet/runtime/windows/src/chromium/view.rs b/rivet/runtime/windows/src/chromium/view.rs index 3e3faa7..49621fd 100644 --- a/rivet/runtime/windows/src/chromium/view.rs +++ b/rivet/runtime/windows/src/chromium/view.rs @@ -24,6 +24,13 @@ impl View { (bounds_offset >= 0x30).then(|| bounds_offset - 0x30) } + /// Where a view keeps its children, from where it keeps its parent: `children_`, a + /// `std::vector` of views, comes right after `parent_` in `ui/views/view.h`. The view walk of + /// `reflect` finds the same pair at run time, each child naming the view 8 bytes before its list. + pub(crate) const fn children_offset(parent_offset: usize) -> usize { + parent_offset + 8 + } + pub(crate) const fn at(address: usize) -> Self { Self(address) } diff --git a/rivet/runtime/windows/src/features/app_window.rs b/rivet/runtime/windows/src/features/app_window.rs index 87dd96e..da9220d 100644 --- a/rivet/runtime/windows/src/features/app_window.rs +++ b/rivet/runtime/windows/src/features/app_window.rs @@ -12,7 +12,22 @@ use crate::builds::AppWindow; /// An address or value of the app window, as an RVA of the browser module where it is a function. pub(crate) fn recorded(name: &str) -> Option { - switched(name).or_else(|| checked_row().and_then(|row| row_value(row, name))) + switched(name).or_else(|| match name { + "vparent" | "vchildren" => { + checked_row()?; + let (parent, children) = view_fields(crate::builds::current()?)?; + Some(if name == "vparent" { parent } else { children }) + } + _ => checked_row().and_then(|row| row_value(row, name)), + }) +} + +/// Where a view of `build` keeps its parent and its children. They follow from where it keeps its +/// bounds by the member order of `views::View`, so they are not values of the build's row. +pub(crate) fn view_fields(build: &crate::builds::Build) -> Option<(usize, usize)> { + use crate::chromium::view::View; + let parent = View::parent_offset(build.layout.view_bounds_offset)?; + Some((parent, View::children_offset(parent))) } /// A value named in the test profile's `rivet-spike.txt`. @@ -121,8 +136,6 @@ pub(crate) fn row_value(row: &AppWindow, name: &str) -> Option { "kind" => Some(row.browser_type), "detach" => row.detach, "insert" => row.insert, - "vparent" => Some(row.view_parent), - "vchildren" => Some(row.view_children), "new" => Some(row.operator_new), "ctor" => Some(row.web_view_ctor), "size" => Some(row.web_view_size), From 990ba4ce6cd38cb55d82ad7b2a22adda22d3bac6 Mon Sep 17 00:00:00 2001 From: BREW <81044362+b-re-w@users.noreply.github.com> Date: Sun, 15 Nov 2026 04:32:27 +0900 Subject: [PATCH 4/4] Feat: Keep Rivet's toolbar lead and top inset adjustment as settings Both are DIPs Rivet chooses for its own layout, not values of the build, so a row keeps them from its prior row as settings instead of listing them as carried. --- rivet/platform/windows/src/row_recipe.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/rivet/platform/windows/src/row_recipe.rs b/rivet/platform/windows/src/row_recipe.rs index 83630c9..a65f945 100644 --- a/rivet/platform/windows/src/row_recipe.rs +++ b/rivet/platform/windows/src/row_recipe.rs @@ -452,8 +452,14 @@ pub fn follow(build: &mut Value) -> Vec { } /// Values Rivet chooses rather than reads from a build, such as how long it waits before it opens -/// a new tab. The row carries them for the runtime, so they are kept from the prior row. -pub const SETTINGS: &[&str] = &["tabs.new_tab_delay_ms"]; +/// a new tab, how far its toolbar starts after the browser view's edge to leave room for Rivet's +/// toggle button, and the DIPs it adds to the top inset it reports. The row carries them for the +/// runtime, so they are kept from the prior row. +pub const SETTINGS: &[&str] = &[ + "tabs.new_tab_delay_ms", + "vertical.toolbar_leading", + "layout.top_inset_adjust", +]; /// Lists of `[id, colour]` pairs: the id is a value of the build, and the colour is Rivet's choice. pub const ID_COLOUR_PAIRS: &[&str] = &["toolbar.dev.colours"]; @@ -741,6 +747,15 @@ mod tests { "toolbar.dev.colours[1][0]" ] ); + let chosen = json!({ + "vertical": {"toolbar_leading": 26, "toolbar_in_view": "0x60"}, + "layout": {"top_inset_adjust": 0}, + }); + assert_eq!(without_recipe(&chosen), vec!["vertical.toolbar_in_view"]); + assert_eq!( + settings(&chosen), + vec!["vertical.toolbar_leading", "layout.top_inset_adjust"] + ); assert_eq!( settings(&build), vec![