layout: Implement basic style sharing.

No improvement on the rainbow page, but necessary for some other
optimizations we want to do.
This commit is contained in:
Patrick Walton 2014-02-07 15:15:56 -08:00
parent cf8203848a
commit 1678cc9a88
16 changed files with 502 additions and 274 deletions

View file

@ -55,7 +55,8 @@ use std::comm::Port;
use std::ptr;
use std::task;
use std::util;
use style::{AuthorOrigin, Stylesheet, Stylist};
use style::{AuthorOrigin, ComputedValues, Stylesheet, Stylist};
use style;
/// Information needed by the layout task.
pub struct LayoutTask {
@ -97,6 +98,9 @@ pub struct LayoutTask {
stylist: ~Stylist,
/// The initial set of CSS values.
initial_css_values: Arc<ComputedValues>,
/// The workers that we use for parallel operation.
parallel_traversal: Option<WorkQueue<*mut LayoutContext,UnsafeFlow>>,
@ -302,6 +306,7 @@ impl LayoutTask {
display_list_collection: None,
stylist: ~new_stylist(),
initial_css_values: Arc::new(style::initial_values()),
parallel_traversal: parallel_traversal,
profiler_chan: profiler_chan,
opts: opts.clone()
@ -332,6 +337,7 @@ impl LayoutTask {
layout_chan: self.chan.clone(),
font_context_info: font_context_info,
stylist: &*self.stylist,
initial_css_values: self.initial_css_values.clone(),
reflow_root: OpaqueNode::from_layout_node(reflow_root),
}
}
@ -565,6 +571,7 @@ impl LayoutTask {
node.match_and_cascade_subtree(self.stylist,
&layout_ctx.layout_chan,
&mut applicable_declarations,
layout_ctx.initial_css_values.get(),
None)
}
Some(ref mut traversal) => {
@ -638,6 +645,7 @@ impl LayoutTask {
.resolve_color(thread_safe_child.style()
.get()
.Background
.get()
.background_color)
.to_gfx_color()
};