VisualViewport.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/EventTarget.h>
  8. namespace Web::CSS {
  9. // https://drafts.csswg.org/cssom-view/#visualviewport
  10. class VisualViewport final : public DOM::EventTarget {
  11. WEB_PLATFORM_OBJECT(VisualViewport, DOM::EventTarget);
  12. public:
  13. [[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);
  14. virtual ~VisualViewport() override = default;
  15. [[nodiscard]] double offset_left() const;
  16. [[nodiscard]] double offset_top() const;
  17. [[nodiscard]] double page_left() const;
  18. [[nodiscard]] double page_top() const;
  19. [[nodiscard]] double width() const;
  20. [[nodiscard]] double height() const;
  21. [[nodiscard]] double scale() const;
  22. void set_onresize(WebIDL::CallbackType*);
  23. WebIDL::CallbackType* onresize();
  24. void set_onscroll(WebIDL::CallbackType*);
  25. WebIDL::CallbackType* onscroll();
  26. void set_onscrollend(WebIDL::CallbackType*);
  27. WebIDL::CallbackType* onscrollend();
  28. private:
  29. explicit VisualViewport(DOM::Document&);
  30. virtual void initialize(JS::Realm&) override;
  31. virtual void visit_edges(Cell::Visitor&) override;
  32. JS::NonnullGCPtr<DOM::Document> m_document;
  33. };
  34. }