aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/window.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-07-20 17:16:46 +0200
committerMs2ger <Ms2ger@gmail.com>2015-11-04 12:30:13 +0100
commitf86502f80c3b6a89b1fc880dd51e8da6531d5865 (patch)
tree77971a51f958af33d76509c7110a48bae4c5c756 /components/script/dom/window.rs
parentb6850853da5fc677ecfa15d273159371a909ac6c (diff)
downloadservo-f86502f80c3b6a89b1fc880dd51e8da6531d5865.tar.gz
servo-f86502f80c3b6a89b1fc880dd51e8da6531d5865.zip
Make BrowsingContext JS-managed.
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r--components/script/dom/window.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 69ddff9430a..0062aed4bee 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -59,7 +59,7 @@ use script_traits::{TimerEventChan, TimerEventId, TimerEventRequest, TimerSource
use selectors::parser::PseudoElement;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
-use std::cell::{Cell, Ref};
+use std::cell::Cell;
use std::collections::HashSet;
use std::default::Default;
use std::ffi::CString;
@@ -119,7 +119,7 @@ pub struct Window {
image_cache_chan: ImageCacheChan,
#[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"]
compositor: IpcSender<ScriptToCompositorMsg>,
- browsing_context: DOMRefCell<Option<BrowsingContext>>,
+ browsing_context: MutNullableHeap<JS<BrowsingContext>>,
page: Rc<Page>,
performance: MutNullableHeap<JS<Performance>>,
navigation_start: u64,
@@ -217,7 +217,7 @@ impl Window {
pub fn clear_js_runtime_for_script_deallocation(&self) {
unsafe {
*self.js_runtime.borrow_for_script_deallocation() = None;
- *self.browsing_context.borrow_for_script_deallocation() = None;
+ self.browsing_context.set(None);
self.current_state.set(WindowState::Zombie);
}
}
@@ -271,8 +271,8 @@ impl Window {
&self.compositor
}
- pub fn browsing_context(&self) -> Ref<Option<BrowsingContext>> {
- self.browsing_context.borrow()
+ pub fn browsing_context(&self) -> Option<Root<BrowsingContext>> {
+ self.browsing_context.get()
}
pub fn page(&self) -> &Page {
@@ -797,7 +797,7 @@ impl Window {
self.current_state.set(WindowState::Zombie);
*self.js_runtime.borrow_mut() = None;
- *self.browsing_context.borrow_mut() = None;
+ self.browsing_context.set(None);
}
/// https://drafts.csswg.org/cssom-view/#dom-window-scroll
@@ -1009,9 +1009,7 @@ impl Window {
}
pub fn init_browsing_context(&self, doc: &Document, frame_element: Option<&Element>) {
- let mut browsing_context = self.browsing_context.borrow_mut();
- *browsing_context = Some(BrowsingContext::new(doc, frame_element));
- (*browsing_context).as_mut().unwrap().create_window_proxy();
+ self.browsing_context.set(Some(&BrowsingContext::new(doc, frame_element)));
}
/// Commence a new URL load which will either replace this window or scroll to a fragment.
@@ -1183,15 +1181,14 @@ impl Window {
}
pub fn parent(&self) -> Option<Root<Window>> {
- let browsing_context = self.browsing_context();
- let browsing_context = browsing_context.as_ref().unwrap();
+ let browsing_context = self.browsing_context().unwrap();
browsing_context.frame_element().map(|frame_element| {
let window = window_from_node(frame_element);
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let r = window.r();
let context = r.browsing_context();
- Root::from_ref(context.as_ref().unwrap().active_window())
+ Root::from_ref(context.unwrap().active_window())
})
}
}
@@ -1234,7 +1231,7 @@ impl Window {
image_cache_task: image_cache_task,
mem_profiler_chan: mem_profiler_chan,
devtools_chan: devtools_chan,
- browsing_context: DOMRefCell::new(None),
+ browsing_context: Default::default(),
performance: Default::default(),
navigation_start: time::get_time().sec as u64,
navigation_start_precise: time::precise_time_ns() as f64,