LineBox.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/NonnullOwnPtrVector.h>
  8. #include <AK/Vector.h>
  9. #include <LibWeb/Layout/LineBoxFragment.h>
  10. namespace Web::Layout {
  11. class LineBox {
  12. public:
  13. LineBox() { }
  14. float width() const { return m_width; }
  15. void add_fragment(Node& layout_node, int start, int length, float width, float height, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
  16. const NonnullOwnPtrVector<LineBoxFragment>& fragments() const { return m_fragments; }
  17. NonnullOwnPtrVector<LineBoxFragment>& fragments() { return m_fragments; }
  18. void trim_trailing_whitespace();
  19. bool is_empty_or_ends_in_whitespace() const;
  20. bool is_empty() { return m_fragments.is_empty(); }
  21. bool ends_with_forced_line_break() const;
  22. private:
  23. friend class BlockContainer;
  24. friend class InlineFormattingContext;
  25. friend class LineBuilder;
  26. NonnullOwnPtrVector<LineBoxFragment> m_fragments;
  27. float m_width { 0 };
  28. };
  29. }