Bug 1230668 - Don't use frame when not in composed document. r=heycam a=sylvestre
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -437,26 +437,28 @@ nsComputedDOMStyle::GetStyleContextForEl
{
MOZ_ASSERT(aElement, "NULL element");
// If the content has a pres shell, we must use it. Otherwise we'd
// potentially mix rule trees by using the wrong pres shell's style
// set. Using the pres shell from the content also means that any
// content that's actually *in* a document will get the style from the
// correct document.
nsIPresShell *presShell = GetPresShellForContent(aElement);
+ bool inDocWithShell = true;
if (!presShell) {
+ inDocWithShell = false;
presShell = aPresShell;
if (!presShell)
return nullptr;
}
// XXX the !aElement->IsHTMLElement(nsGkAtoms::area)
// check is needed due to bug 135040 (to avoid using
// mPrimaryFrame). Remove it once that's fixed.
- if (!aPseudo && aStyleType == eAll &&
+ if (!aPseudo && aStyleType == eAll && inDocWithShell &&
!aElement->IsHTMLElement(nsGkAtoms::area)) {
nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement);
if (frame) {
nsStyleContext* result = frame->StyleContext();
// Don't use the style context if it was influenced by
// pseudo-elements, since then it's not the primary style
// for this element.
if (!result->HasPseudoElementData()) {
@@ -485,17 +487,18 @@ nsComputedDOMStyle::GetStyleContextForEl
RefPtr<nsStyleContext> sc;
if (aPseudo) {
nsCSSPseudoElements::Type type = nsCSSPseudoElements::GetPseudoType(aPseudo);
if (type >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
return nullptr;
}
nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement);
- Element* pseudoElement = frame ? frame->GetPseudoElement(type) : nullptr;
+ Element* pseudoElement =
+ frame && inDocWithShell ? frame->GetPseudoElement(type) : nullptr;
sc = styleSet->ResolvePseudoElementStyle(aElement, type, parentContext,
pseudoElement);
} else {
sc = styleSet->ResolveStyleFor(aElement, parentContext);
}
if (aStyleType == eDefaultOnly) {
// We really only want the user and UA rules. Filter out the other ones.