Auto merge of #9603 - Ms2ger:document-bc, r=jdm

Store a pointer to the browsing context in the Document.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9603)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-02-19 12:49:35 +05:30
commit ee158cc65f
10 changed files with 53 additions and 23 deletions

View file

@ -426,7 +426,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
@ -1095,8 +1095,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.
@ -1283,7 +1284,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()
})
}
}