Bug 1422634: Avoid sheet notifications to dereference a null restyle manager. r?heycam
MozReview-Commit-ID: 2BLUCEqnRDG
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -174,16 +174,22 @@ ServoStyleSet::Init(nsPresContext* aPres
void
ServoStyleSet::Shutdown()
{
// Make sure we drop our cached style contexts before the presshell arena
// starts going away.
ClearNonInheritingStyleContexts();
mRawSet = nullptr;
mStyleRuleMap = nullptr;
+
+ // Also drop the reference to the pres context to avoid notifications from our
+ // stylesheets to dereference a null restyle manager, see bug 1422634.
+ //
+ // We should really fix bug 154199...
+ mPresContext = nullptr;
}
void
ServoStyleSet::InvalidateStyleForCSSRuleChanges()
{
MOZ_ASSERT(StylistNeedsUpdate());
mPresContext->RestyleManager()->AsServo()->PostRestyleEventForCSSRuleChanges();
}
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -595,17 +595,18 @@ private:
ServoStyleSheet* aSheet,
ServoStyleSheet* aBeforeSheet);
void RemoveSheetOfType(SheetType aType,
ServoStyleSheet* aSheet);
const Kind mKind;
- // Nullptr if this is an XBL style set.
+ // Nullptr if this is an XBL style set, or if we've been already detached from
+ // our shell.
nsPresContext* MOZ_NON_OWNING_REF mPresContext = nullptr;
// Because XBL style set could be used by multiple PresContext, we need to
// store the last PresContext pointer which uses this XBL styleset for
// computing medium rule changes.
void* MOZ_NON_OWNING_REF mLastPresContextUsesXBLStyleSet = nullptr;
UniquePtr<RawServoStyleSet> mRawSet;