Bug 1297899 - Part 2: Rename RestyleManagerBase.{h,cpp} to RestyleManager.{h,cpp}. r=bholley
authorCameron McCormack <cam@mcc.id.au>
Mon, 13 Feb 2017 11:21:31 +0800
changeset 389619 09d3a31f1160e4f02cf2c1fdc4a1255503fea89b
parent 389618 f24f346ce8cdcbbbc028cf5321c371ad9d695d23
child 389620 27ebaadd9a7915cb67a5a63603f4fd8fb5358e95
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1297899
milestone54.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 1297899 - Part 2: Rename RestyleManagerBase.{h,cpp} to RestyleManager.{h,cpp}. r=bholley MozReview-Commit-ID: JVsfYommCoI
layout/base/GeckoRestyleManager.h
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
layout/base/RestyleManagerBase.cpp
layout/base/RestyleManagerBase.h
layout/base/ServoRestyleManager.h
layout/base/moz.build
layout/base/nsCSSFrameConstructor.h
--- a/layout/base/GeckoRestyleManager.h
+++ b/layout/base/GeckoRestyleManager.h
@@ -7,17 +7,17 @@
  * Code responsible for managing style changes: tracking what style
  * changes need to happen, scheduling them, and doing them.
  */
 
 #ifndef mozilla_RestyleManager_h
 #define mozilla_RestyleManager_h
 
 #include "mozilla/RestyleLogging.h"
-#include "mozilla/RestyleManagerBase.h"
+#include "mozilla/RestyleManager.h"
 #include "nsISupportsImpl.h"
 #include "nsChangeHint.h"
 #include "RestyleTracker.h"
 #include "nsPresContext.h"
 #include "nsRefreshDriver.h"
 #include "nsRefPtrHashtable.h"
 #include "nsTransitionManager.h"
 
rename from layout/base/RestyleManagerBase.cpp
rename to layout/base/RestyleManager.cpp
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "mozilla/RestyleManagerBase.h"
+#include "mozilla/RestyleManager.h"
 #include "mozilla/StyleSetHandleInlines.h"
 #include "nsIFrame.h"
 #include "nsIPresShellInlines.h"
 
 namespace mozilla {
 
 RestyleManagerBase::RestyleManagerBase(nsPresContext* aPresContext)
   : mPresContext(aPresContext)
new file mode 100644
--- /dev/null
+++ b/layout/base/RestyleManager.h
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_RestyleManagerBase_h
+#define mozilla_RestyleManagerBase_h
+
+#include "mozilla/OverflowChangedTracker.h"
+#include "nsChangeHint.h"
+#include "nsPresContext.h"
+
+class nsCString;
+class nsCSSFrameConstructor;
+class nsStyleChangeList;
+
+namespace mozilla {
+
+class EventStates;
+class RestyleManager;
+class ServoRestyleManager;
+
+namespace dom {
+class Element;
+}
+
+/**
+ * Class for sharing data and logic common to both RestyleManager and
+ * ServoRestyleManager.
+ */
+class RestyleManagerBase
+{
+protected:
+  explicit RestyleManagerBase(nsPresContext* aPresContext);
+
+public:
+  typedef mozilla::dom::Element Element;
+
+  // Get an integer that increments every time we process pending restyles.
+  // The value is never 0.
+  uint32_t GetRestyleGeneration() const { return mRestyleGeneration; }
+
+  // Get an integer that increments every time there is a style change
+  // as a result of a change to the :hover content state.
+  uint32_t GetHoverGeneration() const { return mHoverGeneration; }
+
+  bool ObservingRefreshDriver() const { return mObservingRefreshDriver; }
+
+  void SetObservingRefreshDriver(bool aObserving) {
+      mObservingRefreshDriver = aObserving;
+  }
+
+  void Disconnect() { mPresContext = nullptr; }
+
+  static nsCString RestyleHintToString(nsRestyleHint aHint);
+
+#ifdef DEBUG
+  static nsCString ChangeHintToString(nsChangeHint aHint);
+
+  /**
+   * DEBUG ONLY method to verify integrity of style tree versus frame tree
+   */
+  void DebugVerifyStyleTree(nsIFrame* aFrame);
+#endif
+
+  void FlushOverflowChangedTracker() {
+    mOverflowChangedTracker.Flush();
+  }
+
+  // Should be called when a frame is going to be destroyed and
+  // WillDestroyFrameTree hasn't been called yet.
+  void NotifyDestroyingFrame(nsIFrame* aFrame) {
+    mOverflowChangedTracker.RemoveFrame(aFrame);
+  }
+
+  // Note: It's the caller's responsibility to make sure to wrap a
+  // ProcessRestyledFrames call in a view update batch and a script blocker.
+  // This function does not call ProcessAttachedQueue() on the binding manager.
+  // If the caller wants that to happen synchronously, it needs to handle that
+  // itself.
+  nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
+
+  bool IsInStyleRefresh() const { return mInStyleRefresh; }
+
+  // AnimationsWithDestroyedFrame is used to stop animations and transitions
+  // on elements that have no frame at the end of the restyling process.
+  // It only lives during the restyling process.
+  class MOZ_STACK_CLASS AnimationsWithDestroyedFrame final {
+  public:
+    // Construct a AnimationsWithDestroyedFrame 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 AnimationsWithDestroyedFrame(RestyleManagerBase* aRestyleManager);
+
+    // This method takes the content node for the generated content for
+    // animation/transition on ::before and ::after, rather than the
+    // content node for the real element.
+    void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
+      MOZ_ASSERT(aContent);
+      CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
+      if (pseudoType == CSSPseudoElementType::NotPseudo) {
+        mContents.AppendElement(aContent);
+      } else if (pseudoType == CSSPseudoElementType::before) {
+        MOZ_ASSERT(aContent->NodeInfo()->NameAtom() ==
+                     nsGkAtoms::mozgeneratedcontentbefore);
+        mBeforeContents.AppendElement(aContent->GetParent());
+      } else if (pseudoType == CSSPseudoElementType::after) {
+        MOZ_ASSERT(aContent->NodeInfo()->NameAtom() ==
+                     nsGkAtoms::mozgeneratedcontentafter);
+        mAfterContents.AppendElement(aContent->GetParent());
+      }
+    }
+
+    void StopAnimationsForElementsWithoutFrames();
+
+  private:
+    void StopAnimationsWithoutFrame(nsTArray<RefPtr<nsIContent>>& aArray,
+                                    CSSPseudoElementType aPseudoType);
+
+    RestyleManagerBase* mRestyleManager;
+    AutoRestore<AnimationsWithDestroyedFrame*> mRestorePointer;
+
+    // Below three arrays might include elements that have already had their
+    // animations or transitions stopped.
+    //
+    // mBeforeContents and mAfterContents hold the real element rather than
+    // the content node for the generated content (which might change during
+    // a reframe)
+    nsTArray<RefPtr<nsIContent>> mContents;
+    nsTArray<RefPtr<nsIContent>> mBeforeContents;
+    nsTArray<RefPtr<nsIContent>> mAfterContents;
+  };
+
+  /**
+   * Return the current AnimationsWithDestroyedFrame struct, or null if we're
+   * not currently in a restyling operation.
+   */
+  AnimationsWithDestroyedFrame* GetAnimationsWithDestroyedFrame() {
+    return mAnimationsWithDestroyedFrame;
+  }
+
+protected:
+  ~RestyleManagerBase() {
+    MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
+               "leaving dangling pointers from AnimationsWithDestroyedFrame");
+  }
+
+  void ContentStateChangedInternal(Element* aElement,
+                                   EventStates aStateMask,
+                                   nsChangeHint* aOutChangeHint,
+                                   nsRestyleHint* aOutRestyleHint);
+
+  bool IsDisconnected() { return mPresContext == nullptr; }
+
+  void IncrementHoverGeneration() {
+    ++mHoverGeneration;
+  }
+
+  void IncrementRestyleGeneration() {
+    if (++mRestyleGeneration == 0) {
+      // Keep mRestyleGeneration from being 0, since that's what
+      // nsPresContext::GetRestyleGeneration returns when it no
+      // longer has a RestyleManager.
+      ++mRestyleGeneration;
+    }
+  }
+
+  nsPresContext* PresContext() const {
+    MOZ_ASSERT(mPresContext);
+    return mPresContext;
+  }
+
+  nsCSSFrameConstructor* FrameConstructor() const {
+    return PresContext()->FrameConstructor();
+  }
+
+  inline bool IsGecko() const {
+    return !IsServo();
+  }
+
+  inline bool IsServo() const {
+#ifdef MOZ_STYLO
+    return PresContext()->StyleSet()->IsServo();
+#else
+    return false;
+#endif
+  }
+
+private:
+  nsPresContext* mPresContext; // weak, can be null after Disconnect().
+  uint32_t mRestyleGeneration;
+  uint32_t mHoverGeneration;
+  // True if we're already waiting for a refresh notification.
+  bool mObservingRefreshDriver;
+
+protected:
+  // True if we're in the middle of a nsRefreshDriver refresh
+  bool mInStyleRefresh;
+
+  OverflowChangedTracker mOverflowChangedTracker;
+
+  void PostRestyleEventInternal(bool aForLazyConstruction);
+
+  /**
+   * These are protected static methods that help with the change hint
+   * processing bits of the restyle managers.
+   */
+  static nsIFrame*
+  GetNearestAncestorFrame(nsIContent* aContent);
+
+  static nsIFrame*
+  GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame);
+
+  /**
+   * Get the next continuation or similar ib-split sibling (assuming
+   * block/inline alternation), conditionally on it having the same style.
+   *
+   * Since this is used when deciding to copy the new style context, it
+   * takes as an argument the old style context to check if the style is
+   * the same.  When it is used in other contexts (i.e., where the next
+   * continuation would already have the new style context), the current
+   * style context should be passed.
+   */
+  static nsIFrame*
+  GetNextContinuationWithSameStyle(nsIFrame* aFrame,
+                                   nsStyleContext* aOldStyleContext,
+                                   bool* aHaveMoreContinuations = nullptr);
+
+  AnimationsWithDestroyedFrame* mAnimationsWithDestroyedFrame = nullptr;
+};
+
+} // namespace mozilla
+
+#endif
deleted file mode 100644
--- a/layout/base/RestyleManagerBase.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_RestyleManagerBase_h
-#define mozilla_RestyleManagerBase_h
-
-#include "mozilla/OverflowChangedTracker.h"
-#include "nsChangeHint.h"
-#include "nsPresContext.h"
-
-class nsCString;
-class nsCSSFrameConstructor;
-class nsStyleChangeList;
-
-namespace mozilla {
-
-class EventStates;
-class RestyleManager;
-class ServoRestyleManager;
-
-namespace dom {
-class Element;
-}
-
-/**
- * Class for sharing data and logic common to both RestyleManager and
- * ServoRestyleManager.
- */
-class RestyleManagerBase
-{
-protected:
-  explicit RestyleManagerBase(nsPresContext* aPresContext);
-
-public:
-  typedef mozilla::dom::Element Element;
-
-  // Get an integer that increments every time we process pending restyles.
-  // The value is never 0.
-  uint32_t GetRestyleGeneration() const { return mRestyleGeneration; }
-
-  // Get an integer that increments every time there is a style change
-  // as a result of a change to the :hover content state.
-  uint32_t GetHoverGeneration() const { return mHoverGeneration; }
-
-  bool ObservingRefreshDriver() const { return mObservingRefreshDriver; }
-
-  void SetObservingRefreshDriver(bool aObserving) {
-      mObservingRefreshDriver = aObserving;
-  }
-
-  void Disconnect() { mPresContext = nullptr; }
-
-  static nsCString RestyleHintToString(nsRestyleHint aHint);
-
-#ifdef DEBUG
-  static nsCString ChangeHintToString(nsChangeHint aHint);
-
-  /**
-   * DEBUG ONLY method to verify integrity of style tree versus frame tree
-   */
-  void DebugVerifyStyleTree(nsIFrame* aFrame);
-#endif
-
-  void FlushOverflowChangedTracker() {
-    mOverflowChangedTracker.Flush();
-  }
-
-  // Should be called when a frame is going to be destroyed and
-  // WillDestroyFrameTree hasn't been called yet.
-  void NotifyDestroyingFrame(nsIFrame* aFrame) {
-    mOverflowChangedTracker.RemoveFrame(aFrame);
-  }
-
-  // Note: It's the caller's responsibility to make sure to wrap a
-  // ProcessRestyledFrames call in a view update batch and a script blocker.
-  // This function does not call ProcessAttachedQueue() on the binding manager.
-  // If the caller wants that to happen synchronously, it needs to handle that
-  // itself.
-  nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
-
-  bool IsInStyleRefresh() const { return mInStyleRefresh; }
-
-  // AnimationsWithDestroyedFrame is used to stop animations and transitions
-  // on elements that have no frame at the end of the restyling process.
-  // It only lives during the restyling process.
-  class MOZ_STACK_CLASS AnimationsWithDestroyedFrame final {
-  public:
-    // Construct a AnimationsWithDestroyedFrame 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 AnimationsWithDestroyedFrame(RestyleManagerBase* aRestyleManager);
-
-    // This method takes the content node for the generated content for
-    // animation/transition on ::before and ::after, rather than the
-    // content node for the real element.
-    void Put(nsIContent* aContent, nsStyleContext* aStyleContext) {
-      MOZ_ASSERT(aContent);
-      CSSPseudoElementType pseudoType = aStyleContext->GetPseudoType();
-      if (pseudoType == CSSPseudoElementType::NotPseudo) {
-        mContents.AppendElement(aContent);
-      } else if (pseudoType == CSSPseudoElementType::before) {
-        MOZ_ASSERT(aContent->NodeInfo()->NameAtom() ==
-                     nsGkAtoms::mozgeneratedcontentbefore);
-        mBeforeContents.AppendElement(aContent->GetParent());
-      } else if (pseudoType == CSSPseudoElementType::after) {
-        MOZ_ASSERT(aContent->NodeInfo()->NameAtom() ==
-                     nsGkAtoms::mozgeneratedcontentafter);
-        mAfterContents.AppendElement(aContent->GetParent());
-      }
-    }
-
-    void StopAnimationsForElementsWithoutFrames();
-
-  private:
-    void StopAnimationsWithoutFrame(nsTArray<RefPtr<nsIContent>>& aArray,
-                                    CSSPseudoElementType aPseudoType);
-
-    RestyleManagerBase* mRestyleManager;
-    AutoRestore<AnimationsWithDestroyedFrame*> mRestorePointer;
-
-    // Below three arrays might include elements that have already had their
-    // animations or transitions stopped.
-    //
-    // mBeforeContents and mAfterContents hold the real element rather than
-    // the content node for the generated content (which might change during
-    // a reframe)
-    nsTArray<RefPtr<nsIContent>> mContents;
-    nsTArray<RefPtr<nsIContent>> mBeforeContents;
-    nsTArray<RefPtr<nsIContent>> mAfterContents;
-  };
-
-  /**
-   * Return the current AnimationsWithDestroyedFrame struct, or null if we're
-   * not currently in a restyling operation.
-   */
-  AnimationsWithDestroyedFrame* GetAnimationsWithDestroyedFrame() {
-    return mAnimationsWithDestroyedFrame;
-  }
-
-protected:
-  ~RestyleManagerBase() {
-    MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
-               "leaving dangling pointers from AnimationsWithDestroyedFrame");
-  }
-
-  void ContentStateChangedInternal(Element* aElement,
-                                   EventStates aStateMask,
-                                   nsChangeHint* aOutChangeHint,
-                                   nsRestyleHint* aOutRestyleHint);
-
-  bool IsDisconnected() { return mPresContext == nullptr; }
-
-  void IncrementHoverGeneration() {
-    ++mHoverGeneration;
-  }
-
-  void IncrementRestyleGeneration() {
-    if (++mRestyleGeneration == 0) {
-      // Keep mRestyleGeneration from being 0, since that's what
-      // nsPresContext::GetRestyleGeneration returns when it no
-      // longer has a RestyleManager.
-      ++mRestyleGeneration;
-    }
-  }
-
-  nsPresContext* PresContext() const {
-    MOZ_ASSERT(mPresContext);
-    return mPresContext;
-  }
-
-  nsCSSFrameConstructor* FrameConstructor() const {
-    return PresContext()->FrameConstructor();
-  }
-
-  inline bool IsGecko() const {
-    return !IsServo();
-  }
-
-  inline bool IsServo() const {
-#ifdef MOZ_STYLO
-    return PresContext()->StyleSet()->IsServo();
-#else
-    return false;
-#endif
-  }
-
-private:
-  nsPresContext* mPresContext; // weak, can be null after Disconnect().
-  uint32_t mRestyleGeneration;
-  uint32_t mHoverGeneration;
-  // True if we're already waiting for a refresh notification.
-  bool mObservingRefreshDriver;
-
-protected:
-  // True if we're in the middle of a nsRefreshDriver refresh
-  bool mInStyleRefresh;
-
-  OverflowChangedTracker mOverflowChangedTracker;
-
-  void PostRestyleEventInternal(bool aForLazyConstruction);
-
-  /**
-   * These are protected static methods that help with the change hint
-   * processing bits of the restyle managers.
-   */
-  static nsIFrame*
-  GetNearestAncestorFrame(nsIContent* aContent);
-
-  static nsIFrame*
-  GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame);
-
-  /**
-   * Get the next continuation or similar ib-split sibling (assuming
-   * block/inline alternation), conditionally on it having the same style.
-   *
-   * Since this is used when deciding to copy the new style context, it
-   * takes as an argument the old style context to check if the style is
-   * the same.  When it is used in other contexts (i.e., where the next
-   * continuation would already have the new style context), the current
-   * style context should be passed.
-   */
-  static nsIFrame*
-  GetNextContinuationWithSameStyle(nsIFrame* aFrame,
-                                   nsStyleContext* aOldStyleContext,
-                                   bool* aHaveMoreContinuations = nullptr);
-
-  AnimationsWithDestroyedFrame* mAnimationsWithDestroyedFrame = nullptr;
-};
-
-} // namespace mozilla
-
-#endif
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_ServoRestyleManager_h
 #define mozilla_ServoRestyleManager_h
 
 #include "mozilla/DocumentStyleRootIterator.h"
 #include "mozilla/EventStates.h"
-#include "mozilla/RestyleManagerBase.h"
+#include "mozilla/RestyleManager.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "nsChangeHint.h"
 #include "nsHashKeys.h"
 #include "nsINode.h"
 #include "nsISupportsImpl.h"
 #include "nsPresContext.h"
 
--- a/layout/base/moz.build
+++ b/layout/base/moz.build
@@ -71,17 +71,17 @@ EXPORTS.mozilla += [
     'ArenaObjectID.h',
     'ArenaRefPtr.h',
     'ArenaRefPtrInlines.h',
     'GeckoRestyleManager.h',
     'GeometryUtils.h',
     'OverflowChangedTracker.h',
     'PresShell.h',
     'RestyleLogging.h',
-    'RestyleManagerBase.h',
+    'RestyleManager.h',
     'RestyleManagerHandle.h',
     'RestyleManagerHandleInlines.h',
     'ServoRestyleManager.h',
     'ShapeUtils.h',
     'StaticPresData.h',
 ]
 
 UNIFIED_SOURCES += [
@@ -106,17 +106,17 @@ UNIFIED_SOURCES += [
     'nsLayoutHistoryState.cpp',
     'nsLayoutUtils.cpp',
     'nsPresContext.cpp',
     'nsQuoteList.cpp',
     'nsStyleChangeList.cpp',
     'nsStyleSheetService.cpp',
     'PositionedEventTargeting.cpp',
     'PresShell.cpp',
-    'RestyleManagerBase.cpp',
+    'RestyleManager.cpp',
     'RestyleTracker.cpp',
     'ScrollbarStyles.cpp',
     'ServoRestyleManager.cpp',
     'ShapeUtils.cpp',
     'StackArena.cpp',
     'StaticPresData.cpp',
     'TouchManager.cpp',
     'ZoomConstraintsClient.cpp',
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -8,17 +8,17 @@
  * tree and updating of that tree in response to dynamic changes
  */
 
 #ifndef nsCSSFrameConstructor_h___
 #define nsCSSFrameConstructor_h___
 
 #include "mozilla/Attributes.h"
 #include "mozilla/LinkedList.h"
-#include "mozilla/RestyleManagerBase.h"
+#include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerHandle.h"
 
 #include "nsCOMPtr.h"
 #include "nsILayoutHistoryState.h"
 #include "nsQuoteList.h"
 #include "nsCounterManager.h"
 #include "nsIAnonymousContentCreator.h"
 #include "nsFrameManager.h"