summaryrefslogtreecommitdiff
path: root/chromium/cc/input/scroll_utils.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/cc/input/scroll_utils.h
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/input/scroll_utils.h')
-rw-r--r--chromium/cc/input/scroll_utils.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/chromium/cc/input/scroll_utils.h b/chromium/cc/input/scroll_utils.h
new file mode 100644
index 00000000000..34fb3be7773
--- /dev/null
+++ b/chromium/cc/input/scroll_utils.h
@@ -0,0 +1,43 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_INPUT_SCROLL_UTILS_H_
+#define CC_INPUT_SCROLL_UTILS_H_
+
+#include "cc/cc_export.h"
+
+namespace gfx {
+class Vector2dF;
+class SizeF;
+} // namespace gfx
+
+namespace cc {
+
+static constexpr int kPixelsPerLineStep = 40;
+static constexpr float kMinFractionToStepWhenPaging = 0.875f;
+
+// Each directional scroll for percentage-based units should scroll 1/8th of
+// the scrollable area.
+static constexpr float kPercentDeltaForDirectionalScroll = 0.125f;
+
+// Scroll deltas are lower-bounded by 16 physical pixels in percent-based
+// scrolls.
+static constexpr float kMinPixelDeltaForPercentBasedScroll = 16;
+
+// Class for scroll helper methods in cc and blink.
+class CC_EXPORT ScrollUtils {
+ public:
+ // Transforms a |scroll_delta| in percent units to pixel units based in its
+ // |scroller_size|. Clamps it by 16 pixels to avoid too small deltas for tiny
+ // scrollers and 12.5% of |viewport_size| to avoid too large deltas.
+ // Inputs and output muest be in physical pixels.
+ static gfx::Vector2dF ResolveScrollPercentageToPixels(
+ const gfx::Vector2dF& scroll_delta,
+ const gfx::SizeF& scroller_size,
+ const gfx::SizeF& viewport_size);
+};
+
+} // namespace cc
+
+#endif // CC_INPUT_SCROLL_UTILS_H_