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/. */
5 #ifndef GeckoMVMContext_h_
6 #define GeckoMVMContext_h_
8 #include "MVMContext.h"
10 #include "mozilla/Attributes.h" // for MOZ_NON_OWNING_REF
11 #include "mozilla/RefPtr.h"
22 * An implementation of MVMContext that uses actual Gecko components.
23 * This is intended for production use (whereas TestMVMContext is intended for
26 class GeckoMVMContext final
: public MVMContext
{
28 explicit GeckoMVMContext(dom::Document
* aDocument
, PresShell
* aPresShell
);
29 void AddEventListener(const nsAString
& aType
, nsIDOMEventListener
* aListener
,
30 bool aUseCapture
) override
;
31 void RemoveEventListener(const nsAString
& aType
,
32 nsIDOMEventListener
* aListener
,
33 bool aUseCapture
) override
;
34 void AddObserver(nsIObserver
* aObserver
, const char* aTopic
,
35 bool aOwnsWeak
) override
;
36 void RemoveObserver(nsIObserver
* aObserver
, const char* aTopic
) override
;
37 void Destroy() override
;
39 nsViewportInfo
GetViewportInfo(
40 const ScreenIntSize
& aDisplaySize
) const override
;
41 CSSToLayoutDeviceScale
CSSToDevPixelScale() const override
;
42 float GetResolution() const override
;
43 bool SubjectMatchesDocument(nsISupports
* aSubject
) const override
;
44 Maybe
<CSSRect
> CalculateScrollableRectForRSF() const override
;
45 bool IsResolutionUpdatedByApz() const override
;
46 LayoutDeviceMargin
ScrollbarAreaToExcludeFromCompositionBounds()
48 Maybe
<LayoutDeviceIntSize
> GetContentViewerSize() const override
;
49 bool AllowZoomingForDocument() const override
;
50 bool IsInReaderMode() const override
;
51 bool IsDocumentLoading() const override
;
53 void SetResolutionAndScaleTo(float aResolution
,
54 ResolutionChangeOrigin aOrigin
) override
;
55 void SetVisualViewportSize(const CSSSize
& aSize
) override
;
56 void PostVisualViewportResizeEventByDynamicToolbar() override
;
57 void UpdateDisplayPortMargins() override
;
58 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void Reflow(const CSSSize
& aNewSize
) override
;
61 RefPtr
<dom::Document
> mDocument
;
62 // raw ref since the presShell owns this
63 PresShell
* MOZ_NON_OWNING_REF mPresShell
;
64 nsCOMPtr
<dom::EventTarget
> mEventTarget
;
67 } // namespace mozilla
69 #endif // GeckoMVMContext_h_