Bug 1331047: Return the correct flattened tree parent for ::before and ::after of the root element. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 22 Apr 2017 22:36:15 +0200
changeset 568642 83acbdfe1eac4df7e7f10536fcc8983a4019f8bb
parent 568641 d236a7185f61f288a9983a8abec19a1c34b81613
child 568643 708d1afaa6553f5672137a3c720bf5a6dc46a5f2
push id55935
push userbmo:emilio+bugs@crisal.io
push dateWed, 26 Apr 2017 11:57:38 +0000
reviewersbholley
bugs1331047
milestone55.0a1
Bug 1331047: Return the correct flattened tree parent for ::before and ::after of the root element. r?bholley MozReview-Commit-ID: LEuf9dyknh4
dom/base/FragmentOrElement.cpp
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -161,16 +161,23 @@ nsIContent::GetFlattenedTreeParentNodeIn
     MOZ_ASSERT(!parentNode || parentNode == OwnerDoc());
     return parentNode;
   }
   nsIContent* parent = parentNode->AsContent();
 
   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;
+    }
+
     // 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();