VisualViewport.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. JS_DECLARE_ALLOCATOR(VisualViewport);
  13. public:
  14. [[nodiscard]] static JS::NonnullGCPtr<VisualViewport> create(DOM::Document&);
  15. virtual ~VisualViewport() override = default;
  16. [[nodiscard]] double offset_left() const;
  17. [[nodiscard]] double offset_top() const;
  18. [[nodiscard]] double page_left() const;
  19. [[nodiscard]] double page_top() const;
  20. [[nodiscard]] double width() const;
  21. [[nodiscard]] double height() const;
  22. [[nodiscard]] double scale() const;
  23. void set_onresize(WebIDL::CallbackType*);
  24. WebIDL::CallbackType* onresize();
  25. void set_onscroll(WebIDL::CallbackType*);
  26. WebIDL::CallbackType* onscroll();
  27. void set_onscrollend(WebIDL::CallbackType*);
  28. WebIDL::CallbackType* onscrollend();
  29. private:
  30. explicit VisualViewport(DOM::Document&);
  31. virtual void initialize(JS::Realm&) override;
  32. virtual void visit_edges(Cell::Visitor&) override;
  33. JS::NonnullGCPtr<DOM::Document> m_document;
  34. };
  35. }