mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make EventTypeId reflect DOM inheritance hierarchy
This commit is contained in:
parent
50e1c967e4
commit
d3c60af5c6
4 changed files with 22 additions and 13 deletions
|
@ -19,6 +19,13 @@ use util::str::DOMString;
|
|||
use std::cell::Cell;
|
||||
use std::default::Default;
|
||||
|
||||
#[derive(JSTraceable, PartialEq, HeapSizeOf)]
|
||||
pub enum UIEventTypeId {
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
UIEvent,
|
||||
}
|
||||
|
||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-UIEvent
|
||||
#[dom_struct]
|
||||
#[derive(HeapSizeOf)]
|
||||
|
@ -30,21 +37,24 @@ pub struct UIEvent {
|
|||
|
||||
impl UIEventDerived for Event {
|
||||
fn is_uievent(&self) -> bool {
|
||||
*self.type_id() == EventTypeId::UIEvent
|
||||
match *self.type_id() {
|
||||
EventTypeId::UIEvent(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UIEvent {
|
||||
pub fn new_inherited(type_id: EventTypeId) -> UIEvent {
|
||||
pub fn new_inherited(type_id: UIEventTypeId) -> UIEvent {
|
||||
UIEvent {
|
||||
event: Event::new_inherited(type_id),
|
||||
event: Event::new_inherited(EventTypeId::UIEvent(type_id)),
|
||||
view: Default::default(),
|
||||
detail: Cell::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(window: &Window) -> Root<UIEvent> {
|
||||
reflect_dom_object(box UIEvent::new_inherited(EventTypeId::UIEvent),
|
||||
reflect_dom_object(box UIEvent::new_inherited(UIEventTypeId::UIEvent),
|
||||
GlobalRef::Window(window),
|
||||
UIEventBinding::Wrap)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue