Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
docs(layout): explain scrollbar corrective relayout
ldm090a036d2b894
diff --git a/moli-layout/src/pass.rs b/moli-layout/src/pass.rsindex 2c6292558..ebeb6fb0a 100644--- a/moli-layout/src/pass.rs+++ b/moli-layout/src/pass.rs@@ -304,10 +304,21 @@ where)}-/// Resolves `overflow:auto` with the same monotonic feedback loop used by-/// classic browser scrollbars: lay out without an automatic gutter, reveal-/// every axis that overflows, then repeat because one gutter can make the-/// perpendicular axis overflow. Each axis changes at most once.+/// Resolves `overflow:auto` with a monotonic browser-style feedback loop.+///+/// The first iteration lays out without an automatic gutter. If overflow+/// reveals a scrollbar, its gutter changes the available space and the+/// affected box must be laid out again; that gutter can in turn reveal the+/// perpendicular scrollbar. An axis is only ever revealed, never hidden, so+/// each box/axis changes at most once and the loop converges.+///+/// Every iteration enters Taffy through the synthetic viewport root, but that+/// is a scheduling entry point rather than an unconditional full-tree layout.+/// `invalidate_scrollbar_feedback` clears only changed boxes and their numeric+/// ancestors. All other subtrees keep valid Taffy cache entries and return+/// immediately. This is the same important boundary as Blink's corrective+/// scrollbar relayout: pay a follow-up pass only after state changes, and only+/// recompute the paths whose available space can have changed.#[derive(Default)]struct NumericLayoutMetrics {pass_count: usize,@@ -413,6 +424,10 @@ where}let changed = viewport_changed || !changed_boxes.is_empty();if changed {+ // Do not clear the whole Taffy tree here. Although the next call to+ // `compute_prepared_world_layout` starts at the root, untouched+ // branches remain cache hits; only these boxes and their ancestor+ // paths participate in the corrective numeric layout.metrics.feedback_invalidated_node_count =metrics.feedback_invalidated_node_count.saturating_add(prepared.invalidate_scrollbar_feedback(world, &changed_boxes, viewport_changed),diff --git a/moli-layout/src/taffy_tree.rs b/moli-layout/src/taffy_tree.rsindex 07ecc41e3..e7a891dfa 100644--- a/moli-layout/src/taffy_tree.rs+++ b/moli-layout/src/taffy_tree.rs@@ -73,6 +73,12 @@ impl PreparedWorldLayout {/// Clears only the cache entries on changed scrollbar boxes and their/// numeric ancestors. The reusable mark table makes this proportional to/// the affected paths rather than to every box in the document.+ ///+ /// Taffy's next compute still starts at the viewport root, as its public+ /// API requires, but siblings outside these paths retain their cached+ /// `LayoutOutput`. Thus a second scrollbar-feedback iteration is a local+ /// corrective relayout in cost and invalidation scope, not a second full+ /// document layout.pub(crate) fn invalidate_scrollbar_feedback<N>(&mut self,world: &mut LayoutWorld<N>,