diff options
author | Chris Double <chris.double@double.co.nz> | 2015-03-13 16:42:43 +1300 |
---|---|---|
committer | Chris Double <chris.double@double.co.nz> | 2015-03-17 18:11:33 +1300 |
commit | 618142fac7a580071f758333f91afc683e70f6d7 (patch) | |
tree | 3f37c869bf003ea4c57271e806955994fe5fcdc4 /components/script/parse/html.rs | |
parent | 82c52a7a1c2d1fcdad797fc73564d6f624650473 (diff) | |
download | servo-618142fac7a580071f758333f91afc683e70f6d7.tar.gz servo-618142fac7a580071f758333f91afc683e70f6d7.zip |
Implement displaying of text/plain documents
This is done by detecting the content type as text/plain
and following the requirements from:
https://html.spec.whatwg.org/multipage/browsers.html#read-text
Diffstat (limited to 'components/script/parse/html.rs')
-rw-r--r-- | components/script/parse/html.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index c4417459f96..836eac6dfba 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -180,6 +180,22 @@ pub fn parse_html(document: JSRef<Document>, task_state::enter(IN_HTML_PARSER); } + fn parse_progress(parser: &JSRef<ServoHTMLParser>, url: &Url, load_response: &LoadResponse) { + for msg in load_response.progress_port.iter() { + match msg { + ProgressMsg::Payload(data) => { + // FIXME: use Vec<u8> (html5ever #34) + let data = UTF_8.decode(data.as_slice(), DecoderTrap::Replace).unwrap(); + parser.parse_chunk(data); + } + ProgressMsg::Done(Err(err)) => { + panic!("Failed to load page URL {}, error: {}", url.serialize(), err); + } + ProgressMsg::Done(Ok(())) => break, + } + } + }; + match input { HTMLInput::InputString(s) => { parser.parse_chunk(s); @@ -205,19 +221,7 @@ pub fn parse_html(document: JSRef<Document>, parse_progress(&parser, url, &load_response); }, _ => { - for msg in load_response.progress_port.iter() { - match msg { - ProgressMsg::Payload(data) => { - // FIXME: use Vec<u8> (html5ever #34) - let data = UTF_8.decode(data.as_slice(), DecoderTrap::Replace).unwrap(); - parser.parse_chunk(data); - } - ProgressMsg::Done(Err(err)) => { - panic!("Failed to load page URL {}, error: {}", url.serialize(), err); - } - ProgressMsg::Done(Ok(())) => break, - } - } + parse_progress(&parser, url, &load_response); } } } |