layout: Aggressively try to share styles with the last few nodes seen.

This roughly implements the same cache found in Blink. 50% improvement
on the rainbow page, but at the cost of reducing parallel gains down to
nothing. I added a new page, `perf-rainbow-hard.html`, which disables
the optimizations in both Blink and Servo.
This commit is contained in:
Patrick Walton 2014-02-08 09:14:25 -08:00
parent 0b894113e9
commit d3e56fa9cc
8 changed files with 17838 additions and 103 deletions

View file

@ -6,6 +6,7 @@
/// rendered.
use css::matching::{ApplicableDeclarations, ApplicableDeclarationsCache, MatchMethods};
use css::matching::{StyleSharingCandidateCache};
use css::select::new_stylist;
use css::node_style::StyledNode;
use layout::construct::{FlowConstructionResult, FlowConstructor, NoConstructionResult};
@ -570,11 +571,14 @@ impl LayoutTask {
let mut applicable_declarations = ApplicableDeclarations::new();
let mut applicable_declarations_cache =
ApplicableDeclarationsCache::new();
let mut style_sharing_candidate_cache =
StyleSharingCandidateCache::new();
node.match_and_cascade_subtree(self.stylist,
&layout_ctx.layout_chan,
&mut applicable_declarations,
layout_ctx.initial_css_values.get(),
&mut applicable_declarations_cache,
&mut style_sharing_candidate_cache,
None)
}
Some(ref mut traversal) => {