1/*
2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include <cstdint>
29#include <wtf/Assertions.h>
30
31namespace WebCore {
32
33enum class ScrollType : uint8_t {
34 User,
35 Programmatic
36};
37
38enum ScrollDirection : uint8_t {
39 ScrollUp,
40 ScrollDown,
41 ScrollLeft,
42 ScrollRight
43};
44
45enum ScrollLogicalDirection : uint8_t {
46 ScrollBlockDirectionBackward,
47 ScrollBlockDirectionForward,
48 ScrollInlineDirectionBackward,
49 ScrollInlineDirectionForward
50};
51
52enum class ScrollPositionClamp : uint8_t {
53 None,
54 ToContentEdges,
55};
56
57inline ScrollDirection logicalToPhysical(ScrollLogicalDirection direction, bool isVertical, bool isFlipped)
58{
59 switch (direction) {
60 case ScrollBlockDirectionBackward: {
61 if (isVertical) {
62 if (!isFlipped)
63 return ScrollUp;
64 return ScrollDown;
65 } else {
66 if (!isFlipped)
67 return ScrollLeft;
68 return ScrollRight;
69 }
70 break;
71 }
72 case ScrollBlockDirectionForward: {
73 if (isVertical) {
74 if (!isFlipped)
75 return ScrollDown;
76 return ScrollUp;
77 } else {
78 if (!isFlipped)
79 return ScrollRight;
80 return ScrollLeft;
81 }
82 break;
83 }
84 case ScrollInlineDirectionBackward: {
85 if (isVertical) {
86 if (!isFlipped)
87 return ScrollLeft;
88 return ScrollRight;
89 } else {
90 if (!isFlipped)
91 return ScrollUp;
92 return ScrollDown;
93 }
94 break;
95 }
96 case ScrollInlineDirectionForward: {
97 if (isVertical) {
98 if (!isFlipped)
99 return ScrollRight;
100 return ScrollLeft;
101 } else {
102 if (!isFlipped)
103 return ScrollDown;
104 return ScrollUp;
105 }
106 break;
107 }
108 default:
109 ASSERT_NOT_REACHED();
110 break;
111 }
112 return ScrollUp;
113}
114
115enum ScrollGranularity : uint8_t {
116 ScrollByLine,
117 ScrollByPage,
118 ScrollByDocument,
119 ScrollByPixel
120};
121
122enum ScrollElasticity : uint8_t {
123 ScrollElasticityAutomatic,
124 ScrollElasticityNone,
125 ScrollElasticityAllowed
126};
127
128enum ScrollbarOrientation : uint8_t {
129 HorizontalScrollbar,
130 VerticalScrollbar
131};
132
133enum ScrollbarMode : uint8_t {
134 ScrollbarAuto,
135 ScrollbarAlwaysOff,
136 ScrollbarAlwaysOn
137};
138
139enum ScrollbarControlSize : uint8_t {
140 RegularScrollbar,
141 SmallScrollbar
142};
143
144enum class ScrollbarExpansionState : uint8_t {
145 Regular,
146 Expanded
147};
148
149enum class ScrollEventAxis : uint8_t {
150 Horizontal,
151 Vertical
152};
153
154enum ScrollbarControlStateMask {
155 ActiveScrollbarState = 1,
156 EnabledScrollbarState = 1 << 1,
157 PressedScrollbarState = 1 << 2
158};
159
160enum ScrollbarPart {
161 NoPart = 0,
162 BackButtonStartPart = 1,
163 ForwardButtonStartPart = 1 << 1,
164 BackTrackPart = 1 << 2,
165 ThumbPart = 1 << 3,
166 ForwardTrackPart = 1 << 4,
167 BackButtonEndPart = 1 << 5,
168 ForwardButtonEndPart = 1 << 6,
169 ScrollbarBGPart = 1 << 7,
170 TrackBGPart = 1 << 8,
171 AllParts = 0xffffffff
172};
173
174enum ScrollbarButtonsPlacement : uint8_t {
175 ScrollbarButtonsNone,
176 ScrollbarButtonsSingle,
177 ScrollbarButtonsDoubleStart,
178 ScrollbarButtonsDoubleEnd,
179 ScrollbarButtonsDoubleBoth
180};
181
182enum class ScrollbarStyle : uint8_t {
183 AlwaysVisible,
184 Overlay
185};
186
187enum ScrollbarOverlayStyle: uint8_t {
188 ScrollbarOverlayStyleDefault,
189 ScrollbarOverlayStyleDark,
190 ScrollbarOverlayStyleLight
191};
192
193enum ScrollPinningBehavior : uint8_t {
194 DoNotPin,
195 PinToTop,
196 PinToBottom
197};
198
199enum class ScrollClamping : uint8_t {
200 Unclamped,
201 Clamped
202};
203
204enum ScrollBehaviorForFixedElements : uint8_t {
205 StickToDocumentBounds,
206 StickToViewportBounds
207};
208
209enum class ScrollbarButtonPressAction : uint8_t {
210 None,
211 CenterOnThumb,
212 StartDrag,
213 Scroll
214};
215
216enum class SelectionRevealMode : uint8_t {
217 Reveal,
218 RevealUpToMainFrame, // Scroll overflow and iframes, but not the main frame.
219 DoNotReveal
220};
221
222enum class ScrollPositioningBehavior : uint8_t {
223 None,
224 Moves,
225 Stationary
226};
227
228using ScrollbarControlState = unsigned;
229using ScrollbarControlPartMask = unsigned;
230using ScrollingNodeID = uint64_t;
231
232} // namespace WebCore
233