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/script_task.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/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 3041098e78c..8c8390822c4 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -82,6 +82,7 @@ use js; use url::Url; use libc; +use std::ascii::AsciiExt; use std::any::Any; use std::borrow::ToOwned; use std::cell::{Cell, RefCell}; @@ -984,10 +985,18 @@ impl ScriptTask { headers.get().map(|&LastModified(ref tm)| dom_last_modified(tm)) }); + let content_type = match response.metadata.content_type { + Some((ref t, ref st)) if t.as_slice().eq_ignore_ascii_case("text") && + st.as_slice().eq_ignore_ascii_case("plain") => { + Some("text/plain".to_owned()) + } + _ => None + }; + let document = Document::new(window.r(), Some(final_url.clone()), IsHTMLDocument::HTMLDocument, - None, + content_type, last_modified, DocumentSource::FromParser).root(); |