From ed6ee299517968e532a1ff2883936db48787de5b Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 15 Mar 2016 16:18:33 -0700 Subject: [PATCH] script: Don't paint layouts induced by hit test queries. Reduces CPU usage when mousing over simple pages. Part of #9999. --- components/script/dom/window.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index df7d1f92de7..9ee7fd81160 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -1021,7 +1021,11 @@ impl Window { debug!("script: layout joined"); - self.pending_reflow_count.set(0); + // Pending reflows require display, so only reset the pending reflow count if this reflow + // was to be displayed. + if goal == ReflowGoal::ForDisplay { + self.pending_reflow_count.set(0); + } if let Some(marker) = marker { self.emit_timeline_marker(marker.end()); @@ -1104,7 +1108,7 @@ impl Window { pub fn hit_test_query(&self, hit_test_request: Point2D, update_cursor: bool) -> Option { - self.reflow(ReflowGoal::ForDisplay, + self.reflow(ReflowGoal::ForScriptQuery, ReflowQueryType::HitTestQuery(hit_test_request, update_cursor), ReflowReason::Query); self.layout_rpc.hit_test().node_address