LineBox.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. CSSPixels width() const { return m_width; }
  14. CSSPixels height() const { return m_height; }
  15. CSSPixels bottom() const { return m_bottom; }
  16. CSSPixels baseline() const { return m_baseline; }
  17. void add_fragment(Node const& layout_node, int start, int length, CSSPixels leading_size, CSSPixels trailing_size, CSSPixels leading_margin, CSSPixels trailing_margin, CSSPixels content_width, CSSPixels content_height, CSSPixels border_box_top, CSSPixels border_box_bottom, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
  18. Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
  19. Vector<LineBoxFragment>& fragments() { return m_fragments; }
  20. void trim_trailing_whitespace();
  21. bool is_empty_or_ends_in_whitespace() const;
  22. bool is_empty() const { return m_fragments.is_empty() && !m_has_break; }
  23. private:
  24. friend class BlockContainer;
  25. friend class InlineFormattingContext;
  26. friend class LineBuilder;
  27. Vector<LineBoxFragment> m_fragments;
  28. CSSPixels m_width { 0 };
  29. CSSPixels m_height { 0 };
  30. CSSPixels m_bottom { 0 };
  31. CSSPixels m_baseline { 0 };
  32. bool m_has_break { false };
  33. };
  34. }