зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #5752 - Make ScriptTask::js_context immutable (from Ms2ger:cx-immutable); r=jdm
Since we drop the ScriptTask almost immediately after clearing the field, there's little reason to do it manually. Source-Repo: https://github.com/servo/servo Source-Revision: ccc77caa79344a45003f1efb7184cec5b882edae
This commit is contained in:
Родитель
b4ec90123c
Коммит
e03698dc86
|
@ -311,7 +311,7 @@ pub struct ScriptTask {
|
|||
/// The JavaScript runtime.
|
||||
js_runtime: js::rust::rt,
|
||||
/// The JSContext.
|
||||
js_context: DOMRefCell<Option<Rc<Cx>>>,
|
||||
js_context: Rc<Cx>,
|
||||
|
||||
mouse_over_targets: DOMRefCell<Vec<JS<Node>>>
|
||||
}
|
||||
|
@ -348,7 +348,6 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
|
|||
let window = page.window_for_script_deallocation();
|
||||
(*window.unsafe_get()).clear_js_context_for_script_deallocation();
|
||||
}
|
||||
*owner.js_context.borrow_for_script_deallocation() = None;
|
||||
}
|
||||
}
|
||||
None => (),
|
||||
|
@ -488,7 +487,7 @@ impl ScriptTask {
|
|||
devtools_marker_sender: RefCell::new(None),
|
||||
|
||||
js_runtime: js_runtime,
|
||||
js_context: DOMRefCell::new(Some(js_context)),
|
||||
js_context: js_context,
|
||||
mouse_over_targets: DOMRefCell::new(vec!())
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +517,7 @@ impl ScriptTask {
|
|||
}
|
||||
|
||||
pub fn get_cx(&self) -> *mut JSContext {
|
||||
(**self.js_context.borrow().as_ref().unwrap()).ptr
|
||||
self.js_context.ptr
|
||||
}
|
||||
|
||||
/// Starts the script task. After calling this method, the script task will loop receiving
|
||||
|
@ -962,10 +961,7 @@ impl ScriptTask {
|
|||
let window = page.window().root();
|
||||
if window.r().pipeline() == id {
|
||||
debug!("shutting down layout for root page {:?}", id);
|
||||
// To ensure the elements of the DOM tree remain usable (such as the window global),
|
||||
// don't free the JS context until all interactions with it are finished.
|
||||
shut_down_layout(&page, exit_type);
|
||||
*self.js_context.borrow_mut() = None;
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -1008,9 +1004,6 @@ impl ScriptTask {
|
|||
|
||||
self.compositor.borrow_mut().set_ready_state(incomplete.pipeline_id, Loading);
|
||||
|
||||
let cx = self.js_context.borrow();
|
||||
let cx = cx.as_ref().unwrap();
|
||||
|
||||
// Create a new frame tree entry.
|
||||
let page = Rc::new(Page::new(incomplete.pipeline_id, final_url.clone()));
|
||||
if !root_page_exists {
|
||||
|
@ -1069,7 +1062,7 @@ impl ScriptTask {
|
|||
let mut page_remover = AutoPageRemover::new(self, page_to_remove);
|
||||
|
||||
// Create the window and document objects.
|
||||
let window = Window::new(cx.clone(),
|
||||
let window = Window::new(self.js_context.clone(),
|
||||
page.clone(),
|
||||
self.chan.clone(),
|
||||
self.control_chan.clone(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче