if (mDocument) { result = mDocument->BeginUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result); }
mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, PR_TRUE);
CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex){  NS_ENSURE_ARG_POINTER(aGroup);  NS_ASSERTION(mInner && mInner->mComplete,               "No deleting from an incomplete sheet!");  nsresult result;  nsCOMPtr<nsICSSRule> rule;  result = aGroup->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));  NS_ENSURE_SUCCESS(result, result);    // check that the rule actually belongs to this sheet!  nsCOMPtr<nsIStyleSheet> ruleSheet;  rule->GetStyleSheet(*getter_AddRefs(ruleSheet));  if (this != ruleSheet) {    return NS_ERROR_INVALID_ARG;  }  if (mDocument) {    result = mDocument->BeginUpdate(UPDATE_STYLE);    NS_ENSURE_SUCCESS(result, result);  }  result = WillDirty();  NS_ENSURE_SUCCESS(result, result);  result = aGroup->DeleteStyleRuleAt(aIndex);  NS_ENSURE_SUCCESS(result, result);    rule->SetStyleSheet(nsnull);    DidDirty();  if (mDocument) {    result = mDocument->StyleRuleRemoved(this, rule);    NS_ENSURE_SUCCESS(result, result);        result = mDocument->EndUpdate(UPDATE_STYLE);    NS_ENSURE_SUCCESS(result, result);  }  return NS_OK;}