diff options
author | Piotr Stankiewicz <bionicrift@gmail.com> | 2016-05-15 23:47:15 +0100 |
---|---|---|
committer | Piotr Stankiewicz <bionicrift@gmail.com> | 2016-05-20 18:25:13 +0100 |
commit | d1af39c114d9b1b101826d541afb09105971084b (patch) | |
tree | 75923725099e5a443e76c6a740b7df01ea7a30d3 /components/script/dom/htmlelement.rs | |
parent | 4590fe230f6a498a05109679e3a4064cfafef9e6 (diff) | |
download | servo-d1af39c114d9b1b101826d541afb09105971084b.tar.gz servo-d1af39c114d9b1b101826d541afb09105971084b.zip |
dom: Add missing event handlers
Adding:
* global event handlers,
* window event handlers,
* document and element handlers,
* and support for BeforeUnloadEvent.
Signed-off-by: Piotr Stankiewicz <bionicrift@gmail.com>
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r-- | components/script/dom/htmlelement.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 3ad8f977869..7e310db8903 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -137,6 +137,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#globaleventhandlers global_event_handlers!(NoOnload); + // https://html.spec.whatwg.org/multipage/#documentandelementeventhandlers + document_and_element_event_handlers!(); + // https://html.spec.whatwg.org/multipage/#dom-dataset fn Dataset(&self) -> Root<DOMStringMap> { self.dataset.or_init(|| DOMStringMap::new(self)) @@ -196,6 +199,42 @@ impl HTMLElementMethods for HTMLElement { } } + // https://html.spec.whatwg.org/multipage/#handler-onfocus + fn GetOnfocus(&self) -> Option<Rc<EventHandlerNonNull>> { + if self.is_body_or_frameset() { + window_from_node(self).GetOnfocus() + } else { + self.upcast::<EventTarget>().get_event_handler_common("focus") + } + } + + // https://html.spec.whatwg.org/multipage/#handler-onfocus + fn SetOnfocus(&self, listener: Option<Rc<EventHandlerNonNull>>) { + if self.is_body_or_frameset() { + window_from_node(self).SetOnfocus(listener) + } else { + self.upcast::<EventTarget>().set_event_handler_common("focus", listener) + } + } + + // https://html.spec.whatwg.org/multipage/#handler-onscroll + fn GetOnscroll(&self) -> Option<Rc<EventHandlerNonNull>> { + if self.is_body_or_frameset() { + window_from_node(self).GetOnscroll() + } else { + self.upcast::<EventTarget>().get_event_handler_common("scroll") + } + } + + // https://html.spec.whatwg.org/multipage/#handler-onscroll + fn SetOnscroll(&self, listener: Option<Rc<EventHandlerNonNull>>) { + if self.is_body_or_frameset() { + window_from_node(self).SetOnscroll(listener) + } else { + self.upcast::<EventTarget>().set_event_handler_common("scroll", listener) + } + } + // https://html.spec.whatwg.org/multipage/#dom-click fn Click(&self) { if !self.upcast::<Element>().disabled_state() { |