diff --git a/src/components/layout/construct.rs b/src/components/layout/construct.rs index 3764a343eae..5e93b0136ad 100644 --- a/src/components/layout/construct.rs +++ b/src/components/layout/construct.rs @@ -329,15 +329,6 @@ impl<'a> FlowConstructor<'a> { } else if flow.get().need_anonymous_flow(kid_flow.get()) { consecutive_siblings.push(kid_flow) } else { - // Strip ignorable whitespace from the start of this flow per CSS 2.1 ยง - // 9.2.1.1. - let whitespace_stripping = if flow.get().is_table_kind() || *first_fragment { - *first_fragment = false; - StripWhitespaceFromStart - } else { - NoWhitespaceStripping - }; - // Flush any inline fragments that we were gathering up. This allows us to handle // {ib} splits. debug!("flushing {} inline box(es) to flow A", @@ -346,7 +337,7 @@ impl<'a> FlowConstructor<'a> { mem::replace(inline_fragment_accumulator, InlineFragmentsAccumulator::new()), flow, consecutive_siblings, - whitespace_stripping, + StripWhitespaceFromStart, node); if !consecutive_siblings.is_empty() { let consecutive_siblings = mem::replace(consecutive_siblings, vec!()); @@ -407,8 +398,14 @@ impl<'a> FlowConstructor<'a> { inline_fragment_accumulator.fragments.push_all(successor_fragments); abs_descendants.push_descendants(kid_abs_descendants); } - ConstructionItemConstructionResult(WhitespaceConstructionItem(..)) => { - // Nothing to do here. + ConstructionItemConstructionResult(WhitespaceConstructionItem(whitespace_node, whitespace_style)) => { + // Add whitespace results. They will be stripped out later on when + // between block elements, and retained when between inline elements. + let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::from_text(" ".to_string())); + let fragment = Fragment::from_opaque_node_and_style(whitespace_node, + whitespace_style.clone(), + fragment_info); + inline_fragment_accumulator.fragments.push(fragment, whitespace_style); } ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(_)) => { // TODO: Implement anonymous table objects for missing parents diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index e54c66d3ad1..f49ab627091 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -88,3 +88,5 @@ == pseudo_inherit.html pseudo_inherit_ref.html == float_intrinsic_height.html float_intrinsic_height_ref.html == table_auto_width.html table_auto_width_ref.html +== inline_whitespace_b.html inline_whitespace_ref.html +== inline_whitespace_a.html inline_whitespace_ref.html diff --git a/src/test/ref/inline_whitespace_a.html b/src/test/ref/inline_whitespace_a.html new file mode 100644 index 00000000000..b977423b741 --- /dev/null +++ b/src/test/ref/inline_whitespace_a.html @@ -0,0 +1,14 @@ + + +
+ + + + A B + + diff --git a/src/test/ref/inline_whitespace_b.html b/src/test/ref/inline_whitespace_b.html new file mode 100644 index 00000000000..58af87ba867 --- /dev/null +++ b/src/test/ref/inline_whitespace_b.html @@ -0,0 +1,15 @@ + + + + + + + A + B + + diff --git a/src/test/ref/inline_whitespace_ref.html b/src/test/ref/inline_whitespace_ref.html new file mode 100644 index 00000000000..2bf70eff251 --- /dev/null +++ b/src/test/ref/inline_whitespace_ref.html @@ -0,0 +1,14 @@ + + + + + + + A B + +