diff options
author | Arseniy Ivanov <freeatnet@freeatnet.com> | 2017-02-03 14:45:55 -0500 |
---|---|---|
committer | Arseniy Ivanov <freeatnet@freeatnet.com> | 2017-02-03 14:57:08 -0500 |
commit | 72ec00e0b56943ad64403eb1fefa216a925d98b0 (patch) | |
tree | 93a712f7a8c79c1d91ec992c6a604f89cb4ffc91 /components/script/dom/htmlelement.rs | |
parent | 1bd1bddacffc5fc52f7a74396474f2ab36c57ad5 (diff) | |
download | servo-72ec00e0b56943ad64403eb1fefa216a925d98b0.tar.gz servo-72ec00e0b56943ad64403eb1fefa216a925d98b0.zip |
Refactor some window_from_node calls based on feedback
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r-- | components/script/dom/htmlelement.rs | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 0995c9cb54c..9caa85225ef 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -151,8 +151,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#handler-onload fn GetOnload(&self) -> Option<Rc<EventHandlerNonNull>> { if self.is_body_or_frameset() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).GetOnload() + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().GetOnload() } else { None } @@ -164,8 +165,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() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).SetOnload(listener) + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().SetOnload(listener) } } else { self.upcast::<EventTarget>().set_event_handler_common("load", listener) @@ -175,8 +177,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#handler-onresize fn GetOnresize(&self) -> Option<Rc<EventHandlerNonNull>> { if self.is_body_or_frameset() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).GetOnload() + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().GetOnload() } else { None } @@ -188,8 +191,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() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).SetOnresize(listener); + 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) @@ -199,8 +203,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#handler-onblur fn GetOnblur(&self) -> Option<Rc<EventHandlerNonNull>> { if self.is_body_or_frameset() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).GetOnblur() + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().GetOnblur() } else { None } @@ -212,8 +217,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() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).SetOnblur(listener) + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().SetOnblur(listener) } } else { self.upcast::<EventTarget>().set_event_handler_common("blur", listener) @@ -223,8 +229,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#handler-onfocus fn GetOnfocus(&self) -> Option<Rc<EventHandlerNonNull>> { if self.is_body_or_frameset() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).GetOnfocus() + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().GetOnfocus() } else { None } @@ -236,8 +243,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() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).SetOnfocus(listener) + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().SetOnfocus(listener) } } else { self.upcast::<EventTarget>().set_event_handler_common("focus", listener) @@ -247,8 +255,9 @@ impl HTMLElementMethods for HTMLElement { // https://html.spec.whatwg.org/multipage/#handler-onscroll fn GetOnscroll(&self) -> Option<Rc<EventHandlerNonNull>> { if self.is_body_or_frameset() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).GetOnscroll() + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().GetOnscroll() } else { None } @@ -260,8 +269,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() { - if document_from_node(self).has_browsing_context() { - window_from_node(self).SetOnscroll(listener) + let document = document_from_node(self); + if document.has_browsing_context() { + document.window().SetOnscroll(listener) } } else { self.upcast::<EventTarget>().set_event_handler_common("scroll", listener) |