Viewport.h 921 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/DOM/Document.h>
  8. #include <LibWeb/Layout/BlockContainer.h>
  9. #include <LibWeb/Selection/Selection.h>
  10. namespace Web::Layout {
  11. class Viewport final : public BlockContainer {
  12. JS_CELL(Viewport, BlockContainer);
  13. public:
  14. explicit Viewport(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
  15. virtual ~Viewport() override;
  16. const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*Node::dom_node()); }
  17. JS::GCPtr<Selection::Selection> selection() const;
  18. void recompute_selection_states();
  19. private:
  20. virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
  21. virtual bool is_viewport() const override { return true; }
  22. };
  23. template<>
  24. inline bool Node::fast_is<Viewport>() const { return is_viewport(); }
  25. }