diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b874b4bd88d..87c1414af53 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2415,6 +2415,12 @@ nsDocShell::SetItemType(PRInt32 aItemType) // disable auth prompting for anything but content mAllowAuth = mItemType == typeContent; + nsRefPtr presContext = nsnull; + GetPresContext(getter_AddRefs(presContext)); + if (presContext) { + presContext->UpdateIsChromeCache(); + } + return NS_OK; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 360aebd2901..ee247d89901 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1335,6 +1335,7 @@ nsPresContext::SetContainer(nsISupports* aHandler) if (mContainer) { GetDocumentColorPreferences(); } + UpdateIsChromeCacheInternal(); } already_AddRefed @@ -1624,8 +1625,8 @@ nsPresContext::CountReflows(const char * aName, nsIFrame * aFrame) } #endif -PRBool -nsPresContext::IsChrome() const +void +nsPresContext::UpdateIsChromeCacheInternal() { PRBool isChrome = PR_FALSE; nsCOMPtr container = GetContainer(); @@ -1640,7 +1641,13 @@ nsPresContext::IsChrome() const } } } - return isChrome; + mIsChrome = isChrome; +} + +void +nsPresContext::UpdateIsChromeCacheExternal() +{ + UpdateIsChromeCacheInternal(); } /* virtual */ PRBool diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 845c7c502dc..2dddfa18756 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -810,7 +810,17 @@ public: mType == eContext_PrintPreview); } // Is this presentation in a chrome docshell? - PRBool IsChrome() const; + PRBool IsChrome() const { return mIsChrome; } + + virtual void UpdateIsChromeCacheExternal(); + void UpdateIsChromeCacheInternal(); +#ifdef _IMPL_NS_LAYOUT + void UpdateIsChromeCache() + { UpdateIsChromeCacheInternal(); } +#else + void UpdateIsChromeCache() + { UpdateIsChromeCacheExternal(); } +#endif // Public API for native theme code to get style internals. virtual PRBool HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const; @@ -1115,6 +1125,9 @@ protected: unsigned mProcessingRestyles : 1; unsigned mProcessingAnimationStyleChange : 1; + // Cache whether we are chrome or not because it is expensive. + unsigned mIsChrome : 1; + #ifdef DEBUG PRBool mInitialized; #endif