mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Check for the presence of a window when working with event handlers forwarded to the window
This commit is contained in:
parent
ca73b30fcf
commit
d23b34e243
3 changed files with 12 additions and 3 deletions
|
@ -354,11 +354,17 @@ 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>> {
|
||||
window_from_node(self).$getter()
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).$getter()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn $setter(&self, listener: Option<::std::rc::Rc<$handler>>) {
|
||||
window_from_node(self).$setter(listener)
|
||||
if document_from_node(self).has_browsing_context() {
|
||||
window_from_node(self).$setter(listener)
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue