nsCOMPtr<nsIScriptGlobalObject> gso; doc->GetScriptGlobalObject(getter_AddRefs(gso)); if (gso) { nsCOMPtr<nsIDocShell> docShell; gso->GetDocShell(getter_AddRefs(docShell)); nsCOMPtr<nsIWebNavigation> webNav (do_QueryInterface(docShell)); if (webNav) webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);  else NS_WARNING("refreshing plugins: couldn't get webnav or docshell from gso"); } else NS_WARNING("refreshing plugins: could not get the global script object -- did the plugin set it?");
NS_NOTREACHED("all plugins should have a pres shell!");
nsresult nsPluginDocReframeEvent::HandlePluginDocReframeEvent() {      NS_ENSURE_TRUE(mDocs, NS_ERROR_FAILURE);    PRUint32 c;  mDocs->Count(&c);    // for each document (which previously had a running instance), tell  // the frame constructor to rebuild  for (PRUint32 i = 0; i < c; i++) {    nsCOMPtr<nsIDocument> doc (do_QueryElementAt(mDocs, i));    if (doc) {      nsCOMPtr<nsIPresShell> shell;      doc->GetShellAt(0, getter_AddRefs(shell));            // if this document has a presentation shell, then it has frames and can be reframed      if (shell) {        nsCOMPtr<nsIPresContext> pc;        nsCOMPtr<nsIStyleSet> set;        shell->GetPresContext(getter_AddRefs(pc));        shell->GetStyleSet(getter_AddRefs(set));        if (pc && set) {          nsCOMPtr<nsIStyleFrameConstruction> fc;          set->GetStyleFrameConstruction(getter_AddRefs(fc));          if (fc)                     /**          * A reframe will cause a fresh object frame, instance owner, and instance          * to be created. Reframing of the entire document is necessary as we may have          * recently found new plugins and we want a shot at trying to use them instead          * of leaving alternate renderings.          * We do not want to completely reload all the documents that had running plugins          * because we could possibly trigger a script to run in the unload event handler          * which may want to access our defunct plugin and cause us to crash.          */                      fc->ReconstructDocElementHierarchy(pc); // causes reframe of document        }      } else {  // no pres shell --> full-page plugin               /**        * This document does not have a presentation shell. It may be a full-page plugin.        * Full-page plugins don't really have the same problem of crashing because they        * are not currently scriptable. However, they do leave a non-painting, defunct        * window which doesn't look good. A reload of the page for full-page plugins        * is needed to kickstart the instance.        */                nsCOMPtr<nsIScriptGlobalObject> gso;        doc->GetScriptGlobalObject(getter_AddRefs(gso));        if (gso) {          nsCOMPtr<nsIDocShell> docShell;          gso->GetDocShell(getter_AddRefs(docShell));          nsCOMPtr<nsIWebNavigation> webNav (do_QueryInterface(docShell));          if (webNav)            webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);                    else NS_WARNING("refreshing plugins: couldn't get webnav or docshell from gso");        } else NS_WARNING("refreshing plugins: could not get the global script object -- did the plugin set it?");      }    }  }  return mDocs->Clear();}