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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
use super::*;
/// The Text class.
/// [`Text`](https://developer.mozilla.org/en-US/docs/Web/API/Text)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Text {
inner: CharacterData,
}
impl FromVal for Text {
fn from_val(v: &Any) -> Self {
Text {
inner: CharacterData::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 Text {
type Target = CharacterData;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for Text {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for Text {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for Text {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<Text> for Any {
fn from(s: Text) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&Text> for Any {
fn from(s: &Text) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(Text);
impl Text {
/// Getter of the `wholeText` attribute.
/// [`Text.wholeText`](https://developer.mozilla.org/en-US/docs/Web/API/Text/wholeText)
pub fn whole_text(&self) -> JsString {
self.inner.get("wholeText").as_::<JsString>()
}
}
impl Text {
/// Getter of the `assignedSlot` attribute.
/// [`Text.assignedSlot`](https://developer.mozilla.org/en-US/docs/Web/API/Text/assignedSlot)
pub fn assigned_slot(&self) -> HTMLSlotElement {
self.inner.get("assignedSlot").as_::<HTMLSlotElement>()
}
}
impl Text {
/// The `new Text(..)` constructor, creating a new Text instance
pub fn new() -> Text {
Self {
inner: Any::global("Text").new(&[]).as_::<CharacterData>(),
}
}
}
impl Text {
/// The `new Text(..)` constructor, creating a new Text instance
pub fn new_with_data(data: &JsString) -> Text {
Self {
inner: Any::global("Text")
.new(&[data.into()])
.as_::<CharacterData>(),
}
}
}
impl Text {
/// The splitText method.
/// [`Text.splitText`](https://developer.mozilla.org/en-US/docs/Web/API/Text/splitText)
pub fn split_text(&self, offset: u32) -> Text {
self.inner.call("splitText", &[offset.into()]).as_::<Text>()
}
}
impl Text {
/// The getBoxQuads method.
/// [`Text.getBoxQuads`](https://developer.mozilla.org/en-US/docs/Web/API/Text/getBoxQuads)
pub fn get_box_quads(&self) -> TypedArray<DOMQuad> {
self.inner
.call("getBoxQuads", &[])
.as_::<TypedArray<DOMQuad>>()
}
}
impl Text {
/// The getBoxQuads method.
/// [`Text.getBoxQuads`](https://developer.mozilla.org/en-US/docs/Web/API/Text/getBoxQuads)
pub fn get_box_quads_with_options(&self, options: &BoxQuadOptions) -> TypedArray<DOMQuad> {
self.inner
.call("getBoxQuads", &[options.into()])
.as_::<TypedArray<DOMQuad>>()
}
}
impl Text {
/// The convertQuadFromNode method.
/// [`Text.convertQuadFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertQuadFromNode)
pub fn convert_quad_from_node(&self, quad: &DOMQuadInit, from: &Any) -> DOMQuad {
self.inner
.call("convertQuadFromNode", &[quad.into(), from.into()])
.as_::<DOMQuad>()
}
}
impl Text {
/// The convertQuadFromNode method.
/// [`Text.convertQuadFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertQuadFromNode)
pub fn convert_quad_from_node_with_options(
&self,
quad: &DOMQuadInit,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMQuad {
self.inner
.call(
"convertQuadFromNode",
&[quad.into(), from.into(), options.into()],
)
.as_::<DOMQuad>()
}
}
impl Text {
/// The convertRectFromNode method.
/// [`Text.convertRectFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertRectFromNode)
pub fn convert_rect_from_node(&self, rect: &DOMRectReadOnly, from: &Any) -> DOMQuad {
self.inner
.call("convertRectFromNode", &[rect.into(), from.into()])
.as_::<DOMQuad>()
}
}
impl Text {
/// The convertRectFromNode method.
/// [`Text.convertRectFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertRectFromNode)
pub fn convert_rect_from_node_with_options(
&self,
rect: &DOMRectReadOnly,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMQuad {
self.inner
.call(
"convertRectFromNode",
&[rect.into(), from.into(), options.into()],
)
.as_::<DOMQuad>()
}
}
impl Text {
/// The convertPointFromNode method.
/// [`Text.convertPointFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertPointFromNode)
pub fn convert_point_from_node(&self, point: &DOMPointInit, from: &Any) -> DOMPoint {
self.inner
.call("convertPointFromNode", &[point.into(), from.into()])
.as_::<DOMPoint>()
}
}
impl Text {
/// The convertPointFromNode method.
/// [`Text.convertPointFromNode`](https://developer.mozilla.org/en-US/docs/Web/API/Text/convertPointFromNode)
pub fn convert_point_from_node_with_options(
&self,
point: &DOMPointInit,
from: &Any,
options: &ConvertCoordinateOptions,
) -> DOMPoint {
self.inner
.call(
"convertPointFromNode",
&[point.into(), from.into(), options.into()],
)
.as_::<DOMPoint>()
}
}