Viewport.h 975 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. void paint_all_phases(PaintContext&);
  18. JS::GCPtr<Selection::Selection> selection() const;
  19. void build_stacking_context_tree_if_needed();
  20. void recompute_selection_states();
  21. private:
  22. void build_stacking_context_tree();
  23. virtual bool is_viewport() const override { return true; }
  24. };
  25. template<>
  26. inline bool Node::fast_is<Viewport>() const { return is_viewport(); }
  27. }