Bug 1391736. Relax the ExpectedOwnerForChild assert in the ServoRestyleState constructor. r=emilio
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 02 Oct 2017 16:36:49 -0400
changeset 383992 ce3e3c2f1598
parent 383991 06d4a47016eb
child 383993 5ac9fffe4f7f
push id95691
push userbzbarsky@mozilla.com
push dateMon, 02 Oct 2017 20:37:54 +0000
treeherdermozilla-inbound@ce3e3c2f1598 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1391736
milestone58.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 1391736. Relax the ExpectedOwnerForChild assert in the ServoRestyleState constructor. r=emilio
layout/base/ServoRestyleManager.cpp
layout/base/crashtests/1391736.html
layout/base/crashtests/crashtests.list
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -112,19 +112,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
@@ -501,8 +501,9 @@ load 1397398-1.html
 load 1397398-2.html
 load 1397398-3.html
 load 1398500.html
 load 1400438-1.html
 load 1400599-1.html
 load 1401739.html
 load 1401840.html
 load 1402476.html
+load 1391736.html