summaryrefslogtreecommitdiffstats
path: root/layout/base/nsCSSFrameConstructor.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 05:01:17 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 05:01:17 -0400
commit0d362ca50335d964a78dbba7e7d32574ee67899a (patch)
tree8b5de5f34019b97ad0b3c155c270a810608cd775 /layout/base/nsCSSFrameConstructor.cpp
parentde45820b64ab03768336c7242622ef9f499347cf (diff)
downloadUXP-0d362ca50335d964a78dbba7e7d32574ee67899a.tar
UXP-0d362ca50335d964a78dbba7e7d32574ee67899a.tar.gz
UXP-0d362ca50335d964a78dbba7e7d32574ee67899a.tar.lz
UXP-0d362ca50335d964a78dbba7e7d32574ee67899a.tar.xz
UXP-0d362ca50335d964a78dbba7e7d32574ee67899a.zip
Bug 1330843 - Allow JS to create NAC pseudo-elements
Tag #1375
Diffstat (limited to 'layout/base/nsCSSFrameConstructor.cpp')
-rw-r--r--layout/base/nsCSSFrameConstructor.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
index 3be7c2a0b..b574e7690 100644
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5041,8 +5041,19 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
aParentStyleContext);
}
} else {
- MOZ_ASSERT(aOriginatingElementOrNull);
MOZ_ASSERT(aContent->IsInNativeAnonymousSubtree());
+ if (!aOriginatingElementOrNull) {
+ // For pseudo-implementing NAC created by JS using the ChromeOnly
+ // document.createElement(..., { pseudo: ... }) API, we find the
+ // originating element by lookup the tree until we find a non-NAC
+ // ancestor. (These are the correct semantics for C++-generated pseudo-
+ // implementing NAC as well, but for those cases we already have a
+ // correct originating element passed in.)
+ MOZ_ASSERT(nsCSSPseudoElements::PseudoElementIsJSCreatedNAC(pseudoType));
+ aOriginatingElementOrNull =
+ nsContentUtils::GetClosestNonNativeAnonymousAncestor(aContent->AsElement());
+ }
+ MOZ_ASSERT(aOriginatingElementOrNull);
result = styleSet->ResolvePseudoElementStyle(aOriginatingElementOrNull,
pseudoType,
aParentStyleContext,