mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Extend window presence checks to non-native event handlers
This commit is contained in:
parent
60679d9b6d
commit
1bd1bddacf
1 changed files with 40 additions and 10 deletions
|
@ -151,7 +151,11 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||
fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).GetOnload()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).GetOnload()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().get_event_handler_common("load")
|
||||
}
|
||||
|
@ -160,7 +164,9 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onload
|
||||
fn SetOnload(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).SetOnload(listener)
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).SetOnload(listener)
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().set_event_handler_common("load", listener)
|
||||
}
|
||||
|
@ -169,7 +175,11 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onresize
|
||||
fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).GetOnload()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).GetOnload()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().get_event_handler_common("resize")
|
||||
}
|
||||
|
@ -178,7 +188,9 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onresize
|
||||
fn SetOnresize(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).SetOnresize(listener);
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).SetOnresize(listener);
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().set_event_handler_common("resize", listener)
|
||||
}
|
||||
|
@ -187,7 +199,11 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onblur
|
||||
fn GetOnblur(&self) -> Option<Rc<EventHandlerNonNull>> {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).GetOnblur()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).GetOnblur()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().get_event_handler_common("blur")
|
||||
}
|
||||
|
@ -196,7 +212,9 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// https://html.spec.whatwg.org/multipage/#handler-onblur
|
||||
fn SetOnblur(&self, listener: Option<Rc<EventHandlerNonNull>>) {
|
||||
if self.is_body_or_frameset() {
|
||||
window_from_node(self).SetOnblur(listener)
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).SetOnblur(listener)
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().set_event_handler_common("blur", listener)
|
||||
}
|
||||
|
@ -205,7 +223,11 @@ 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()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).GetOnfocus()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().get_event_handler_common("focus")
|
||||
}
|
||||
|
@ -214,7 +236,9 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// 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)
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).SetOnfocus(listener)
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().set_event_handler_common("focus", listener)
|
||||
}
|
||||
|
@ -223,7 +247,11 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// 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()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).GetOnscroll()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().get_event_handler_common("scroll")
|
||||
}
|
||||
|
@ -232,7 +260,9 @@ impl HTMLElementMethods for HTMLElement {
|
|||
// 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)
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).SetOnscroll(listener)
|
||||
}
|
||||
} else {
|
||||
self.upcast::<EventTarget>().set_event_handler_common("scroll", listener)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue