/src/serenity/Userland/Libraries/LibWeb/Layout/LineBoxFragment.h
Line | Count | Source (jump to first uncovered line) |
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 <LibGfx/Rect.h> |
10 | | #include <LibGfx/TextLayout.h> |
11 | | #include <LibJS/Heap/GCPtr.h> |
12 | | #include <LibWeb/Forward.h> |
13 | | #include <LibWeb/Painting/BorderRadiiData.h> |
14 | | #include <LibWeb/PixelUnits.h> |
15 | | |
16 | | namespace Web::Layout { |
17 | | |
18 | | class LineBoxFragment { |
19 | | friend class LineBox; |
20 | | |
21 | | public: |
22 | | LineBoxFragment(Node const& layout_node, int start, int length, CSSPixelPoint offset, CSSPixelSize size, CSSPixels border_box_top, CSS::Direction, RefPtr<Gfx::GlyphRun>); |
23 | | |
24 | 0 | Node const& layout_node() const { return m_layout_node; } |
25 | 0 | int start() const { return m_start; } |
26 | 0 | int length() const { return m_length; } |
27 | | CSSPixelRect const absolute_rect() const; |
28 | | |
29 | 0 | CSSPixelPoint offset() const { return m_offset; } |
30 | 0 | void set_offset(CSSPixelPoint offset) { m_offset = offset; } |
31 | | |
32 | | // The baseline of a fragment is the number of pixels from the top to the text baseline. |
33 | 0 | void set_baseline(CSSPixels y) { m_baseline = y; } |
34 | 0 | CSSPixels baseline() const { return m_baseline; } |
35 | | |
36 | | CSSPixelSize size() const |
37 | 0 | { |
38 | 0 | return m_size; |
39 | 0 | } |
40 | 0 | void set_width(CSSPixels width) { m_size.set_width(width); } |
41 | 0 | void set_height(CSSPixels height) { m_size.set_height(height); } |
42 | 0 | CSSPixels width() const { return m_size.width(); } |
43 | 0 | CSSPixels height() const { return m_size.height(); } |
44 | | |
45 | 0 | CSSPixels border_box_top() const { return m_border_box_top; } |
46 | | |
47 | | bool ends_in_whitespace() const; |
48 | | bool is_justifiable_whitespace() const; |
49 | | StringView text() const; |
50 | | |
51 | | bool is_atomic_inline() const; |
52 | | |
53 | 0 | RefPtr<Gfx::GlyphRun> glyph_run() const { return m_glyph_run; } |
54 | | void append_glyph_run(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width); |
55 | | |
56 | | private: |
57 | | CSS::Direction resolve_glyph_run_direction(Gfx::GlyphRun::TextType) const; |
58 | | void append_glyph_run_ltr(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width); |
59 | | void append_glyph_run_rtl(RefPtr<Gfx::GlyphRun> const&, CSSPixels run_width); |
60 | | |
61 | | JS::NonnullGCPtr<Node const> m_layout_node; |
62 | | int m_start { 0 }; |
63 | | int m_length { 0 }; |
64 | | CSSPixelPoint m_offset; |
65 | | CSSPixelSize m_size; |
66 | | CSSPixels m_border_box_top { 0 }; |
67 | | CSSPixels m_baseline { 0 }; |
68 | | CSS::Direction m_direction { CSS::Direction::Ltr }; |
69 | | |
70 | | RefPtr<Gfx::GlyphRun> m_glyph_run; |
71 | | float m_insert_position { 0 }; |
72 | | CSS::Direction m_current_insert_direction { CSS::Direction::Ltr }; |
73 | | }; |
74 | | |
75 | | } |