nsCOMPtr<nsICSSStyleSheet> cssSheet; sheet->QueryInterface(NS_GET_IID(nsICSSStyleSheet), getter_AddRefs(cssSheet));
nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(sheet);
NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable){  nsresult rv = NS_OK;  if (nsnull == mQuirkStyleSheet) {    // first find the quirk sheet:    // - run through all of the agent sheets and check for a CSSStyleSheet that    //   has the URL we want    PRUint32 i, nSheets = GetNumberOfAgentStyleSheets();    for (i=0; i< nSheets; i++) {      nsCOMPtr<nsIStyleSheet> sheet;      sheet = getter_AddRefs(GetAgentStyleSheetAt(i));      if (sheet) {        nsCOMPtr<nsICSSStyleSheet> cssSheet;        sheet->QueryInterface(NS_GET_IID(nsICSSStyleSheet), getter_AddRefs(cssSheet));        if (cssSheet) {          nsCOMPtr<nsIStyleSheet> quirkSheet;          PRBool bHasSheet = PR_FALSE;          NS_ASSERTION(gQuirkURI != nsnull, "StyleSetImpl::gQuirkStyleSet is not initialized!");          if (gQuirkURI != nsnull              && NS_SUCCEEDED(cssSheet->ContainsStyleSheet(gQuirkURI, bHasSheet,                                                            getter_AddRefs(quirkSheet)))               && 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);            // only one quirk style sheet can exist, so stop looking            break;          }        }      }    }  }  NS_ASSERTION(mQuirkStyleSheet, "no quirk stylesheet");  if (mQuirkStyleSheet) {#if defined(DEBUG_warren) || defined(DEBUG_attinasi)    printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" );#endif#ifdef DEBUG_dbaron // XXX Make this |DEBUG| once it stops firing.    PRUint32 count = 0;    if (mAgentRuleProcessors)      mAgentRuleProcessors->Count(&count);    PRBool applicableNow;    mQuirkStyleSheet->GetApplicable(applicableNow);    NS_ASSERTION(count == 0 || aEnable == applicableNow,                 "enabling/disabling quirk stylesheet too late or incomplete quirk stylesheet");    if (count != 0 && aEnable == applicableNow)      printf("WARNING: We set the quirks mode too many times.\n"); // we do!#endif    mQuirkStyleSheet->SetEnabled(aEnable);  }  return rv;}