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

@ -32,6 +32,7 @@ use dom::bindings::js::{RootCollectionPtr, RootedReference};
use dom::bindings::refcounted::{LiveDOMReferences, Trusted, TrustedReference, trace_refcounted_objects};
use dom::bindings::trace::{JSTraceable, RootedVec, trace_traceables};
use dom::bindings::utils::{DOM_CALLBACKS, WRAP_CALLBACKS};
use dom::browsingcontext::BrowsingContext;
use dom::document::{Document, DocumentProgressHandler, DocumentSource, FocusType, IsHTMLDocument};
use dom::element::Element;
use dom::event::{Event, EventBubbles, EventCancelable};
@ -1792,6 +1793,10 @@ impl ScriptThread {
incomplete.parent_info,
incomplete.window_size);
let frame_element = frame_element.r().map(Castable::upcast);
let browsing_context = BrowsingContext::new(&window, frame_element);
window.init_browsing_context(&browsing_context);
let last_modified = metadata.headers.as_ref().and_then(|headers| {
headers.get().map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
});
@ -1819,16 +1824,14 @@ impl ScriptThread {
};
let document = Document::new(window.r(),
Some(&browsing_context),
Some(final_url.clone()),
is_html_document,
content_type,
last_modified,
DocumentSource::FromParser,
loader);
let frame_element = frame_element.r().map(Castable::upcast);
window.init_browsing_context(document.r(), frame_element);
browsing_context.init(&document);
document.set_ready_state(DocumentReadyState::Loading);
// Create the root frame