aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout/construct.rs128
-rw-r--r--components/layout/css/matching.rs1
-rw-r--r--components/layout/extra.rs44
-rw-r--r--components/layout/flow.rs26
-rw-r--r--components/layout/layout_task.rs12
-rw-r--r--components/layout/lib.rs1
-rw-r--r--components/layout/parallel.rs4
-rw-r--r--components/layout/wrapper.rs30
8 files changed, 117 insertions, 129 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs
index a76034c02de..f730a08bf85 100644
--- a/components/layout/construct.rs
+++ b/components/layout/construct.rs
@@ -73,7 +73,7 @@ pub enum ConstructionResult {
/// This node contributed a flow at the proper position in the tree.
/// Nothing more needs to be done for this node. It has bubbled up fixed
- /// and absolute descendant flows that have a CB above it.
+ /// and absolute descendant flows that have a containing block above it.
FlowConstructionResult(FlowRef, AbsDescendants),
/// This node contributed some object or objects that will be needed to construct a proper flow
@@ -82,8 +82,8 @@ pub enum ConstructionResult {
}
/// Represents the output of flow construction for a DOM node that has not yet resulted in a
-/// complete flow. Construction items bubble up the tree until they find a `Flow` to be
-/// attached to.
+/// complete flow. Construction items bubble up the tree until they find a `Flow` to be attached
+/// to.
pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragmentsConstructionItem(InlineFragmentsConstructionResult),
@@ -244,30 +244,36 @@ impl<'a> FlowConstructor<'a> {
}
}
- /// Creates an inline flow from a set of inline fragments, then adds it as a child of the given flow
- /// or pushes it onto the given flow list.
+ /// Creates an inline flow from a set of inline fragments, then adds it as a child of the given
+ /// flow or pushes it onto the given flow list.
///
/// `#[inline(always)]` because this is performance critical and LLVM will not inline it
/// otherwise.
#[inline(always)]
fn flush_inline_fragments_to_flow_or_list(&mut self,
- fragment_accumulator: InlineFragmentsAccumulator,
- flow: &mut FlowRef,
- flow_list: &mut Vec<FlowRef>,
- whitespace_stripping: WhitespaceStrippingMode,
- node: &ThreadSafeLayoutNode) {
+ fragment_accumulator: InlineFragmentsAccumulator,
+ flow: &mut FlowRef,
+ flow_list: &mut Vec<FlowRef>,
+ whitespace_stripping: WhitespaceStrippingMode,
+ node: &ThreadSafeLayoutNode) {
let mut fragments = fragment_accumulator.finish();
- if fragments.is_empty() { return };
+ if fragments.is_empty() {
+ return
+ };
match whitespace_stripping {
NoWhitespaceStripping => {}
StripWhitespaceFromStart => {
fragments.strip_ignorable_whitespace_from_start();
- if fragments.is_empty() { return };
+ if fragments.is_empty() {
+ return
+ };
}
StripWhitespaceFromEnd => {
fragments.strip_ignorable_whitespace_from_end();
- if fragments.is_empty() { return };
+ if fragments.is_empty() {
+ return
+ };
}
}
@@ -306,7 +312,7 @@ impl<'a> FlowConstructor<'a> {
}
}
- fn build_block_flow_using_children_construction_result(&mut self,
+ fn build_block_flow_using_construction_result_of_child(&mut self,
flow: &mut FlowRef,
consecutive_siblings: &mut Vec<FlowRef>,
node: &ThreadSafeLayoutNode,
@@ -321,9 +327,8 @@ impl<'a> FlowConstructor<'a> {
// If kid_flow is TableCaptionFlow, kid_flow should be added under
// TableWrapperFlow.
if flow.get().is_table() && kid_flow.get().is_table_caption() {
- kid.set_flow_construction_result(FlowConstructionResult(
- kid_flow,
- Descendants::new()))
+ kid.set_flow_construction_result(FlowConstructionResult(kid_flow,
+ Descendants::new()))
} else if flow.get().need_anonymous_flow(kid_flow.get()) {
consecutive_siblings.push(kid_flow)
} else {
@@ -419,8 +424,8 @@ impl<'a> FlowConstructor<'a> {
/// this block flow.
/// Also, deal with the absolute and fixed descendants bubbled up by
/// children nodes.
- fn build_flow_using_children(&mut self, mut flow: FlowRef, node: &ThreadSafeLayoutNode)
- -> ConstructionResult {
+ fn build_flow_for_block(&mut self, mut flow: FlowRef, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
// Gather up fragments for the inline flows we might need to create.
let mut inline_fragment_accumulator = InlineFragmentsAccumulator::new();
let mut consecutive_siblings = vec!();
@@ -433,22 +438,23 @@ impl<'a> FlowConstructor<'a> {
self.process(&kid);
}
- self.build_block_flow_using_children_construction_result(&mut flow,
- &mut consecutive_siblings,
- node,
- kid,
- &mut inline_fragment_accumulator,
- &mut abs_descendants,
- &mut first_fragment);
+ self.build_block_flow_using_construction_result_of_child(
+ &mut flow,
+ &mut consecutive_siblings,
+ node,
+ kid,
+ &mut inline_fragment_accumulator,
+ &mut abs_descendants,
+ &mut first_fragment);
}
// Perform a final flush of any inline fragments that we were gathering up to handle {ib}
// splits, after stripping ignorable whitespace.
self.flush_inline_fragments_to_flow_or_list(inline_fragment_accumulator,
- &mut flow,
- &mut consecutive_siblings,
- StripWhitespaceFromEnd,
- node);
+ &mut flow,
+ &mut consecutive_siblings,
+ StripWhitespaceFromEnd,
+ node);
if !consecutive_siblings.is_empty() {
self.generate_anonymous_missing_child(consecutive_siblings, &mut flow, node);
}
@@ -460,7 +466,7 @@ impl<'a> FlowConstructor<'a> {
let is_absolutely_positioned = flow.get_mut().as_block().is_absolutely_positioned();
if is_positioned {
// This is the CB for all the absolute descendants.
- flow.set_abs_descendants(abs_descendants);
+ flow.set_absolute_descendants(abs_descendants);
abs_descendants = Descendants::new();
@@ -476,9 +482,10 @@ impl<'a> FlowConstructor<'a> {
/// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly
/// other `BlockFlow`s or `InlineFlow`s underneath it, depending on whether {ib} splits needed
/// to happen.
- fn build_flow_for_block(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
+ fn build_flow_for_nonfloated_block(&mut self, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
let flow = box BlockFlow::from_node(self, node) as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Builds the flow for a node with `float: {left|right}`. This yields a float `BlockFlow` with
@@ -486,12 +493,13 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_floated_block(&mut self, node: &ThreadSafeLayoutNode, float_kind: FloatKind)
-> ConstructionResult {
let flow = box BlockFlow::float_from_node(self, node, float_kind) as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Concatenates the fragments of kids, adding in our own borders/padding/margins if necessary.
/// Returns the `InlineFragmentsConstructionResult`, if any. There will be no
- /// `InlineFragmentsConstructionResult` if this node consisted entirely of ignorable whitespace.
+ /// `InlineFragmentsConstructionResult` if this node consisted entirely of ignorable
+ /// whitespace.
fn build_fragments_for_nonreplaced_inline_content(&mut self, node: &ThreadSafeLayoutNode)
-> ConstructionResult {
let mut opt_inline_block_splits: Vec<InlineBlockSplit> = Vec::new();
@@ -510,8 +518,9 @@ impl<'a> FlowConstructor<'a> {
// accumulator to hold any subsequent fragments we come across.
let split = InlineBlockSplit {
predecessors:
- mem::replace(&mut fragment_accumulator,
- InlineFragmentsAccumulator::from_inline_node(node)).finish(),
+ mem::replace(
+ &mut fragment_accumulator,
+ InlineFragmentsAccumulator::from_inline_node(node)).finish(),
flow: flow,
};
opt_inline_block_splits.push(split);
@@ -566,7 +575,8 @@ impl<'a> FlowConstructor<'a> {
// Finally, make a new construction result.
if opt_inline_block_splits.len() > 0 || fragment_accumulator.fragments.len() > 0
|| abs_descendants.len() > 0 {
- let construction_item = InlineFragmentsConstructionItem(InlineFragmentsConstructionResult {
+ let construction_item = InlineFragmentsConstructionItem(
+ InlineFragmentsConstructionResult {
splits: opt_inline_block_splits,
fragments: fragment_accumulator.finish(),
abs_descendants: abs_descendants,
@@ -606,8 +616,9 @@ impl<'a> FlowConstructor<'a> {
ConstructionItemConstructionResult(construction_item)
}
- fn build_fragment_for_inline_block(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
- let block_flow_result = self.build_flow_for_block(node);
+ fn build_fragment_for_inline_block(&mut self, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
+ let block_flow_result = self.build_flow_for_nonfloated_block(node);
let (block_flow, abs_descendants) = match block_flow_result {
FlowConstructionResult(block_flow, abs_descendants) => (block_flow, abs_descendants),
_ => unreachable!()
@@ -701,7 +712,7 @@ impl<'a> FlowConstructor<'a> {
// We first populate the TableFlow with other flows than TableCaptionFlow.
// We then populate the TableWrapperFlow with TableCaptionFlow, and attach
// the TableFlow to the TableWrapperFlow
- let construction_result = self.build_flow_using_children(table_flow, node);
+ let construction_result = self.build_flow_for_block(table_flow, node);
self.place_table_caption_under_table_wrapper(&mut wrapper_flow, node);
let mut abs_descendants = Descendants::new();
@@ -725,8 +736,8 @@ impl<'a> FlowConstructor<'a> {
.as_block()
.is_absolutely_positioned();
if is_positioned {
- // This is the CB for all the absolute descendants.
- wrapper_flow.set_abs_descendants(abs_descendants);
+ // This is the containing block for all the absolute descendants.
+ wrapper_flow.set_absolute_descendants(abs_descendants);
abs_descendants = Descendants::new();
@@ -735,7 +746,7 @@ impl<'a> FlowConstructor<'a> {
fixed_descendants.push(wrapper_flow.clone());
} else if is_absolutely_positioned {
// This is now the only absolute flow in the subtree which hasn't yet
- // reached its CB.
+ // reached its containing block.
abs_descendants.push(wrapper_flow.clone());
}
}
@@ -759,16 +770,17 @@ impl<'a> FlowConstructor<'a> {
/// with possibly other `BlockFlow`s or `InlineFlow`s underneath it.
fn build_flow_for_table_caption(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let flow = box TableCaptionFlow::from_node(self, node) as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Builds a flow for a node with `display: table-row-group`. This yields a `TableRowGroupFlow`
/// with possibly other `TableRowFlow`s underneath it.
- fn build_flow_for_table_rowgroup(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
+ fn build_flow_for_table_rowgroup(&mut self, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
let fragment = Fragment::new_from_specific_info(node, TableRowFragment);
let flow = box TableRowGroupFlow::from_node_and_fragment(node, fragment);
let flow = flow as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Builds a flow for a node with `display: table-row`. This yields a `TableRowFlow` with
@@ -776,7 +788,7 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_row(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let fragment = Fragment::new_from_specific_info(node, TableRowFragment);
let flow = box TableRowFlow::from_node_and_fragment(node, fragment) as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Builds a flow for a node with `display: table-cell`. This yields a `TableCellFlow` with
@@ -784,11 +796,12 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_cell(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
let fragment = Fragment::new_from_specific_info(node, TableCellFragment);
let flow = box TableCellFlow::from_node_and_fragment(node, fragment) as Box<Flow>;
- self.build_flow_using_children(FlowRef::new(flow), node)
+ self.build_flow_for_block(FlowRef::new(flow), node)
}
/// Creates a fragment for a node with `display: table-column`.
- fn build_fragments_for_table_column(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
+ fn build_fragments_for_table_column(&mut self, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
// CSS 2.1 § 17.2.1. Treat all child fragments of a `table-column` as `display: none`.
for kid in node.children() {
kid.set_flow_construction_result(NoConstructionResult)
@@ -803,15 +816,18 @@ impl<'a> FlowConstructor<'a> {
/// Builds a flow for a node with `display: table-column-group`.
/// This yields a `TableColGroupFlow`.
- fn build_flow_for_table_colgroup(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
- let fragment = Fragment::new_from_specific_info(node,
- TableColumnFragment(TableColumnFragmentInfo::new(node)));
+ fn build_flow_for_table_colgroup(&mut self, node: &ThreadSafeLayoutNode)
+ -> ConstructionResult {
+ let fragment = Fragment::new_from_specific_info(
+ node,
+ TableColumnFragment(TableColumnFragmentInfo::new(node)));
let mut col_fragments = vec!();
for kid in node.children() {
// CSS 2.1 § 17.2.1. Treat all non-column child fragments of `table-column-group`
// as `display: none`.
match kid.swap_out_construction_result() {
- ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(fragment)) => {
+ ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(
+ fragment)) => {
col_fragments.push(fragment);
}
_ => {}
@@ -888,7 +904,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
// flow here - instead, let it match the inline case
// below.
(display::block, _, position::absolute) | (_, _, position::fixed) => {
- node.set_flow_construction_result(self.build_flow_for_block(node))
+ node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
}
// Inline items contribute inline fragment construction results.
@@ -948,7 +964,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
// properties separately.
(_, float::none, _) => {
- node.set_flow_construction_result(self.build_flow_for_block(node))
+ node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node))
}
// Floated flows contribute float flow construction results.
diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs
index 7abc683f4ad..039e176e843 100644
--- a/components/layout/css/matching.rs
+++ b/components/layout/css/matching.rs
@@ -7,7 +7,6 @@
use css::node_style::StyledNode;
use construct::FlowConstructor;
use context::LayoutContext;
-use extra::LayoutAuxMethods;
use util::{LayoutDataAccess, LayoutDataWrapper};
use wrapper::{LayoutElement, LayoutNode, PostorderNodeMutTraversal, ThreadSafeLayoutNode};
diff --git a/components/layout/extra.rs b/components/layout/extra.rs
deleted file mode 100644
index 7b731185272..00000000000
--- a/components/layout/extra.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//! Code for managing the layout data in the DOM.
-
-use util::{PrivateLayoutData, LayoutDataAccess, LayoutDataWrapper};
-use wrapper::LayoutNode;
-use script::dom::node::SharedLayoutData;
-use script::layout_interface::LayoutChan;
-
-/// Functionality useful for querying the layout-specific data on DOM nodes.
-pub trait LayoutAuxMethods {
- fn initialize_layout_data(&self, chan: LayoutChan);
- fn initialize_style_for_subtree(&self, chan: LayoutChan);
-}
-
-impl<'ln> LayoutAuxMethods for LayoutNode<'ln> {
- /// Resets layout data and styles for the node.
- ///
- /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
- fn initialize_layout_data(&self, chan: LayoutChan) {
- let mut layout_data_ref = self.mutate_layout_data();
- match *layout_data_ref {
- None => {
- *layout_data_ref = Some(LayoutDataWrapper {
- chan: Some(chan),
- shared_data: SharedLayoutData { style: None },
- data: box PrivateLayoutData::new(),
- });
- }
- Some(_) => {}
- }
- }
-
- /// Resets layout data and styles for a Node tree.
- ///
- /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
- fn initialize_style_for_subtree(&self, chan: LayoutChan) {
- for n in self.traverse_preorder() {
- n.initialize_layout_data(chan.clone());
- }
- }
-}
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 7a4c98a8361..e5e869dcc15 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -8,9 +8,9 @@
/// inline and block layout.
///
/// Flows are interior nodes in the layout tree and correspond closely to *flow contexts* in the
-/// CSS specification. Flows are responsible for positioning their child flow contexts and fragments.
-/// Flows have purpose-specific fields, such as auxiliary line structs, out-of-flow child
-/// lists, and so on.
+/// CSS specification. Flows are responsible for positioning their child flow contexts and
+/// fragments. Flows have purpose-specific fields, such as auxiliary line structs, out-of-flow
+/// child lists, and so on.
///
/// Currently, the important types of flows are:
///
@@ -36,13 +36,13 @@ use incremental::RestyleDamage;
use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use parallel::FlowParallelInfo;
-use table_wrapper::TableWrapperFlow;
use table::TableFlow;
-use table_colgroup::TableColGroupFlow;
-use table_rowgroup::TableRowGroupFlow;
-use table_row::TableRowFlow;
use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
+use table_colgroup::TableColGroupFlow;
+use table_row::TableRowFlow;
+use table_rowgroup::TableRowGroupFlow;
+use table_wrapper::TableWrapperFlow;
use wrapper::ThreadSafeLayoutNode;
use collections::dlist::DList;
@@ -404,7 +404,7 @@ pub trait MutableOwnedFlowUtils {
/// Set absolute descendants for this flow.
///
/// Set this flow as the Containing Block for all the absolute descendants.
- fn set_abs_descendants(&mut self, abs_descendants: AbsDescendants);
+ fn set_absolute_descendants(&mut self, abs_descendants: AbsDescendants);
}
#[deriving(Encodable, PartialEq, Show)]
@@ -656,7 +656,15 @@ pub struct BaseFlow {
/// The children of this flow.
pub children: FlowList,
+
+ /// The flow's next sibling.
+ ///
+ /// FIXME(pcwalton): Make this private. Misuse of this can lead to data races.
pub next_sibling: Link,
+
+ /// The flow's previous sibling.
+ ///
+ /// FIXME(pcwalton): Make this private. Misuse of this can lead to data races.
pub prev_sibling: Link,
/* layout computations */
@@ -1086,7 +1094,7 @@ impl MutableOwnedFlowUtils for FlowRef {
/// This is called during flow construction, so nothing else can be accessing the descendant
/// flows. This is enforced by the fact that we have a mutable `FlowRef`, which only flow
/// construction is allowed to possess.
- fn set_abs_descendants(&mut self, abs_descendants: AbsDescendants) {
+ fn set_absolute_descendants(&mut self, abs_descendants: AbsDescendants) {
let this = self.clone();
let block = self.get_mut().as_block();
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs
index d6811617c0a..d535e1c247a 100644
--- a/components/layout/layout_task.rs
+++ b/components/layout/layout_task.rs
@@ -54,9 +54,9 @@ use servo_util::geometry;
use servo_util::logical_geometry::LogicalPoint;
use servo_util::opts::Opts;
use servo_util::smallvec::{SmallVec, SmallVec1};
+use servo_util::task::spawn_named_with_send_on_failure;
use servo_util::time::{TimeProfilerChan, profile};
use servo_util::time;
-use servo_util::task::spawn_named_with_send_on_failure;
use servo_util::workqueue::WorkQueue;
use std::cell::Cell;
use std::comm::{channel, Sender, Receiver, Select};
@@ -629,7 +629,7 @@ impl LayoutTask {
// positioned, it would return a reference to itself in
// `abs_descendants` and would lead to a circular reference.
// Set Root as CB for any remaining absolute descendants.
- flow.set_abs_descendants(abs_descendants);
+ flow.set_absolute_descendants(abs_descendants);
flow
}
_ => fail!("Flow construction didn't result in a flow at the root of the tree!"),
@@ -655,11 +655,7 @@ impl LayoutTask {
layout_root.traverse_postorder(&mut traversal);
}
- // FIXME(kmc): We want to prune nodes without the Reflow restyle damage
- // bit, but FloatContext values can't be reused, so we need to
- // recompute them every time.
- // NOTE: this currently computes borders, so any pruning should separate that operation
- // out.
+ // FIXME(pcwalton): Prune these two passes.
{
let mut traversal = AssignISizesTraversal {
layout_context: layout_context,
@@ -667,7 +663,6 @@ impl LayoutTask {
layout_root.traverse_preorder(&mut traversal);
}
- // FIXME(pcwalton): Prune this pass as well.
{
let mut traversal = AssignBSizesAndStoreOverflowTraversal {
layout_context: layout_context,
@@ -733,7 +728,6 @@ impl LayoutTask {
};
debug!("layout: received layout request for: {:s}", data.url.serialize());
- debug!("layout: damage is {:?}", data.damage);
debug!("layout: parsed Node tree");
debug!("{:?}", node.dump());
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index 171852573c8..3bc8b828771 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -62,7 +62,6 @@ pub mod text;
pub mod util;
pub mod incremental;
pub mod wrapper;
-pub mod extra;
pub mod css {
mod node_util;
diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs
index 30d431b389f..9bd0ea43094 100644
--- a/components/layout/parallel.rs
+++ b/components/layout/parallel.rs
@@ -9,7 +9,6 @@
use css::matching::{ApplicableDeclarations, CannotShare, MatchMethods, StyleWasShared};
use construct::FlowConstructor;
use context::{LayoutContext, SharedLayoutContext};
-use extra::LayoutAuxMethods;
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
use flow;
use flow_ref::FlowRef;
@@ -109,8 +108,7 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
/// Process current flow and potentially traverse its ancestors.
///
/// If we are the last child that finished processing, recursively process
- /// our parent. Else, stop.
- /// Also, stop at the root (obviously :P).
+ /// our parent. Else, stop. Also, stop at the root.
///
/// Thus, if we start with all the leaves of a tree, we end up traversing
/// the whole tree bottom-up because each parent will be processed exactly
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index bdabc3b5840..c27cfe924d8 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -34,7 +34,7 @@
//! `html_element_in_html_document_for_layout()`.
use css::node_style::StyledNode;
-use util::LayoutDataWrapper;
+use util::{LayoutDataAccess, LayoutDataWrapper, PrivateLayoutData};
use script::dom::bindings::codegen::InheritTypes::{HTMLIFrameElementDerived};
use script::dom::bindings::codegen::InheritTypes::{HTMLImageElementDerived, TextDerived};
@@ -44,8 +44,9 @@ use script::dom::element::{HTMLLinkElementTypeId, LayoutElementHelpers, RawLayou
use script::dom::htmliframeelement::HTMLIFrameElement;
use script::dom::htmlimageelement::{HTMLImageElement, LayoutHTMLImageElementHelpers};
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId};
-use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, TextNodeTypeId};
+use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutData, TextNodeTypeId};
use script::dom::text::Text;
+use script::layout_interface::LayoutChan;
use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_util::atom::Atom;
use servo_util::namespace::Namespace;
@@ -219,9 +220,26 @@ impl<'ln> LayoutNode<'ln> {
}
}
- pub unsafe fn get_jsmanaged<'a>(&'a self) -> &'a JS<Node> {
- &self.node
- }
+ pub unsafe fn get_jsmanaged<'a>(&'a self) -> &'a JS<Node> {
+ &self.node
+ }
+
+ /// Resets layout data and styles for the node.
+ ///
+ /// FIXME(pcwalton): Do this as part of fragment building instead of in a traversal.
+ pub fn initialize_layout_data(&self, chan: LayoutChan) {
+ let mut layout_data_ref = self.mutate_layout_data();
+ match *layout_data_ref {
+ None => {
+ *layout_data_ref = Some(LayoutDataWrapper {
+ chan: Some(chan),
+ shared_data: SharedLayoutData { style: None },
+ data: box PrivateLayoutData::new(),
+ });
+ }
+ Some(_) => {}
+ }
+ }
}
impl<'ln> TNode<LayoutElement<'ln>> for LayoutNode<'ln> {
@@ -536,7 +554,6 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
}
}
-
impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Creates a new `ThreadSafeLayoutNode` from the given `LayoutNode`.
pub fn new<'a>(node: &LayoutNode<'a>) -> ThreadSafeLayoutNode<'a> {
@@ -793,3 +810,4 @@ pub unsafe fn layout_node_from_unsafe_layout_node(node: &UnsafeLayoutNode) -> La
let (node, _) = *node;
mem::transmute(node)
}
+