if (mMedium != nsLayoutAtoms::print && baseURI) { PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; baseURI->SchemeIs("chrome", &isChrome); baseURI->SchemeIs("resource", &isRes);  if (!isChrome && !isRes) mImageAnimationMode = mImageAnimationModePref; else mImageAnimationMode = imgIContainer::kNormalAnimMode; }  if (mLangService) { doc->AddCharSetObserver(this); UpdateCharSet(doc->GetDocumentCharacterSet());
if (mLangService) { nsAutoString charset; doc->AddCharSetObserver(this); doc->GetDocumentCharacterSet(charset); UpdateCharSet(charset.get()); }
nsPresContext::SetShell(nsIPresShell* aShell){  if (mShell) {    // Remove ourselves as the charset observer from the shell's doc, because    // this shell may be going away for good.    nsIDocument *doc = mShell->GetDocument();    if (doc) {      doc->RemoveCharSetObserver(this);    }  }      mShell = aShell;  if (mShell) {    nsIDocument *doc = mShell->GetDocument();    NS_ASSERTION(doc, "expect document here");    if (doc) {      nsIURI *baseURI = doc->GetBaseURI();      if (mMedium != nsLayoutAtoms::print && baseURI) {        PRBool isChrome = PR_FALSE;        PRBool isRes = PR_FALSE;        baseURI->SchemeIs("chrome", &isChrome);        baseURI->SchemeIs("resource", &isRes);        if (!isChrome && !isRes)          mImageAnimationMode = mImageAnimationModePref;        else          mImageAnimationMode = imgIContainer::kNormalAnimMode;      }      if (mLangService) {        doc->AddCharSetObserver(this);        UpdateCharSet(doc->GetDocumentCharacterSet());      }    }  }}