servo: Merge #10419 - Whitespace stripping should not result in a dangling, open border (from notriddle:whitespace_border); r=mbrubeck
authorMichael Howell <michael@notriddle.com>
Wed, 06 Apr 2016 15:01:21 +0500
changeset 338423 f6846c0685a52f8986ab656aa08674e93d87dba9
parent 338422 cf0478c6e6a65563da8e0469d6e2e48cd3c76f01
child 338424 adfaee395308aeff6a4edf292ed4c2150588fc1b
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
servo: Merge #10419 - Whitespace stripping should not result in a dangling, open border (from notriddle:whitespace_border); r=mbrubeck No open issue (found it while working on #7681). Source-Repo: https://github.com/servo/servo Source-Revision: cb943b016f77b9d670291c5026b8566b5c0d5edf
servo/components/layout/construct.rs
servo/components/layout/inline.rs
--- a/servo/components/layout/construct.rs
+++ b/servo/components/layout/construct.rs
@@ -1777,30 +1777,30 @@ pub fn strip_ignorable_whitespace_from_s
             }
             WhitespaceStrippingResult::FragmentContainedOnlyWhitespace => {
                 let removed_fragment = this.pop_front().unwrap();
                 if let Some(ref mut remaining_fragment) = this.front_mut() {
                     if let Some(ref mut inline_context_of_remaining_fragment) =
                             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);
                             }
                         }
                     }
                 }
             }
         }
     }
--- a/servo/components/layout/inline.rs
+++ b/servo/components/layout/inline.rs
@@ -1869,16 +1869,18 @@ bitflags! {
 impl fmt::Debug for InlineFragmentNodeInfo {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{:?}", self.flags.bits())
     }
 }
 
 #[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<InlineFragmentNodeInfo>,
 }
 
 impl InlineFragmentContext {
     pub fn new() -> InlineFragmentContext {
         InlineFragmentContext {
             nodes: vec!(),
         }