diff options
Diffstat (limited to 'components/script/dom/browsingcontext.rs')
-rw-r--r-- | components/script/dom/browsingcontext.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs index 77c6eac2941..6363e08095f 100644 --- a/components/script/dom/browsingcontext.rs +++ b/components/script/dom/browsingcontext.rs @@ -29,6 +29,7 @@ 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::FrameId; use msg::constellation_msg::PipelineId; use std::cell::Cell; use std::ptr; @@ -45,6 +46,11 @@ pub struct BrowsingContext { /// changes Window. reflector: Reflector, + /// The frame id of the browsing context. + /// In the case that this is a nested browsing context, this is the frame id + /// of the container. + frame_id: FrameId, + /// 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, @@ -60,9 +66,14 @@ pub struct BrowsingContext { } impl BrowsingContext { - pub fn new_inherited(currently_active: PipelineId, frame_element: Option<&Element>) -> BrowsingContext { + pub fn new_inherited(frame_id: FrameId, + currently_active: PipelineId, + frame_element: Option<&Element>) + -> BrowsingContext + { BrowsingContext { reflector: Reflector::new(), + frame_id: frame_id, currently_active: Cell::new(Some(currently_active)), discarded: Cell::new(false), frame_element: frame_element.map(JS::from_ref), @@ -70,7 +81,7 @@ impl BrowsingContext { } #[allow(unsafe_code)] - pub fn new(window: &Window, frame_element: Option<&Element>) -> Root<BrowsingContext> { + pub fn new(window: &Window, frame_id: FrameId, frame_element: Option<&Element>) -> Root<BrowsingContext> { unsafe { let WindowProxyHandler(handler) = window.windowproxy_handler(); assert!(!handler.is_null()); @@ -87,7 +98,7 @@ impl BrowsingContext { // Create a new browsing context. let currently_active = window.global().pipeline_id(); - let mut browsing_context = box BrowsingContext::new_inherited(currently_active, frame_element); + let mut browsing_context = box BrowsingContext::new_inherited(frame_id, currently_active, frame_element); // The window proxy owns the browsing context. // When we finalize the window proxy, it drops the browsing context it owns. @@ -111,6 +122,10 @@ impl BrowsingContext { self.discarded.get() } + pub fn frame_id(&self) -> FrameId { + self.frame_id + } + pub fn frame_element(&self) -> Option<&Element> { self.frame_element.r() } |