mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Refactor some window_from_node calls based on feedback
This commit is contained in:
parent
1bd1bddacf
commit
72ec00e0b5
3 changed files with 37 additions and 25 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue