From 2b75ef09f7f27ce26fb786a8145128f952ac9913 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 5 Apr 2016 11:39:49 -0700 Subject: [PATCH] Whitespace stripping should not result in a dangling, open border. --- components/layout/construct.rs | 14 +++++------ components/layout/inline.rs | 2 ++ tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../css/whitespace_no_affect_border.html | 5 ++++ .../css/whitespace_no_affect_border_ref.html | 4 ++++ 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 tests/wpt/mozilla/tests/css/whitespace_no_affect_border.html create mode 100644 tests/wpt/mozilla/tests/css/whitespace_no_affect_border_ref.html diff --git a/components/layout/construct.rs b/components/layout/construct.rs index d9727e5c8d9..6ee484e4c33 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -1782,20 +1782,20 @@ pub fn strip_ignorable_whitespace_from_start(this: &mut LinkedList) { remaining_fragment.inline_context { if let Some(ref inline_context_of_removed_fragment) = removed_fragment.inline_context { - for (i, inline_context_node_from_removed_fragment) in - inline_context_of_removed_fragment.nodes.iter().enumerate() { - if i >= inline_context_of_remaining_fragment.nodes.len() { - break - } + for (inline_context_node_from_removed_fragment, + inline_context_node_from_remaining_fragment) in + inline_context_of_removed_fragment.nodes.iter().rev().zip( + inline_context_of_remaining_fragment.nodes.iter_mut().rev() + ) { if !inline_context_node_from_removed_fragment.flags.contains( FIRST_FRAGMENT_OF_ELEMENT) { continue } if inline_context_node_from_removed_fragment.address != - inline_context_of_remaining_fragment.nodes[i].address { + inline_context_node_from_remaining_fragment.address { continue } - inline_context_of_remaining_fragment.nodes[i].flags.insert( + inline_context_node_from_remaining_fragment.flags.insert( FIRST_FRAGMENT_OF_ELEMENT); } } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index c0e209d5f78..c283179afdf 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1874,6 +1874,8 @@ impl fmt::Debug for InlineFragmentNodeInfo { #[derive(Clone)] pub struct InlineFragmentContext { + /// The list of nodes that this fragment will be inheriting styles from, + /// from the most deeply-nested node out. pub nodes: Vec, } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 41a4d229f32..7d7df0a75ca 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -5323,6 +5323,18 @@ "url": "/_mozilla/css/white_space_intrinsic_sizes_a.html" } ], + "css/whitespace_no_affect_border.html": [ + { + "path": "css/whitespace_no_affect_border.html", + "references": [ + [ + "/_mozilla/css/whitespace_no_affect_border_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/whitespace_no_affect_border.html" + } + ], "css/whitespace_nowrap_a.html": [ { "path": "css/whitespace_nowrap_a.html", @@ -11781,6 +11793,18 @@ "url": "/_mozilla/css/white_space_intrinsic_sizes_a.html" } ], + "css/whitespace_no_affect_border.html": [ + { + "path": "css/whitespace_no_affect_border.html", + "references": [ + [ + "/_mozilla/css/whitespace_no_affect_border_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/whitespace_no_affect_border.html" + } + ], "css/whitespace_nowrap_a.html": [ { "path": "css/whitespace_nowrap_a.html", diff --git a/tests/wpt/mozilla/tests/css/whitespace_no_affect_border.html b/tests/wpt/mozilla/tests/css/whitespace_no_affect_border.html new file mode 100644 index 00000000000..2927baf910c --- /dev/null +++ b/tests/wpt/mozilla/tests/css/whitespace_no_affect_border.html @@ -0,0 +1,5 @@ + + +Whitespace stripping should not affect the border + + text next diff --git a/tests/wpt/mozilla/tests/css/whitespace_no_affect_border_ref.html b/tests/wpt/mozilla/tests/css/whitespace_no_affect_border_ref.html new file mode 100644 index 00000000000..a5d31243945 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/whitespace_no_affect_border_ref.html @@ -0,0 +1,4 @@ + + +Whitespace stripping should not affect the border +text next