LineBox.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2018-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/Layout/LineBoxFragment.h>
  9. namespace Web::Layout {
  10. class LineBox {
  11. public:
  12. LineBox() = default;
  13. float width() const { return m_width; }
  14. float bottom() const { return m_bottom; }
  15. float baseline() const { return m_baseline; }
  16. void add_fragment(Node const& layout_node, int start, int length, float leading_size, float trailing_size, float leading_margin, float trailing_margin, float content_width, float content_height, float border_box_top, float border_box_bottom, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
  17. Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
  18. Vector<LineBoxFragment>& fragments() { return m_fragments; }
  19. void trim_trailing_whitespace();
  20. bool is_empty_or_ends_in_whitespace() const;
  21. bool is_empty() const { return m_fragments.is_empty(); }
  22. private:
  23. friend class BlockContainer;
  24. friend class InlineFormattingContext;
  25. friend class LineBuilder;
  26. Vector<LineBoxFragment> m_fragments;
  27. float m_width { 0 };
  28. float m_bottom { 0 };
  29. float m_baseline { 0 };
  30. };
  31. }