Bug 1297899 - Part 4: Store concrete restyle manager type on RestyleManager. r?bholley
MozReview-Commit-ID: AmsNPqPVm8c
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -79,17 +79,17 @@ ElementTagToString(dom::Element* aElemen
nsCString result;
nsDependentAtomString buf(aElement->NodeInfo()->NameAtom());
result.AppendPrintf("(%s@%p)", NS_ConvertUTF16toUTF8(buf).get(), aElement);
return result;
}
#endif
GeckoRestyleManager::GeckoRestyleManager(nsPresContext* aPresContext)
- : RestyleManager(aPresContext)
+ : RestyleManager(StyleBackendType::Gecko, aPresContext)
, mDoRebuildAllStyleData(false)
, mInRebuildAllStyleData(false)
, mSkipAnimationRules(false)
, mHavePendingNonAnimationRestyles(false)
, mRebuildAllExtraHint(nsChangeHint(0))
, mRebuildAllRestyleHint(nsRestyleHint(0))
, mAnimationGeneration(0)
, mReframingStyleContexts(nullptr)
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -6,20 +6,22 @@
#include "mozilla/RestyleManager.h"
#include "mozilla/StyleSetHandleInlines.h"
#include "nsIFrame.h"
#include "nsIPresShellInlines.h"
namespace mozilla {
-RestyleManager::RestyleManager(nsPresContext* aPresContext)
+RestyleManager::RestyleManager(StyleBackendType aType,
+ nsPresContext* aPresContext)
: mPresContext(aPresContext)
, mRestyleGeneration(1)
, mHoverGeneration(0)
+ , mType(aType)
, mObservingRefreshDriver(false)
, mInStyleRefresh(false)
{
MOZ_ASSERT(mPresContext);
}
/**
* Calculates the change hint and the restyle hint for a given content state
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -27,17 +27,17 @@ class Element;
/**
* Class for sharing data and logic common to both GeckoRestyleManager and
* ServoRestyleManager.
*/
class RestyleManager
{
protected:
- explicit RestyleManager(nsPresContext* aPresContext);
+ RestyleManager(StyleBackendType aType, 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; }
@@ -171,32 +171,25 @@ protected:
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
- }
+ MOZ_DECL_STYLO_METHODS(GeckoRestyleManager, ServoRestyleManager)
private:
nsPresContext* mPresContext; // weak, can be null after Disconnect().
uint32_t mRestyleGeneration;
uint32_t mHoverGeneration;
+
+ const StyleBackendType mType;
+
// 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;
@@ -224,13 +217,16 @@ protected:
* style context should be passed.
*/
static nsIFrame*
GetNextContinuationWithSameStyle(nsIFrame* aFrame,
nsStyleContext* aOldStyleContext,
bool* aHaveMoreContinuations = nullptr);
AnimationsWithDestroyedFrame* mAnimationsWithDestroyedFrame = nullptr;
+
+ friend class mozilla::GeckoRestyleManager;
+ friend class mozilla::ServoRestyleManager;
};
} // namespace mozilla
#endif
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -14,17 +14,17 @@
#include "nsPrintfCString.h"
#include "nsStyleChangeList.h"
using namespace mozilla::dom;
namespace mozilla {
ServoRestyleManager::ServoRestyleManager(nsPresContext* aPresContext)
- : RestyleManager(aPresContext)
+ : RestyleManager(StyleBackendType::Servo, aPresContext)
, mReentrantChanges(nullptr)
{
}
void
ServoRestyleManager::PostRestyleEvent(Element* aElement,
nsRestyleHint aRestyleHint,
nsChangeHint aMinChangeHint)