Bug 1391736 - Relax the ExpectedOwnerForChild assert in the ServoRestyleState constructor. r=emilio, a=ritu
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 02 Oct 2017 16:36:49 -0400
changeset 432149 0b73ed645d56
parent 432148 f22fa49006ca
child 432150 1338d62a031f
push id7889
push userryanvm@gmail.com
push dateWed, 04 Oct 2017 00:51:09 +0000
treeherdermozilla-beta@1338d62a031f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio, ritu
bugs1391736
milestone57.0
Bug 1391736 - Relax the ExpectedOwnerForChild assert in the ServoRestyleState constructor. r=emilio, a=ritu
layout/base/ServoRestyleManager.cpp
layout/base/crashtests/1391736.html
layout/base/crashtests/crashtests.list
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -106,19 +106,36 @@ ExpectedOwnerForChild(const nsIFrame& aF
 }
 
 void
 ServoRestyleState::AssertOwner(const ServoRestyleState& aParent) const
 {
   MOZ_ASSERT(mOwner);
   MOZ_ASSERT(!mOwner->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW));
   // We allow aParent.mOwner to be null, for cases when we're not starting at
-  // the root of the tree.
-  MOZ_ASSERT_IF(aParent.mOwner,
-                ExpectedOwnerForChild(*mOwner) == aParent.mOwner);
+  // the root of the tree.  We also allow aParent.mOwner to be somewhere up our
+  // expected owner chain not our immediate owner, which allows us creating long
+  // chains of ServoRestyleStates in some cases where it's just not worth it.
+#ifdef DEBUG
+  if (aParent.mOwner) {
+    const nsIFrame* owner = ExpectedOwnerForChild(*mOwner);
+    if (owner != aParent.mOwner) {
+      MOZ_ASSERT(IsAnonBox(*owner),
+                 "Should only have expected owner weirdness when anon boxes are involved");
+      bool found = false;
+      for (; owner; owner = ExpectedOwnerForChild(*owner)) {
+        if (owner == aParent.mOwner) {
+          found = true;
+          break;
+        }
+      }
+      MOZ_ASSERT(found, "Must have aParent.mOwner on our expected owner chain");
+    }
+  }
+#endif
 }
 
 nsChangeHint
 ServoRestyleState::ChangesHandledFor(const nsIFrame& aFrame) const
 {
   if (!mOwner) {
     MOZ_ASSERT(!mChangesHandled);
     return mChangesHandled;
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1391736.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="UTF-8">
+<script>
+window.onload = () => {
+  a = document.createElement("div")
+  b = document.createElement("div")
+  a.appendChild(b)
+  document.documentElement.appendChild(a)
+  a.style.overflow = "scroll"
+  a.style.columnWidth = "calc(-15px)"
+  b.style.display = "table-caption"
+  requestIdleCallback(() => {
+    a.style.stopColor = "#000"
+    b.style.gridColumn = "crispEdges"
+    window.saved = b.offsetWidth;
+    document.documentElement.className = "";
+  })
+}
+</script>
+</head>
+</html>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -490,16 +490,17 @@ load 1308848-2.html
 load 1338772-1.html
 load 1343937.html
 asserts(0-1) load 1343606.html # bug 1343948
 load 1352380.html
 load 1362423-1.html
 load 1381323.html
 asserts-if(!stylo,1) load 1388625-1.html # bug 1389286
 load 1390389.html
+load 1391736.html
 load 1395591-1.html
 load 1395715-1.html
 load 1397398-1.html
 load 1397398-2.html
 load 1397398-3.html
 load 1398500.html
 load 1400438-1.html
 load 1400599-1.html