MVMContext.h (2800B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef MVMContext_h_ 6 #define MVMContext_h_ 7 8 #include "Units.h" 9 #include "mozilla/Maybe.h" 10 #include "mozilla/PresShellForwards.h" 11 #include "nsISupportsImpl.h" 12 #include "nsStringFwd.h" 13 #include "nsViewportInfo.h" 14 15 class nsIDOMEventListener; 16 class nsIObserver; 17 class nsISupports; 18 19 namespace mozilla::dom { 20 enum class InteractiveWidget : uint8_t; 21 } // namespace mozilla::dom 22 23 namespace mozilla { 24 25 /** 26 * The interface MobileViewportManager uses to interface with its surroundings. 27 * This mainly exists to facilitate testing MobileViewportManager in isolation 28 * from the rest of Gecko. 29 */ 30 class MVMContext { 31 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MVMContext) 32 protected: 33 virtual ~MVMContext() {} 34 35 public: 36 virtual void AddEventListener(const nsAString& aType, 37 nsIDOMEventListener* aListener, 38 bool aUseCapture) = 0; 39 virtual void RemoveEventListener(const nsAString& aType, 40 nsIDOMEventListener* aListener, 41 bool aUseCapture) = 0; 42 virtual void AddObserver(nsIObserver* aObserver, const char* aTopic, 43 bool aOwnsWeak) = 0; 44 virtual void RemoveObserver(nsIObserver* aObserver, const char* aTopic) = 0; 45 virtual void Destroy() = 0; 46 47 virtual nsViewportInfo GetViewportInfo( 48 const ScreenIntSize& aDisplaySize) const = 0; 49 virtual CSSToLayoutDeviceScale CSSToDevPixelScale() const = 0; 50 virtual float GetResolution() const = 0; 51 virtual bool SubjectMatchesDocument(nsISupports* aSubject) const = 0; 52 virtual Maybe<CSSRect> CalculateScrollableRectForRSF() const = 0; 53 virtual bool IsResolutionUpdatedByApz() const = 0; 54 virtual LayoutDeviceMargin ScrollbarAreaToExcludeFromCompositionBounds() 55 const = 0; 56 virtual Maybe<LayoutDeviceIntSize> GetDocumentViewerSize() const = 0; 57 virtual bool AllowZoomingForDocument() const = 0; 58 virtual bool IsInReaderMode() const = 0; 59 virtual bool IsDocumentLoading() const = 0; 60 virtual bool IsDocumentFullscreen() const = 0; 61 62 virtual void SetResolutionAndScaleTo(float aResolution, 63 ResolutionChangeOrigin aOrigin) = 0; 64 virtual void SetVisualViewportSize(const CSSSize& aSize) = 0; 65 virtual void PostVisualViewportResizeEventByDynamicToolbar() = 0; 66 virtual void UpdateDisplayPortMargins() = 0; 67 68 virtual void Reflow(const CSSSize& aNewSize) = 0; 69 virtual ScreenIntCoord GetDynamicToolbarOffset() = 0; 70 virtual dom::InteractiveWidget GetInteractiveWidgetMode() const = 0; 71 }; 72 73 } // namespace mozilla 74 75 #endif // MVMContext_h_