Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / gfx / src / CompositorHitTestInfo.h
blob840d1e5dd54875bdd9823a6f49703b48c886e60d
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/. */
7 #ifndef MOZILLA_GFX_COMPOSITORHITTESTINFO_H_
8 #define MOZILLA_GFX_COMPOSITORHITTESTINFO_H_
10 #include "mozilla/EnumSet.h"
11 #include "mozilla/EnumTypeTraits.h"
13 namespace mozilla {
14 namespace gfx {
16 // This set of flags is used to figure out what information a frame has
17 // that is relevant to hit-testing in the compositor. The flags are
18 // intentionally set up so that if all of them are 0 the item is effectively
19 // invisible to hit-testing, and no information for this frame needs to be
20 // sent to the compositor.
21 // Each enumerator is annotated with the value it contributes to an
22 // EnumSet (2 ^ <value of enumerator>), in hexadecimal.
23 enum class CompositorHitTestFlags : uint8_t {
24 // The frame participates in hit-testing
25 eVisibleToHitTest = 0, // 0x0001
27 // The frame may have odd shapes that requires the main thread to do accurate
28 // hit-testing.
29 eIrregularArea, // 0x0002
30 // The frame has APZ-aware listeners and so inputs targeted at this area
31 // need to be handled by the main thread before APZ can use them, as they
32 // might be prevent-defaulted.
33 eApzAwareListeners, // 0x0004
34 // This is an inactive scrollframe or unlayerized scrollthumb. In this state
35 // it cannot be used by APZ for async scrolling, so APZ will defer to the main
36 // thread.
37 eInactiveScrollframe, // 0x0008
39 // The touch action flags are set up so that the default of
40 // touch-action:auto on an element leaves all the flags as 0.
41 eTouchActionPanXDisabled, // 0x0010
42 eTouchActionPanYDisabled, // 0x0020
43 eTouchActionPinchZoomDisabled, // 0x0040
44 eTouchActionAnimatingZoomDisabled, // 0x0080
46 // The frame is a scrollbar or a subframe inside a scrollbar (including
47 // scroll thumbs)
48 eScrollbar, // 0x0100
49 // The frame is a scrollthumb. If this is set then eScrollbar will also be
50 // set, unless gecko somehow generates a scroll thumb without a containing
51 // scrollbar.
52 eScrollbarThumb, // 0x0200
53 // If eScrollbar is set, this flag indicates if the scrollbar is a vertical
54 // one (if set) or a horizontal one (if not set)
55 eScrollbarVertical, // 0x0400
57 // Events targeting this frame should only be processed if a target
58 // confirmation is received from the main thread. If no such confirmation
59 // is received within a timeout period, the event may be dropped.
60 // Only meaningful in combination with eDispatchToContent.
61 eRequiresTargetConfirmation, // 0x0800
63 // Bits 0x1000, 0x2000, 0x4000, and 0x8000 are used by SideBitsPacked in
64 // WebRenderAPI.cpp when we pack SideBits and CompositorHitTestInfo into a
65 // uint16_t and pass in into webrender to store in the item tag.
69 using CompositorHitTestInfo = EnumSet<CompositorHitTestFlags, uint32_t>;
71 // A CompositorHitTestInfo with none of the flags set
72 constexpr CompositorHitTestInfo CompositorHitTestInvisibleToHit;
74 // Mask to check for all the touch-action flags at once
75 constexpr CompositorHitTestInfo CompositorHitTestTouchActionMask(
76 CompositorHitTestFlags::eTouchActionPanXDisabled,
77 CompositorHitTestFlags::eTouchActionPanYDisabled,
78 CompositorHitTestFlags::eTouchActionPinchZoomDisabled,
79 CompositorHitTestFlags::eTouchActionAnimatingZoomDisabled);
81 // Mask to check all the flags that involve APZ waiting for results from the
82 // main thread
83 constexpr CompositorHitTestInfo CompositorHitTestDispatchToContent(
84 CompositorHitTestFlags::eIrregularArea,
85 CompositorHitTestFlags::eApzAwareListeners,
86 CompositorHitTestFlags::eInactiveScrollframe);
88 } // namespace gfx
90 // Used for IPDL serialization. The 'value' have to be the biggest enum from
91 // CompositorHitTestFlags.
92 template <>
93 struct MaxEnumValue<::mozilla::gfx::CompositorHitTestFlags> {
94 static constexpr unsigned int value = static_cast<unsigned int>(
95 gfx::CompositorHitTestFlags::eRequiresTargetConfirmation);
98 namespace gfx {
100 // Checks if the CompositorHitTestFlags max enum value is less than N.
101 template <int N>
102 static constexpr bool DoesCompositorHitTestInfoFitIntoBits() {
103 if (MaxEnumValue<CompositorHitTestInfo::valueType>::value < N) {
104 return true;
107 return false;
109 } // namespace gfx
111 } // namespace mozilla
113 #endif /* MOZILLA_GFX_COMPOSITORHITTESTINFO_H_ */