mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Ensure that the scroll frame deregisters its refresh driver observers (mAsyncScroll & mAsyncSmoothMSDScroll) before it's destroyed.
Tag #345
This commit is contained in:
parent
f85bb5c221
commit
eb83cf3ac8
2 changed files with 31 additions and 23 deletions
|
|
@ -1774,6 +1774,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, Flush_Style);
|
||||
mCallee = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Private destructor, to discourage deletion outside of Release():
|
||||
~AsyncSmoothMSDScroll() {
|
||||
|
|
@ -1786,17 +1798,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, Flush_Style);
|
||||
}
|
||||
}
|
||||
|
||||
mozilla::layers::AxisPhysicsMSDModel mXAxisModel, mYAxisModel;
|
||||
nsRect mRange;
|
||||
mozilla::TimeStamp mLastRefreshTime;
|
||||
|
|
@ -1875,24 +1876,25 @@ 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) {
|
||||
RefreshDriver(mCallee)->RemoveRefreshObserver(this, Flush_Style);
|
||||
APZCCallbackHelper::SuppressDisplayport(false, mCallee->mOuter->PresContext()->PresShell());
|
||||
mCallee = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ScrollFrameHelper *mCallee;
|
||||
|
||||
nsRefreshDriver* RefreshDriver(ScrollFrameHelper* aCallee) {
|
||||
return aCallee->mOuter->PresContext()->RefreshDriver();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -4586,6 +4588,12 @@ ScrollFrameHelper::Destroy()
|
|||
mScrollActivityTimer->Cancel();
|
||||
mScrollActivityTimer = nullptr;
|
||||
}
|
||||
if (mAsyncScroll) {
|
||||
mAsyncScroll->RemoveObserver();
|
||||
}
|
||||
if (mAsyncSmoothMSDScroll) {
|
||||
mAsyncSmoothMSDScroll->RemoveObserver();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue