Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

perf(layout): keep hit results free of unused box models

ldm0636d97e21c68
diff --git a/moli-layout/src/layout_tree/hit_test.rs b/moli-layout/src/layout_tree/hit_test.rs
index 62778c3c7..4918612b9 100644
--- a/moli-layout/src/layout_tree/hit_test.rs
+++ b/moli-layout/src/layout_tree/hit_test.rs
@@ -56,8 +56,8 @@ pub struct LayoutHit<N> {
/// The exact physical content box in the hit fragment's own coordinate
/// space.
///
- /// Unlike `box_model`, this rectangle has not been projected through CSS
- /// transforms. Embedded-content consumers use it to enter the child frame
+ /// This rectangle has not been projected through CSS transforms.
+ /// Embedded-content consumers use it to enter the child frame
/// without reconstructing the iframe's used size from authored CSS.
pub local_content_box: Option<LayoutRect>,
/// Converts a point from this tree's viewport into the hit fragment's
@@ -65,11 +65,6 @@ pub struct LayoutHit<N> {
/// frame and native-scrollbar routing can compose the same inverse
/// transforms that produced `local_point`.
pub viewport_to_local: LayoutTransform2D,
- /// Box geometry copied from the same frozen tree when the hit source owns a
- /// CSS box. Consumers use it for source-dependent follow-up work such as
- /// descending through a transformed child-frame content box without
- /// forcing a second parent-document pass.
- pub box_model: Option<LayoutBoxModel>,
}
/// Caret geometry resolved from the same text fragments and coordinate spaces
@@ -473,7 +468,6 @@ where
is_text: entry.is_text,
local_content_box,
viewport_to_local: inverse,
- box_model: self.box_model_for_source(entry.source),
})
}
}
diff --git a/moli-layout/tests/phase5_output_contract.rs b/moli-layout/tests/phase5_output_contract.rs
index 271f032e4..1fcc438b0 100644
--- a/moli-layout/tests/phase5_output_contract.rs
+++ b/moli-layout/tests/phase5_output_contract.rs
@@ -2935,9 +2935,11 @@ fn transformed_hit_retains_exact_local_content_box_and_inverse_mapping() {
.local_content_box
.expect("box hit should retain its unprojected content box");
assert_rect(local_content, LayoutRect::new(7.0, 7.0, 100.0, 60.0));
- let projected_content = hit
- .box_model
- .expect("box hit should retain its projected protocol model")
+ // Full CSSOM geometry is an explicit query, not part of every hit. It
+ // still comes from the same tree without another layout pass.
+ let projected_content = output
+ .box_model_for_source(hit.source)
+ .expect("the hit source should have a projected protocol model")
.content
.bounding_rect();
assert_close(projected_content.width, 50.0);
diff --git a/moli-renderer-v8/src/native_bridge/element/geometry/mock/queries.rs b/moli-renderer-v8/src/native_bridge/element/geometry/mock/queries.rs
index 47de6e914..599c75ad2 100644
--- a/moli-renderer-v8/src/native_bridge/element/geometry/mock/queries.rs
+++ b/moli-renderer-v8/src/native_bridge/element/geometry/mock/queries.rs
@@ -93,7 +93,6 @@ pub(crate) fn answer_queries(
is_text: false,
local_content_box: None,
viewport_to_local: moli_layout::LayoutTransform2D::IDENTITY,
- box_model: mock_box_model(runtime, source),
}),
),
LayoutQuery::HitTestAll {
@@ -110,7 +109,6 @@ pub(crate) fn answer_queries(
is_text: false,
local_content_box: None,
viewport_to_local: moli_layout::LayoutTransform2D::IDENTITY,
- box_model: mock_box_model(runtime, source),
}]
})
.unwrap_or_default(),