/src/serenity/Userland/Libraries/LibWeb/Layout/LineBox.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/Vector.h> |
10 | | #include <LibWeb/Layout/LineBoxFragment.h> |
11 | | |
12 | | namespace Web::Layout { |
13 | | |
14 | | class LineBox { |
15 | | public: |
16 | | LineBox(CSS::Direction direction) |
17 | 0 | : m_direction(direction) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | 0 | CSSPixels width() const { return m_width; } |
22 | 0 | CSSPixels height() const { return m_height; } |
23 | 0 | CSSPixels bottom() const { return m_bottom; } |
24 | 0 | CSSPixels baseline() const { return m_baseline; } |
25 | | |
26 | | 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, RefPtr<Gfx::GlyphRun> glyph_run = {}); |
27 | | |
28 | 0 | Vector<LineBoxFragment> const& fragments() const { return m_fragments; } |
29 | 0 | Vector<LineBoxFragment>& fragments() { return m_fragments; } |
30 | | |
31 | | void trim_trailing_whitespace(); |
32 | | |
33 | | bool is_empty_or_ends_in_whitespace() const; |
34 | 0 | bool is_empty() const { return m_fragments.is_empty() && !m_has_break; } |
35 | | |
36 | 0 | AvailableSize original_available_width() const { return m_original_available_width; } |
37 | | |
38 | | private: |
39 | | friend class BlockContainer; |
40 | | friend class InlineFormattingContext; |
41 | | friend class LineBuilder; |
42 | | |
43 | | Vector<LineBoxFragment> m_fragments; |
44 | | CSSPixels m_width { 0 }; |
45 | | CSSPixels m_height { 0 }; |
46 | | CSSPixels m_bottom { 0 }; |
47 | | CSSPixels m_baseline { 0 }; |
48 | | CSS::Direction m_direction { CSS::Direction::Ltr }; |
49 | | |
50 | | // The amount of available width that was originally available when creating this line box. Used for text justification. |
51 | | AvailableSize m_original_available_width { AvailableSize::make_indefinite() }; |
52 | | |
53 | | bool m_has_break { false }; |
54 | | bool m_has_forced_break { false }; |
55 | | }; |
56 | | |
57 | | } |