Bug 1869043 allow a device to be specified with MediaTrackGraph::NotifyWhenDeviceStar...
[gecko.git] / layout / base / PresShellForwards.h
blobf1f81d4c3372f7156267e492648a4ee2dc8ffd88
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_PresShellForwards_h
8 #define mozilla_PresShellForwards_h
10 #include "mozilla/TypedEnumBits.h"
11 #include "mozilla/Maybe.h"
13 struct CapturingContentInfo;
15 namespace mozilla {
17 class PresShell;
19 // Flags to pass to PresShell::SetCapturingContent().
20 enum class CaptureFlags {
21 None = 0,
22 // When assigning capture, ignore whether capture is allowed or not.
23 IgnoreAllowedState = 1 << 0,
24 // Set if events should be targeted at the capturing content or its children.
25 RetargetToElement = 1 << 1,
26 // Set if the current capture wants drags to be prevented.
27 PreventDragStart = 1 << 2,
28 // Set when the mouse is pointer locked, and events are sent to locked
29 // element.
30 PointerLock = 1 << 3,
33 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CaptureFlags)
35 enum class ResizeReflowOptions : uint32_t {
36 NoOption = 0,
37 // the resulting BSize can be less than the given one, producing
38 // shrink-to-fit sizing in the block dimension
39 BSizeLimit = 1 << 0,
42 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ResizeReflowOptions)
44 enum class IntrinsicDirty {
45 // Don't mark any intrinsic inline sizes dirty.
46 None,
47 // Mark intrinsic inline sizes dirty on aFrame and its ancestors.
48 FrameAndAncestors,
49 // Mark intrinsic inline sizes dirty on aFrame, its ancestors, and its
50 // descendants.
51 FrameAncestorsAndDescendants,
54 enum class ReflowRootHandling {
55 PositionOrSizeChange, // aFrame is changing position or size
56 NoPositionOrSizeChange, // ... NOT changing ...
57 InferFromBitToAdd, // is changing iff (aBitToAdd == NS_FRAME_IS_DIRTY)
59 // Note: With IntrinsicDirty::FrameAncestorsAndDescendants, these can also
60 // apply to out-of-flows in addition to aFrame.
63 // Indicates where to scroll on a given axis.
64 struct WhereToScroll {
65 // The percentage of the scroll axis that we're scrolling to.
66 // Nothing() represents "scroll to nearest".
67 Maybe<int16_t> mPercentage;
69 // Default is nearest.
70 constexpr WhereToScroll() = default;
72 explicit constexpr WhereToScroll(int16_t aPercentage)
73 : mPercentage(Some(aPercentage)) {}
75 enum { Nearest };
76 MOZ_IMPLICIT constexpr WhereToScroll(decltype(Nearest)) : WhereToScroll() {}
77 enum { Start };
78 MOZ_IMPLICIT constexpr WhereToScroll(decltype(Start)) : WhereToScroll(0) {}
79 enum { Center };
80 MOZ_IMPLICIT constexpr WhereToScroll(decltype(Center)) : WhereToScroll(50) {}
81 enum { End };
82 MOZ_IMPLICIT constexpr WhereToScroll(decltype(End)) : WhereToScroll(100) {}
85 // See the comment for constructor of ScrollAxis for the detail.
86 enum class WhenToScroll : uint8_t {
87 Always,
88 IfNotVisible,
89 IfNotFullyVisible,
92 struct ScrollAxis final {
93 /**
94 * aWhere:
95 * Either a percentage or a special value. PresShell defines:
96 * * (Default) kScrollMinimum = -1: The visible area is scrolled the
97 * minimum amount to show as much as possible of the frame. This won't
98 * hide any initially visible part of the frame.
99 * * kScrollToTop = 0: The frame's upper edge is aligned with the top edge
100 * of the visible area.
101 * * kScrollToBottom = 100: The frame's bottom edge is aligned with the
102 * bottom edge of the visible area.
103 * * kScrollToLeft = 0: The frame's left edge is aligned with the left edge
104 * of the visible area.
105 * * kScrollToRight = 100: The frame's right edge is aligned* with the right
106 * edge of the visible area.
107 * * kScrollToCenter = 50: The frame is centered along the axis the
108 * ScrollAxis is used for.
110 * Other values are treated as a percentage, and the point*"percent"
111 * down the frame is placed at the point "percent" down the visible area.
113 * aWhen:
114 * * (Default) WhenToScroll::IfNotFullyVisible: Move the frame only if it is
115 * not fully visible (including if it's not visible at all). Note that
116 * in this case if the frame is too large to fit in view, it will only
117 * be scrolled if more of it can fit than is already in view.
118 * * WhenToScroll::IfNotVisible: Move the frame only if none of it is
119 * visible.
120 * * WhenToScroll::Always: Move the frame regardless of its current
121 * visibility.
123 * aOnlyIfPerceivedScrollableDirection:
124 * If the direction is not a perceived scrollable direction (i.e. no
125 * scrollbar showing and less than one device pixel of scrollable
126 * distance), don't scroll. Defaults to false.
128 explicit ScrollAxis(WhereToScroll aWhere = WhereToScroll::Nearest,
129 WhenToScroll aWhen = WhenToScroll::IfNotFullyVisible,
130 bool aOnlyIfPerceivedScrollableDirection = false)
131 : mWhereToScroll(aWhere),
132 mWhenToScroll(aWhen),
133 mOnlyIfPerceivedScrollableDirection(
134 aOnlyIfPerceivedScrollableDirection) {}
136 WhereToScroll mWhereToScroll;
137 WhenToScroll mWhenToScroll;
138 bool mOnlyIfPerceivedScrollableDirection : 1;
141 enum class ScrollFlags {
142 None = 0,
143 ScrollFirstAncestorOnly = 1 << 0,
144 ScrollOverflowHidden = 1 << 1,
145 ScrollNoParentFrames = 1 << 2,
146 ScrollSmooth = 1 << 3,
147 ScrollSmoothAuto = 1 << 4,
148 TriggeredByScript = 1 << 5,
149 // ScrollOverflowHidden | ScrollNoParentFrames
150 AnchorScrollFlags = (1 << 1) | (1 << 2),
151 ALL_BITS = (1 << 6) - 1,
154 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollFlags)
156 // See comment at declaration of RenderDocument() for the detail.
157 enum class RenderDocumentFlags {
158 None = 0,
159 IsUntrusted = 1 << 0,
160 IgnoreViewportScrolling = 1 << 1,
161 DrawCaret = 1 << 2,
162 UseWidgetLayers = 1 << 3,
163 AsyncDecodeImages = 1 << 4,
164 DocumentRelative = 1 << 5,
165 DrawWindowNotFlushing = 1 << 6,
166 UseHighQualityScaling = 1 << 7,
167 ResetViewportScrolling = 1 << 8,
170 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderDocumentFlags)
172 // See comment at declaration of RenderSelection() for the detail.
173 enum class RenderImageFlags {
174 None = 0,
175 IsImage = 1 << 0,
176 AutoScale = 1 << 1,
179 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags)
181 enum class ResolutionChangeOrigin : uint8_t {
182 Apz,
183 Test,
184 MainThreadRestore,
185 MainThreadAdjustment,
188 enum class PaintFlags {
189 None = 0,
190 /* Sync-decode images. */
191 PaintSyncDecodeImages = 1 << 1,
194 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintFlags)
196 enum class PaintInternalFlags {
197 None = 0,
198 /* Sync-decode images. */
199 PaintSyncDecodeImages = 1 << 1,
200 /* Composite layers to the window. */
201 PaintComposite = 1 << 2,
204 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintInternalFlags)
206 // This is a private enum class of PresShell, but currently,
207 // MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS isn't available in class definition.
208 // Therefore, we need to put this here.
209 enum class RenderingStateFlags : uint8_t {
210 None = 0,
211 IgnoringViewportScrolling = 1 << 0,
212 DrawWindowNotFlushing = 1 << 1,
215 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderingStateFlags)
217 // The state of the dynamic toolbar on Mobile.
218 enum class DynamicToolbarState {
219 None, // No dynamic toolbar, i.e. the toolbar is static or there is
220 // no available toolbar.
221 Expanded, // The dynamic toolbar is expanded to the maximum height.
222 InTransition, // The dynamic toolbar is being shown/hidden.
223 Collapsed, // The dynamic toolbar is collapsed to zero height.
226 #ifdef DEBUG
228 enum class VerifyReflowFlags {
229 None = 0,
230 On = 1 << 0,
231 Noisy = 1 << 1,
232 All = 1 << 2,
233 DumpCommands = 1 << 3,
234 NoisyCommands = 1 << 4,
235 ReallyNoisyCommands = 1 << 5,
236 DuringResizeReflow = 1 << 6,
239 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VerifyReflowFlags)
241 #endif // #ifdef DEBUG
243 } // namespace mozilla
245 #endif // #ifndef mozilla_PresShellForwards_h