Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set sw=2 ts=8 et 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_APZUtils_h
8 : #define mozilla_layers_APZUtils_h
9 :
10 : #include <stdint.h> // for uint32_t
11 : #include "LayersTypes.h"
12 : #include "UnitTransforms.h"
13 : #include "mozilla/gfx/Point.h"
14 : #include "mozilla/FloatingPoint.h"
15 :
16 : namespace mozilla {
17 : namespace layers {
18 :
19 : enum HitTestResult {
20 : HitNothing,
21 : HitLayer,
22 : HitLayerTouchActionNone,
23 : HitLayerTouchActionPanX,
24 : HitLayerTouchActionPanY,
25 : HitLayerTouchActionPanXY,
26 : HitDispatchToContentRegion,
27 : };
28 :
29 : enum CancelAnimationFlags : uint32_t {
30 : Default = 0x0, /* Cancel all animations */
31 : ExcludeOverscroll = 0x1, /* Don't clear overscroll */
32 : ScrollSnap = 0x2, /* Snap to snap points */
33 : ExcludeWheel = 0x4, /* Don't stop wheel smooth-scroll animations */
34 : };
35 :
36 : inline CancelAnimationFlags
37 0 : operator|(CancelAnimationFlags a, CancelAnimationFlags b)
38 : {
39 0 : return static_cast<CancelAnimationFlags>(static_cast<int>(a)
40 0 : | static_cast<int>(b));
41 : }
42 :
43 : enum class ScrollSource {
44 : // scrollTo() or something similar.
45 : DOM,
46 :
47 : // Touch-screen or trackpad with gesture support.
48 : Touch,
49 :
50 : // Mouse wheel.
51 : Wheel
52 : };
53 :
54 : typedef uint32_t TouchBehaviorFlags;
55 :
56 : // Epsilon to be used when comparing 'float' coordinate values
57 : // with FuzzyEqualsAdditive. The rationale is that 'float' has 7 decimal
58 : // digits of precision, and coordinate values should be no larger than in the
59 : // ten thousands. Note also that the smallest legitimate difference in page
60 : // coordinates is 1 app unit, which is 1/60 of a (CSS pixel), so this epsilon
61 : // isn't too large.
62 : const float COORDINATE_EPSILON = 0.01f;
63 :
64 : template <typename Units>
65 2 : static bool IsZero(const gfx::PointTyped<Units>& aPoint)
66 : {
67 2 : return FuzzyEqualsAdditive(aPoint.x, 0.0f, COORDINATE_EPSILON)
68 2 : && FuzzyEqualsAdditive(aPoint.y, 0.0f, COORDINATE_EPSILON);
69 : }
70 :
71 : // Deem an AsyncTransformComponentMatrix (obtained by multiplying together
72 : // one or more AsyncTransformComponentMatrix objects) as constituting a
73 : // complete async transform.
74 : inline AsyncTransformMatrix
75 45 : CompleteAsyncTransform(const AsyncTransformComponentMatrix& aMatrix)
76 : {
77 : return ViewAs<AsyncTransformMatrix>(aMatrix,
78 45 : PixelCastJustification::MultipleAsyncTransforms);
79 : }
80 :
81 : } // namespace layers
82 : } // namespace mozilla
83 :
84 : #endif // mozilla_layers_APZUtils_h
|