Skip to content

The design language that makes your AI harness better at design.

JavaScript

Read the stored box before walking the tree in the spill collision scan

Paul Bakaus6d38d0dc7d3f
diff --git a/crates/core/src/browser/element_checks.rs b/crates/core/src/browser/element_checks.rs
index 5181aa2f3..4020cfa04 100644
--- a/crates/core/src/browser/element_checks.rs
+++ b/crates/core/src/browser/element_checks.rs
@@ -2962,9 +2962,8 @@ fn spill_meets_another_box(
regions.push((reach.0 - tolerance, box_.0));
}
for other in dom.query_all(None, "*").unwrap_or_default() {
- if other == el || dom.contains(other, el) || dom.contains(el, other) {
- continue;
- }
+ // The stored box first: most of the page shares no line with `el`,
+ // and the tree walks below cost more than reading a rect.
let r = dom.rect(other);
if !(r.all_finite() && r.width > 0.0 && r.height > 0.0) {
continue;
@@ -2973,6 +2972,9 @@ fn spill_meets_another_box(
if js::math_min(r.bottom, own.bottom) - js::math_max(r.top, own.top) <= 1.0 {
continue;
}
+ if other == el || dom.contains(other, el) || dom.contains(el, other) {
+ continue;
+ }
let holds_el = r.left <= own.left + 1.0
&& r.right >= own.right - 1.0
&& r.top <= own.top + 1.0