mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Avoid an index-out-of-bounds error in ScriptMemoryFailsafe.
Fixes #11059. Fixes #11400. Fixes #11481. Fixes #11671. Fixes #11682.
This commit is contained in:
parent
77e0089c12
commit
7455dc4a50
2 changed files with 10 additions and 2 deletions
|
@ -108,6 +108,12 @@ impl BrowsingContext {
|
||||||
Root::from_ref(&self.history.borrow()[self.active_index.get()].document)
|
Root::from_ref(&self.history.borrow()[self.active_index.get()].document)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn maybe_active_document(&self) -> Option<Root<Document>> {
|
||||||
|
self.history.borrow().get(self.active_index.get()).map(|entry| {
|
||||||
|
Root::from_ref(&*entry.document)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn active_window(&self) -> Root<Window> {
|
pub fn active_window(&self) -> Root<Window> {
|
||||||
Root::from_ref(self.active_document().window())
|
Root::from_ref(self.active_document().window())
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,8 +422,10 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
|
||||||
Some(owner) => {
|
Some(owner) => {
|
||||||
let context = owner.browsing_context.get();
|
let context = owner.browsing_context.get();
|
||||||
for context in context.iter() {
|
for context in context.iter() {
|
||||||
let window = context.active_window();
|
if let Some(document) = context.maybe_active_document() {
|
||||||
window.clear_js_runtime_for_script_deallocation();
|
let window = document.window();
|
||||||
|
window.clear_js_runtime_for_script_deallocation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => (),
|
None => (),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue