diff options
author | bors-servo <release+servo@mozilla.com> | 2014-01-29 15:09:52 -0800 |
---|---|---|
committer | bors-servo <release+servo@mozilla.com> | 2014-01-29 15:09:52 -0800 |
commit | 9f6ab8ed7761edd218ac6e65e74cfb7aafca4cb2 (patch) | |
tree | 9d68fe37eece7bb42ad71e54237d7d739bc2df41 /src/components/main/layout/construct.rs | |
parent | 7e3075522dd7584f6f898041536e7706c4775f4d (diff) | |
parent | e579daefc2956a2eb151588b628c51342de236d0 (diff) | |
download | servo-9f6ab8ed7761edd218ac6e65e74cfb7aafca4cb2.tar.gz servo-9f6ab8ed7761edd218ac6e65e74cfb7aafca4cb2.zip |
auto merge of #1589 : pcwalton/servo/stop-removing-flows, r=larsbergstrom
to be leaves.
60% improvement in flow tree construction time on the rainbow page.
r? @larsbergstrom
Diffstat (limited to 'src/components/main/layout/construct.rs')
-rw-r--r-- | src/components/main/layout/construct.rs | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/components/main/layout/construct.rs b/src/components/main/layout/construct.rs index e2605e6bd6c..dbb0f9d9b5b 100644 --- a/src/components/main/layout/construct.rs +++ b/src/components/main/layout/construct.rs @@ -26,7 +26,7 @@ use layout::box_::{Box, GenericBox, IframeBox, IframeBoxInfo, ImageBox, ImageBox use layout::box_::{UnscannedTextBox, UnscannedTextBoxInfo, InlineInfo, InlineParentInfo}; use layout::context::LayoutContext; use layout::float_context::FloatType; -use layout::flow::{BaseFlow, Flow, LeafSet, MutableOwnedFlowUtils}; +use layout::flow::{BaseFlow, Flow, ImmutableFlowUtils, LeafSet, MutableOwnedFlowUtils}; use layout::inline::InlineFlow; use layout::text::TextRunScanner; use layout::util::{LayoutDataAccess, OpaqueNode}; @@ -274,13 +274,10 @@ impl<'fc> FlowConstructor<'fc> { let inline_base = BaseFlow::new(self.next_flow_id(), node); let mut inline_flow = ~InlineFlow::from_boxes(inline_base, boxes) as ~Flow; - self.layout_context.leaf_set.access(|leaf_set| leaf_set.insert(&inline_flow)); + self.layout_context.leaf_set.access(|leaf_set| inline_flow.mark_as_leaf(leaf_set)); TextRunScanner::new().scan_for_runs(self.font_context, inline_flow); - let mut inline_flow = Some(inline_flow); - self.layout_context.leaf_set.access(|leaf_set| { - flow.add_new_child(inline_flow.take_unwrap(), leaf_set) - }) + flow.add_new_child(inline_flow) } /// Creates an inline flow from a set of inline boxes, if present, and adds it as a child of @@ -323,10 +320,7 @@ impl<'fc> FlowConstructor<'fc> { self.flush_inline_boxes_to_flow_if_necessary(&mut opt_boxes_for_inline_flow, flow, node); - let mut kid_flow = Some(kid_flow); - self.layout_context.leaf_set.access(|leaf_set| { - flow.add_new_child(kid_flow.take_unwrap(), leaf_set) - }) + flow.add_new_child(kid_flow) } ConstructionItemConstructionResult(InlineBoxesConstructionItem( InlineBoxesConstructionResult { @@ -366,10 +360,7 @@ impl<'fc> FlowConstructor<'fc> { // Push the flow generated by the {ib} split onto our list of // flows. - let mut kid_flow = Some(kid_flow); - self.layout_context.leaf_set.access(|leaf_set| { - flow.add_new_child(kid_flow.take_unwrap(), leaf_set) - }) + flow.add_new_child(kid_flow) } } } @@ -386,6 +377,13 @@ impl<'fc> FlowConstructor<'fc> { self.flush_inline_boxes_to_flow_if_necessary(&mut opt_boxes_for_inline_flow, flow, node); + + // The flow is done. If it ended up with no kids, add the flow to the leaf set. + if flow.child_count() == 0 { + self.layout_context.leaf_set.access(|leaf_set| flow.mark_as_leaf(leaf_set)) + } else { + flow.mark_as_nonleaf() + } } /// Builds a flow for a node with `display: block`. This yields a `BlockFlow` with possibly @@ -395,9 +393,6 @@ impl<'fc> FlowConstructor<'fc> { let base = BaseFlow::new(self.next_flow_id(), node); let box_ = self.build_box_for_node(node); let mut flow = ~BlockFlow::from_box(base, box_, is_fixed) as ~Flow; - - self.layout_context.leaf_set.access(|leaf_set| leaf_set.insert(&flow)); - self.build_children_of_block_flow(&mut flow, node); flow } @@ -410,9 +405,6 @@ impl<'fc> FlowConstructor<'fc> { let box_ = self.build_box_for_node(node); let mut flow = ~BlockFlow::float_from_box(base, float_type, box_) as ~Flow; - - self.layout_context.leaf_set.access(|leaf_set| leaf_set.insert(&flow)); - self.build_children_of_block_flow(&mut flow, node); flow } |