From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 46 +++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'gfx/layers/apz/src/AsyncPanZoomController.cpp') diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 342375c019..edbd2ecffa 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -106,6 +106,10 @@ static mozilla::LazyLogModule sApzCtlLog("apz.controller"); APZC_LOG("%p(%s scrollId=%" PRIu64 "): " fmt, (apzc), \ (apzc)->IsRootContent() ? "root" : "subframe", \ (apzc)->GetScrollId(), ##__VA_ARGS__) +#define APZC_LOGV_DETAIL(fmt, apzc, ...) \ + APZC_LOGV("%p(%s scrollId=%" PRIu64 "): " fmt, (apzc), \ + (apzc)->IsRootContent() ? "root" : "subframe", \ + (apzc)->GetScrollId(), ##__VA_ARGS__) #define APZC_LOG_FM_COMMON(fm, prefix, level, ...) \ if (MOZ_LOG_TEST(sApzCtlLog, level)) { \ @@ -2248,6 +2252,11 @@ CSSRect AsyncPanZoomController::GetCurrentScrollRangeInCssPixels() const { return Metrics().CalculateScrollRange(); } +bool AsyncPanZoomController::AllowOneTouchPinch() const { + return StaticPrefs::apz_one_touch_pinch_enabled() && + ZoomConstraintsAllowZoom(); +} + // Return whether or not the underlying layer can be scrolled on either axis. bool AsyncPanZoomController::CanScroll(const InputData& aEvent) const { ParentLayerPoint delta = GetDeltaForEvent(aEvent); @@ -4734,7 +4743,7 @@ bool AsyncPanZoomController::UpdateAnimation( // Even if there's no animation, if we have a scroll offset change pending due // to the frame delay, we need to keep compositing. if (mLastSampleTime == aSampleTime) { - APZC_LOG_DETAIL( + APZC_LOGV_DETAIL( "UpdateAnimation short-circuit, animation=%p, pending frame-delayed " "offset=%d\n", this, mAnimation.get(), HavePendingFrameDelayedOffset()); @@ -4754,8 +4763,8 @@ bool AsyncPanZoomController::UpdateAnimation( // so that e.g. a main-thread animation can stay in sync with user-driven // scrolling or a compositor animation. bool needComposite = SampleCompositedAsyncTransform(aProofOfLock); - APZC_LOG_DETAIL("UpdateAnimation needComposite=%d mAnimation=%p\n", this, - needComposite, mAnimation.get()); + APZC_LOGV_DETAIL("UpdateAnimation needComposite=%d mAnimation=%p\n", this, + needComposite, mAnimation.get()); TimeDuration sampleTimeDelta = aSampleTime - mLastSampleTime; mLastSampleTime = aSampleTime; @@ -5581,17 +5590,6 @@ void AsyncPanZoomController::NotifyLayersUpdated( aScrollMetadata.GetOverscrollBehavior()); } - if (needToReclampScroll) { - // Whenever scrollable rect or composition bounds has changed, we need to - // re-clamp the scroll offset since it may be out of bounds. Also note that - // we need to re-clamp before updating new scroll offsets from content since - // we will use the last scroll offset to reflect the new offsets. - ClampAndSetVisualScrollOffset(Metrics().GetVisualScrollOffset()); - for (auto& sampledState : mSampledState) { - sampledState.ClampVisualScrollOffset(Metrics()); - } - } - bool instantScrollMayTriggerTransform = false; bool scrollOffsetUpdated = false; bool smoothScrollRequested = false; @@ -5738,20 +5736,11 @@ void AsyncPanZoomController::NotifyLayersUpdated( relativeDelta = Some(Metrics().ApplyPureRelativeScrollUpdateFrom(scrollUpdate)); Metrics().RecalculateLayoutViewportOffset(); - } else if (scrollUpdate.GetType() == ScrollUpdateType::MergeableAbsolute) { - APZC_LOG("%p mergeable updating scroll offset from %s to %s\n", this, - ToString(Metrics().GetVisualScrollOffset()).c_str(), - ToString(scrollUpdate.GetDestination()).c_str()); - relativeDelta = - Some(Metrics().ApplyAbsoluteScrollUpdateFrom(scrollUpdate).second); - Metrics().RecalculateLayoutViewportOffset(); - scrollOffsetUpdated = true; } else { APZC_LOG("%p updating scroll offset from %s to %s\n", this, ToString(Metrics().GetVisualScrollOffset()).c_str(), ToString(scrollUpdate.GetDestination()).c_str()); - auto [offsetChanged, _] = - Metrics().ApplyAbsoluteScrollUpdateFrom(scrollUpdate); + bool offsetChanged = Metrics().ApplyScrollUpdateFrom(scrollUpdate); Metrics().RecalculateLayoutViewportOffset(); if (offsetChanged || scrollUpdate.GetMode() != ScrollMode::Instant || @@ -5788,6 +5777,15 @@ void AsyncPanZoomController::NotifyLayersUpdated( } } + if (aIsFirstPaint || needToReclampScroll) { + // The scrollable rect or composition bounds may have changed in a way that + // makes our local scroll offset out of bounds, so clamp it. + ClampAndSetVisualScrollOffset(Metrics().GetVisualScrollOffset()); + for (auto& sampledState : mSampledState) { + sampledState.ClampVisualScrollOffset(Metrics()); + } + } + if (scrollOffsetUpdated) { for (auto& sampledState : mSampledState) { if (!didCancelAnimation && cumulativeRelativeDelta.isSome()) { -- cgit v1.2.3