/work/obj-fuzz/dist/include/mozilla/ScrollStyles.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_ScrollStyles_h |
8 | | #define mozilla_ScrollStyles_h |
9 | | |
10 | | #include <stdint.h> |
11 | | #include "nsStyleConsts.h" // for NS_STYLE_SCROLL_SNAP_* |
12 | | #include "nsStyleCoord.h" // for nsStyleCoord |
13 | | #include "mozilla/dom/WindowBinding.h" |
14 | | |
15 | | // Forward declarations |
16 | | struct nsStyleDisplay; |
17 | | |
18 | | namespace mozilla { |
19 | | |
20 | | struct ScrollStyles |
21 | | { |
22 | | // Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN, |
23 | | // or NS_STYLE_OVERFLOW_AUTO. |
24 | | uint8_t mHorizontal; |
25 | | uint8_t mVertical; |
26 | | // Always one of NS_STYLE_SCROLL_BEHAVIOR_AUTO or |
27 | | // NS_STYLE_SCROLL_BEHAVIOR_SMOOTH |
28 | | uint8_t mScrollBehavior; |
29 | | mozilla::StyleOverscrollBehavior mOverscrollBehaviorX; |
30 | | mozilla::StyleOverscrollBehavior mOverscrollBehaviorY; |
31 | | // Always one of NS_STYLE_SCROLL_SNAP_NONE, NS_STYLE_SCROLL_SNAP_MANDATORY, |
32 | | // or NS_STYLE_SCROLL_SNAP_PROXIMITY. |
33 | | uint8_t mScrollSnapTypeX; |
34 | | uint8_t mScrollSnapTypeY; |
35 | | nsStyleCoord mScrollSnapPointsX; |
36 | | nsStyleCoord mScrollSnapPointsY; |
37 | | nsStyleCoord::CalcValue mScrollSnapDestinationX; |
38 | | nsStyleCoord::CalcValue mScrollSnapDestinationY; |
39 | | |
40 | | ScrollStyles(uint8_t aH, uint8_t aV) |
41 | | : mHorizontal(aH), mVertical(aV), |
42 | | mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO), |
43 | | mOverscrollBehaviorX(StyleOverscrollBehavior::Auto), |
44 | | mOverscrollBehaviorY(StyleOverscrollBehavior::Auto), |
45 | | mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE), |
46 | | mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE), |
47 | | mScrollSnapPointsX(nsStyleCoord(eStyleUnit_None)), |
48 | 0 | mScrollSnapPointsY(nsStyleCoord(eStyleUnit_None)) { |
49 | 0 |
|
50 | 0 | mScrollSnapDestinationX.mPercent = 0; |
51 | 0 | mScrollSnapDestinationX.mLength = nscoord(0.0f); |
52 | 0 | mScrollSnapDestinationX.mHasPercent = false; |
53 | 0 | mScrollSnapDestinationY.mPercent = 0; |
54 | 0 | mScrollSnapDestinationY.mLength = nscoord(0.0f); |
55 | 0 | mScrollSnapDestinationY.mHasPercent = false; |
56 | 0 | } |
57 | | |
58 | | explicit ScrollStyles(const nsStyleDisplay* aDisplay); |
59 | | ScrollStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay); |
60 | 0 | bool operator==(const ScrollStyles& aStyles) const { |
61 | 0 | return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical && |
62 | 0 | aStyles.mScrollBehavior == mScrollBehavior && |
63 | 0 | aStyles.mOverscrollBehaviorX == mOverscrollBehaviorX && |
64 | 0 | aStyles.mOverscrollBehaviorY == mOverscrollBehaviorY && |
65 | 0 | aStyles.mScrollSnapTypeX == mScrollSnapTypeX && |
66 | 0 | aStyles.mScrollSnapTypeY == mScrollSnapTypeY && |
67 | 0 | aStyles.mScrollSnapPointsX == mScrollSnapPointsX && |
68 | 0 | aStyles.mScrollSnapPointsY == mScrollSnapPointsY && |
69 | 0 | aStyles.mScrollSnapDestinationX == mScrollSnapDestinationX && |
70 | 0 | aStyles.mScrollSnapDestinationY == mScrollSnapDestinationY; |
71 | 0 | } |
72 | 0 | bool operator!=(const ScrollStyles& aStyles) const { |
73 | 0 | return !(*this == aStyles); |
74 | 0 | } |
75 | 0 | bool IsHiddenInBothDirections() const { |
76 | 0 | return mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && |
77 | 0 | mVertical == NS_STYLE_OVERFLOW_HIDDEN; |
78 | 0 | } |
79 | 0 | bool IsSmoothScroll(dom::ScrollBehavior aBehavior) const { |
80 | 0 | return aBehavior == dom::ScrollBehavior::Smooth || |
81 | 0 | (aBehavior == dom::ScrollBehavior::Auto && |
82 | 0 | mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH); |
83 | 0 | } |
84 | | }; |
85 | | |
86 | | } // namespace mozilla |
87 | | |
88 | | #endif // mozilla_ScrollStyles_h |