nsCOMPtr<nsIStyleSheet> sheet; aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet));
nsIStyleSheet *sheet = aDocument->GetStyleSheetAt(index, PR_TRUE);
DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,                                   nsIStyleSet** aStyleSet){  // this should eventually get expanded to allow for creating  // different sets for different media  nsresult rv;  if (!mUAStyleSheet) {    NS_WARNING("unable to load UA style sheet");  }  rv = CallCreateInstance(kStyleSetCID, aStyleSet);  if (NS_OK == rv) {    PRInt32 index = 0;    aDocument->GetNumberOfStyleSheets(PR_TRUE, &index);    while (0 < index--) {      nsCOMPtr<nsIStyleSheet> sheet;      aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet));      /*       * GetStyleSheetAt will return all style sheets in the document but       * we're only interested in the ones that are enabled.       */      PRBool styleApplicable;      sheet->GetApplicable(styleApplicable);      if (styleApplicable) {        (*aStyleSet)->AddDocStyleSheet(sheet, aDocument);      }    }    nsCOMPtr<nsIChromeRegistry> chromeRegistry =      do_GetService("@mozilla.org/chrome/chrome-registry;1");    if (chromeRegistry) {      nsCOMPtr<nsISupportsArray> sheets;      // Now handle the user sheets.      nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(mContainer));      PRInt32 shellType;      docShell->GetItemType(&shellType);      PRBool isChrome = (shellType == nsIDocShellTreeItem::typeChrome);      sheets = nsnull;      chromeRegistry->GetUserSheets(isChrome, getter_AddRefs(sheets));      if(sheets){        nsCOMPtr<nsICSSStyleSheet> sheet;        PRUint32 count;        sheets->Count(&count);        // Insert the user sheets at the front of the user sheet list        // so that they are most significant user sheets.        for(PRUint32 i=0; i<count; i++) {          sheets->GetElementAt(i, getter_AddRefs(sheet));          (*aStyleSet)->InsertUserStyleSheetBefore(sheet, nsnull);        }      }      // Append chrome sheets (scrollbars + forms).      nsCOMPtr<nsIDocShell> ds(do_QueryInterface(mContainer));      chromeRegistry->GetAgentSheets(ds, getter_AddRefs(sheets));      if(sheets){        nsCOMPtr<nsICSSStyleSheet> sheet;        PRUint32 count;        sheets->Count(&count);        for(PRUint32 i=0; i<count; i++) {          sheets->GetElementAt(i, getter_AddRefs(sheet));          (*aStyleSet)->AppendAgentStyleSheet(sheet);        }      }    }    if (mUAStyleSheet) {      (*aStyleSet)->AppendAgentStyleSheet(mUAStyleSheet);    }  }  return NS_OK;}