diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2016-03-15 16:18:00 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2016-03-21 08:39:45 -0700 |
commit | 7cb9429a0f7eb6f3dc9a5b6d3306bea7536fa44a (patch) | |
tree | 0ecc4323519ae7b1847b3cb72aed3692e1bc9bc7 /components/layout/layout_thread.rs | |
parent | acfd8e448cb01a8765de73c2a4fd43cbadda6310 (diff) | |
download | servo-7cb9429a0f7eb6f3dc9a5b6d3306bea7536fa44a.tar.gz servo-7cb9429a0f7eb6f3dc9a5b6d3306bea7536fa44a.zip |
layout: Don't start the reflow pass unless some node needs to be
reflowed.
Reduces CPU usage when mousing over simple pages.
Part of #9999.
Diffstat (limited to 'components/layout/layout_thread.rs')
-rw-r--r-- | components/layout/layout_thread.rs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/components/layout/layout_thread.rs b/components/layout/layout_thread.rs index 26c14af3b80..f473979c72d 100644 --- a/components/layout/layout_thread.rs +++ b/components/layout/layout_thread.rs @@ -30,7 +30,8 @@ use gfx::font_context; use gfx::paint_thread::LayoutToPaintMsg; use gfx_traits::{color, Epoch, LayerId, ScrollPolicy}; use heapsize::HeapSizeOf; -use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT}; +use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REFLOW_OUT_OF_FLOW}; +use incremental::{REPAINT}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layout_debug; @@ -1331,26 +1332,28 @@ impl LayoutThread { // Perform the primary layout passes over the flow tree to compute the locations of all // the boxes. - profile(time::ProfilerCategory::LayoutMain, - self.profiler_metadata(), - self.time_profiler_chan.clone(), - || { - let profiler_metadata = self.profiler_metadata(); - match self.parallel_traversal { - None => { - // Sequential mode. - LayoutThread::solve_constraints(&mut root_flow, &layout_context) - } - Some(ref mut parallel) => { - // Parallel mode. - LayoutThread::solve_constraints_parallel(parallel, - &mut root_flow, - profiler_metadata, - self.time_profiler_chan.clone(), - &*layout_context); + if flow::base(&*root_flow).restyle_damage.intersects(REFLOW | REFLOW_OUT_OF_FLOW) { + profile(time::ProfilerCategory::LayoutMain, + self.profiler_metadata(), + self.time_profiler_chan.clone(), + || { + let profiler_metadata = self.profiler_metadata(); + match self.parallel_traversal { + None => { + // Sequential mode. + LayoutThread::solve_constraints(&mut root_flow, &layout_context) + } + Some(ref mut parallel) => { + // Parallel mode. + LayoutThread::solve_constraints_parallel(parallel, + &mut root_flow, + profiler_metadata, + self.time_profiler_chan.clone(), + &*layout_context); + } } - } - }); + }); + } profile(time::ProfilerCategory::LayoutStoreOverflow, self.profiler_metadata(), |