Backed out changeset e6663f10c42b (bug 1404316) for crashing in devtools/server/tests/browser/browser_canvasframe_helper_04.js on Windows 7 debug with non-e10s builds. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 01 Oct 2017 10:08:17 +0200
changeset 426506 1340a2e8b79fd360552a7c24ba8061e9ecfb18d3
parent 426505 3a0ac72b90db6776118409bb7fd5e0a5cfc97aea
child 426507 a6ce4b7b0721d2d4d7046f6c0b3622280fba50bb
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersbackout
bugs1404316
milestone58.0a1
backs oute6663f10c42bf9a2a7b240a3302627a27ed98a2f
Backed out changeset e6663f10c42b (bug 1404316) for crashing in devtools/server/tests/browser/browser_canvasframe_helper_04.js on Windows 7 debug with non-e10s builds. r=backout
dom/base/FragmentOrElement.cpp
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -159,52 +159,58 @@ nsIContent::GetFlattenedTreeParentNodeIn
 {
   nsINode* parentNode = GetParentNode();
   if (!parentNode || !parentNode->IsContent()) {
     MOZ_ASSERT(!parentNode || parentNode == OwnerDoc());
     return parentNode;
   }
   nsIContent* parent = parentNode->AsContent();
 
-  // When getting the flattened tree parent for style, we return null
-  // for any "document level" native anonymous content subtree root.
-  // This is NAC generated by an ancestor frame of the document element's
-  // primary frame, and includes scrollbar elements created by the root
-  // scroll frame, and the "custom content container" and accessible caret
-  // generated by the nsCanvasFrame.  We distinguish document level NAC
-  // from NAC generated by the root element's primary frame below.
   if (aType == eForStyle &&
       IsRootOfNativeAnonymousSubtree() &&
       OwnerDoc()->GetRootElement() == parent) {
     // First, check if this is generated ::before/::after content for the root.
     // If it is, we know what to do.
     if (IsGeneratedContentContainerForBefore() ||
         IsGeneratedContentContainerForAfter()) {
       return parent;
     }
 
-    AutoTArray<nsIContent*, 8> rootElementNAC;
-    nsContentUtils::AppendNativeAnonymousChildren(
-        parent, rootElementNAC, nsIContent::eSkipDocumentLevelNativeAnonymousContent);
-    bool isDocLevelNAC = !rootElementNAC.Contains(this);
-
-#ifdef DEBUG
-    {
-      // The code below would be slightly more direct, but it gets the wrong
-      // answer when the root scrollframe is being bootstrapped and we're
-      // trying to style the scrollbars (since GetRootScrollFrame() still returns
-      // null at that point). Verify that the results match otherwise.
-      AutoTArray<nsIContent*, 8> docLevelNAC;
-      nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(OwnerDoc(), docLevelNAC);
-      MOZ_ASSERT_IF(OwnerDoc()->GetShell()->GetRootScrollFrame(),
-                    isDocLevelNAC == docLevelNAC.Contains(this));
+    // When getting the flattened tree parent for style, we return null
+    // for any "document level" native anonymous content subtree root.
+    // This is NAC generated by an ancestor frame of the document element's
+    // primary frame, and includes scrollbar elements created by the root
+    // scroll frame, and the "custom content container" and accessible caret
+    // generated by the nsCanvasFrame.  We distinguish document level NAC
+    // from NAC generated by the root element's primary frame below.
+    nsIFrame* parentFrame = parent->GetPrimaryFrame();
+    if (!parentFrame) {
+      // If the root element has no primary frame, it means it can't have
+      // generated any NAC itself.  Thus any NAC we have here must have
+      // been generated by an ancestor frame.
+      //
+      // If we are in here, then either the root element is display:none, or
+      // we are in the middle of constructing the root of the frame tree and
+      // we are trying to eagerly restyle document level NAC in
+      // nsCSSFrameConstructor::GetAnonymousContent before the root
+      // element's frame has been constructed.
+      return OwnerDoc();
     }
-#endif
-
-    if (isDocLevelNAC) {
+    nsIAnonymousContentCreator* creator = do_QueryFrame(parentFrame);
+    if (!creator) {
+      // If the root element does have a frame, but does not implement
+      // nsIAnonymousContentCreator, then this must be document level NAC.
+      return OwnerDoc();
+    }
+    AutoTArray<nsIContent*, 8> elements;
+    creator->AppendAnonymousContentTo(elements, 0);
+    if (!elements.Contains(this)) {
+      // If the root element does have a frame, and also does implement
+      // nsIAnonymousContentCreator, but didn't create this node, then
+      // it must be document level NAC.
       return OwnerDoc();
     }
   }
 
   if (parent && nsContentUtils::HasDistributedChildren(parent) &&
       nsContentUtils::IsInSameAnonymousTree(parent, this)) {
     // This node is distributed to insertion points, thus we
     // need to consult the destination insertion points list to