mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Combine two conditionals in ScriptTask::load.
Now that the code lives in the same function, I see no reason for them to remain separate.
This commit is contained in:
parent
9f08d563ae
commit
fbedf030d4
1 changed files with 31 additions and 40 deletions
|
@ -744,50 +744,41 @@ impl ScriptTask {
|
|||
});
|
||||
}
|
||||
|
||||
let parser_input = if !is_javascript {
|
||||
InputUrl(url.clone())
|
||||
let (parser_input, base_url, load_response) = 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 {
|
||||
url: url.clone(),
|
||||
method: load_data.method,
|
||||
headers: load_data.headers,
|
||||
data: load_data.data,
|
||||
cors: None,
|
||||
consumer: input_chan,
|
||||
}));
|
||||
|
||||
let load_response = input_port.recv();
|
||||
|
||||
load_response.metadata.headers.as_ref().map(|headers| {
|
||||
headers.get().map(|&LastModified(ref tm)| {
|
||||
document.set_last_modified(dom_last_modified(tm));
|
||||
});
|
||||
});
|
||||
|
||||
let base_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));
|
||||
}
|
||||
|
||||
(InputUrl(url.clone()), base_url, Some(load_response))
|
||||
} else {
|
||||
let evalstr = load_data.url.non_relative_scheme_data().unwrap();
|
||||
let jsval = window.evaluate_js_with_result(evalstr);
|
||||
let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval, Empty);
|
||||
InputString(strval.unwrap_or("".to_string()))
|
||||
};
|
||||
|
||||
let (base_url, load_response) = match parser_input {
|
||||
InputUrl(ref url) => {
|
||||
// Wait for the LoadResponse so that the parser knows the final URL.
|
||||
let (input_chan, input_port) = channel();
|
||||
self.resource_task.send(Load(NetLoadData {
|
||||
url: url.clone(),
|
||||
method: load_data.method,
|
||||
headers: load_data.headers,
|
||||
data: load_data.data,
|
||||
cors: None,
|
||||
consumer: input_chan,
|
||||
}));
|
||||
|
||||
let load_response = input_port.recv();
|
||||
|
||||
load_response.metadata.headers.as_ref().map(|headers| {
|
||||
headers.get().map(|&LastModified(ref tm)| {
|
||||
document.set_last_modified(dom_last_modified(tm));
|
||||
});
|
||||
});
|
||||
|
||||
let base_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));
|
||||
}
|
||||
|
||||
(base_url, Some(load_response))
|
||||
},
|
||||
InputString(_) => {
|
||||
(doc_url, None)
|
||||
},
|
||||
(InputString(strval.unwrap_or("".to_string())), doc_url, None)
|
||||
};
|
||||
|
||||
parse_html(*document, parser_input, base_url, load_response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue