IAPZCTreeManager.h (5797B)
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_layers_IAPZCTreeManager_h 8 #define mozilla_layers_IAPZCTreeManager_h 9 10 #include <stdint.h> // for uint64_t, uint32_t 11 12 #include "mozilla/layers/LayersTypes.h" // for TouchBehaviorFlags 13 #include "mozilla/layers/ScrollableLayerGuid.h" // for ScrollableLayerGuid, etc 14 #include "mozilla/layers/ZoomConstraints.h" // for ZoomConstraints 15 #include "nsTArrayForwardDeclare.h" // for nsTArray, nsTArray_Impl, etc 16 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc 17 #include "Units.h" // for CSSRect, etc 18 19 namespace mozilla { 20 namespace layers { 21 22 class APZInputBridge; 23 class KeyboardMap; 24 struct ZoomTarget; 25 26 enum AllowedTouchBehavior { 27 NONE = 0, 28 VERTICAL_PAN = 1 << 0, 29 HORIZONTAL_PAN = 1 << 1, 30 PINCH_ZOOM = 1 << 2, 31 ANIMATING_ZOOM = 1 << 3, 32 UNKNOWN = 1 << 4 33 }; 34 35 enum ZoomToRectBehavior : uint32_t { 36 DEFAULT_BEHAVIOR = 0, 37 DISABLE_ZOOM_OUT = 1 << 0, 38 PAN_INTO_VIEW_ONLY = 1 << 1, 39 ONLY_ZOOM_TO_DEFAULT_SCALE = 1 << 2, 40 ZOOM_TO_FOCUSED_INPUT = 1 << 3, 41 ZOOM_TO_FOCUSED_INPUT_ON_RESIZES_VISUAL = 1 << 4, 42 }; 43 44 enum class BrowserGestureResponse : bool; 45 46 class AsyncDragMetrics; 47 struct APZHandledResult; 48 49 class IAPZCTreeManager { 50 NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING(IAPZCTreeManager) 51 52 public: 53 /** 54 * Set the keyboard shortcuts to use for translating keyboard events. 55 */ 56 virtual void SetKeyboardMap(const KeyboardMap& aKeyboardMap) = 0; 57 58 /** 59 * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom 60 * in. The actual animation is done on the sampler thread after being set 61 * up. |aRect| must be given in CSS pixels, relative to the document. 62 * |aFlags| is a combination of the ZoomToRectBehavior enum values. 63 */ 64 virtual void ZoomToRect(const ScrollableLayerGuid& aGuid, 65 const ZoomTarget& aZoomTarget, 66 const uint32_t aFlags = DEFAULT_BEHAVIOR) = 0; 67 68 /** 69 * If we have touch listeners, this should always be called when we know 70 * definitively whether or not content has preventDefaulted any touch events 71 * that have come in. If |aPreventDefault| is true, any touch events in the 72 * queue will be discarded. This function must be called on the controller 73 * thread. 74 */ 75 virtual void ContentReceivedInputBlock(uint64_t aInputBlockId, 76 bool aPreventDefault) = 0; 77 78 /** 79 * When the event regions code is enabled, this function should be invoked to 80 * to confirm the target of the input block. This is only needed in cases 81 * where the initial input event of the block hit a dispatch-to-content region 82 * but is safe to call for all input blocks. This function should always be 83 * invoked on the controller thread. 84 * The different elements in the array of targets correspond to the targets 85 * for the different touch points. In the case where the touch point has no 86 * target, or the target is not a scrollable frame, the target's |mScrollId| 87 * should be set to ScrollableLayerGuid::NULL_SCROLL_ID. 88 */ 89 virtual void SetTargetAPZC(uint64_t aInputBlockId, 90 const nsTArray<ScrollableLayerGuid>& aTargets) = 0; 91 92 /** 93 * Updates any zoom constraints contained in the <meta name="viewport"> tag. 94 * If the |aConstraints| is Nothing() then previously-provided constraints for 95 * the given |aGuid| are cleared. 96 */ 97 virtual void UpdateZoomConstraints( 98 const ScrollableLayerGuid& aGuid, 99 const Maybe<ZoomConstraints>& aConstraints) = 0; 100 101 virtual void SetDPI(float aDpiValue) = 0; 102 103 /** 104 * Sets allowed touch behavior values for current touch-session for specific 105 * input block (determined by aInputBlock). 106 * Should be invoked by the widget. Each value of the aValues arrays 107 * corresponds to the different touch point that is currently active. 108 * Must be called after receiving the TOUCH_START event that starts the 109 * touch-session. 110 * This must be called on the controller thread. 111 */ 112 virtual void SetAllowedTouchBehavior( 113 uint64_t aInputBlockId, const nsTArray<TouchBehaviorFlags>& aValues) = 0; 114 115 virtual void SetBrowserGestureResponse(uint64_t aInputBlockId, 116 BrowserGestureResponse aResponse) = 0; 117 118 virtual void StartScrollbarDrag(const ScrollableLayerGuid& aGuid, 119 const AsyncDragMetrics& aDragMetrics) = 0; 120 121 virtual bool StartAutoscroll(const ScrollableLayerGuid& aGuid, 122 const ScreenPoint& aAnchorLocation) = 0; 123 124 virtual void StopAutoscroll(const ScrollableLayerGuid& aGuid) = 0; 125 126 /** 127 * Function used to disable LongTap gestures. 128 * 129 * On slow running tests, drags and touch events can be misinterpreted 130 * as a long tap. This allows tests to disable long tap gesture detection. 131 */ 132 virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0; 133 134 /** 135 * Returns an APZInputBridge interface that can be used to send input 136 * events to APZ in a synchronous manner. This will always be non-null, and 137 * the returned object's lifetime will match the lifetime of this 138 * IAPZCTreeManager implementation. 139 * It is only valid to call this function in the UI process. 140 */ 141 virtual APZInputBridge* InputBridge() = 0; 142 143 protected: 144 // Discourage destruction outside of decref 145 146 virtual ~IAPZCTreeManager() = default; 147 }; 148 149 } // namespace layers 150 } // namespace mozilla 151 152 #endif // mozilla_layers_IAPZCTreeManager_h