auto merge of #4305 : Ms2ger/servo/script_task, r=jdm

This commit is contained in:
bors-servo 2014-12-09 12:16:07 -07:00
commit 3a70a9fa6b
2 changed files with 10 additions and 11 deletions

View file

@ -163,7 +163,7 @@ impl<'a> TreeSink<TrustedNodeAddress> for servohtmlparser::Sink {
pub fn parse_html(document: JSRef<Document>, pub fn parse_html(document: JSRef<Document>,
input: HTMLInput, input: HTMLInput,
url: Url) { url: &Url) {
let parser = ServoHTMLParser::new(Some(url.clone()), document).root(); let parser = ServoHTMLParser::new(Some(url.clone()), document).root();
let parser: JSRef<ServoHTMLParser> = *parser; let parser: JSRef<ServoHTMLParser> = *parser;

View file

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