Bug 1415940 Part 4: Generalize a StyleSheet cast in ServoStyleRuleDeclaration::SetCSSDeclaration to prevent a NULL dereference from AsServo().
MozReview-Commit-ID: GXHb3gLOEkt
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -72,17 +72,19 @@ ServoStyleRuleDeclaration::GetCSSDeclara
{
return mDecls;
}
nsresult
ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
{
ServoStyleRule* rule = Rule();
- if (RefPtr<ServoStyleSheet> sheet = rule->GetStyleSheet()->AsServo()) {
+ if (RefPtr<StyleSheet> sheet = rule->GetStyleSheet()) {
+ MOZ_ASSERT(sheet->IsServo(), "Servo style rules should have "
+ "servo stylesheets.");
nsCOMPtr<nsIDocument> doc = sheet->GetAssociatedDocument();
mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
if (aDecl != mDecls) {
mDecls->SetOwningRule(nullptr);
RefPtr<ServoDeclarationBlock> decls = aDecl->AsServo();
Servo_StyleRule_SetStyle(rule->Raw(), decls->Raw());
mDecls = decls.forget();
mDecls->SetOwningRule(rule);