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_KeyboardScrollAction_h
8 #define mozilla_layers_KeyboardScrollAction_h
9 
10 #include "mozilla/DefineEnum.h"  // for MOZ_DEFINE_ENUM
11 #include "nsIScrollableFrame.h"  // for nsIScrollableFrame::ScrollUnit
12 
13 namespace mozilla {
14 namespace layers {
15 
16 /**
17  * This class represents a scrolling action to be performed on a scrollable
18  * layer.
19  */
20 struct KeyboardScrollAction final {
21  public:
22   // clang-format off
23   MOZ_DEFINE_ENUM_WITH_BASE_AT_CLASS_SCOPE(
24     KeyboardScrollActionType, uint8_t, (
25       eScrollCharacter,
26       eScrollLine,
27       eScrollPage,
28       eScrollComplete
29   ));
30   // clang-format on
31 
32   static nsIScrollableFrame::ScrollUnit GetScrollUnit(
33       KeyboardScrollActionType aDeltaType);
34 
35   KeyboardScrollAction();
36   KeyboardScrollAction(KeyboardScrollActionType aType, bool aForward);
37 
38   // The type of scroll to perform for this action
39   KeyboardScrollActionType mType;
40   // Whether to scroll forward or backward along the axis of this action type
41   bool mForward;
42 };
43 
44 }  // namespace layers
45 }  // namespace mozilla
46 
47 #endif  // mozilla_layers_KeyboardScrollAction_h
48