diff options
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 } |