diff options
author | Alan Jeffrey <ajeffrey@mozilla.com> | 2016-11-30 16:54:12 -0600 |
---|---|---|
committer | Alan Jeffrey <ajeffrey@mozilla.com> | 2017-01-05 21:12:57 +0000 |
commit | 7c2de62124995c8c353756abdb1ec7c08973ae3a (patch) | |
tree | f6b54e6a181ee1498f0bf8fc06665f802078c5a0 /components/script/dom/browsingcontext.rs | |
parent | 143dfc879e609603839502d61bc064fba96cc80f (diff) | |
download | servo-7c2de62124995c8c353756abdb1ec7c08973ae3a.tar.gz servo-7c2de62124995c8c353756abdb1ec7c08973ae3a.zip |
Implement browsing context discarding.
Diffstat (limited to 'components/script/dom/browsingcontext.rs')
-rw-r--r-- | components/script/dom/browsingcontext.rs | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs index 1a7f26253a0..9652445d96f 100644 --- a/components/script/dom/browsingcontext.rs +++ b/components/script/dom/browsingcontext.rs @@ -3,16 +3,13 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject}; -use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; +use dom::bindings::js::{JS, Root, RootedReference}; use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor}; use dom::bindings::reflector::{DomObject, MutDomObject, Reflector}; use dom::bindings::trace::JSTraceable; use dom::bindings::utils::WindowProxyHandler; use dom::bindings::utils::get_array_index_from_id; -use dom::document::Document; use dom::element::Element; -use dom::globalscope::GlobalScope; use dom::window::Window; use js::JSCLASS_IS_GLOBAL; use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy}; @@ -26,7 +23,6 @@ use js::jsapi::{MutableHandle, MutableHandleObject, MutableHandleValue}; use js::jsapi::{ObjectOpResult, PropertyDescriptor}; use js::jsval::{UndefinedValue, PrivateValue}; use js::rust::get_object_class; -use msg::constellation_msg::PipelineId; use std::cell::Cell; #[dom_struct] @@ -40,10 +36,8 @@ pub struct BrowsingContext { /// Indicates if reflow is required when reloading. needs_reflow: Cell<bool>, - /// The current active document. - /// Note that the session history is stored in the constellation, - /// in the script thread we just track the current active document. - active_document: MutNullableJS<Document>, + /// Has this browsing context been discarded? + discarded: Cell<bool>, /// The containing iframe element, if this is a same-origin iframe frame_element: Option<JS<Element>>, @@ -54,7 +48,7 @@ impl BrowsingContext { BrowsingContext { reflector: Reflector::new(), needs_reflow: Cell::new(true), - active_document: Default::default(), + discarded: Cell::new(false), frame_element: frame_element.map(JS::from_ref), } } @@ -84,20 +78,12 @@ impl BrowsingContext { } } - pub fn set_active_document(&self, document: &Document) { - self.active_document.set(Some(document)) + pub fn discard(&self) { + self.discarded.set(true); } - pub fn active_document(&self) -> Root<Document> { - self.active_document.get().expect("No active document.") - } - - pub fn maybe_active_document(&self) -> Option<Root<Document>> { - self.active_document.get() - } - - pub fn active_window(&self) -> Root<Window> { - Root::from_ref(self.active_document().window()) + pub fn is_discarded(&self) -> bool { + self.discarded.get() } pub fn frame_element(&self) -> Option<&Element> { @@ -115,15 +101,6 @@ impl BrowsingContext { self.needs_reflow.set(status); old } - - pub fn active_pipeline_id(&self) -> Option<PipelineId> { - self.active_document.get() - .map(|doc| doc.window().upcast::<GlobalScope>().pipeline_id()) - } - - pub fn unset_active_document(&self) { - self.active_document.set(None) - } } #[allow(unsafe_code)] |