mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Bug 1467722: Don't return null for getComputedStyle when there's no pres shell. r=heycam
We need to deal with this case regardless from getPropertyValue, and this causes pain and webcompat issues. MozReview-Commit-ID: Gbpzq0N4O2T
This commit is contained in:
parent
9c36800bd7
commit
9bed821e90
@ -228,7 +228,9 @@ AnonymousContent::GetComputedStylePropertyValue(const nsAString& aElementId,
|
||||
}
|
||||
|
||||
RefPtr<nsComputedDOMStyle> cs =
|
||||
new nsComputedDOMStyle(element, NS_LITERAL_STRING(""), shell,
|
||||
new nsComputedDOMStyle(element,
|
||||
NS_LITERAL_STRING(""),
|
||||
element->OwnerDoc(),
|
||||
nsComputedDOMStyle::eAll);
|
||||
aRv = cs->GetPropertyValue(aPropertyName, aResult);
|
||||
}
|
||||
|
@ -6691,35 +6691,12 @@ nsGlobalWindowOuter::GetComputedStyleHelperOuter(Element& aElt,
|
||||
const nsAString& aPseudoElt,
|
||||
bool aDefaultStylesOnly)
|
||||
{
|
||||
if (!mDocShell) {
|
||||
if (!mDoc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell = mDocShell->GetPresShell();
|
||||
|
||||
if (!presShell) {
|
||||
// Try flushing frames on our parent in case there's a pending
|
||||
// style change that will create the presshell.
|
||||
auto* parent = nsGlobalWindowOuter::Cast(GetPrivateParent());
|
||||
if (!parent) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
parent->FlushPendingNotifications(FlushType::Frames);
|
||||
|
||||
// Might have killed mDocShell
|
||||
if (!mDocShell) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
presShell = mDocShell->GetPresShell();
|
||||
if (!presShell) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<nsICSSDeclaration> compStyle =
|
||||
NS_NewComputedDOMStyle(&aElt, aPseudoElt, presShell,
|
||||
NS_NewComputedDOMStyle(&aElt, aPseudoElt, mDoc,
|
||||
aDefaultStylesOnly ? nsComputedDOMStyle::eDefaultOnly :
|
||||
nsComputedDOMStyle::eAll);
|
||||
|
||||
|
@ -556,11 +556,8 @@ CSSEditUtils::GetComputedStyle(Element* aElement)
|
||||
nsIDocument* doc = aElement->GetComposedDoc();
|
||||
NS_ENSURE_TRUE(doc, nullptr);
|
||||
|
||||
nsIPresShell* presShell = doc->GetShell();
|
||||
NS_ENSURE_TRUE(presShell, nullptr);
|
||||
|
||||
RefPtr<nsComputedDOMStyle> style =
|
||||
NS_NewComputedDOMStyle(aElement, EmptyString(), presShell);
|
||||
NS_NewComputedDOMStyle(aElement, EmptyString(), doc);
|
||||
|
||||
return style.forget();
|
||||
}
|
||||
|
@ -68,12 +68,13 @@ using namespace mozilla::dom;
|
||||
*/
|
||||
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
NS_NewComputedDOMStyle(dom::Element* aElement, const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell,
|
||||
NS_NewComputedDOMStyle(dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIDocument* aDocument,
|
||||
nsComputedDOMStyle::StyleType aStyleType)
|
||||
{
|
||||
RefPtr<nsComputedDOMStyle> computedStyle =
|
||||
new nsComputedDOMStyle(aElement, aPseudoElt, aPresShell, aStyleType);
|
||||
new nsComputedDOMStyle(aElement, aPseudoElt, aDocument, aStyleType);
|
||||
return computedStyle.forget();
|
||||
}
|
||||
|
||||
@ -312,7 +313,7 @@ ComputedStyleMap::Update()
|
||||
|
||||
nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell,
|
||||
nsIDocument* aDocument,
|
||||
StyleType aStyleType)
|
||||
: mDocumentWeak(nullptr)
|
||||
, mOuterFrame(nullptr)
|
||||
@ -326,10 +327,11 @@ nsComputedDOMStyle::nsComputedDOMStyle(dom::Element* aElement,
|
||||
, mFlushedPendingReflows(false)
|
||||
#endif
|
||||
{
|
||||
MOZ_ASSERT(aElement && aPresShell);
|
||||
MOZ_ASSERT(aPresShell->GetPresContext());
|
||||
|
||||
mDocumentWeak = do_GetWeakReference(aPresShell->GetDocument());
|
||||
MOZ_ASSERT(aElement);
|
||||
MOZ_ASSERT(aDocument);
|
||||
// TODO(emilio, bug 548397, https://github.com/w3c/csswg-drafts/issues/2403):
|
||||
// Should use aElement->OwnerDoc() instead.
|
||||
mDocumentWeak = do_GetWeakReference(aDocument);
|
||||
mContent = aElement;
|
||||
mPseudo = nsCSSPseudoElements::GetPseudoAtom(aPseudoElt);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
|
||||
nsComputedDOMStyle(mozilla::dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell,
|
||||
nsIDocument* aDocument,
|
||||
StyleType aStyleType);
|
||||
|
||||
virtual nsINode *GetParentObject() override
|
||||
@ -786,7 +786,7 @@ private:
|
||||
already_AddRefed<nsComputedDOMStyle>
|
||||
NS_NewComputedDOMStyle(mozilla::dom::Element* aElement,
|
||||
const nsAString& aPseudoElt,
|
||||
nsIPresShell* aPresShell,
|
||||
nsIDocument* aDocument,
|
||||
nsComputedDOMStyle::StyleType aStyleType =
|
||||
nsComputedDOMStyle::eAll);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user