mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 980679 - Filter redundant scroll offset updates by scroll generation value. r=botond
This commit is contained in:
parent
ddafbb93e1
commit
a9019c7fc6
@ -204,6 +204,12 @@ public:
|
||||
mZoom.scale *= aFactor;
|
||||
}
|
||||
|
||||
void CopyScrollInfoFrom(const FrameMetrics& aOther)
|
||||
{
|
||||
mScrollOffset = aOther.mScrollOffset;
|
||||
mScrollGeneration = aOther.mScrollGeneration;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The following metrics are all in widget space/device pixels.
|
||||
//
|
||||
|
@ -67,7 +67,7 @@
|
||||
#define APZC_LOG_FM(fm, prefix, ...) \
|
||||
APZC_LOG(prefix ":" \
|
||||
" i=(%ld %lld) cb=(%d %d %d %d) dp=(%.3f %.3f %.3f %.3f) v=(%.3f %.3f %.3f %.3f) " \
|
||||
"s=(%.3f %.3f) sr=(%.3f %.3f %.3f %.3f) z=(%.3f %.3f %.3f %.3f) u=(%d %llu)\n", \
|
||||
"s=(%.3f %.3f) sr=(%.3f %.3f %.3f %.3f) z=(%.3f %.3f %.3f %.3f) u=(%d %lu)\n", \
|
||||
__VA_ARGS__, \
|
||||
fm.mPresShellId, fm.mScrollId, \
|
||||
fm.mCompositionBounds.x, fm.mCompositionBounds.y, fm.mCompositionBounds.width, fm.mCompositionBounds.height, \
|
||||
@ -1718,6 +1718,13 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
|
||||
mFrameMetrics.mViewport = aLayerMetrics.mViewport;
|
||||
}
|
||||
|
||||
// If the layers update was not triggered by our own repaint request, then
|
||||
// we want to take the new scroll offset. Check the scroll generation as well
|
||||
// to filter duplicate calls to NotifyLayersUpdated with the same scroll offset
|
||||
// update message.
|
||||
bool scrollOffsetUpdated = aLayerMetrics.GetScrollOffsetUpdated()
|
||||
&& (aLayerMetrics.GetScrollGeneration() != mFrameMetrics.GetScrollGeneration());
|
||||
|
||||
if (aIsFirstPaint || isDefault) {
|
||||
// Initialize our internal state to something sane when the content
|
||||
// that was just painted is something we knew nothing about previously
|
||||
@ -1753,14 +1760,12 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
|
||||
mFrameMetrics.mCumulativeResolution = aLayerMetrics.mCumulativeResolution;
|
||||
mFrameMetrics.mHasScrollgrab = aLayerMetrics.mHasScrollgrab;
|
||||
|
||||
// If the layers update was not triggered by our own repaint request, then
|
||||
// we want to take the new scroll offset.
|
||||
if (aLayerMetrics.GetScrollOffsetUpdated()) {
|
||||
if (scrollOffsetUpdated) {
|
||||
APZC_LOG("%p updating scroll offset from (%f, %f) to (%f, %f)\n", this,
|
||||
mFrameMetrics.mScrollOffset.x, mFrameMetrics.mScrollOffset.y,
|
||||
aLayerMetrics.mScrollOffset.x, aLayerMetrics.mScrollOffset.y);
|
||||
|
||||
mFrameMetrics.SetScrollOffset(aLayerMetrics.GetScrollOffset());
|
||||
mFrameMetrics.CopyScrollInfoFrom(aLayerMetrics);
|
||||
|
||||
// Because of the scroll offset update, any inflight paint requests are
|
||||
// going to be ignored by layout, and so mLastDispatchedPaintMetrics
|
||||
@ -1771,13 +1776,14 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
|
||||
}
|
||||
}
|
||||
|
||||
if (aLayerMetrics.GetScrollOffsetUpdated()) {
|
||||
if (scrollOffsetUpdated) {
|
||||
// Once layout issues a scroll offset update, it becomes impervious to
|
||||
// scroll offset updates from APZ until we acknowledge the update it sent.
|
||||
// This prevents APZ updates from clobbering scroll updates from other
|
||||
// more "legitimate" sources like content scripts.
|
||||
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
|
||||
if (controller) {
|
||||
APZC_LOG("%p sending scroll update acknowledgement with gen %lu\n", this, aLayerMetrics.GetScrollGeneration());
|
||||
controller->AcknowledgeScrollUpdate(aLayerMetrics.mScrollId,
|
||||
aLayerMetrics.GetScrollGeneration());
|
||||
}
|
||||
|
@ -1552,7 +1552,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
|
||||
, mOuter(aOuter)
|
||||
, mAsyncScroll(nullptr)
|
||||
, mOriginOfLastScroll(nsGkAtoms::other)
|
||||
, mScrollGeneration(0)
|
||||
, mScrollGeneration(1) // we start off pretending we scrolled to 0,0 to flush a notification to APZ
|
||||
, mDestination(0, 0)
|
||||
, mScrollPosAtLastPaint(0, 0)
|
||||
, mRestorePos(-1, -1)
|
||||
|
Loading…
Reference in New Issue
Block a user