Bug 1484559 - Ensure that the scroll frame deregister its refresh driver observers (mAsyncScroll & mAsyncSmoothMSDScroll) before it's destroyed. r=dholbert

This commit is contained in:
Mats Palmgren 2018-08-21 14:55:22 +02:00
Родитель d2cd03866d
Коммит 2f53d4f281
1 изменённых файлов: 29 добавлений и 22 удалений

Просмотреть файл

@ -1853,6 +1853,18 @@ public:
return true;
}
/**
* The mCallee holds a strong ref to us since the refresh driver doesn't.
* Our dtor and mCallee's Destroy() method both call RemoveObserver() -
* whichever comes first removes us from the refresh driver.
*/
void RemoveObserver() {
if (mCallee) {
RefreshDriver(mCallee)->RemoveRefreshObserver(this, FlushType::Style);
mCallee = nullptr;
}
}
private:
// Private destructor, to discourage deletion outside of Release():
~AsyncSmoothMSDScroll() {
@ -1865,17 +1877,6 @@ private:
return aCallee->mOuter->PresContext()->RefreshDriver();
}
/*
* The refresh driver doesn't hold a reference to its observers,
* so releasing this object can (and is) used to remove the observer on DTOR.
* Currently, this object is released once the scrolling ends.
*/
void RemoveObserver() {
if (mCallee) {
RefreshDriver(mCallee)->RemoveRefreshObserver(this, FlushType::Style);
}
}
mozilla::layers::AxisPhysicsMSDModel mXAxisModel, mYAxisModel;
nsRect mRange;
mozilla::TimeStamp mLastRefreshTime;
@ -1974,17 +1975,10 @@ public:
ScrollFrameHelper::AsyncScrollCallback(mCallee, aTime);
}
private:
ScrollFrameHelper *mCallee;
nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) {
return aCallee->mOuter->PresContext()->RefreshDriver();
}
/*
* The refresh driver doesn't hold a reference to its observers,
* so releasing this object can (and is) used to remove the observer on DTOR.
* Currently, this object is released once the scrolling ends.
/**
* The mCallee holds a strong ref to us since the refresh driver doesn't.
* Our dtor and mCallee's Destroy() method both call RemoveObserver() -
* whichever comes first removes us from the refresh driver.
*/
void RemoveObserver() {
if (mCallee) {
@ -1992,8 +1986,15 @@ private:
if (nsIPresShell* shell = mCallee->mOuter->PresShell()) {
shell->SuppressDisplayport(false);
}
mCallee = nullptr;
}
}
private:
ScrollFrameHelper *mCallee;
nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) {
return aCallee->mOuter->PresContext()->RefreshDriver();
}
};
/*
@ -4891,6 +4892,12 @@ ScrollFrameHelper::Destroy(PostDestroyData& aPostDestroyData)
mScrollActivityTimer->Cancel();
mScrollActivityTimer = nullptr;
}
if (mAsyncScroll) {
mAsyncScroll->RemoveObserver();
}
if (mAsyncSmoothMSDScroll) {
mAsyncSmoothMSDScroll->RemoveObserver();
}
}
/**