PresShellForwards.h (7798B)
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_PresShellForwards_h 8 #define mozilla_PresShellForwards_h 9 10 #include "mozilla/Maybe.h" 11 #include "mozilla/TypedEnumBits.h" 12 13 struct CapturingContentInfo; 14 15 namespace mozilla { 16 17 class PresShell; 18 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, 31 }; 32 33 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CaptureFlags) 34 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, 40 }; 41 42 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ResizeReflowOptions) 43 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, 52 }; 53 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) 58 59 // Note: With IntrinsicDirty::FrameAncestorsAndDescendants, these can also 60 // apply to out-of-flows in addition to aFrame. 61 }; 62 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; 68 69 // Default is nearest. 70 constexpr WhereToScroll() = default; 71 72 explicit constexpr WhereToScroll(int16_t aPercentage) 73 : mPercentage(Some(aPercentage)) {} 74 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) {} 83 }; 84 85 // See the comment for constructor of ScrollAxis for the detail. 86 enum class WhenToScroll : uint8_t { 87 Always, 88 IfNotVisible, 89 IfNotFullyVisible, 90 }; 91 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. 109 * 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. 112 * 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. 122 */ 123 explicit ScrollAxis(WhereToScroll aWhere = WhereToScroll::Nearest, 124 WhenToScroll aWhen = WhenToScroll::IfNotFullyVisible) 125 : mWhereToScroll(aWhere), mWhenToScroll(aWhen) {} 126 127 WhereToScroll mWhereToScroll; 128 WhenToScroll mWhenToScroll; 129 }; 130 131 enum class ScrollFlags : uint8_t { 132 None = 0, 133 ScrollFirstAncestorOnly = 1 << 0, 134 ScrollOverflowHidden = 1 << 1, 135 ScrollNoParentFrames = 1 << 2, 136 ScrollSmooth = 1 << 3, 137 ScrollSmoothAuto = 1 << 4, 138 TriggeredByScript = 1 << 5, 139 AxesAreLogical = 1 << 6, 140 ForZoomToFocusedInput = 1 << 7, 141 // NOTE: `Anchor` means here is "scrolling to an anchor", not "CSS scroll 142 // anchoring". 143 AnchorScrollFlags = 144 ScrollOverflowHidden | ScrollNoParentFrames | TriggeredByScript, 145 ALL_BITS = (1 << 8) - 1, 146 }; 147 148 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollFlags) 149 150 // See comment at declaration of RenderDocument() for the detail. 151 enum class RenderDocumentFlags { 152 None = 0, 153 IsUntrusted = 1 << 0, 154 IgnoreViewportScrolling = 1 << 1, 155 DrawCaret = 1 << 2, 156 UseWidgetLayers = 1 << 3, 157 AsyncDecodeImages = 1 << 4, 158 DocumentRelative = 1 << 5, 159 DrawWindowNotFlushing = 1 << 6, 160 UseHighQualityScaling = 1 << 7, 161 ResetViewportScrolling = 1 << 8, 162 }; 163 164 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderDocumentFlags) 165 166 // See comment at declaration of RenderSelection() for the detail. 167 enum class RenderImageFlags { 168 None = 0, 169 IsImage = 1 << 0, 170 AutoScale = 1 << 1, 171 }; 172 173 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags) 174 175 enum class ResolutionChangeOrigin : uint8_t { 176 Apz, 177 Test, 178 MainThreadRestore, 179 MainThreadAdjustment, 180 }; 181 182 enum class PaintFlags { 183 None = 0, 184 /* Sync-decode images. */ 185 PaintSyncDecodeImages = 1 << 1, 186 /* Render without presenting to the window */ 187 PaintCompositeOffscreen = 1 << 2, 188 }; 189 190 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintFlags) 191 192 enum class PaintInternalFlags { 193 None = 0, 194 /* Sync-decode images. */ 195 PaintSyncDecodeImages = 1 << 1, 196 /* Composite layers to the window. */ 197 PaintComposite = 1 << 2, 198 /* Render without presenting to the window */ 199 PaintCompositeOffscreen = 1 << 3, 200 }; 201 202 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintInternalFlags) 203 204 // This is a private enum class of PresShell, but currently, 205 // MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS isn't available in class definition. 206 // Therefore, we need to put this here. 207 enum class RenderingStateFlags : uint8_t { 208 None = 0, 209 IgnoringViewportScrolling = 1 << 0, 210 DrawWindowNotFlushing = 1 << 1, 211 }; 212 213 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderingStateFlags) 214 215 // The state of the dynamic toolbar on Mobile. 216 enum class DynamicToolbarState { 217 None, // No dynamic toolbar, i.e. the toolbar is static or there is 218 // no available toolbar. 219 Expanded, // The dynamic toolbar is expanded to the maximum height. 220 InTransition, // The dynamic toolbar is being shown/hidden. 221 Collapsed, // The dynamic toolbar is collapsed to zero height. 222 }; 223 224 #ifdef DEBUG 225 226 enum class VerifyReflowFlags { 227 None = 0, 228 On = 1 << 0, 229 Noisy = 1 << 1, 230 All = 1 << 2, 231 DumpCommands = 1 << 3, 232 NoisyCommands = 1 << 4, 233 ReallyNoisyCommands = 1 << 5, 234 DuringResizeReflow = 1 << 6, 235 }; 236 237 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VerifyReflowFlags) 238 239 #endif // #ifdef DEBUG 240 241 } // namespace mozilla 242 243 #endif // #ifndef mozilla_PresShellForwards_h