Make sure we remove our RefreshDriver observers in CompleteAsyncScroll.

Follow-up to fdbac095968bc952fec6a03765a7156940ae4733
This commit is contained in:
wolfbeast 2018-11-02 10:47:05 +01:00 • committed by Roy Tam
commit bf30898e2c
2 changed files with 12 additions and 2 deletions

View file

@ -2152,8 +2152,7 @@ void
ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin) ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin)
{ {
// Apply desired destination range since this is the last step of scrolling. // Apply desired destination range since this is the last step of scrolling.
mAsyncSmoothMSDScroll = nullptr; RemoveObservers();
mAsyncScroll = nullptr;
nsWeakFrame weakFrame(mOuter); nsWeakFrame weakFrame(mOuter);
ScrollToImpl(mDestination, aRange, aOrigin); ScrollToImpl(mDestination, aRange, aOrigin);
if (!weakFrame.IsAlive()) { if (!weakFrame.IsAlive()) {
@ -4588,11 +4587,19 @@ ScrollFrameHelper::Destroy()
mScrollActivityTimer->Cancel(); mScrollActivityTimer->Cancel();
mScrollActivityTimer = nullptr; mScrollActivityTimer = nullptr;
} }
RemoveObservers();
}
void
ScrollFrameHelper::RemoveObservers()
{
if (mAsyncScroll) { if (mAsyncScroll) {
mAsyncScroll->RemoveObserver(); mAsyncScroll->RemoveObserver();
mAsyncScroll = nullptr;
} }
if (mAsyncSmoothMSDScroll) { if (mAsyncSmoothMSDScroll) {
mAsyncSmoothMSDScroll->RemoveObserver(); mAsyncSmoothMSDScroll->RemoveObserver();
mAsyncSmoothMSDScroll = nullptr;
} }
} }

View file

@ -638,6 +638,9 @@ protected:
bool HasBgAttachmentLocal() const; bool HasBgAttachmentLocal() const;
uint8_t GetScrolledFrameDir() const; uint8_t GetScrolledFrameDir() const;
// Removes any RefreshDriver observers we might have registered.
void RemoveObservers();
static void EnsureFrameVisPrefsCached(); static void EnsureFrameVisPrefsCached();
static bool sFrameVisPrefsCached; static bool sFrameVisPrefsCached;
// The number of scrollports wide/high to expand when tracking frame visibility. // The number of scrollports wide/high to expand when tracking frame visibility.