Bug 1332353 - Make it clearer when a stylesheet is really owned by its mDocument

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 05:46:23 -04:00 committed by Roy Tam
commit 5d444ef68a
13 changed files with 83 additions and 38 deletions

View file

@ -1209,13 +1209,13 @@ DOMCSSDeclarationImpl::SetCSSDeclaration(DeclarationBlock* aDecl)
NS_PRECONDITION(mRule,
"can only be called when |GetCSSDeclaration| returned a declaration");
nsCOMPtr<nsIDocument> owningDoc;
nsCOMPtr<nsIDocument> doc;
RefPtr<CSSStyleSheet> sheet = mRule->GetStyleSheet();
if (sheet) {
owningDoc = sheet->GetOwningDocument();
doc = sheet->GetAssociatedDocument();
}
mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, true);
mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
mRule->SetDeclaration(aDecl->AsGecko());
@ -1223,8 +1223,8 @@ DOMCSSDeclarationImpl::SetCSSDeclaration(DeclarationBlock* aDecl)
sheet->DidDirty();
}
if (owningDoc) {
owningDoc->StyleRuleChanged(sheet, mRule);
if (doc) {
doc->StyleRuleChanged(sheet, mRule);
}
return NS_OK;
}