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.
This commit is contained in:
Patrick Walton 2016-03-15 16:18:00 -07:00
parent acfd8e448c
commit 7cb9429a0f

View file

@ -30,7 +30,8 @@ use gfx::font_context;
use gfx::paint_thread::LayoutToPaintMsg; use gfx::paint_thread::LayoutToPaintMsg;
use gfx_traits::{color, Epoch, LayerId, ScrollPolicy}; use gfx_traits::{color, Epoch, LayerId, ScrollPolicy};
use heapsize::HeapSizeOf; 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::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use layout_debug; use layout_debug;
@ -1331,26 +1332,28 @@ impl LayoutThread {
// Perform the primary layout passes over the flow tree to compute the locations of all // Perform the primary layout passes over the flow tree to compute the locations of all
// the boxes. // the boxes.
profile(time::ProfilerCategory::LayoutMain, if flow::base(&*root_flow).restyle_damage.intersects(REFLOW | REFLOW_OUT_OF_FLOW) {
self.profiler_metadata(), profile(time::ProfilerCategory::LayoutMain,
self.time_profiler_chan.clone(), self.profiler_metadata(),
|| { self.time_profiler_chan.clone(),
let profiler_metadata = self.profiler_metadata(); || {
match self.parallel_traversal { let profiler_metadata = self.profiler_metadata();
None => { match self.parallel_traversal {
// Sequential mode. None => {
LayoutThread::solve_constraints(&mut root_flow, &layout_context) // 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);
}
} }
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, profile(time::ProfilerCategory::LayoutStoreOverflow,
self.profiler_metadata(), self.profiler_metadata(),