Bug 1461231 - Don't omit deleted items when constructing the DAG, since we need to record that we made a modification during MergeDisplayLists. r=miko, a=RyanVM
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 15 May 2018 14:20:59 +1200
changeset 473353 2932a4b5f7e77885014ce42d09ae14e3096f37b6
parent 473352 a5b962b8bb3d9a9301430bc47ce975e5279b2043
child 473354 909e56123552926e7b3b7f2431604a849d51c36c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmiko, RyanVM
bugs1461231
milestone61.0
Bug 1461231 - Don't omit deleted items when constructing the DAG, since we need to record that we made a modification during MergeDisplayLists. r=miko, a=RyanVM We can unconditionally delete the item though, and just put a placeholder entry into the DAG. MozReview-Commit-ID: 7a2UnaByIZu
layout/painting/RetainedDisplayListBuilder.cpp
layout/reftests/display-list/1461231-1.html
layout/reftests/display-list/reftest.list
--- a/layout/painting/RetainedDisplayListBuilder.cpp
+++ b/layout/painting/RetainedDisplayListBuilder.cpp
@@ -113,26 +113,27 @@ RetainedDisplayListBuilder::PreProcessDi
 
   }
 
   nsDisplayList saved;
   aList->mOldItems.SetCapacity(aList->Count());
   MOZ_ASSERT(aList->mOldItems.IsEmpty());
   while (nsDisplayItem* item = aList->RemoveBottom()) {
     if (item->HasDeletedFrame() || !item->CanBeReused()) {
-      // If we haven't yet initialized the DAG, then we can
-      // just drop this item. Otherwise we need to keep it
-      // around to preserve indices, and merging will
-      // get rid of it.
+      size_t i = aList->mOldItems.Length();
+      aList->mOldItems.AppendElement(OldItemInfo(nullptr));
+      item->Destroy(&mBuilder);
+
       if (initializeDAG) {
-        item->Destroy(&mBuilder);
-      } else {
-        size_t i = aList->mOldItems.Length();
-        aList->mOldItems.AppendElement(OldItemInfo(item));
-        item->SetOldListIndex(aList, OldListIndex(i));
+        if (i == 0) {
+          aList->mDAG.AddNode(Span<const MergedListIndex>());
+        } else {
+          MergedListIndex previous(i - 1);
+          aList->mDAG.AddNode(Span<const MergedListIndex>(&previous, 1));
+        }
       }
       continue;
     }
 
     size_t i = aList->mOldItems.Length();
     aList->mOldItems.AppendElement(OldItemInfo(item));
     item->SetOldListIndex(aList, OldListIndex(i));
     if (initializeDAG) {
@@ -232,17 +233,19 @@ OldItemInfo::AddedMatchToMergedList(Reta
 
 void
 OldItemInfo::Discard(RetainedDisplayListBuilder* aBuilder,
                      nsTArray<MergedListIndex>&& aDirectPredecessors)
 {
   MOZ_ASSERT(!IsUsed());
   mUsed = mDiscarded = true;
   mDirectPredecessors = Move(aDirectPredecessors);
-  mItem->Destroy(aBuilder->Builder());
+  if (mItem) {
+    mItem->Destroy(aBuilder->Builder());
+  }
   mItem = nullptr;
 }
 
 bool
 OldItemInfo::IsChanged()
 {
   return !mItem || mItem->HasDeletedFrame() || !mItem->CanBeReused();
 }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1461231-1.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en" class="reftest-wait">
+<head>
+<style>
+  #test {
+    background: #050;
+    position: fixed;
+    width: 200px;
+    height: 200px;
+  }
+</style>
+</head>
+<body>
+<p id="test" onclick="this.remove()"></p>
+</body>
+<script>
+  function doTest() {
+    document.getElementById("test").remove();
+    document.documentElement.removeAttribute('class');
+  }
+  window.addEventListener("MozReftestInvalidate", doTest);
+</script>
+</html>
--- a/layout/reftests/display-list/reftest.list
+++ b/layout/reftests/display-list/reftest.list
@@ -26,8 +26,9 @@ skip-if(!asyncPan) == 1437374-1.html 143
 == 1439809-1.html 1439809-1-ref.html
 == 1443027-1.html 1443027-ref.html
 == 1443027-2.html 1443027-ref.html
 == 1443027-3.html 1443027-3-ref.html
 == 1451971-1.html 1451971-ref.html
 == 1453541-1.html 1453541-ref.html
 == 1453541-2.html 1453541-ref.html
 == 1452805-1.html 1452805-ref.html
+== 1461231-1.html about:blank