Bug 1110277 patch 4 - Add a RestyleManager member to ReframingStyleContexts. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Tue, 13 Jan 2015 21:03:13 -0800
changeset 223722 a616039ccd7ba1705eec98a10c8e892b8bcf0842
parent 223721 e12e9be31708823df8f30ebdcbbc4f01223071d0
child 223723 b232139eb2c79e32980e40d85315e524c41e1bc1
push id10811
push usercbook@mozilla.com
push dateWed, 14 Jan 2015 13:52:17 +0000
treeherderfx-team@b8d38d19dbd9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1110277
milestone38.0a1
Bug 1110277 patch 4 - Add a RestyleManager member to ReframingStyleContexts. r=heycam This is needed for patch 7.
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -979,16 +979,22 @@ RestyleManager::RestyleElement(Element* 
         newContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS) {
       // Style change for a display:contents node that did not recreate frames.
       ComputeAndProcessStyleChange(newContext, aElement, aMinHint,
                                    aRestyleTracker, aRestyleHint);
     }
   }
 }
 
+RestyleManager::ReframingStyleContexts::ReframingStyleContexts(
+                                          RestyleManager* aRestyleManager)
+  : mRestyleManager(aRestyleManager)
+{
+}
+
 static inline dom::Element*
 ElementForStyleContext(nsIContent* aParentContent,
                        nsIFrame* aFrame,
                        nsCSSPseudoElements::Type aPseudoType);
 
 // Forwarded nsIDocumentObserver method, to handle restyling (and
 // passing the notification to the frame).
 nsresult
@@ -3903,17 +3909,17 @@ RestyleManager::ComputeAndProcessStyleCh
                                              nsChangeHint       aMinChange,
                                              RestyleTracker&    aRestyleTracker,
                                              nsRestyleHint      aRestyleHint)
 {
   // Create a ReframingStyleContexts struct on the stack and put it in
   // our mReframingStyleContexts for the scope of this function.
   MOZ_ASSERT(!mReframingStyleContexts, "shouldn't call recursively");
   AutoRestore<ReframingStyleContexts*> ar(mReframingStyleContexts);
-  ReframingStyleContexts reframingStyleContexts;
+  ReframingStyleContexts reframingStyleContexts(this);
   mReframingStyleContexts = &reframingStyleContexts;
 
   nsStyleChangeList changeList;
   ElementRestyler::ComputeStyleChangeFor(aFrame, &changeList, aMinChange,
                                          aRestyleTracker, aRestyleHint);
   ProcessRestyledFrames(changeList);
 }
 
@@ -3923,17 +3929,17 @@ RestyleManager::ComputeAndProcessStyleCh
                                              nsChangeHint       aMinChange,
                                              RestyleTracker&    aRestyleTracker,
                                              nsRestyleHint      aRestyleHint)
 {
   // Create a ReframingStyleContexts struct on the stack and put it in
   // our mReframingStyleContexts for the scope of this function.
   MOZ_ASSERT(!mReframingStyleContexts, "shouldn't call recursively");
   AutoRestore<ReframingStyleContexts*> ar(mReframingStyleContexts);
-  ReframingStyleContexts reframingStyleContexts;
+  ReframingStyleContexts reframingStyleContexts(this);
   mReframingStyleContexts = &reframingStyleContexts;
 
   MOZ_ASSERT(aNewContext->StyleDisplay()->mDisplay == NS_STYLE_DISPLAY_CONTENTS);
   nsIFrame* frame = GetNearestAncestorFrame(aElement);
   MOZ_ASSERT(frame, "display:contents node in map although it's a "
                     "display:none descendant?");
   TreeMatchContext treeMatchContext(true,
                                     nsRuleWalker::eRelevantLinkUnvisited,
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -176,18 +176,26 @@ public:
    * In all cases, the content node in the hash table is the real
    * content node, not the anonymous content node we create for ::before
    * or ::after.  The content node passed to the Get and Put methods is,
    * however, the content node to be associate with the frame's style
    * context.
    */
   typedef nsRefPtrHashtable<nsRefPtrHashKey<nsIContent>, nsStyleContext>
             ReframingStyleContextTable;
-  class ReframingStyleContexts {
+  class MOZ_STACK_CLASS ReframingStyleContexts {
   public:
+    /**
+     * Construct a ReframingStyleContexts object.  The caller must
+     * ensure that aRestyleManager lives at least as long as the
+     * object.  (This is generally easy since the caller is typically a
+     * method of RestyleManager.)
+     */
+    explicit ReframingStyleContexts(RestyleManager* aRestyleManager);
+
     void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
       MOZ_ASSERT(aContent);
       nsCSSPseudoElements::Type pseudoType = aStyleContext->GetPseudoType();
       if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
         mElementContexts.Put(aContent, aStyleContext);
       } else if (pseudoType == nsCSSPseudoElements::ePseudo_before) {
         MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentbefore);
         mBeforePseudoContexts.Put(aContent->GetParent(), aStyleContext);
@@ -210,16 +218,17 @@ public:
       if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
         MOZ_ASSERT(aContent->Tag() == nsGkAtoms::mozgeneratedcontentafter);
         return mAfterPseudoContexts.GetWeak(aContent->GetParent());
       }
       MOZ_ASSERT(false, "unexpected aPseudoType");
       return nullptr;
     }
   private:
+    RestyleManager* mRestyleManager;
     ReframingStyleContextTable mElementContexts;
     ReframingStyleContextTable mBeforePseudoContexts;
     ReframingStyleContextTable mAfterPseudoContexts;
   };
 
   /**
    * Return the current ReframingStyleContexts struct, or null if we're
    * not currently in a restyling operation.