From 0d362ca50335d964a78dbba7e7d32574ee67899a Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 05:01:17 -0400 Subject: Bug 1330843 - Allow JS to create NAC pseudo-elements Tag #1375 --- layout/base/RestyleManager.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'layout/base/RestyleManager.cpp') diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index c3eeb8c71..16db4c18b 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1062,6 +1062,25 @@ ElementForStyleContext(nsIContent* aParentContent, return f->GetContent()->AsElement(); } + Element* frameElement = aFrame->GetContent()->AsElement(); + if (frameElement->IsNativeAnonymous() && + nsCSSPseudoElements::PseudoElementIsJSCreatedNAC(aPseudoType)) { + // NAC-implemented pseudos use the closest non-NAC element as their + // element to inherit from. + // + // FIXME(heycam): In theory we shouldn't need to limit this only to + // JS-created pseudo-implementing NAC, as all pseudo-implementing + // should use the closest non-native anonymous ancestor element as + // its originating element. But removing that part of the condition + // reveals some bugs in style resultion with display:contents and + // XBL. See bug 1345809. + Element* originatingElement = + nsContentUtils::GetClosestNonNativeAnonymousAncestor(frameElement); + if (originatingElement) { + return originatingElement; + } + } + if (aParentContent) { return aParentContent->AsElement(); } -- cgit v1.2.3