mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move the load response into the HTMLInput enum.
It is None iff the parser input is an InputString variant, so it makes more sense to pass it in the same enum.
This commit is contained in:
parent
fbedf030d4
commit
e76c3386ce
2 changed files with 7 additions and 9 deletions
|
@ -33,7 +33,7 @@ use string_cache::QualName;
|
|||
|
||||
pub enum HTMLInput {
|
||||
InputString(String),
|
||||
InputUrl(Url),
|
||||
InputUrl(Url, LoadResponse),
|
||||
}
|
||||
|
||||
trait SinkHelpers {
|
||||
|
@ -163,8 +163,7 @@ impl<'a> TreeSink<TrustedNodeAddress> for servohtmlparser::Sink {
|
|||
|
||||
pub fn parse_html(document: JSRef<Document>,
|
||||
input: HTMLInput,
|
||||
base_url: Url,
|
||||
load_response: Option<LoadResponse>) {
|
||||
base_url: Url) {
|
||||
let parser = ServoHTMLParser::new(Some(base_url.clone()), document).root();
|
||||
let parser: JSRef<ServoHTMLParser> = *parser;
|
||||
|
||||
|
@ -174,8 +173,7 @@ pub fn parse_html(document: JSRef<Document>,
|
|||
InputString(s) => {
|
||||
parser.parse_chunk(s);
|
||||
}
|
||||
InputUrl(url) => {
|
||||
let load_response = load_response.unwrap();
|
||||
InputUrl(url, load_response) => {
|
||||
match load_response.metadata.content_type {
|
||||
Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case("image") => {
|
||||
let page = format!("<html><body><img src='{:s}' /></body></html>", base_url.serialize());
|
||||
|
|
|
@ -744,7 +744,7 @@ impl ScriptTask {
|
|||
});
|
||||
}
|
||||
|
||||
let (parser_input, base_url, load_response) = if !is_javascript {
|
||||
let (parser_input, base_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 {
|
||||
|
@ -773,15 +773,15 @@ impl ScriptTask {
|
|||
*page.mut_url() = Some((base_url.clone(), true));
|
||||
}
|
||||
|
||||
(InputUrl(url.clone()), base_url, Some(load_response))
|
||||
(InputUrl(url.clone(), load_response), base_url)
|
||||
} 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())), doc_url, None)
|
||||
(InputString(strval.unwrap_or("".to_string())), doc_url)
|
||||
};
|
||||
|
||||
parse_html(*document, parser_input, base_url, load_response);
|
||||
parse_html(*document, parser_input, base_url);
|
||||
url = page.get_url().clone();
|
||||
|
||||
document.set_ready_state(DocumentReadyStateValues::Interactive);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue