Incremental Style Recalc

This patch puts in the initial framework for incremental reflow. Nodes' styles
are no longer recalculated unless the node has changed.

I've been hacking on the general problem of incremental reflow for the past
couple weeks, and I've yet to get a full implementation that actually passes all
the reftests + wikipedia + cnn. Therefore, I'm going to try to land the different
parts of it one by one.

This patch only does incremental style recalc, without incremental flow
construction, inline-size bubbling, reflow, or display lists. Those will be coming
in that order as I finish them.

At least with this strategy, I can land a working version of incremental reflow,
even if not yet complete.

r? @pcwalton
This commit is contained in:
Clark Gaebel 2014-10-06 11:40:05 -04:00
parent 510f8a817f
commit d12c6e7383
31 changed files with 641 additions and 424 deletions

View file

@ -18,7 +18,7 @@ use dom::location::Location;
use dom::navigator::Navigator;
use dom::performance::Performance;
use dom::screen::Screen;
use layout_interface::{ReflowGoal, DocumentDamageLevel};
use layout_interface::{ReflowGoal, ReflowForDisplay};
use page::Page;
use script_task::{ExitWindowMsg, FireTimerMsg, ScriptChan, TriggerLoadMsg, TriggerFragmentMsg};
use script_traits::ScriptControlChan;
@ -366,7 +366,7 @@ impl Reflectable for Window {
}
pub trait WindowHelpers {
fn damage_and_reflow(self, damage: DocumentDamageLevel);
fn reflow(self);
fn flush_layout(self, goal: ReflowGoal);
fn wait_until_safe_to_modify_dom(self);
fn init_browser_context(self, doc: JSRef<Document>);
@ -399,9 +399,12 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
})
}
fn damage_and_reflow(self, damage: DocumentDamageLevel) {
self.page().damage(damage);
self.page().avoided_reflows.set(self.page().avoided_reflows.get() + 1);
fn reflow(self) {
self.page().damage();
// FIXME This should probably be ReflowForQuery, not Display. All queries currently
// currently rely on the display list, which means we can't destroy it by
// doing a query reflow.
self.page().reflow(ReflowForDisplay, self.control_chan.clone(), &*self.compositor);
}
fn flush_layout(self, goal: ReflowGoal) {