Skip to main content

topcoat_runtime/surrogate/
event.rs

1//! Facade types for DOM events. These exist purely so handler bodies inside
2//! `expr!` can be type-checked by rustc; they are never constructed
3//! server-side. The browser resolves field accesses against the real DOM
4//! `Event` at runtime.
5
6use std::marker::PhantomData;
7
8use crate::{BoolSurrogate, F64Surrogate, StringSurrogate};
9
10pub struct Event {
11    pub alt_key: BoolSurrogate,
12    pub bubbles: BoolSurrogate,
13    pub button: F64Surrogate,
14    pub buttons: F64Surrogate,
15    pub cancelable: BoolSurrogate,
16    pub client_x: F64Surrogate,
17    pub client_y: F64Surrogate,
18    pub code: StringSurrogate,
19    pub ctrl_key: BoolSurrogate,
20    pub current_target: EventTarget,
21    pub data: StringSurrogate,
22    pub default_prevented: BoolSurrogate,
23    pub delta_x: F64Surrogate,
24    pub delta_y: F64Surrogate,
25    pub delta_z: F64Surrogate,
26    pub event_type: StringSurrogate,
27    pub input_type: StringSurrogate,
28    pub is_composing: BoolSurrogate,
29    pub key: StringSurrogate,
30    pub meta_key: BoolSurrogate,
31    pub movement_x: F64Surrogate,
32    pub movement_y: F64Surrogate,
33    pub offset_x: F64Surrogate,
34    pub offset_y: F64Surrogate,
35    pub page_x: F64Surrogate,
36    pub page_y: F64Surrogate,
37    pub pointer_id: F64Surrogate,
38    pub pointer_type: StringSurrogate,
39    pub repeat: BoolSurrogate,
40    pub screen_x: F64Surrogate,
41    pub screen_y: F64Surrogate,
42    pub shift_key: BoolSurrogate,
43    pub target: EventTarget,
44    pub time_stamp: F64Surrogate,
45    _priv: PhantomData<()>,
46}
47
48impl Event {
49    pub fn prevent_default(&self) {
50        unreachable!();
51    }
52
53    pub fn stop_propagation(&self) {
54        unreachable!();
55    }
56
57    pub fn stop_immediate_propagation(&self) {
58        unreachable!();
59    }
60}
61
62pub struct EventTarget {
63    pub checked: BoolSurrogate,
64    pub id: StringSurrogate,
65    pub name: StringSurrogate,
66    pub text_content: StringSurrogate,
67    pub value: StringSurrogate,
68}