PRInt32 useCount; mMapped->GetUseCount(useCount); if (1 < useCount) { nsHTMLMappedAttributes* single; result = mMapped->Clone(&single); if (NS_SUCCEEDED(result)) { mMapped->ReleaseUse(); NS_RELEASE(mMapped); mMapped = single; mMapped->AddUse(); } } else { if (aSheet) { aSheet->DropMappedAttributes(mMapped); }
nsHTMLMappedAttributes* single; result = mMapped->Clone(&single); if (NS_SUCCEEDED(result)) { mMapped->ReleaseUse(); NS_RELEASE(mMapped); mMapped = single; mMapped->AddUse();
HTMLAttributesImpl::EnsureSingleMappedFor(nsIHTMLContent* aContent,                                          nsIHTMLStyleSheet* aSheet,                                          PRBool aCreate){  nsresult result = NS_OK;  if (mMapped) {    PRInt32 useCount;    mMapped->GetUseCount(useCount);    if (1 < useCount) { // shared, clone it      nsHTMLMappedAttributes* single;      result = mMapped->Clone(&single);      if (NS_SUCCEEDED(result)) {        mMapped->ReleaseUse();        NS_RELEASE(mMapped);        mMapped = single;        mMapped->AddUse();      }    }    else {  // single use, remove it from unique table before modifying      if (aSheet) {        aSheet->DropMappedAttributes(mMapped);      }    }  }  else if (aCreate) {  // create one    mMapped = new nsHTMLMappedAttributes();    if (mMapped) {      NS_ADDREF(mMapped);      mMapped->AddUse();      if (aContent) {        nsMapRuleToAttributesFunc mapRuleFunc;        aContent->GetAttributeMappingFunction(mapRuleFunc);        result = mMapped->Init(aSheet, mapRuleFunc);      }    }    else {      result = NS_ERROR_OUT_OF_MEMORY;    }  }  return result;}