Bug 1290335: Reuse the OverflowChangedTracker between both restyle managers.
MozReview-Commit-ID: objnqfecZD
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -101,22 +101,16 @@ RestyleManager::RestyleManager(nsPresCon
#ifdef RESTYLE_LOGGING
, mLoggingDepth(0)
#endif
{
mPendingRestyles.Init(this);
}
void
-RestyleManager::NotifyDestroyingFrame(nsIFrame* aFrame)
-{
- mOverflowChangedTracker.RemoveFrame(aFrame);
-}
-
-void
RestyleManager::RestyleElement(Element* aElement,
nsIFrame* aPrimaryFrame,
nsChangeHint aMinHint,
RestyleTracker& aRestyleTracker,
nsRestyleHint aRestyleHint,
const RestyleHintData& aRestyleHintData)
{
MOZ_ASSERT(mReframingStyleContexts, "should have rsc");
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -52,20 +52,16 @@ private:
"temporary member should be nulled out before destruction");
MOZ_ASSERT(!mAnimationsWithDestroyedFrame,
"leaving dangling pointers from AnimationsWithDestroyedFrame");
}
public:
NS_INLINE_DECL_REFCOUNTING(mozilla::RestyleManager)
- // Should be called when a frame is going to be destroyed and
- // WillDestroyFrameTree hasn't been called yet.
- void NotifyDestroyingFrame(nsIFrame* aFrame);
-
// Forwarded nsIDocumentObserver method, to handle restyling (and
// passing the notification to the frame).
nsresult ContentStateChanged(nsIContent* aContent,
EventStates aStateMask);
// Forwarded nsIMutationObserver method, to handle restyling.
void AttributeWillChange(Element* aElement,
int32_t aNameSpaceID,
@@ -390,21 +386,16 @@ public:
nsChangeHint aMinChangeHint,
const RestyleHintData* aRestyleHintData = nullptr);
void PostRestyleEventForLazyConstruction()
{
PostRestyleEventInternal(true);
}
- void FlushOverflowChangedTracker()
- {
- mOverflowChangedTracker.Flush();
- }
-
#ifdef DEBUG
static nsCString ChangeHintToString(nsChangeHint aHint);
#endif
private:
void PostRestyleEventInternal(bool aForLazyConstruction);
public:
@@ -514,18 +505,16 @@ private:
bool mInStyleRefresh : 1;
// Whether rule matching should skip styles associated with animation
bool mSkipAnimationRules : 1;
bool mHavePendingNonAnimationRestyles : 1;
nsChangeHint mRebuildAllExtraHint;
nsRestyleHint mRebuildAllRestyleHint;
- OverflowChangedTracker mOverflowChangedTracker;
-
// The total number of animation flushes by this frame constructor.
// Used to keep the layer and animation manager in sync.
uint64_t mAnimationGeneration;
ReframingStyleContexts* mReframingStyleContexts;
AnimationsWithDestroyedFrame* mAnimationsWithDestroyedFrame;
RestyleTracker mPendingRestyles;
--- a/layout/base/RestyleManagerBase.h
+++ b/layout/base/RestyleManagerBase.h
@@ -2,23 +2,23 @@
/* 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"
class nsStyleChangeList;
namespace mozilla {
-class OverflowChangedTracker;
class ServoRestyleManager;
class RestyleManager;
/**
* Class for sharing data and logic common to both RestyleManager and
* ServoRestyleManager.
*/
class RestyleManagerBase
@@ -49,16 +49,26 @@ public:
#ifdef DEBUG
/**
* DEBUG ONLY method to verify integrity of style tree versus frame tree
*/
static 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);
+ }
+
protected:
void ContentStateChangedInternal(Element* aElement,
EventStates aStateMask,
nsChangeHint* aOutChangeHint,
nsRestyleHint* aOutRestyleHint);
bool IsDisconnected() { return mPresContext == nullptr; }
@@ -98,21 +108,23 @@ protected:
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:
+ OverflowChangedTracker mOverflowChangedTracker;
+
/**
* These are protected static methods that help with the change hint
* processing bits of the restyle managers.
*/
-protected:
static nsIFrame*
GetNearestAncestorFrame(nsIContent* aContent);
static nsIFrame*
GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame);
static nsresult
ProcessRestyledFrames(nsStyleChangeList& aChangeList,
--- a/layout/base/RestyleManagerHandle.h
+++ b/layout/base/RestyleManagerHandle.h
@@ -135,16 +135,17 @@ public:
const nsAttrValue* aOldValue);
inline nsresult ReparentStyleContext(nsIFrame* aFrame);
inline bool HasPendingRestyles();
inline uint64_t GetRestyleGeneration() const;
inline uint32_t GetHoverGeneration() const;
inline void SetObservingRefreshDriver(bool aObserving);
inline nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
inline void FlushOverflowChangedTracker();
+ inline void NotifyDestroyingFrame(nsIFrame* aFrame);
private:
// Stores a pointer to an RestyleManager or a ServoRestyleManager. The least
// significant bit is 0 for the former, 1 for the latter. This is
// valid as the least significant bit will never be used for a pointer
// value on platforms we care about.
uintptr_t mValue;
};
--- a/layout/base/RestyleManagerHandleInlines.h
+++ b/layout/base/RestyleManagerHandleInlines.h
@@ -162,15 +162,20 @@ RestyleManagerHandle::Ptr::GetHoverGener
}
void
RestyleManagerHandle::Ptr::SetObservingRefreshDriver(bool aObserving)
{
FORWARD(SetObservingRefreshDriver, (aObserving));
}
+void
+RestyleManagerHandle::Ptr::NotifyDestroyingFrame(nsIFrame* aFrame)
+{
+ FORWARD(NotifyDestroyingFrame, (aFrame));
+}
} // namespace mozilla
#undef FORWARD
#undef FORWARD_CONCRETE
#endif // mozilla_RestyleManagerHandleInlines_h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -359,22 +359,13 @@ ServoRestyleManager::SnapshotForElement(
// NB: aElement is the argument for the construction of the snapshot in the
// not found case.
return mModifiedElements.LookupOrAdd(aElement, aElement);
}
nsresult
ServoRestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
{
- // XXX Hook the overflow tracker somewhere.
- OverflowChangedTracker overflowChangedTracker;
return base_type::ProcessRestyledFrames(aChangeList, *PresContext(),
- overflowChangedTracker);
-}
-
-void
-ServoRestyleManager::FlushOverflowChangedTracker()
-{
- MOZ_CRASH("stylo: ServoRestyleManager::FlushOverflowChangedTracker "
- "not implemented for Servo-backed style system");
+ mOverflowChangedTracker);
}
} // namespace mozilla
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -70,17 +70,16 @@ public:
nsIAtom* aAttribute, int32_t aModType,
const nsAttrValue* aOldValue)
{
MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs());
}
nsresult ReparentStyleContext(nsIFrame* aFrame);
nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
- void FlushOverflowChangedTracker();
bool HasPendingRestyles() { return !mModifiedElements.IsEmpty(); }
protected:
~ServoRestyleManager() {}
private:
ServoElementSnapshot* SnapshotForElement(Element* aElement);
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1606,21 +1606,17 @@ nsCSSFrameConstructor::NotifyDestroyingF
if (mCounterManager.DestroyNodesFor(aFrame)) {
// Technically we don't need to update anything if we destroyed only
// USE nodes. However, this is unlikely to happen in the real world
// since USE nodes generally go along with INCREMENT nodes.
CountersDirty();
}
- // stylo: ServoRestyleManager does not need to be notified of frames being
- // destroyed.
- if (mozilla::RestyleManager* geckoRM = RestyleManager()->GetAsGecko()) {
- geckoRM->NotifyDestroyingFrame(aFrame);
- }
+ RestyleManager()->NotifyDestroyingFrame(aFrame);
nsFrameManager::NotifyDestroyingFrame(aFrame);
}
struct nsGenConInitializer {
nsAutoPtr<nsGenConNode> mNode;
nsGenConList* mList;
void (nsCSSFrameConstructor::*mDirtyAll)();