Coverage Report

Created: 2026-07-25 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/Painting/PaintableFragment.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/Layout/LineBoxFragment.h>
10
#include <LibWeb/Layout/Node.h>
11
#include <LibWeb/Painting/BorderRadiiData.h>
12
#include <LibWeb/PixelUnits.h>
13
14
namespace Web::Painting {
15
16
class PaintableFragment {
17
    friend class InlinePaintable;
18
    friend class PaintableWithLines;
19
20
public:
21
    explicit PaintableFragment(Layout::LineBoxFragment const&);
22
23
0
    Layout::Node const& layout_node() const { return m_layout_node; }
24
0
    Paintable const& paintable() const { return *m_layout_node->paintable(); }
25
26
0
    int start() const { return m_start; }
27
0
    int length() const { return m_length; }
28
29
0
    CSSPixels baseline() const { return m_baseline; }
30
0
    CSSPixelPoint offset() const { return m_offset; }
31
0
    void set_offset(CSSPixelPoint offset) { m_offset = offset; }
32
0
    CSSPixelSize size() const { return m_size; }
33
34
0
    BorderRadiiData const& border_radii_data() const { return m_border_radii_data; }
35
0
    void set_border_radii_data(BorderRadiiData const& border_radii_data) { m_border_radii_data = border_radii_data; }
36
37
0
    Vector<ShadowData> const& shadows() const { return m_shadows; }
38
0
    void set_shadows(Vector<ShadowData>&& shadows) { m_shadows = shadows; }
39
40
    CSSPixelRect const absolute_rect() const;
41
42
0
    RefPtr<Gfx::GlyphRun> glyph_run() const { return m_glyph_run; }
43
44
    CSSPixelRect selection_rect(Gfx::Font const&) const;
45
    CSSPixelRect range_rect(Gfx::Font const&, DOM::Range const&) const;
46
47
0
    CSSPixels width() const { return m_size.width(); }
48
0
    CSSPixels height() const { return m_size.height(); }
49
50
    int text_index_at(CSSPixels) const;
51
52
    StringView string_view() const;
53
54
private:
55
    JS::NonnullGCPtr<Layout::Node const> m_layout_node;
56
    CSSPixelPoint m_offset;
57
    CSSPixelSize m_size;
58
    CSSPixels m_baseline;
59
    int m_start;
60
    int m_length;
61
    Painting::BorderRadiiData m_border_radii_data;
62
    RefPtr<Gfx::GlyphRun> m_glyph_run;
63
    Vector<ShadowData> m_shadows;
64
};
65
66
}