aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorPatrick Shaughnessy <pshaughn@comcast.net>2020-01-29 21:10:22 -0500
committerPatrick Shaughnessy <pshaughn@comcast.net>2020-01-30 10:00:16 -0500
commitf043a3eee2fa4088a8f58d25ac04ef6a68094460 (patch)
treed98ba17f5e051217b61374d3058c0de6fe6fcb43 /components/script/dom
parent6d220d02de9cd8e50421080179355875789f1100 (diff)
downloadservo-f043a3eee2fa4088a8f58d25ac04ef6a68094460.tar.gz
servo-f043a3eee2fa4088a8f58d25ac04ef6a68094460.zip
Error and resize get special getter/setters for reflection
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlelement.rs60
-rw-r--r--components/script/dom/macros.rs3
2 files changed, 47 insertions, 16 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index c5b7e6d0251..b5cd0930def 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -5,6 +5,7 @@
use crate::dom::activation::{synthetic_click_activation, ActivationSource};
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
+use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull;
use crate::dom::bindings::codegen::Bindings::HTMLElementBinding;
use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
use crate::dom::bindings::codegen::Bindings::HTMLLabelElementBinding::HTMLLabelElementMethods;
@@ -181,36 +182,37 @@ impl HTMLElementMethods for HTMLElement {
self.dataset.or_init(|| DOMStringMap::new(self))
}
- // https://html.spec.whatwg.org/multipage/#handler-onload
- fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
+ // https://html.spec.whatwg.org/multipage/#handler-onerror
+ fn GetOnerror(&self) -> Option<Rc<OnErrorEventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().GetOnload()
+ document.window().GetOnerror()
} else {
None
}
} else {
self.upcast::<EventTarget>()
- .get_event_handler_common("load")
+ .get_event_handler_common("error")
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onload
- fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ // https://html.spec.whatwg.org/multipage/#handler-onerror
+ fn SetOnerror(&self, listener: Option<Rc<OnErrorEventHandlerNonNull>>) {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().SetOnload(listener)
+ document.window().SetOnerror(listener)
}
} else {
+ // special setter for error
self.upcast::<EventTarget>()
- .set_event_handler_common("load", listener)
+ .set_error_event_handler("error", listener)
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onresize
- fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
+ // https://html.spec.whatwg.org/multipage/#handler-onload
+ fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
@@ -220,20 +222,20 @@ impl HTMLElementMethods for HTMLElement {
}
} else {
self.upcast::<EventTarget>()
- .get_event_handler_common("resize")
+ .get_event_handler_common("load")
}
}
- // https://html.spec.whatwg.org/multipage/#handler-onresize
- fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ // https://html.spec.whatwg.org/multipage/#handler-onload
+ fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
if self.is_body_or_frameset() {
let document = document_from_node(self);
if document.has_browsing_context() {
- document.window().SetOnresize(listener);
+ document.window().SetOnload(listener)
}
} else {
self.upcast::<EventTarget>()
- .set_event_handler_common("resize", listener)
+ .set_event_handler_common("load", listener)
}
}
@@ -293,6 +295,34 @@ impl HTMLElementMethods for HTMLElement {
}
}
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
+ if self.is_body_or_frameset() {
+ let document = document_from_node(self);
+ if document.has_browsing_context() {
+ document.window().GetOnresize()
+ } else {
+ None
+ }
+ } else {
+ self.upcast::<EventTarget>()
+ .get_event_handler_common("resize")
+ }
+ }
+
+ // https://html.spec.whatwg.org/multipage/#handler-onresize
+ fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
+ if self.is_body_or_frameset() {
+ let document = document_from_node(self);
+ if document.has_browsing_context() {
+ document.window().SetOnresize(listener)
+ }
+ } else {
+ self.upcast::<EventTarget>()
+ .set_event_handler_common("resize", listener)
+ }
+ }
+
// https://html.spec.whatwg.org/multipage/#handler-onscroll
fn GetOnscroll(&self) -> Option<Rc<EventHandlerNonNull>> {
if self.is_body_or_frameset() {
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index fe578f6f675..21124fd37c4 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -430,7 +430,9 @@ macro_rules! window_owned_beforeunload_event_handler(
// As more methods get added, just update them here.
macro_rules! global_event_handlers(
() => (
+ // These are special when on body/frameset elements
event_handler!(blur, GetOnblur, SetOnblur);
+ error_event_handler!(error, GetOnerror, SetOnerror);
event_handler!(focus, GetOnfocus, SetOnfocus);
event_handler!(load, GetOnload, SetOnload);
event_handler!(resize, GetOnresize, SetOnresize);
@@ -460,7 +462,6 @@ macro_rules! global_event_handlers(
event_handler!(durationchange, GetOndurationchange, SetOndurationchange);
event_handler!(emptied, GetOnemptied, SetOnemptied);
event_handler!(ended, GetOnended, SetOnended);
- error_event_handler!(error, GetOnerror, SetOnerror);
event_handler!(formdata, GetOnformdata, SetOnformdata);
event_handler!(input, GetOninput, SetOninput);
event_handler!(invalid, GetOninvalid, SetOninvalid);