Bug 969099 - Initialize nsPresContext::mIsChrome eagerly. r=roc

This commit is contained in:
Cameron McCormack 2014-02-07 14:08:49 +11:00
parent 00049bd7e5
commit 8ed1a22ca0
3 changed files with 7 additions and 31 deletions

View File

@ -2896,7 +2896,7 @@ nsDocShell::SetItemType(int32_t aItemType)
nsRefPtr<nsPresContext> presContext = nullptr;
GetPresContext(getter_AddRefs(presContext));
if (presContext) {
presContext->InvalidateIsChromeCache();
presContext->UpdateIsChrome();
}
return NS_OK;

View File

@ -1550,7 +1550,7 @@ nsPresContext::SetContainer(nsIDocShell* aDocShell)
} else {
mContainer = WeakPtr<nsDocShell>();
}
InvalidateIsChromeCache();
UpdateIsChrome();
if (mContainer) {
GetDocumentColorPreferences();
}
@ -2043,19 +2043,11 @@ nsPresContext::CountReflows(const char * aName, nsIFrame * aFrame)
}
#endif
bool
nsPresContext::IsChromeSlow() const
void
nsPresContext::UpdateIsChrome()
{
mIsChrome = mContainer &&
nsIDocShellTreeItem::typeChrome == mContainer->ItemType();
mIsChromeIsCached = true;
return mIsChrome;
}
void
nsPresContext::InvalidateIsChromeCacheExternal()
{
InvalidateIsChromeCacheInternal();
}
/* virtual */ bool

View File

@ -813,20 +813,8 @@ public:
mType == eContext_PrintPreview); }
// Is this presentation in a chrome docshell?
bool IsChrome() const
{
return mIsChromeIsCached ? mIsChrome : IsChromeSlow();
}
virtual void InvalidateIsChromeCacheExternal();
void InvalidateIsChromeCacheInternal() { mIsChromeIsCached = false; }
#ifdef MOZILLA_INTERNAL_API
void InvalidateIsChromeCache()
{ InvalidateIsChromeCacheInternal(); }
#else
void InvalidateIsChromeCache()
{ InvalidateIsChromeCacheExternal(); }
#endif
bool IsChrome() const { return mIsChrome; }
void UpdateIsChrome();
// Public API for native theme code to get style internals.
virtual bool HasAuthorSpecifiedRules(nsIFrame *aFrame, uint32_t ruleTypeMask) const;
@ -1314,11 +1302,7 @@ protected:
unsigned mFireAfterPaintEvents : 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.
mutable unsigned mIsChromeIsCached : 1;
mutable unsigned mIsChrome : 1;
unsigned mIsChrome : 1;
// Should we paint flash in this context? Do not use this variable directly.
// Use GetPaintFlashing() method instead.