diff options
-rw-r--r-- | components/layout/block.rs | 20 | ||||
-rw-r--r-- | components/layout/construct.rs | 20 | ||||
-rw-r--r-- | components/layout/flow.rs | 10 | ||||
-rw-r--r-- | components/layout/fragment.rs | 45 | ||||
-rw-r--r-- | components/layout/inline.rs | 45 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 5 | ||||
-rw-r--r-- | components/layout/table.rs | 5 | ||||
-rw-r--r-- | components/layout/table_cell.rs | 4 | ||||
-rw-r--r-- | components/layout/table_colgroup.rs | 2 | ||||
-rw-r--r-- | components/layout/table_row.rs | 5 | ||||
-rw-r--r-- | components/layout/table_rowgroup.rs | 4 | ||||
-rw-r--r-- | components/layout/text.rs | 17 | ||||
-rw-r--r-- | components/layout/traversal.rs | 2 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 30 | ||||
-rw-r--r-- | tests/ref/basic.list | 1 | ||||
-rw-r--r-- | tests/ref/img_simple.html | 3 | ||||
-rw-r--r-- | tests/ref/img_simple_ref.html | 2 |
17 files changed, 123 insertions, 97 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index 62c40da0672..f3ec9e0f373 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -811,7 +811,7 @@ impl BlockFlow { pub fn assign_block_size_block_base<'a>(&mut self, layout_context: &'a LayoutContext<'a>, margins_may_collapse: MarginsMayCollapseFlag) { - let _scope = layout_debug_scope!("assign_block_size_block_base {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("assign_block_size_block_base {:x}", self.base.debug_id()); // Our current border-box position. let mut cur_b = Au(0); @@ -1513,7 +1513,7 @@ impl Flow for BlockFlow { /// This function must decide minimum/preferred inline-sizes based on its children's /// inline-sizes and the dimensions of any fragments it is responsible for flowing. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("block::bubble_inline_sizes {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("block::bubble_inline_sizes {:x}", self.base.debug_id()); let mut flags = self.base.flags; flags.set_has_left_floated_descendants(false); @@ -1583,7 +1583,7 @@ impl Flow for BlockFlow { /// Dual fragments consume some inline-size first, and the remainder is assigned to all child /// (block) contexts. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("block::assign_inline_sizes {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("block::assign_inline_sizes {:x}", self.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", if self.is_float() { @@ -1683,7 +1683,7 @@ impl Flow for BlockFlow { fn assign_block_size<'a>(&mut self, ctx: &'a LayoutContext<'a>) { if self.is_replaced_content() { - let _scope = layout_debug_scope!("assign_replaced_block_size_if_necessary {:s}", + let _scope = layout_debug_scope!("assign_replaced_block_size_if_necessary {:x}", self.base.debug_id()); // Assign block-size for fragment if it is an image fragment. @@ -1842,15 +1842,7 @@ impl Flow for BlockFlow { impl fmt::Show for BlockFlow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "BlockFlow")); - if self.is_float() { - try!(write!(f, "(Float)")); - } else if self.is_root() { - try!(write!(f, "(Root)")); - } else if self.is_absolutely_positioned() { - try!(write!(f, "(Absolute)")); - } - write!(f, ": {} ({})", self.fragment, self.base) + write!(f, "{} - {:x}: frag={} ({})", self.class(), self.base.debug_id(), self.fragment, self.base) } } @@ -2010,6 +2002,7 @@ pub trait ISizeAndMarginsComputer { // We also resize the block itself, to ensure that overflow is not calculated // as the inline-size of our parent. We might be smaller and we might be larger if we // overflow. + flow::mut_base(block).position.size.inline = inline_size + extra_inline_size_from_margin; } @@ -2567,4 +2560,3 @@ fn propagate_column_inline_sizes_to_child(kid: &mut Flow, *inline_start_margin_edge = *inline_start_margin_edge + inline_size } } - diff --git a/components/layout/construct.rs b/components/layout/construct.rs index c795f5025f4..fb550b6cf2a 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -66,6 +66,7 @@ use sync::Arc; use url::Url; /// The results of flow construction for a DOM node. +#[deriving(Clone)] pub enum ConstructionResult { /// This node contributes nothing at all (`display: none`). Alternately, this is what newly /// created nodes have their `ConstructionResult` set to. @@ -84,22 +85,25 @@ pub enum ConstructionResult { impl ConstructionResult { pub fn swap_out(&mut self, layout_context: &LayoutContext) -> ConstructionResult { if layout_context.shared.opts.incremental_layout { - match *self { - NoConstructionResult => - return NoConstructionResult, - FlowConstructionResult(ref flow_ref, ref abs_descendants) => - return FlowConstructionResult((*flow_ref).clone(), (*abs_descendants).clone()), - ConstructionItemConstructionResult(_) => {}, - } + return (*self).clone(); } mem::replace(self, NoConstructionResult) } + + pub fn debug_id(&self) -> uint { + match self { + &NoConstructionResult => 0u, + &ConstructionItemConstructionResult(_) => 0u, + &FlowConstructionResult(ref flow_ref, _) => flow::base(flow_ref.deref()).debug_id(), + } + } } /// 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. +#[deriving(Clone)] pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. InlineFragmentsConstructionItem(InlineFragmentsConstructionResult), @@ -110,6 +114,7 @@ pub enum ConstructionItem { } /// Represents inline fragments and {ib} splits that are bubbling up from an inline. +#[deriving(Clone)] pub struct InlineFragmentsConstructionResult { /// Any {ib} splits that we're bubbling up. pub splits: Vec<InlineBlockSplit>, @@ -147,6 +152,7 @@ pub struct InlineFragmentsConstructionResult { /// C /// ]) /// ``` +#[deriving(Clone)] pub struct InlineBlockSplit { /// The inline fragments that precede the flow. pub predecessors: InlineFragments, diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 9231e448ba7..49a182d54aa 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -854,8 +854,9 @@ impl BaseFlow { &self.ref_count } - pub fn debug_id(&self) -> String { - format!("{:p}", self as *const _) + pub fn debug_id(&self) -> uint { + let p = self as *const _; + p as uint } } @@ -1020,7 +1021,9 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a { for _ in range(0, level) { indent.push_str("| ") } - debug!("{}+ {}", indent, self.to_string()); + + error!("{}+ {}", indent, self.to_string()); + for kid in imm_child_iter(self) { kid.dump_with_level(level + 1) } @@ -1217,7 +1220,6 @@ impl<'a> MutableFlowUtils for &'a mut Flow + 'a { doit(self, RestyleDamage::empty(), &mut DirtyFloats { left: false, right: false }); } - fn nonincremental_reset(self) { fn reset_flow(flow: &mut Flow) { let base = mut_base(flow); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 63992e37413..56b14754ca6 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -379,15 +379,19 @@ pub struct ScannedTextFragmentInfo { /// The new_line_pos is eaten during line breaking. If we need to re-merge /// fragments, it will have to be restored. pub original_new_line_pos: Option<Vec<CharIndex>>, + + /// The inline-size of the text fragment. + pub content_inline_size: Au, } impl ScannedTextFragmentInfo { /// Creates the information specific to a scanned text fragment from a range and a text run. - pub fn new(run: Arc<Box<TextRun>>, range: Range<CharIndex>) -> ScannedTextFragmentInfo { + pub fn new(run: Arc<Box<TextRun>>, range: Range<CharIndex>, content_inline_size: Au) -> ScannedTextFragmentInfo { ScannedTextFragmentInfo { run: run, range: range, original_new_line_pos: None, + content_inline_size: content_inline_size, } } } @@ -552,6 +556,11 @@ impl Fragment { } } + pub fn reset_inline_sizes(&mut self) { + self.border_padding = LogicalMargin::zero(self.style.writing_mode); + self.margin = LogicalMargin::zero(self.style.writing_mode); + } + /// Saves the new_line_pos vector into a `ScannedTextFragment`. This will fail /// if called on any other type of fragment. pub fn save_new_line_pos(&mut self) { @@ -586,16 +595,20 @@ impl Fragment { /// Transforms this fragment into another fragment of the given type, with the given size, preserving all /// the other data. - pub fn transform(&self, size: LogicalSize<Au>, specific: SpecificFragmentInfo) -> Fragment { + pub fn transform(&self, size: LogicalSize<Au>, mut info: ScannedTextFragmentInfo) -> Fragment { + let new_border_box = + LogicalRect::from_point_size(self.style.writing_mode, self.border_box.start, size); + + info.content_inline_size = size.inline; + Fragment { node: self.node, style: self.style.clone(), restyle_damage: RestyleDamage::all(), - border_box: LogicalRect::from_point_size( - self.style.writing_mode, self.border_box.start, size), + border_box: new_border_box, border_padding: self.border_padding, margin: self.margin, - specific: specific, + specific: ScannedTextFragment(info), new_line_pos: self.new_line_pos.clone(), inline_context: self.inline_context.clone(), debug_id: self.debug_id, @@ -1685,10 +1698,10 @@ impl Fragment { block_flow.base.intrinsic_inline_sizes.preferred_inline_size; block_flow.base.block_container_inline_size = self.border_box.size.inline; } - ScannedTextFragment(_) => { + ScannedTextFragment(ref info) => { // Scanned text fragments will have already had their content inline-sizes assigned // by this point. - self.border_box.size.inline = self.border_box.size.inline + noncontent_inline_size + self.border_box.size.inline = info.content_inline_size + noncontent_inline_size } ImageFragment(ref mut image_fragment_info) => { // TODO(ksh8281): compute border,margin @@ -1960,24 +1973,8 @@ impl Fragment { } impl fmt::Show for Fragment { - /// Outputs a debugging string describing this fragment. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "({} ", - match self.specific { - GenericFragment => "GenericFragment", - IframeFragment(_) => "IframeFragment", - ImageFragment(_) => "ImageFragment", - InlineAbsoluteHypotheticalFragment(_) => "InlineAbsoluteHypotheticalFragment", - InlineBlockFragment(_) => "InlineBlockFragment", - InputFragment => "InputFragment", - ScannedTextFragment(_) => "ScannedTextFragment", - TableFragment => "TableFragment", - TableCellFragment => "TableCellFragment", - TableColumnFragment(_) => "TableColumnFragment", - TableRowFragment => "TableRowFragment", - TableWrapperFragment => "TableWrapperFragment", - UnscannedTextFragment(_) => "UnscannedTextFragment", - })); + try!(write!(f, "({} {} ", self.debug_id(), self.specific.get_type())); try!(write!(f, "bp {}", self.border_padding)); try!(write!(f, " ")); try!(write!(f, "m {}", self.margin)); diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 3fd918502ed..0babaa46234 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -405,11 +405,14 @@ impl LineBreaker { let writing_mode = self.floats.writing_mode; let split_fragment = |split: SplitInfo| { - let info = ScannedTextFragmentInfo::new(run.clone(), split.range); - let specific = ScannedTextFragment(info); + let info = + ScannedTextFragmentInfo::new( + run.clone(), + split.range, + in_fragment.border_box.size.inline); let size = LogicalSize::new( writing_mode, split.inline_size, in_fragment.border_box.size.block); - in_fragment.transform(size, specific) + in_fragment.transform(size, info) }; debug!("LineBreaker: Pushing the fragment to the inline_start of the new-line character \ @@ -493,12 +496,15 @@ impl LineBreaker { line_is_empty); match split.map(|(inline_start, inline_end, run)| { let split_fragment = |split: SplitInfo| { - let info = ScannedTextFragmentInfo::new(run.clone(), split.range); - let specific = ScannedTextFragment(info); + let info = + ScannedTextFragmentInfo::new( + run.clone(), + split.range, + in_fragment.border_box.size.inline); let size = LogicalSize::new(self.floats.writing_mode, split.inline_size, in_fragment.border_box.size.block); - in_fragment.transform(size, specific) + in_fragment.transform(size, info) }; (inline_start.map(|x| { @@ -562,12 +568,19 @@ impl LineBreaker { } /// Represents a list of inline fragments, including element ranges. -#[deriving(Encodable)] +#[deriving(Encodable, Clone)] pub struct InlineFragments { /// The fragments themselves. pub fragments: Vec<Fragment>, } +impl fmt::Show for InlineFragments { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.fragments) + } +} + + impl InlineFragments { /// Creates an empty set of inline fragments. pub fn new() -> InlineFragments { @@ -584,7 +597,7 @@ impl InlineFragments { /// Returns true if this list contains no fragments and false if it contains at least one /// fragment. pub fn is_empty(&self) -> bool { - self.len() == 0 + self.fragments.is_empty() } /// Pushes a new inline fragment. @@ -989,7 +1002,7 @@ impl Flow for InlineFlow { fn bubble_inline_sizes(&mut self) { self.update_restyle_damage(); - let _scope = layout_debug_scope!("inline::bubble_inline_sizes {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("inline::bubble_inline_sizes {:x}", self.base.debug_id()); let writing_mode = self.base.writing_mode; for kid in self.base.child_iter() { @@ -1007,7 +1020,7 @@ impl Flow for InlineFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, _: &LayoutContext) { - let _scope = layout_debug_scope!("inline::assign_inline_sizes {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("inline::assign_inline_sizes {:x}", self.base.debug_id()); // Initialize content fragment inline-sizes if they haven't been initialized already. // @@ -1039,7 +1052,7 @@ impl Flow for InlineFlow { /// Calculate and set the block-size of this flow. See CSS 2.1 § 10.6.1. fn assign_block_size(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("inline::assign_block_size {:s}", self.base.debug_id()); + let _scope = layout_debug_scope!("inline::assign_block_size {:x}", self.base.debug_id()); // Collect various offsets needed by absolutely positioned inline-block or hypothetical // absolute descendants. @@ -1244,15 +1257,7 @@ impl Flow for InlineFlow { impl fmt::Show for InlineFlow { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "InlineFlow")); - for (i, fragment) in self.fragments.fragments.iter().enumerate() { - if i == 0 { - try!(write!(f, ": {}", fragment)) - } else { - try!(write!(f, ", {}", fragment)) - } - } - write!(f, " ({})", self.base) + write!(f, "{} - {:x} - {}", self.class(), self.base.debug_id(), self.fragments) } } diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index c36ad0433f6..60b2a53938a 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -159,6 +159,7 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder { let f: proc(ImageResponseMsg, UntrustedNodeAddress):Send = proc(_, node_address) { let ScriptControlChan(chan) = script_chan; + debug!("Dirtying {:x}", node_address as uint); let mut nodes = SmallVec1::new(); nodes.vec_push(node_address); drop(chan.send_opt(SendEventMsg(id.clone(), ReflowEvent(nodes)))) @@ -675,6 +676,10 @@ impl LayoutTask { } }); + if self.opts.dump_flow_tree { + layout_root.dump(); + } + // Build the display list if necessary, and send it to the renderer. if data.goal == ReflowForDisplay { let writing_mode = flow::base(layout_root.deref()).writing_mode; diff --git a/components/layout/table.rs b/components/layout/table.rs index e066e7adc6a..55312d97267 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -159,7 +159,7 @@ impl Flow for TableFlow { /// The maximum min/pref inline-sizes of each column are set from the rows for the automatic /// table layout calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("table::bubble_inline_sizes {:s}", + let _scope = layout_debug_scope!("table::bubble_inline_sizes {:x}", self.block_flow.base.debug_id()); let mut computation = IntrinsicISizesContribution::new(); @@ -233,7 +233,7 @@ impl Flow for TableFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) { - let _scope = layout_debug_scope!("table::assign_inline_sizes {:s}", + let _scope = layout_debug_scope!("table::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table"); @@ -396,4 +396,3 @@ impl ColumnInlineSize { } } } - diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 0cda4fb922a..d79c4d532b0 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -78,7 +78,7 @@ impl Flow for TableCellFlow { /// Minimum/preferred inline-sizes set by this function are used in automatic table layout /// calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("table_cell::bubble_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_cell::bubble_inline_sizes {:x}", self.block_flow.base.debug_id()); self.block_flow.bubble_inline_sizes(); @@ -102,7 +102,7 @@ impl Flow for TableCellFlow { /// When called on this context, the context has had its inline-size set by the parent table /// row. fn assign_inline_sizes(&mut self, ctx: &LayoutContext) { - let _scope = layout_debug_scope!("table_cell::assign_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_cell::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_cell"); diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 664d28e8100..5db1dd3ab2a 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -57,7 +57,7 @@ impl Flow for TableColGroupFlow { } fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("table_colgroup::bubble_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_colgroup::bubble_inline_sizes {:x}", self.base.debug_id()); for fragment in self.cols.iter() { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 0ee0441e3ca..ea3395704d4 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -162,7 +162,7 @@ impl Flow for TableRowFlow { /// The specified column inline-sizes of children cells are used in fixed table layout /// calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("table_row::bubble_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_row::bubble_inline_sizes {:x}", self.block_flow.base.debug_id()); // Bubble up the specified inline-sizes from child table cells. @@ -209,7 +209,7 @@ impl Flow for TableRowFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, ctx: &LayoutContext) { - let _scope = layout_debug_scope!("table_row::assign_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_row::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_row"); @@ -253,4 +253,3 @@ impl fmt::Show for TableRowFlow { write!(f, "TableRowFlow: {}", self.block_flow.fragment) } } - diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 1a4b1ce374a..f0a6483515e 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -124,7 +124,7 @@ impl Flow for TableRowGroupFlow { /// Also, this function finds the specified column inline-sizes from the first row. These are /// used in fixed table layout calculation. fn bubble_inline_sizes(&mut self) { - let _scope = layout_debug_scope!("table_rowgroup::bubble_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_rowgroup::bubble_inline_sizes {:x}", self.block_flow.base.debug_id()); let mut computation = IntrinsicISizesContribution::new(); @@ -167,7 +167,7 @@ impl Flow for TableRowGroupFlow { /// Recursively (top-down) determines the actual inline-size of child contexts and fragments. /// When called on this context, the context has had its inline-size set by the parent context. fn assign_inline_sizes(&mut self, ctx: &LayoutContext) { - let _scope = layout_debug_scope!("table_rowgroup::assign_inline_sizes {:s}", + let _scope = layout_debug_scope!("table_rowgroup::assign_inline_sizes {:x}", self.block_flow.base.debug_id()); debug!("assign_inline_sizes({}): assigning inline_size for flow", "table_rowgroup"); diff --git a/components/layout/text.rs b/components/layout/text.rs index be79be0c06d..19338d4c021 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -7,7 +7,7 @@ #![deny(unsafe_block)] use flow::Flow; -use fragment::{Fragment, ScannedTextFragment, ScannedTextFragmentInfo, UnscannedTextFragment}; +use fragment::{Fragment, ScannedTextFragmentInfo, UnscannedTextFragment}; use gfx::font::{FontMetrics,RunMetrics}; use gfx::font_context::FontContext; @@ -154,9 +154,9 @@ impl TextRunScanner { let new_metrics = run.metrics_for_range(&range); let bounding_box_size = bounding_box_for_run_metrics( &new_metrics, old_fragment.style.writing_mode); - let new_text_fragment_info = ScannedTextFragmentInfo::new(Arc::new(run), range); - let mut new_fragment = old_fragment.transform( - bounding_box_size, ScannedTextFragment(new_text_fragment_info)); + let new_text_fragment_info = + ScannedTextFragmentInfo::new(Arc::new(run), range, old_fragment.border_box.size.inline); + let mut new_fragment = old_fragment.transform(bounding_box_size, new_text_fragment_info); new_fragment.new_line_pos = new_line_pos; out_fragments.push(new_fragment) } @@ -235,13 +235,16 @@ impl TextRunScanner { continue } - let new_text_fragment_info = ScannedTextFragmentInfo::new(run.as_ref().unwrap().clone(), range); let old_fragment = &in_fragments[i.to_uint()]; + let new_text_fragment_info = + ScannedTextFragmentInfo::new( + run.as_ref().unwrap().clone(), + range, + old_fragment.border_box.size.inline); let new_metrics = new_text_fragment_info.run.metrics_for_range(&range); let bounding_box_size = bounding_box_for_run_metrics( &new_metrics, old_fragment.style.writing_mode); - let mut new_fragment = old_fragment.transform( - bounding_box_size, ScannedTextFragment(new_text_fragment_info)); + let mut new_fragment = old_fragment.transform(bounding_box_size, new_text_fragment_info); new_fragment.new_line_pos = new_line_positions[logical_offset.to_uint()].new_line_pos.clone(); out_fragments.push(new_fragment) } diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index c05e67b4dc0..cb2f4a245fa 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -212,9 +212,9 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> { if node.has_dirty_descendants() { tnode.set_restyle_damage(RestyleDamage::all()); - debug!("Constructing flow for {}", tnode.debug_id()); let mut flow_constructor = FlowConstructor::new(self.layout_context); flow_constructor.process(&tnode); + debug!("Constructed flow for {:x}: {:x}", tnode.debug_id(), tnode.flow_debug_id()); } // Reset the layout damage in this node. It's been propagated to the diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 0b78a2f97ac..c4085522692 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -205,17 +205,25 @@ impl<'ln> LayoutNode<'ln> { }) } + pub fn flow_debug_id(self) -> uint { + let layout_data_ref = self.borrow_layout_data(); + match *layout_data_ref { + None => 0u, + Some(ref layout_data) => layout_data.data.flow_construction_result.debug_id() + } + } + /// Iterates over this node and all its descendants, in preorder. /// /// FIXME(pcwalton): Terribly inefficient. We should use parallelism. - pub fn traverse_preorder(&self) -> LayoutTreeIterator<'ln> { + pub fn traverse_preorder(self) -> LayoutTreeIterator<'ln> { let mut nodes = vec!(); gather_layout_nodes(self, &mut nodes, false); LayoutTreeIterator::new(nodes) } /// Returns an iterator over this node's children. - pub fn children(&self) -> LayoutNodeChildrenIterator<'ln> { + pub fn children(self) -> LayoutNodeChildrenIterator<'ln> { // FIXME(zwarich): Remove this when UFCS lands and there is a better way // of disambiguating methods. fn first_child<T: TLayoutNode>(this: &T) -> Option<T> { @@ -223,7 +231,7 @@ impl<'ln> LayoutNode<'ln> { } LayoutNodeChildrenIterator { - current_node: first_child(self), + current_node: first_child(&self), } } @@ -234,7 +242,7 @@ impl<'ln> LayoutNode<'ln> { /// 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) { + pub fn initialize_layout_data(self, chan: LayoutChan) { let mut layout_data_ref = self.mutate_layout_data(); match *layout_data_ref { None => { @@ -248,14 +256,14 @@ impl<'ln> LayoutNode<'ln> { } } - pub fn has_children(&self) -> bool { + pub fn has_children(self) -> bool { self.first_child().is_some() } /// While doing a reflow, the node at the root has no parent, as far as we're /// concerned. This method returns `None` at the reflow root. - pub fn layout_parent_node(&self, shared: &SharedLayoutContext) -> Option<LayoutNode<'ln>> { - let opaque_node: OpaqueNode = OpaqueNodeMethods::from_layout_node(self); + pub fn layout_parent_node(self, shared: &SharedLayoutContext) -> Option<LayoutNode<'ln>> { + let opaque_node: OpaqueNode = OpaqueNodeMethods::from_layout_node(&self); if opaque_node == shared.reflow_root { None } else { @@ -425,12 +433,12 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutTreeIterator<'a> { } /// FIXME(pcwalton): This is super inefficient. -fn gather_layout_nodes<'a>(cur: &LayoutNode<'a>, refs: &mut Vec<LayoutNode<'a>>, postorder: bool) { +fn gather_layout_nodes<'a>(cur: LayoutNode<'a>, refs: &mut Vec<LayoutNode<'a>>, postorder: bool) { if !postorder { refs.push(cur.clone()); } for kid in cur.children() { - gather_layout_nodes(&kid, refs, postorder) + gather_layout_nodes(kid, refs, postorder) } if postorder { refs.push(cur.clone()); @@ -690,6 +698,10 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { self.node.debug_id() } + pub fn flow_debug_id(self) -> uint { + self.node.flow_debug_id() + } + /// Returns the next sibling of this node. Unsafe and private because this can lead to races. unsafe fn next_sibling(&self) -> Option<ThreadSafeLayoutNode<'ln>> { if self.pseudo.is_before() { diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 015d379e01e..d35bc28c0b9 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -1,3 +1,4 @@ +!= img_simple.html img_simple_ref.html == basic_width_px.html basic_width_em.html == br.html br-ref.html # `?` and `#` in the name is a test for https://github.com/servo/servo/issues/3340 diff --git a/tests/ref/img_simple.html b/tests/ref/img_simple.html new file mode 100644 index 00000000000..056cef562c9 --- /dev/null +++ b/tests/ref/img_simple.html @@ -0,0 +1,3 @@ +<!doctype html> +Hello +<img src=400x400_green.png> diff --git a/tests/ref/img_simple_ref.html b/tests/ref/img_simple_ref.html new file mode 100644 index 00000000000..c1ad2a4335d --- /dev/null +++ b/tests/ref/img_simple_ref.html @@ -0,0 +1,2 @@ +<!doctype html> +<img src=400x400_green.png> |