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/TypedEnumBits.h" 11 12 struct CapturingContentInfo; 13 14 namespace mozilla { 15 16 class PresShell; 17 18 // Flags to pass to PresShell::SetCapturingContent(). 19 enum class CaptureFlags { 20 None = 0, 21 // When assigning capture, ignore whether capture is allowed or not. 22 IgnoreAllowedState = 1 << 0, 23 // Set if events should be targeted at the capturing content or its children. 24 RetargetToElement = 1 << 1, 25 // Set if the current capture wants drags to be prevented. 26 PreventDragStart = 1 << 2, 27 // Set when the mouse is pointer locked, and events are sent to locked 28 // element. 29 PointerLock = 1 << 3, 30 }; 31 32 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(CaptureFlags) 33 34 enum class ResizeReflowOptions : uint32_t { 35 NoOption = 0, 36 // the resulting BSize can be less than the given one, producing 37 // shrink-to-fit sizing in the block dimension 38 BSizeLimit = 1 << 0, 39 // Invalidate layout, but don't reflow. 40 // 41 // TODO(emilio): Ideally this should just become the default, or we should 42 // unconditionally not reflow and rely on the caller to do so, having a 43 // separate API for shrink-to-fit. 44 SuppressReflow = 1 << 1, 45 }; 46 47 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ResizeReflowOptions) 48 49 enum class IntrinsicDirty { 50 // XXXldb eResize should be renamed 51 Resize, // don't mark any intrinsic widths dirty 52 TreeChange, // mark intrinsic widths dirty on aFrame and its ancestors 53 StyleChange, // Do eTreeChange, plus all of aFrame's descendants 54 }; 55 56 enum class ReflowRootHandling { 57 PositionOrSizeChange, // aFrame is changing position or size 58 NoPositionOrSizeChange, // ... NOT changing ... 59 InferFromBitToAdd, // is changing iff (aBitToAdd == NS_FRAME_IS_DIRTY) 60 61 // Note: With eStyleChange, these can also apply to out-of-flows 62 // in addition to aFrame. 63 }; 64 65 // WhereToScroll should be 0 ~ 100 or -1. When it's in 0 ~ 100, it means 66 // percentage of scrollTop/scrollLeft in scrollHeight/scrollWidth. 67 // See the comment for constructor of ScrollAxis for the detail. 68 typedef int16_t WhereToScroll; 69 static const WhereToScroll kScrollToTop = 0; 70 static const WhereToScroll kScrollToLeft = 0; 71 static const WhereToScroll kScrollToCenter = 50; 72 static const WhereToScroll kScrollToBottom = 100; 73 static const WhereToScroll kScrollToRight = 100; 74 static const WhereToScroll kScrollMinimum = -1; 75 76 // See the comment for constructor of ScrollAxis for the detail. 77 enum class WhenToScroll : uint8_t { 78 Always, 79 IfNotVisible, 80 IfNotFullyVisible, 81 }; 82 83 struct ScrollAxis final { 84 /** 85 * aWhere: 86 * Either a percentage or a special value. PresShell defines: 87 * * (Default) kScrollMinimum = -1: The visible area is scrolled the 88 * minimum amount to show as much as possible of the frame. This won't 89 * hide any initially visible part of the frame. 90 * * kScrollToTop = 0: The frame's upper edge is aligned with the top edge 91 * of the visible area. 92 * * kScrollToBottom = 100: The frame's bottom edge is aligned with the 93 * bottom edge of the visible area. 94 * * kScrollToLeft = 0: The frame's left edge is aligned with the left edge 95 * of the visible area. 96 * * kScrollToRight = 100: The frame's right edge is aligned* with the right 97 * edge of the visible area. 98 * * kScrollToCenter = 50: The frame is centered along the axis the 99 * ScrollAxis is used for. 100 * 101 * Other values are treated as a percentage, and the point*"percent" 102 * down the frame is placed at the point "percent" down the visible area. 103 * 104 * aWhen: 105 * * (Default) WhenToScroll::IfNotFullyVisible: Move the frame only if it is 106 * not fully visible (including if it's not visible at all). Note that 107 * in this case if the frame is too large to fit in view, it will only 108 * be scrolled if more of it can fit than is already in view. 109 * * WhenToScroll::IfNotVisible: Move the frame only if none of it is 110 * visible. 111 * * WhenToScroll::Always: Move the frame regardless of its current 112 * visibility. 113 * 114 * aOnlyIfPerceivedScrollableDirection: 115 * If the direction is not a perceived scrollable direction (i.e. no 116 * scrollbar showing and less than one device pixel of scrollable 117 * distance), don't scroll. Defaults to false. 118 */ 119 explicit ScrollAxis(WhereToScroll aWhere = kScrollMinimum, 120 WhenToScroll aWhen = WhenToScroll::IfNotFullyVisible, 121 bool aOnlyIfPerceivedScrollableDirection = false) mWhereToScrollfinal122 : mWhereToScroll(aWhere), 123 mWhenToScroll(aWhen), 124 mOnlyIfPerceivedScrollableDirection( 125 aOnlyIfPerceivedScrollableDirection) {} 126 127 WhereToScroll mWhereToScroll; 128 WhenToScroll mWhenToScroll; 129 bool mOnlyIfPerceivedScrollableDirection : 1; 130 }; 131 132 enum class ScrollFlags { 133 None = 0, 134 ScrollFirstAncestorOnly = 1 << 0, 135 ScrollOverflowHidden = 1 << 1, 136 ScrollNoParentFrames = 1 << 2, 137 ScrollSmooth = 1 << 3, 138 ScrollSmoothAuto = 1 << 4, 139 ScrollSnap = 1 << 5, 140 TriggeredByScript = 1 << 6, 141 // ScrollOverflowHidden | ScrollNoParentFrames 142 AnchorScrollFlags = (1 << 1) | (1 << 2), 143 ALL_BITS = (1 << 7) - 1, 144 }; 145 146 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollFlags) 147 148 // See comment at declaration of RenderDocument() for the detail. 149 enum class RenderDocumentFlags { 150 None = 0, 151 IsUntrusted = 1 << 0, 152 IgnoreViewportScrolling = 1 << 1, 153 DrawCaret = 1 << 2, 154 UseWidgetLayers = 1 << 3, 155 AsyncDecodeImages = 1 << 4, 156 DocumentRelative = 1 << 5, 157 DrawWindowNotFlushing = 1 << 6, 158 UseHighQualityScaling = 1 << 7, 159 ResetViewportScrolling = 1 << 8, 160 }; 161 162 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderDocumentFlags) 163 164 // See comment at declaration of RenderSelection() for the detail. 165 enum class RenderImageFlags { 166 None = 0, 167 IsImage = 1 << 0, 168 AutoScale = 1 << 1, 169 }; 170 171 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderImageFlags) 172 173 enum class ResolutionChangeOrigin : uint8_t { 174 Apz, 175 Test, 176 MainThreadRestore, 177 MainThreadAdjustment, 178 }; 179 180 // See comment at declaration of AddCanvasBackgroundColorItem() for the detail. 181 enum class AddCanvasBackgroundColorFlags { 182 None = 0, 183 ForceDraw = 1 << 0, 184 }; 185 186 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(AddCanvasBackgroundColorFlags) 187 188 enum class PaintFlags { 189 None = 0, 190 /* Sync-decode images. */ 191 PaintSyncDecodeImages = 1 << 1, 192 }; 193 194 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintFlags) 195 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, 202 }; 203 204 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(PaintInternalFlags) 205 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, 213 }; 214 215 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RenderingStateFlags) 216 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. 224 }; 225 226 #ifdef DEBUG 227 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, 237 }; 238 239 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(VerifyReflowFlags) 240 241 #endif // #ifdef DEBUG 242 243 } // namespace mozilla 244 245 #endif // #ifndef mozilla_PresShellForwards_h 246