if (NS_SUCCEEDED(cssSheet->ContainsStyleSheet(url, bHasSheet, getter_AddRefs(quirkSheet))) && url && bHasSheet) {
NS_ASSERTION(gQuirkURI != nsnull, "StyleSetImpl::gQuirkStyleSet is not initialized!"); if (gQuirkURI != nsnull && NS_SUCCEEDED(cssSheet->ContainsStyleSheet(gQuirkURI, bHasSheet, getter_AddRefs(quirkSheet))) && bHasSheet) {
NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable){  const char kQuirk_href[] = "resource:/res/quirk.css";  nsresult rv = NS_OK;  if (nsnull == mQuirkStyleSheet) {    // first find the quirk sheet:    // - run through all of the backstop sheets and check for a CSSStyleSheet that    //   has the URL we want    PRUint32 i, nSheets = GetNumberOfBackstopStyleSheets();    for (i=0; i< nSheets; i++) {      nsCOMPtr<nsIStyleSheet> sheet;      sheet = getter_AddRefs(GetBackstopStyleSheetAt(i));      if (sheet) {        nsCOMPtr<nsICSSStyleSheet> cssSheet;        sheet->QueryInterface(nsICSSStyleSheet::GetIID(), getter_AddRefs(cssSheet));        if (cssSheet) {          static nsIURI *url = nsnull;          if (url == nsnull) NS_NewURI(&url, kQuirk_href);          nsCOMPtr<nsIStyleSheet> quirkSheet;          PRBool bHasSheet = PR_FALSE;          if (NS_SUCCEEDED(cssSheet->ContainsStyleSheet(url, bHasSheet, getter_AddRefs(quirkSheet))) && url && bHasSheet) {            NS_ASSERTION(quirkSheet, "QuirkSheet must be set: ContainsStyleSheet is hosed");            // cache the sheet for faster lookup next time            mQuirkStyleSheet = quirkSheet.get();            // addref for our cached reference            NS_ADDREF(mQuirkStyleSheet);          }        }      }    }  }  if (mQuirkStyleSheet) {#ifdef DEBUG    printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" );#endif    mQuirkStyleSheet->SetEnabled(aEnable);  }  return rv;}