Bug 1330843 - Allow JS to create NAC pseudo-elements. r=bholley

MozReview-Commit-ID: 2aBPoCOsT6R
This commit is contained in:
Cameron McCormack
2017-03-17 15:30:34 +08:00
parent c17f544013
commit 0344da46e0
8 changed files with 103 additions and 5 deletions

View File

@@ -5096,8 +5096,19 @@ nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
LazyComputeBehavior::Assert);
}
} 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,