Source code

Revision control

Other Tools

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
public:
30
/**
31
* @param aDeltaX DeltaX for a wheel event whose delta values will
32
* be adjusted upon calling adjust() when
33
* ShouldBeAdjusted() returns true.
34
* @param aDeltaY DeltaY for a wheel event, like DeltaX.
35
* @param aAxisX The X axis information provider for the current
36
* frame, such as whether the frame can be scrolled
37
* horizontally, leftwards or rightwards.
38
* @param aAxisY The Y axis information provider for the current
39
* frame, such as whether the frame can be scrolled
40
* vertically, upwards or downwards.
41
* @param aIsHorizontalContentRightToLeft
42
* Indicates whether the horizontal content starts
43
* at rightside. This value will decide which edge
44
* the adjusted scroll goes towards, in other words,
45
* it will decide the sign of the adjusted delta
46
* values). For detailed information, see
47
* IsHorizontalContentRightToLeft() in
48
* the base class AutoDirWheelDeltaAdjuster.
49
*/
50
APZAutoDirWheelDeltaAdjuster(double& aDeltaX, double& aDeltaY,
51
const AxisX& aAxisX, const AxisY& aAxisY,
52
bool aIsHorizontalContentRightToLeft)
53
: AutoDirWheelDeltaAdjuster(aDeltaX, aDeltaY),
54
mAxisX(aAxisX),
55
mAxisY(aAxisY),
56
mIsHorizontalContentRightToLeft(aIsHorizontalContentRightToLeft) {}
57
58
private:
59
virtual bool CanScrollAlongXAxis() const override {
60
return mAxisX.CanScroll();
61
}
62
virtual bool CanScrollAlongYAxis() const override {
63
return mAxisY.CanScroll();
64
}
65
virtual bool CanScrollUpwards() const override {
66
return mAxisY.CanScrollTo(eSideTop);
67
}
68
virtual bool CanScrollDownwards() const override {
69
return mAxisY.CanScrollTo(eSideBottom);
70
}
71
virtual bool CanScrollLeftwards() const override {
72
return mAxisX.CanScrollTo(eSideLeft);
73
}
74
virtual bool CanScrollRightwards() const override {
75
return mAxisX.CanScrollTo(eSideRight);
76
}
77
virtual bool IsHorizontalContentRightToLeft() const override {
78
return mIsHorizontalContentRightToLeft;
79
}
80
81
const AxisX& mAxisX;
82
const AxisY& mAxisY;
83
bool mIsHorizontalContentRightToLeft;
84
};
85
86
} // namespace layers
87
} // namespace mozilla
88
89
#endif // __mozilla_layers_AutoDirWheelDeltaAdjuster_h__