LineBox.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 height() const { return m_height; }
  15. float bottom() const { return m_bottom; }
  16. float baseline() const { return m_baseline; }
  17. 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);
  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(); }
  23. private:
  24. friend class BlockContainer;
  25. friend class InlineFormattingContext;
  26. friend class LineBuilder;
  27. Vector<LineBoxFragment> m_fragments;
  28. float m_width { 0 };
  29. float m_height { 0 };
  30. float m_bottom { 0 };
  31. float m_baseline { 0 };
  32. };
  33. }