Bug 1461974: Account for ongoing shell destruction on both code paths. r?hiro
If the shell is being destroyed and the canvas is not in the doc then we may try
to call ResolveForDeclarations on a being-destroyed shell.
MozReview-Commit-ID: 51sB49Tgepw
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -2695,33 +2695,33 @@ GetFontStyleForServo(Element* aElement,
ServoStyleSet* styleSet = aPresShell->StyleSet();
RefPtr<ComputedStyle> parentStyle;
// have to get a parent ComputedStyle for inherit-like relative
// values (2em, bolder, etc.)
if (aElement && aElement->IsInComposedDoc()) {
parentStyle = nsComputedDOMStyle::GetComputedStyle(aElement, nullptr);
- if (!parentStyle) {
- // The flush killed the shell, so we couldn't get any meaningful style
- // back.
- aError.Throw(NS_ERROR_FAILURE);
- return nullptr;
- }
} else {
RefPtr<RawServoDeclarationBlock> declarations =
CreateFontDeclarationForServo(NS_LITERAL_STRING("10px sans-serif"),
aPresShell->GetDocument());
MOZ_ASSERT(declarations);
-
- parentStyle = aPresShell->StyleSet()->
- ResolveForDeclarations(nullptr, declarations);
- }
-
- MOZ_RELEASE_ASSERT(parentStyle, "Should have a valid parent style");
+ if (!aPresShell->IsDestroying()) {
+ parentStyle =
+ aPresShell->StyleSet()->ResolveForDeclarations(nullptr, declarations);
+ }
+ }
+
+ if (!parentStyle) {
+ // Either the flush killed the shell, so we couldn't get any meaningful
+ // style back, or the shell was already destroying.
+ aError.Throw(NS_ERROR_FAILURE);
+ return nullptr;
+ }
MOZ_ASSERT(!aPresShell->IsDestroying(),
"We should have returned an error above if the presshell is "
"being destroyed.");
RefPtr<ComputedStyle> sc =
styleSet->ResolveForDeclarations(parentStyle, declarations);