Bug 1331047: Return the correct flattened tree parent for ::before and ::after of the root element. r?bholley
MozReview-Commit-ID: LEuf9dyknh4
--- 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();