tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

GeckoMVMContext.h (2799B)


      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 GeckoMVMContext_h_
      6 #define GeckoMVMContext_h_
      7 
      8 #include "MVMContext.h"
      9 #include "mozilla/Attributes.h"  // for MOZ_NON_OWNING_REF
     10 #include "mozilla/RefPtr.h"
     11 #include "nsCOMPtr.h"
     12 
     13 namespace mozilla {
     14 class PresShell;
     15 namespace dom {
     16 class Document;
     17 class EventTarget;
     18 enum class InteractiveWidget : uint8_t;
     19 }  // namespace dom
     20 
     21 /**
     22 * An implementation of MVMContext that uses actual Gecko components.
     23 * This is intended for production use (whereas TestMVMContext is intended for
     24 * testing.)
     25 */
     26 class GeckoMVMContext final : public MVMContext {
     27 public:
     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;
     38 
     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()
     47      const override;
     48  Maybe<LayoutDeviceIntSize> GetDocumentViewerSize() const override;
     49  bool AllowZoomingForDocument() const override;
     50  bool IsInReaderMode() const override;
     51  bool IsDocumentLoading() const override;
     52  bool IsDocumentFullscreen() const override;
     53 
     54  void SetResolutionAndScaleTo(float aResolution,
     55                               ResolutionChangeOrigin aOrigin) override;
     56  void SetVisualViewportSize(const CSSSize& aSize) override;
     57  void PostVisualViewportResizeEventByDynamicToolbar() override;
     58  void UpdateDisplayPortMargins() override;
     59  MOZ_CAN_RUN_SCRIPT_BOUNDARY void Reflow(const CSSSize& aNewSize) override;
     60  ScreenIntCoord GetDynamicToolbarOffset() override;
     61  dom::InteractiveWidget GetInteractiveWidgetMode() const override;
     62 
     63 private:
     64  RefPtr<dom::Document> mDocument;
     65  // raw ref since the presShell owns this
     66  PresShell* MOZ_NON_OWNING_REF mPresShell;
     67  nsCOMPtr<dom::EventTarget> mEventTarget;
     68 };
     69 
     70 }  // namespace mozilla
     71 
     72 #endif  // GeckoMVMContext_h_