LineBuilder.h 943 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Layout/InlineFormattingContext.h>
  8. namespace Web::Layout {
  9. class LineBuilder {
  10. AK_MAKE_NONCOPYABLE(LineBuilder);
  11. AK_MAKE_NONMOVABLE(LineBuilder);
  12. public:
  13. explicit LineBuilder(InlineFormattingContext&);
  14. ~LineBuilder();
  15. void break_line();
  16. void begin_new_line();
  17. void append_box(Box&);
  18. void append_text_chunk(TextNode&, size_t offset_in_node, size_t length_in_node, float width, float height);
  19. void break_if_needed(LayoutMode, float next_item_width);
  20. float available_width_for_current_line() const { return m_available_width_for_current_line; }
  21. void update_last_line();
  22. private:
  23. InlineFormattingContext& m_context;
  24. float m_available_width_for_current_line { 0 };
  25. float m_current_y { 0 };
  26. float m_max_height_on_current_line { 0 };
  27. };
  28. }