nsCOMPtr<nsIScriptGlobalObject> globalObj; mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));
nsIScriptGlobalObject *globalObj = mDocument->GetScriptGlobalObject();
PresShell::SetPreferenceStyleRules(PRBool aForceReflow){  if (!mDocument) {    return NS_ERROR_NULL_POINTER;  }  nsCOMPtr<nsIScriptGlobalObject> globalObj;  mDocument->GetScriptGlobalObject(getter_AddRefs(globalObj));  // If the document doesn't have a global object there's no need to  // notify its presshell about changes to preferences since the  // document is in a state where it doesn't matter any more (see  // DocumentViewerImpl::Close()).  if (!globalObj) {    return NS_ERROR_NULL_POINTER;  }   NS_PRECONDITION(mPresContext, "presContext cannot be null");  if (mPresContext) {    nsresult result = NS_OK;    // zeroth, make sure this feature is enabled    // XXX: may get more granularity later     //      (i.e. each pref may be controlled independently)    if (!mEnablePrefStyleSheet) {#ifdef DEBUG_attinasi      printf("PrefStyleSheet disabled\n");#endif      return PR_TRUE;    }    // first, make sure this is not a chrome shell     nsCOMPtr<nsISupports> container;    result = mPresContext->GetContainer(getter_AddRefs(container));    if (NS_SUCCEEDED(result) && container) {      nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(container, &result));      if (NS_SUCCEEDED(result) && docShell){        PRInt32 docShellType;        result = docShell->GetItemType(&docShellType);        if (NS_SUCCEEDED(result)){          if (nsIDocShellTreeItem::typeChrome == docShellType){            return NS_OK;          }        }            }    }    if (NS_SUCCEEDED(result)) {    #ifdef DEBUG_attinasi      printf("Setting Preference Style Rules:\n");#endif      // if here, we need to create rules for the prefs      // - this includes the background-color, the text-color,      //   the link color, the visited link color and the link-underlining          // first clear any exising rules      result = ClearPreferenceStyleRules();            // now do the color rules      if (NS_SUCCEEDED(result)) {        result = SetPrefColorRules();      }      // now the link rules (must come after the color rules, or links will not be correct color!)      // XXX - when there is both an override and agent pref stylesheet this won't matter,      //       as the color rules will be overrides and the links rules will be agent      if (NS_SUCCEEDED(result)) {        result = SetPrefLinkRules();      }      if (NS_SUCCEEDED(result)) {        result = SetPrefFocusRules();      }      if (NS_SUCCEEDED(result)) {        result = SetPrefNoScriptRule();      }      // update the styleset now that we are done inserting our rules      if (NS_SUCCEEDED(result)) {        if (mStyleSet) {          mStyleSet->NotifyStyleSheetStateChanged(PR_TRUE);        }      }    }#ifdef DEBUG_attinasi    printf( "Preference Style Rules set: error=%ld\n", (long)result);#endif        if (aForceReflow){      mPresContext->ClearStyleDataAndReflow();    }    return result;  }  return NS_ERROR_NULL_POINTER;}