diff options
Diffstat (limited to 'components/script/dom/windowproxy.rs')
-rw-r--r-- | components/script/dom/windowproxy.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/components/script/dom/windowproxy.rs b/components/script/dom/windowproxy.rs index e022e69a810..2578bb3b46c 100644 --- a/components/script/dom/windowproxy.rs +++ b/components/script/dom/windowproxy.rs @@ -30,6 +30,7 @@ use js::jsval::{UndefinedValue, PrivateValue}; use js::rust::get_object_class; use msg::constellation_msg::BrowsingContextId; use msg::constellation_msg::PipelineId; +use msg::constellation_msg::TopLevelBrowsingContextId; use std::cell::Cell; use std::ptr; @@ -50,6 +51,10 @@ pub struct WindowProxy { /// of the container. browsing_context_id: BrowsingContextId, + /// The frame id of the top-level ancestor browsing context. + /// In the case that this is a top-level window, this is our id. + top_level_browsing_context_id: TopLevelBrowsingContextId, + /// The pipeline id of the currently active document. /// May be None, when the currently active document is in another script thread. /// We do not try to keep the pipeline id for documents in other threads, @@ -69,6 +74,7 @@ pub struct WindowProxy { impl WindowProxy { pub fn new_inherited(browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, currently_active: Option<PipelineId>, frame_element: Option<&Element>, parent: Option<&WindowProxy>) @@ -77,6 +83,7 @@ impl WindowProxy { WindowProxy { reflector: Reflector::new(), browsing_context_id: browsing_context_id, + top_level_browsing_context_id: top_level_browsing_context_id, currently_active: Cell::new(currently_active), discarded: Cell::new(false), frame_element: frame_element.map(JS::from_ref), @@ -87,6 +94,7 @@ impl WindowProxy { #[allow(unsafe_code)] pub fn new(window: &Window, browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, frame_element: Option<&Element>, parent: Option<&WindowProxy>) -> Root<WindowProxy> @@ -107,7 +115,11 @@ impl WindowProxy { // Create a new browsing context. let current = Some(window.global().pipeline_id()); - let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, current, frame_element, parent); + let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, + top_level_browsing_context_id, + current, + frame_element, + parent); // The window proxy owns the browsing context. // When we finalize the window proxy, it drops the browsing context it owns. @@ -126,6 +138,7 @@ impl WindowProxy { #[allow(unsafe_code)] pub fn new_dissimilar_origin(global_to_clone_from: &GlobalScope, browsing_context_id: BrowsingContextId, + top_level_browsing_context_id: TopLevelBrowsingContextId, parent: Option<&WindowProxy>) -> Root<WindowProxy> { @@ -136,7 +149,11 @@ impl WindowProxy { let cx = global_to_clone_from.get_cx(); // Create a new browsing context. - let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, None, None, parent); + let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, + top_level_browsing_context_id, + None, + None, + parent); // Create a new dissimilar-origin window. let window = DissimilarOriginWindow::new(global_to_clone_from, &*window_proxy); @@ -175,6 +192,10 @@ impl WindowProxy { self.browsing_context_id } + pub fn top_level_browsing_context_id(&self) -> TopLevelBrowsingContextId { + self.top_level_browsing_context_id + } + pub fn frame_element(&self) -> Option<&Element> { self.frame_element.r() } |