Dactyloidae/dom/base/VisualViewport.h
Moonchild a036cfeb69 Issue #2714 - Implement the Visual Viewport API
This DOM/Web API is entirely irrelevant for desktop use.
We give back the width/height of the root scrollframe of content and
for scale we pass forward our dpp resolution (usually 1.0).
Since we have no "no touch" zones in our content on desktop,. the rest
(origin and offset) is hard-coded to (0,0).
2025-08-04 21:32:39 +08:00

49 lines
1.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_VisualViewport_h
#define mozilla_dom_VisualViewport_h
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/VisualViewportBinding.h"
#include "Units.h"
#include "nsIPresShell.h"
namespace mozilla {
namespace dom {
/* Visual Viewport API spec: https://wicg.github.io/visual-viewport/#the-visualviewport-interface */
class VisualViewport final: public mozilla::DOMEventTargetHelper
{
public:
explicit VisualViewport(nsPIDOMWindowInner* aWindow);
explicit VisualViewport(nsIGlobalObject* aGlobal);
double OffsetLeft() const;
double OffsetTop() const;
double PageLeft() const;
double PageTop() const;
double Width() const;
double Height() const;
double Scale() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
private:
virtual ~VisualViewport();
CSSSize VisualViewportSize() const;
CSSPoint VisualViewportOffset() const;
CSSPoint LayoutViewportOffset() const;
nsIPresShell* GetPresShell() const;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_VisualViewport_h