Store a pointer to the browsing context in the Document.

This commit is contained in:
Ms2ger 2016-02-09 14:00:39 +01:00
parent 0b27807ad4
commit 152cec69eb
10 changed files with 53 additions and 23 deletions

View file

@ -425,7 +425,7 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-document-2
fn Document(&self) -> Root<Document> {
Root::from_ref(self.browsing_context().as_ref().unwrap().active_document())
self.browsing_context().as_ref().unwrap().active_document()
}
// https://html.spec.whatwg.org/multipage/#dom-location
@ -1094,8 +1094,9 @@ impl Window {
(element, response.rect)
}
pub fn init_browsing_context(&self, doc: &Document, frame_element: Option<&Element>) {
self.browsing_context.set(Some(&BrowsingContext::new(doc, frame_element)));
pub fn init_browsing_context(&self, browsing_context: &BrowsingContext) {
assert!(self.browsing_context.get().is_none());
self.browsing_context.set(Some(&browsing_context));
}
/// Commence a new URL load which will either replace this window or scroll to a fragment.
@ -1282,7 +1283,7 @@ impl Window {
browsing_context.frame_element().map(|frame_element| {
let window = window_from_node(frame_element);
let context = window.browsing_context();
Root::from_ref(context.unwrap().active_window())
context.unwrap().active_window()
})
}
}