diff options
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() { |