LineBox.h 967 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 ends_with_forced_line_break() const;
  21. private:
  22. friend class BlockContainer;
  23. friend class InlineFormattingContext;
  24. NonnullOwnPtrVector<LineBoxFragment> m_fragments;
  25. float m_width { 0 };
  26. };
  27. }