BlockFormattingContext.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/Layout/FormattingContext.h>
  10. namespace Web::Layout {
  11. class BlockFormattingContext : public FormattingContext {
  12. public:
  13. explicit BlockFormattingContext(Box&, FormattingContext* parent);
  14. ~BlockFormattingContext();
  15. virtual void run(Box&, LayoutMode) override;
  16. bool is_initial() const;
  17. const Vector<Box*>& left_floating_boxes() const { return m_left_floating_boxes; }
  18. const Vector<Box*>& right_floating_boxes() const { return m_right_floating_boxes; }
  19. static float compute_theoretical_height(const Box&);
  20. void compute_width(Box&);
  21. protected:
  22. static void compute_height(Box&);
  23. void compute_position(Box&);
  24. private:
  25. virtual bool is_block_formatting_context() const final { return true; }
  26. void compute_width_for_floating_box(Box&);
  27. void compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox&);
  28. void layout_initial_containing_block(LayoutMode);
  29. void layout_block_level_children(Box&, LayoutMode);
  30. void layout_inline_children(Box&, LayoutMode);
  31. void place_block_level_replaced_element_in_normal_flow(Box& child, Box& container);
  32. void place_block_level_non_replaced_element_in_normal_flow(Box& child, Box& container);
  33. void layout_floating_child(Box&, Box& containing_block);
  34. Vector<Box*> m_left_floating_boxes;
  35. Vector<Box*> m_right_floating_boxes;
  36. };
  37. }