Bug 969099 - Initialize nsPresContext::mIsChrome eagerly. r=roc
authorCameron McCormack <cam@mcc.id.au>
Fri, 07 Feb 2014 14:08:49 +1100
changeset 167420 3c925e73a1d0
parent 167419 d7c466f72d2a
child 167421 3b87641dd2f8
push id26168
push usercbook@mozilla.com
push date2014-02-07 08:51 +0000
treeherdermozilla-central@1ca0ce406aad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs969099
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 969099 - Initialize nsPresContext::mIsChrome eagerly. r=roc
docshell/base/nsDocShell.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -2891,17 +2891,17 @@ nsDocShell::SetItemType(int32_t aItemTyp
     mItemType = aItemType;
 
     // disable auth prompting for anything but content
     mAllowAuth = mItemType == typeContent; 
 
     nsRefPtr<nsPresContext> presContext = nullptr;
     GetPresContext(getter_AddRefs(presContext));
     if (presContext) {
-        presContext->InvalidateIsChromeCache();
+        presContext->UpdateIsChrome();
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetParent(nsIDocShellTreeItem ** aParent)
 {
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1545,17 +1545,17 @@ nsPresContext::ScreenWidthInchesForFontI
 void
 nsPresContext::SetContainer(nsIDocShell* aDocShell)
 {
   if (aDocShell) {
     mContainer = static_cast<nsDocShell*>(aDocShell)->asWeakPtr();
   } else {
     mContainer = WeakPtr<nsDocShell>();
   }
-  InvalidateIsChromeCache();
+  UpdateIsChrome();
   if (mContainer) {
     GetDocumentColorPreferences();
   }
 }
 
 nsISupports*
 nsPresContext::GetContainerWeakInternal() const
 {
@@ -2038,29 +2038,21 @@ void
 nsPresContext::CountReflows(const char * aName, nsIFrame * aFrame)
 {
   if (mShell) {
     mShell->CountReflows(aName, 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
 nsPresContext::HasAuthorSpecifiedRules(nsIFrame *aFrame, uint32_t ruleTypeMask) const
 {
   return
     nsRuleNode::HasAuthorSpecifiedRules(aFrame->StyleContext(),
                                         ruleTypeMask,
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -808,30 +808,18 @@ public:
   gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
 
   bool IsDynamic() { return (mType == eContext_PageLayout || mType == eContext_Galley); }
   bool IsScreen() { return (mMedium == nsGkAtoms::screen ||
                               mType == eContext_PageLayout ||
                               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;
 
   // Is it OK to let the page specify colors and backgrounds?
   bool UseDocumentColors() const {
     return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome();
   }
@@ -1309,21 +1297,17 @@ protected:
 
   unsigned              mIsVisual : 1;
 
   unsigned              mProcessingRestyles : 1;
   unsigned              mProcessingAnimationStyleChange : 1;
 
   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.
   mutable unsigned mPaintFlashing : 1;
   mutable unsigned mPaintFlashingInitialized : 1;
 
 #ifdef DEBUG
   bool                  mInitialized;