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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use super::*;
/// The TextMetrics class.
/// [`TextMetrics`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct TextMetrics {
inner: Any,
}
impl FromVal for TextMetrics {
fn from_val(v: &Any) -> Self {
TextMetrics {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for TextMetrics {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for TextMetrics {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for TextMetrics {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for TextMetrics {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<TextMetrics> for Any {
fn from(s: TextMetrics) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&TextMetrics> for Any {
fn from(s: &TextMetrics) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(TextMetrics);
impl TextMetrics {
/// Getter of the `width` attribute.
/// [`TextMetrics.width`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/width)
pub fn width(&self) -> f64 {
self.inner.get("width").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `actualBoundingBoxLeft` attribute.
/// [`TextMetrics.actualBoundingBoxLeft`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxLeft)
pub fn actual_bounding_box_left(&self) -> f64 {
self.inner.get("actualBoundingBoxLeft").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `actualBoundingBoxRight` attribute.
/// [`TextMetrics.actualBoundingBoxRight`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxRight)
pub fn actual_bounding_box_right(&self) -> f64 {
self.inner.get("actualBoundingBoxRight").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `fontBoundingBoxAscent` attribute.
/// [`TextMetrics.fontBoundingBoxAscent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/fontBoundingBoxAscent)
pub fn font_bounding_box_ascent(&self) -> f64 {
self.inner.get("fontBoundingBoxAscent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `fontBoundingBoxDescent` attribute.
/// [`TextMetrics.fontBoundingBoxDescent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/fontBoundingBoxDescent)
pub fn font_bounding_box_descent(&self) -> f64 {
self.inner.get("fontBoundingBoxDescent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `actualBoundingBoxAscent` attribute.
/// [`TextMetrics.actualBoundingBoxAscent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxAscent)
pub fn actual_bounding_box_ascent(&self) -> f64 {
self.inner.get("actualBoundingBoxAscent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `actualBoundingBoxDescent` attribute.
/// [`TextMetrics.actualBoundingBoxDescent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/actualBoundingBoxDescent)
pub fn actual_bounding_box_descent(&self) -> f64 {
self.inner.get("actualBoundingBoxDescent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `emHeightAscent` attribute.
/// [`TextMetrics.emHeightAscent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/emHeightAscent)
pub fn em_height_ascent(&self) -> f64 {
self.inner.get("emHeightAscent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `emHeightDescent` attribute.
/// [`TextMetrics.emHeightDescent`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/emHeightDescent)
pub fn em_height_descent(&self) -> f64 {
self.inner.get("emHeightDescent").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `hangingBaseline` attribute.
/// [`TextMetrics.hangingBaseline`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/hangingBaseline)
pub fn hanging_baseline(&self) -> f64 {
self.inner.get("hangingBaseline").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `alphabeticBaseline` attribute.
/// [`TextMetrics.alphabeticBaseline`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/alphabeticBaseline)
pub fn alphabetic_baseline(&self) -> f64 {
self.inner.get("alphabeticBaseline").as_::<f64>()
}
}
impl TextMetrics {
/// Getter of the `ideographicBaseline` attribute.
/// [`TextMetrics.ideographicBaseline`](https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics/ideographicBaseline)
pub fn ideographic_baseline(&self) -> f64 {
self.inner.get("ideographicBaseline").as_::<f64>()
}
}