Bug 1551053 - Check both list end and non-container items separately during display item merging r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Mon, 13 May 2019 21:13:01 +0000
changeset 473666 e7e7717d923630782861c01221c5fc5048b04c37
parent 473665 770dba43cd13487111289577e0097821d7abb624
child 473667 b231eb222b8c8b9eab3014459ff4cf48b6f1d24b
push id36009
push userapavel@mozilla.com
push dateTue, 14 May 2019 04:07:34 +0000
treeherdermozilla-central@96563508f9fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1551053
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551053 - Check both list end and non-container items separately during display item merging r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D30941
layout/painting/nsDisplayList.h
layout/reftests/display-list/1551053-1-ref.html
layout/reftests/display-list/1551053-1.html
layout/reftests/display-list/reftest.list
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -7355,26 +7355,16 @@ class FlattenedDisplayListIterator {
                 : mNext->GetChildren();
 
         mNext = childItems->GetBottom();
       }
     }
   }
 
   /**
-   * Returns the the display item above |aCurrent| casted to nsDisplayWrapList,
-   * if possible.
-   */
-  nsDisplayWrapList* GetNextAsWrapList(nsDisplayItem* aCurrent) const {
-    MOZ_ASSERT(aCurrent);
-    nsDisplayItem* next = aCurrent->GetAbove();
-    return next ? next->AsDisplayWrapList() : nullptr;
-  }
-
-  /**
    * Tries to merge display items starting from |aCurrent|.
    * Updates the internal pointer to the next display item.
    */
   nsDisplayItem* TryMergingFrom(nsDisplayItem* aCurrent) {
     MOZ_ASSERT(aCurrent);
     MOZ_ASSERT(aCurrent->GetAbove());
 
     nsDisplayWrapList* current = aCurrent->AsDisplayWrapList();
@@ -7387,24 +7377,25 @@ class FlattenedDisplayListIterator {
 
     // Attempt to merge |next| with |current|.
     if (current->CanMerge(next)) {
       // Merging is possible, collect all the successive mergeable items.
       AutoTArray<nsDisplayWrapList*, 2> willMerge{current};
 
       do {
         willMerge.AppendElement(next);
-      } while ((next = GetNextAsWrapList(next)) && current->CanMerge(next));
+        mNext = next->GetAbove();
+        next = mNext ? mNext->AsDisplayWrapList() : nullptr;
+      } while (next && current->CanMerge(next));
 
       current = mBuilder->MergeItems(willMerge);
     }
 
-    // |mNext| will be either the first item that could not be merged with
+    // Here |mNext| will be either the first item that could not be merged with
     // |current|, or nullptr.
-    mNext = next;
     return current;
   }
 
  private:
   nsDisplayListBuilder* mBuilder;
   nsDisplayItem* mNext;
   AutoTArray<nsDisplayItem*, 16> mStack;
 };
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1551053-1-ref.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8">
+<style>
+.will-merge {
+  opacity: 0.5;
+}
+</style>
+</head>
+
+<body>
+<span class="will-merge">bar<br>baz</span>
+<span>qux</span>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1551053-1.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8">
+<style>
+.will-merge {
+  opacity: 0.5;
+}
+</style>
+</head>
+
+<body>
+<span id="foo">foo</span>
+<span class="will-merge">bar<br>baz</span>
+<span>qux</span>
+<script type="text/javascript">
+function doTest() {
+  var e = document.getElementById("foo");
+  e.parentNode.removeChild(e);
+  document.documentElement.removeAttribute("class");
+}
+
+window.addEventListener("MozReftestInvalidate", doTest);
+setTimeout(doTest, 5000);
+</script>
+</body>
+</html>
--- a/layout/reftests/display-list/reftest.list
+++ b/layout/reftests/display-list/reftest.list
@@ -36,8 +36,9 @@ skip-if(!asyncPan) == 1437374-1.html 143
 == 1453541-2.html 1453541-ref.html
 == 1452805-1.html 1452805-ref.html
 == 1461231-1.html about:blank
 fuzzy(0-2,0-40000) skip-if(!asyncPan) == 1464288-1.html 1464288-ref.html
 == 1482403-1.html 1482403-1-ref.html
 == 1504233-1.html 1504233-1-ref.html
 == 1533317-1.html 1533317-1-ref.html
 == 1544948-1.html 1544948-1-ref.html
+skip-if(retainedDisplayList) == 1551053-1.html 1551053-1-ref.html