servo: Merge #4305 - Cleanup ScriptTask::load some more (from Ms2ger:script_task); r=jdm

Source-Repo: https://github.com/servo/servo
Source-Revision: 3a70a9fa6bdbfda405ff7b027a09596a2a2747f5
This commit is contained in:
Ms2ger
2014-12-09 12:16:07 -07:00
parent d9fa5e29a5
commit 4c10b22c29
2 changed files with 10 additions and 11 deletions

View File

@@ -690,7 +690,7 @@ impl ScriptTask {
/// The entry point to document loading. Defines bindings, sets up the window and document
/// objects, parses HTML and CSS, and kicks off initial layout.
fn load(&self, pipeline_id: PipelineId, load_data: LoadData) {
let mut url = load_data.url.clone();
let url = load_data.url.clone();
debug!("ScriptTask: loading {} on page {}", url, pipeline_id);
let page = self.page.borrow_mut();
@@ -744,7 +744,7 @@ impl ScriptTask {
});
}
let (parser_input, base_url) = if !is_javascript {
let (parser_input, final_url) = if !is_javascript {
// Wait for the LoadResponse so that the parser knows the final URL.
let (input_chan, input_port) = channel();
self.resource_task.send(Load(NetLoadData {
@@ -764,16 +764,16 @@ impl ScriptTask {
});
});
let base_url = load_response.metadata.final_url.clone();
let final_url = load_response.metadata.final_url.clone();
{
// Store the final URL before we start parsing, so that DOM routines
// (e.g. HTMLImageElement::update_image) can resolve relative URLs
// correctly.
*page.mut_url() = Some((base_url.clone(), true));
*page.mut_url() = Some((final_url.clone(), true));
}
(InputUrl(load_response), base_url)
(InputUrl(load_response), final_url)
} else {
let evalstr = load_data.url.non_relative_scheme_data().unwrap();
let jsval = window.evaluate_js_with_result(evalstr);
@@ -781,20 +781,19 @@ impl ScriptTask {
(InputString(strval.unwrap_or("".to_string())), doc_url)
};
parse_html(*document, parser_input, base_url);
url = page.get_url().clone();
parse_html(*document, parser_input, &final_url);
document.set_ready_state(DocumentReadyStateValues::Interactive);
// Kick off the initial reflow of the page.
debug!("kicking off initial reflow of {}", url);
debug!("kicking off initial reflow of {}", final_url);
document.content_changed(NodeCast::from_ref(*document));
window.flush_layout();
{
// No more reflow required
let mut page_url = page.mut_url();
*page_url = Some((url.clone(), false));
*page_url = Some((final_url.clone(), false));
}
// https://html.spec.whatwg.org/multipage/#the-end step 4
@@ -814,7 +813,7 @@ impl ScriptTask {
let wintarget: JSRef<EventTarget> = EventTargetCast::from_ref(*window);
let _ = wintarget.dispatch_event_with_target(Some(doctarget), *event);
*page.fragment_name.borrow_mut() = url.fragment;
*page.fragment_name.borrow_mut() = final_url.fragment;
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(LoadCompleteMsg);