Refactor some window_from_node calls based on feedback

This commit is contained in:
Arseniy Ivanov 2017-02-03 14:45:55 -05:00
parent 1bd1bddacf
commit 72ec00e0b5
3 changed files with 37 additions and 25 deletions

View file

@ -354,16 +354,18 @@ macro_rules! define_event_handler(
macro_rules! define_window_owned_event_handler(
($handler: ident, $event_type: ident, $getter: ident, $setter: ident) => (
fn $getter(&self) -> Option<::std::rc::Rc<$handler>> {
if document_from_node(self).has_browsing_context() {
window_from_node(self).$getter()
let document = document_from_node(self);
if document.has_browsing_context() {
document.window().$getter()
} else {
None
}
}
fn $setter(&self, listener: Option<::std::rc::Rc<$handler>>) {
if document_from_node(self).has_browsing_context() {
window_from_node(self).$setter(listener)
let document = document_from_node(self);
if document.has_browsing_context() {
document.window().$setter(listener)
}
}
)