summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/TextMetrics.h
blob: 8b3a064d2326ec2b688e32b2a3ce3c862813e859 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibJS/Heap/Handle.h>
#include <LibWeb/Bindings/Wrappable.h>

namespace Web::HTML {

class TextMetrics
    : public RefCounted<TextMetrics>
    , public Bindings::Wrappable {
public:
    using WrapperType = Bindings::TextMetricsWrapper;

    static RefPtr<TextMetrics> create();

    double width() const { return m_width; }
    double actual_bounding_box_left() const { return m_actual_bounding_box_left; }
    double actual_bounding_box_right() const { return m_actual_bounding_box_right; }
    double font_bounding_box_ascent() const { return m_font_bounding_box_ascent; }
    double font_bounding_box_descent() const { return m_font_bounding_box_descent; }
    double actual_bounding_box_ascent() const { return m_actual_bounding_box_ascent; }
    double actual_bounding_box_descent() const { return m_actual_bounding_box_descent; }
    double em_height_ascent() const { return m_em_height_ascent; }
    double em_height_descent() const { return m_em_height_descent; }
    double hanging_baseline() const { return m_hanging_baseline; }
    double alphabetic_baseline() const { return m_alphabetic_baseline; }
    double ideographic_baseline() const { return m_ideographic_baseline; }

    void set_width(double width) { m_width = width; }
    void set_actual_bounding_box_left(double left) { m_actual_bounding_box_left = left; }
    void set_actual_bounding_box_right(double right) { m_actual_bounding_box_right = right; }
    void set_font_bounding_box_ascent(double ascent) { m_font_bounding_box_ascent = ascent; }
    void set_font_bounding_box_descent(double descent) { m_font_bounding_box_descent = descent; }
    void set_actual_bounding_box_ascent(double ascent) { m_actual_bounding_box_ascent = ascent; }
    void set_actual_bounding_box_descent(double descent) { m_actual_bounding_box_descent = descent; }
    void set_em_height_ascent(double ascent) { m_em_height_ascent = ascent; }
    void set_em_height_descent(double descent) { m_em_height_descent = descent; }
    void set_hanging_baseline(double baseline) { m_hanging_baseline = baseline; }
    void set_alphabetic_baseline(double baseline) { m_alphabetic_baseline = baseline; }
    void set_ideographic_baseline(double baseline) { m_ideographic_baseline = baseline; }

private:
    explicit TextMetrics() { }

    double m_width { 0 };
    double m_actual_bounding_box_left { 0 };
    double m_actual_bounding_box_right { 0 };

    double m_font_bounding_box_ascent { 0 };
    double m_font_bounding_box_descent { 0 };
    double m_actual_bounding_box_ascent { 0 };
    double m_actual_bounding_box_descent { 0 };
    double m_em_height_ascent { 0 };
    double m_em_height_descent { 0 };
    double m_hanging_baseline { 0 };
    double m_alphabetic_baseline { 0 };
    double m_ideographic_baseline { 0 };
};

}