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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
use super::*;
/// The EditContext class.
/// [`EditContext`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct EditContext {
inner: EventTarget,
}
impl FromVal for EditContext {
fn from_val(v: &Any) -> Self {
EditContext {
inner: EventTarget::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 EditContext {
type Target = EventTarget;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for EditContext {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for EditContext {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for EditContext {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<EditContext> for Any {
fn from(s: EditContext) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&EditContext> for Any {
fn from(s: &EditContext) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(EditContext);
impl EditContext {
/// Getter of the `text` attribute.
/// [`EditContext.text`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/text)
pub fn text(&self) -> JsString {
self.inner.get("text").as_::<JsString>()
}
}
impl EditContext {
/// Getter of the `selectionStart` attribute.
/// [`EditContext.selectionStart`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/selectionStart)
pub fn selection_start(&self) -> u32 {
self.inner.get("selectionStart").as_::<u32>()
}
}
impl EditContext {
/// Getter of the `selectionEnd` attribute.
/// [`EditContext.selectionEnd`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/selectionEnd)
pub fn selection_end(&self) -> u32 {
self.inner.get("selectionEnd").as_::<u32>()
}
}
impl EditContext {
/// Getter of the `characterBoundsRangeStart` attribute.
/// [`EditContext.characterBoundsRangeStart`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/characterBoundsRangeStart)
pub fn character_bounds_range_start(&self) -> u32 {
self.inner.get("characterBoundsRangeStart").as_::<u32>()
}
}
impl EditContext {
/// Getter of the `ontextupdate` attribute.
/// [`EditContext.ontextupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/ontextupdate)
pub fn ontextupdate(&self) -> Any {
self.inner.get("ontextupdate").as_::<Any>()
}
/// Setter of the `ontextupdate` attribute.
/// [`EditContext.ontextupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/ontextupdate)
pub fn set_ontextupdate(&mut self, value: &Any) {
self.inner.set("ontextupdate", value);
}
}
impl EditContext {
/// Getter of the `ontextformatupdate` attribute.
/// [`EditContext.ontextformatupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/ontextformatupdate)
pub fn ontextformatupdate(&self) -> Any {
self.inner.get("ontextformatupdate").as_::<Any>()
}
/// Setter of the `ontextformatupdate` attribute.
/// [`EditContext.ontextformatupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/ontextformatupdate)
pub fn set_ontextformatupdate(&mut self, value: &Any) {
self.inner.set("ontextformatupdate", value);
}
}
impl EditContext {
/// Getter of the `oncharacterboundsupdate` attribute.
/// [`EditContext.oncharacterboundsupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncharacterboundsupdate)
pub fn oncharacterboundsupdate(&self) -> Any {
self.inner.get("oncharacterboundsupdate").as_::<Any>()
}
/// Setter of the `oncharacterboundsupdate` attribute.
/// [`EditContext.oncharacterboundsupdate`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncharacterboundsupdate)
pub fn set_oncharacterboundsupdate(&mut self, value: &Any) {
self.inner.set("oncharacterboundsupdate", value);
}
}
impl EditContext {
/// Getter of the `oncompositionstart` attribute.
/// [`EditContext.oncompositionstart`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncompositionstart)
pub fn oncompositionstart(&self) -> Any {
self.inner.get("oncompositionstart").as_::<Any>()
}
/// Setter of the `oncompositionstart` attribute.
/// [`EditContext.oncompositionstart`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncompositionstart)
pub fn set_oncompositionstart(&mut self, value: &Any) {
self.inner.set("oncompositionstart", value);
}
}
impl EditContext {
/// Getter of the `oncompositionend` attribute.
/// [`EditContext.oncompositionend`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncompositionend)
pub fn oncompositionend(&self) -> Any {
self.inner.get("oncompositionend").as_::<Any>()
}
/// Setter of the `oncompositionend` attribute.
/// [`EditContext.oncompositionend`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/oncompositionend)
pub fn set_oncompositionend(&mut self, value: &Any) {
self.inner.set("oncompositionend", value);
}
}
impl EditContext {
/// The `new EditContext(..)` constructor, creating a new EditContext instance
pub fn new() -> EditContext {
Self {
inner: Any::global("EditContext").new(&[]).as_::<EventTarget>(),
}
}
}
impl EditContext {
/// The `new EditContext(..)` constructor, creating a new EditContext instance
pub fn new_with_options(options: &EditContextInit) -> EditContext {
Self {
inner: Any::global("EditContext")
.new(&[options.into()])
.as_::<EventTarget>(),
}
}
}
impl EditContext {
/// The updateText method.
/// [`EditContext.updateText`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/updateText)
pub fn update_text(&self, range_start: u32, range_end: u32, text: &JsString) -> Undefined {
self.inner
.call(
"updateText",
&[range_start.into(), range_end.into(), text.into()],
)
.as_::<Undefined>()
}
}
impl EditContext {
/// The updateSelection method.
/// [`EditContext.updateSelection`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/updateSelection)
pub fn update_selection(&self, start: u32, end: u32) -> Undefined {
self.inner
.call("updateSelection", &[start.into(), end.into()])
.as_::<Undefined>()
}
}
impl EditContext {
/// The updateControlBounds method.
/// [`EditContext.updateControlBounds`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/updateControlBounds)
pub fn update_control_bounds(&self, control_bounds: &DOMRect) -> Undefined {
self.inner
.call("updateControlBounds", &[control_bounds.into()])
.as_::<Undefined>()
}
}
impl EditContext {
/// The updateSelectionBounds method.
/// [`EditContext.updateSelectionBounds`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/updateSelectionBounds)
pub fn update_selection_bounds(&self, selection_bounds: &DOMRect) -> Undefined {
self.inner
.call("updateSelectionBounds", &[selection_bounds.into()])
.as_::<Undefined>()
}
}
impl EditContext {
/// The updateCharacterBounds method.
/// [`EditContext.updateCharacterBounds`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/updateCharacterBounds)
pub fn update_character_bounds(
&self,
range_start: u32,
character_bounds: &TypedArray<DOMRect>,
) -> Undefined {
self.inner
.call(
"updateCharacterBounds",
&[range_start.into(), character_bounds.into()],
)
.as_::<Undefined>()
}
}
impl EditContext {
/// The attachedElements method.
/// [`EditContext.attachedElements`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/attachedElements)
pub fn attached_elements(&self) -> TypedArray<HTMLElement> {
self.inner
.call("attachedElements", &[])
.as_::<TypedArray<HTMLElement>>()
}
}
impl EditContext {
/// The characterBounds method.
/// [`EditContext.characterBounds`](https://developer.mozilla.org/en-US/docs/Web/API/EditContext/characterBounds)
pub fn character_bounds(&self) -> TypedArray<DOMRect> {
self.inner
.call("characterBounds", &[])
.as_::<TypedArray<DOMRect>>()
}
}