/src/mozilla-central/gfx/layers/apz/src/AutoDirWheelDeltaAdjuster.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef __mozilla_layers_AutoDirWheelDeltaAdjuster_h__ |
8 | | #define __mozilla_layers_AutoDirWheelDeltaAdjuster_h__ |
9 | | |
10 | | #include "Axis.h" // for AxisX, AxisY, Side |
11 | | #include "mozilla/WheelHandlingHelper.h" // for AutoDirWheelDeltaAdjuster |
12 | | |
13 | | namespace mozilla { |
14 | | namespace layers { |
15 | | |
16 | | /** |
17 | | * About AutoDirWheelDeltaAdjuster: |
18 | | * For an AutoDir wheel scroll, there's some situations where we should adjust a |
19 | | * wheel event's delta values. AutoDirWheelDeltaAdjuster converts delta values |
20 | | * for AutoDir scrolling. An AutoDir wheel scroll lets the user scroll a frame |
21 | | * with only one scrollbar, using either a vertical or a horzizontal wheel. |
22 | | * For more detail about the concept of AutoDir scrolling, see the comments in |
23 | | * AutoDirWheelDeltaAdjuster. |
24 | | * |
25 | | * This is the APZ implementation of AutoDirWheelDeltaAdjuster. |
26 | | */ |
27 | | class MOZ_STACK_CLASS APZAutoDirWheelDeltaAdjuster final |
28 | | : public AutoDirWheelDeltaAdjuster |
29 | | { |
30 | | public: |
31 | | /** |
32 | | * @param aDeltaX DeltaX for a wheel event whose delta values will |
33 | | * be adjusted upon calling adjust() when |
34 | | * ShouldBeAdjusted() returns true. |
35 | | * @param aDeltaY DeltaY for a wheel event, like DeltaX. |
36 | | * @param aAxisX The X axis information provider for the current |
37 | | * frame, such as whether the frame can be scrolled |
38 | | * horizontally, leftwards or rightwards. |
39 | | * @param aAxisY The Y axis information provider for the current |
40 | | * frame, such as whether the frame can be scrolled |
41 | | * vertically, upwards or downwards. |
42 | | * @param aIsHorizontalContentRightToLeft |
43 | | * Indicates whether the horizontal content starts |
44 | | * at rightside. This value will decide which edge |
45 | | * the adjusted scroll goes towards, in other words, |
46 | | * it will decide the sign of the adjusted delta |
47 | | * values). For detailed information, see |
48 | | * IsHorizontalContentRightToLeft() in |
49 | | * the base class AutoDirWheelDeltaAdjuster. |
50 | | */ |
51 | | explicit |
52 | | APZAutoDirWheelDeltaAdjuster(double& aDeltaX, |
53 | | double& aDeltaY, |
54 | | const AxisX& aAxisX, |
55 | | const AxisY& aAxisY, |
56 | | bool aIsHorizontalContentRightToLeft) |
57 | | : AutoDirWheelDeltaAdjuster(aDeltaX, aDeltaY) |
58 | | , mAxisX(aAxisX) |
59 | | , mAxisY(aAxisY) |
60 | | , mIsHorizontalContentRightToLeft(aIsHorizontalContentRightToLeft) |
61 | 0 | { |
62 | 0 | } |
63 | | |
64 | | private: |
65 | | virtual bool CanScrollAlongXAxis() const override |
66 | 0 | { |
67 | 0 | return mAxisX.CanScroll(); |
68 | 0 | } |
69 | | virtual bool CanScrollAlongYAxis() const override |
70 | 0 | { |
71 | 0 | return mAxisY.CanScroll(); |
72 | 0 | } |
73 | | virtual bool CanScrollUpwards() const override |
74 | 0 | { |
75 | 0 | return mAxisY.CanScrollTo(eSideTop); |
76 | 0 | } |
77 | | virtual bool CanScrollDownwards() const override |
78 | 0 | { |
79 | 0 | return mAxisY.CanScrollTo(eSideBottom); |
80 | 0 | } |
81 | | virtual bool CanScrollLeftwards() const override |
82 | 0 | { |
83 | 0 | return mAxisX.CanScrollTo(eSideLeft); |
84 | 0 | } |
85 | | virtual bool CanScrollRightwards() const override |
86 | 0 | { |
87 | 0 | return mAxisX.CanScrollTo(eSideRight); |
88 | 0 | } |
89 | | virtual bool IsHorizontalContentRightToLeft() const override |
90 | 0 | { |
91 | 0 | return mIsHorizontalContentRightToLeft; |
92 | 0 | } |
93 | | |
94 | | const AxisX& mAxisX; |
95 | | const AxisY& mAxisY; |
96 | | bool mIsHorizontalContentRightToLeft; |
97 | | }; |
98 | | |
99 | | } // namespace layers |
100 | | } // namespace mozilla |
101 | | |
102 | | #endif // __mozilla_layers_AutoDirWheelDeltaAdjuster_h__ |