result = mDocument->EndUpdate(UPDATE_STYLE); NS_ENSURE_SUCCESS(result, result);
CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex){  nsresult result = NS_ERROR_DOM_INDEX_SIZE_ERR;  // No doing this if the sheet is not complete!  PRBool complete;  GetComplete(complete);  if (!complete) {    return NS_ERROR_DOM_INVALID_ACCESS_ERR;  }  // XXX TBI: handle @rule types  if (mInner && mInner->mOrderedRules) {    if (mDocument) {      result = mDocument->BeginUpdate(UPDATE_STYLE);      if (NS_FAILED(result))        return result;    }    result = WillDirty();    if (NS_SUCCEEDED(result)) {      PRUint32 count;      mInner->mOrderedRules->Count(&count);      if (aIndex >= count)        return NS_ERROR_DOM_INDEX_SIZE_ERR;      nsCOMPtr<nsICSSRule> rule =        dont_AddRef((nsICSSRule*)mInner->mOrderedRules->ElementAt(aIndex));      if (rule) {        mInner->mOrderedRules->RemoveElementAt(aIndex);        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 result;}