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
;
19 // Flags to pass to PresShell::SetCapturingContent().
20 enum class CaptureFlags
{
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
33 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CaptureFlags
)
35 enum class ResizeReflowOptions
: uint32_t {
37 // the resulting BSize can be less than the given one, producing
38 // shrink-to-fit sizing in the block dimension
42 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ResizeReflowOptions
)
44 enum class IntrinsicDirty
{
45 // Don't mark any intrinsic inline sizes dirty.
47 // Mark intrinsic inline sizes dirty on aFrame and its ancestors.
49 // Mark intrinsic inline sizes dirty on aFrame, its ancestors, and its
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
)) {}
76 MOZ_IMPLICIT
constexpr WhereToScroll(decltype(Nearest
)) : WhereToScroll() {}
78 MOZ_IMPLICIT
constexpr WhereToScroll(decltype(Start
)) : WhereToScroll(0) {}
80 MOZ_IMPLICIT
constexpr WhereToScroll(decltype(Center
)) : WhereToScroll(50) {}
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 {
92 struct ScrollAxis final
{
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.
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
120 * * WhenToScroll::Always: Move the frame regardless of its current
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
: uint8_t {
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 // NOTE: `Anchor` means here is "scrolling to an anchor", not "CSS scroll
152 ScrollOverflowHidden
| ScrollNoParentFrames
| TriggeredByScript
,
153 ALL_BITS
= (1 << 6) - 1,
156 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollFlags
)
158 // See comment at declaration of RenderDocument() for the detail.
159 enum class RenderDocumentFlags
{
161 IsUntrusted
= 1 << 0,
162 IgnoreViewportScrolling
= 1 << 1,
164 UseWidgetLayers
= 1 << 3,
165 AsyncDecodeImages
= 1 << 4,
166 DocumentRelative
= 1 << 5,
167 DrawWindowNotFlushing
= 1 << 6,
168 UseHighQualityScaling
= 1 << 7,
169 ResetViewportScrolling
= 1 << 8,
172 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderDocumentFlags
)
174 // See comment at declaration of RenderSelection() for the detail.
175 enum class RenderImageFlags
{
181 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags
)
183 enum class ResolutionChangeOrigin
: uint8_t {
187 MainThreadAdjustment
,
190 enum class PaintFlags
{
192 /* Sync-decode images. */
193 PaintSyncDecodeImages
= 1 << 1,
196 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintFlags
)
198 enum class PaintInternalFlags
{
200 /* Sync-decode images. */
201 PaintSyncDecodeImages
= 1 << 1,
202 /* Composite layers to the window. */
203 PaintComposite
= 1 << 2,
206 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintInternalFlags
)
208 // This is a private enum class of PresShell, but currently,
209 // MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS isn't available in class definition.
210 // Therefore, we need to put this here.
211 enum class RenderingStateFlags
: uint8_t {
213 IgnoringViewportScrolling
= 1 << 0,
214 DrawWindowNotFlushing
= 1 << 1,
217 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderingStateFlags
)
219 // The state of the dynamic toolbar on Mobile.
220 enum class DynamicToolbarState
{
221 None
, // No dynamic toolbar, i.e. the toolbar is static or there is
222 // no available toolbar.
223 Expanded
, // The dynamic toolbar is expanded to the maximum height.
224 InTransition
, // The dynamic toolbar is being shown/hidden.
225 Collapsed
, // The dynamic toolbar is collapsed to zero height.
230 enum class VerifyReflowFlags
{
235 DumpCommands
= 1 << 3,
236 NoisyCommands
= 1 << 4,
237 ReallyNoisyCommands
= 1 << 5,
238 DuringResizeReflow
= 1 << 6,
241 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VerifyReflowFlags
)
243 #endif // #ifdef DEBUG
245 } // namespace mozilla
247 #endif // #ifndef mozilla_PresShellForwards_h