From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- gfx/layers/apz/src/SampledAPZCState.h | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 gfx/layers/apz/src/SampledAPZCState.h (limited to 'gfx/layers/apz/src/SampledAPZCState.h') diff --git a/gfx/layers/apz/src/SampledAPZCState.h b/gfx/layers/apz/src/SampledAPZCState.h new file mode 100644 index 0000000000..a521eeaf87 --- /dev/null +++ b/gfx/layers/apz/src/SampledAPZCState.h @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_layers_SampledAPZCState_h +#define mozilla_layers_SampledAPZCState_h + +#include "FrameMetrics.h" +#include "mozilla/Maybe.h" +#include "mozilla/ScrollGeneration.h" + +namespace mozilla { +namespace layers { + +class SampledAPZCState { + public: + SampledAPZCState(); + explicit SampledAPZCState(const FrameMetrics& aMetrics); + SampledAPZCState(const FrameMetrics& aMetrics, + Maybe&& aPayload, + APZScrollGeneration aGeneration); + + bool operator==(const SampledAPZCState& aOther) const; + bool operator!=(const SampledAPZCState& aOther) const; + + CSSRect GetLayoutViewport() const { return mLayoutViewport; } + CSSPoint GetVisualScrollOffset() const { return mVisualScrollOffset; } + CSSToParentLayerScale GetZoom() const { return mZoom; } + Maybe TakeScrollPayload(); + const APZScrollGeneration& Generation() const { return mGeneration; } + + void UpdateScrollProperties(const FrameMetrics& aMetrics); + void UpdateScrollPropertiesWithRelativeDelta(const FrameMetrics& aMetrics, + const CSSPoint& aRelativeDelta); + + void UpdateZoomProperties(const FrameMetrics& aMetrics); + + /** + * Re-clamp mVisualScrollOffset to the scroll range specified by the provided + * metrics. This only needs to be called if the scroll offset changes + * outside of AsyncPanZoomController::SampleCompositedAsyncTransform(). + * It also recalculates mLayoutViewport so that it continues to enclose + * the visual viewport. This only needs to be called if the + * layout viewport changes outside of SampleCompositedAsyncTransform(). + */ + void ClampVisualScrollOffset(const FrameMetrics& aMetrics); + + void ZoomBy(float aScale); + + private: + // These variables cache the layout viewport, scroll offset, and zoom stored + // in |Metrics()| at the time this class was constructed. + CSSRect mLayoutViewport; + CSSPoint mVisualScrollOffset; + CSSToParentLayerScale mZoom; + // An optional payload that rides along with the sampled state. + Maybe mScrollPayload; + APZScrollGeneration mGeneration; + + void RemoveFractionalAsyncDelta(); + // A handy wrapper to call + // FrameMetrics::KeepLayoutViewportEnclosingVisualViewport with this + // SampledAPZCState and the given |aMetrics|. + void KeepLayoutViewportEnclosingVisualViewport(const FrameMetrics& aMetrics); +}; + +} // namespace layers +} // namespace mozilla + +#endif // mozilla_layers_SampledAPZCState_h -- cgit v1.2.3