mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Error and resize get special getter/setters for reflection
This commit is contained in:
parent
6d220d02de
commit
f043a3eee2
5 changed files with 60 additions and 75 deletions
|
@ -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,6 +182,35 @@ impl HTMLElementMethods for HTMLElement {
|
|||
self.dataset.or_init(|| DOMStringMap::new(self))
|
||||
}
|
||||
|
||||
// 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().GetOnerror()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>()
|
||||
.get_event_handler_common("error")
|
||||
}
|
||||
}
|
||||
|
||||
// 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().SetOnerror(listener)
|
||||
}
|
||||
} else {
|
||||
// special setter for error
|
||||
self.upcast::<EventTarget>()
|
||||
.set_error_event_handler("error", listener)
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||
if self.is_body_or_frameset() {
|
||||
|
@ -209,34 +239,6 @@ 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().GetOnload()
|
||||
} 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-onblur
|
||||
fn GetOnblur(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||
if self.is_body_or_frameset() {
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue