зеркало из https://github.com/mozilla/gecko-dev.git
Bug 553359. Cache whether the PresContext is chrome or not. r=bzbarsky
This commit is contained in:
Родитель
215ce3cb75
Коммит
9166d4f4fe
|
@ -2415,6 +2415,12 @@ nsDocShell::SetItemType(PRInt32 aItemType)
|
|||
// disable auth prompting for anything but content
|
||||
mAllowAuth = mItemType == typeContent;
|
||||
|
||||
nsRefPtr<nsPresContext> presContext = nsnull;
|
||||
GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext) {
|
||||
presContext->InvalidateIsChromeCache();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1332,6 +1332,7 @@ void
|
|||
nsPresContext::SetContainer(nsISupports* aHandler)
|
||||
{
|
||||
mContainer = do_GetWeakReference(aHandler);
|
||||
mIsChromeIsCached = PR_FALSE;
|
||||
if (mContainer) {
|
||||
GetDocumentColorPreferences();
|
||||
}
|
||||
|
@ -1646,7 +1647,7 @@ nsPresContext::CountReflows(const char * aName, nsIFrame * aFrame)
|
|||
#endif
|
||||
|
||||
PRBool
|
||||
nsPresContext::IsChrome() const
|
||||
nsPresContext::IsChromeSlow()
|
||||
{
|
||||
PRBool isChrome = PR_FALSE;
|
||||
nsCOMPtr<nsISupports> container = GetContainer();
|
||||
|
@ -1661,11 +1662,25 @@ nsPresContext::IsChrome() const
|
|||
}
|
||||
}
|
||||
}
|
||||
return isChrome;
|
||||
mIsChrome = isChrome;
|
||||
mIsChromeIsCached = PR_TRUE;
|
||||
return mIsChrome;
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::InvalidateIsChromeCacheInternal()
|
||||
{
|
||||
mIsChromeIsCached = PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::InvalidateIsChromeCacheExternal()
|
||||
{
|
||||
InvalidateIsChromeCacheInternal();
|
||||
}
|
||||
|
||||
/* virtual */ PRBool
|
||||
nsPresContext::HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const
|
||||
nsPresContext::HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask)
|
||||
{
|
||||
return
|
||||
nsRuleNode::HasAuthorSpecifiedRules(aFrame->GetStyleContext(),
|
||||
|
|
|
@ -810,13 +810,26 @@ public:
|
|||
mType == eContext_PrintPreview); }
|
||||
|
||||
// Is this presentation in a chrome docshell?
|
||||
PRBool IsChrome() const;
|
||||
PRBool IsChrome()
|
||||
{
|
||||
return mIsChromeIsCached ? mIsChrome : IsChromeSlow();
|
||||
}
|
||||
|
||||
virtual void InvalidateIsChromeCacheExternal();
|
||||
void InvalidateIsChromeCacheInternal();
|
||||
#ifdef _IMPL_NS_LAYOUT
|
||||
void InvalidateIsChromeCache()
|
||||
{ InvalidateIsChromeCacheInternal(); }
|
||||
#else
|
||||
void InvalidateIsChromeCache()
|
||||
{ InvalidateIsChromeCacheExternal(); }
|
||||
#endif
|
||||
|
||||
// Public API for native theme code to get style internals.
|
||||
virtual PRBool HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask) const;
|
||||
virtual PRBool HasAuthorSpecifiedRules(nsIFrame *aFrame, PRUint32 ruleTypeMask);
|
||||
|
||||
// Is it OK to let the page specify colors and backgrounds?
|
||||
PRBool UseDocumentColors() const {
|
||||
PRBool UseDocumentColors() {
|
||||
return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome();
|
||||
}
|
||||
|
||||
|
@ -980,6 +993,8 @@ protected:
|
|||
// Can't be inline because we can't include nsStyleSet.h.
|
||||
PRBool HasCachedStyleData();
|
||||
|
||||
PRBool IsChromeSlow();
|
||||
|
||||
// IMPORTANT: The ownership implicit in the following member variables
|
||||
// has been explicitly checked. If you add any members to this class,
|
||||
// please make the ownership explicit (pinkerton, scc).
|
||||
|
@ -1115,6 +1130,12 @@ protected:
|
|||
unsigned mProcessingRestyles : 1;
|
||||
unsigned mProcessingAnimationStyleChange : 1;
|
||||
|
||||
// Cache whether we are chrome or not because it is expensive.
|
||||
// mIsChromeIsCached tells us if mIsChrome is valid or we need to get the
|
||||
// value the slow way.
|
||||
unsigned mIsChromeIsCached : 1;
|
||||
unsigned mIsChrome : 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool mInitialized;
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче