aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/main/layout/context.rs4
-rw-r--r--src/components/main/layout/layout_task.rs12
-rw-r--r--src/components/main/layout/parallel.rs7
3 files changed, 19 insertions, 4 deletions
diff --git a/src/components/main/layout/context.rs b/src/components/main/layout/context.rs
index 801b474c824..9a405dad147 100644
--- a/src/components/main/layout/context.rs
+++ b/src/components/main/layout/context.rs
@@ -17,6 +17,7 @@ use std::rt::task::Task;
use geom::size::Size2D;
use gfx::font_context::{FontContext, FontContextInfo};
+use script::layout_interface::LayoutChan;
use servo_msg::constellation_msg::ConstellationChan;
use servo_net::local_image_cache::LocalImageCache;
use servo_util::geometry::Au;
@@ -40,6 +41,9 @@ pub struct LayoutContext {
/// The set of leaf DOM nodes.
dom_leaf_set: MutexArc<DomLeafSet>,
+ /// A channel up to the layout task.
+ layout_chan: LayoutChan,
+
/// The set of leaf flows.
flow_leaf_set: MutexArc<FlowLeafSet>,
diff --git a/src/components/main/layout/layout_task.rs b/src/components/main/layout/layout_task.rs
index c8b9c435f14..28a19b657be 100644
--- a/src/components/main/layout/layout_task.rs
+++ b/src/components/main/layout/layout_task.rs
@@ -324,6 +324,7 @@ impl LayoutTask {
constellation_chan: self.constellation_chan.clone(),
dom_leaf_set: self.dom_leaf_set.clone(),
flow_leaf_set: self.flow_leaf_set.clone(),
+ layout_chan: self.chan.clone(),
font_context_info: font_context_info,
stylist: &*self.stylist,
reflow_root: OpaqueNode::from_layout_node(reflow_root),
@@ -549,10 +550,13 @@ impl LayoutTask {
|| {
// Initialize layout data for each node.
//
- // FIXME: This is inefficient. We don't need an entire traversal to do this!
- profile(time::LayoutAuxInitCategory, self.profiler_chan.clone(), || {
- node.initialize_style_for_subtree(self.chan.clone());
- });
+ // FIXME(pcwalton): This is inefficient. We don't need an entire traversal to do this
+ // in sequential mode!
+ if self.parallel_traversal.is_none() {
+ profile(time::LayoutAuxInitCategory, self.profiler_chan.clone(), || {
+ node.initialize_style_for_subtree(self.chan.clone());
+ });
+ }
// Perform CSS selector matching if necessary.
match data.damage.level {
diff --git a/src/components/main/layout/parallel.rs b/src/components/main/layout/parallel.rs
index 859a3839333..a64abdc9a5c 100644
--- a/src/components/main/layout/parallel.rs
+++ b/src/components/main/layout/parallel.rs
@@ -8,6 +8,7 @@
use css::matching::MatchMethods;
use layout::context::LayoutContext;
+use layout::extra::LayoutAuxMethods;
use layout::flow::{Flow, FlowLeafSet, PostorderFlowTraversal};
use layout::flow;
use layout::layout_task::{AssignHeightsAndStoreOverflowTraversal, BubbleWidthsTraversal};
@@ -130,6 +131,12 @@ fn match_and_cascade_node(unsafe_layout_node: UnsafeLayoutNode,
// Get a real layout node.
let node: LayoutNode = cast::transmute(unsafe_layout_node);
+ // Initialize layout data.
+ //
+ // FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
+ // parser.
+ node.initialize_layout_data(layout_context.layout_chan.clone());
+
if node.is_element() {
// Perform the CSS selector matching.
let stylist: &Stylist = cast::transmute(layout_context.stylist);