aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorConnor Brewster <brewsterc@my.caspercollege.edu>2016-04-14 14:56:38 -0600
committerConnor Brewster <brewsterc@my.caspercollege.edu>2016-04-27 08:44:13 -0600
commit3389c497c0ca740dbcd4fd56a4fc8d490f7a8592 (patch)
tree86aebd6dafad16ac7c54ebd0a366226b5ebc8836 /components/script/script_thread.rs
parent2729864af73d62719ea0fd55cef417c43bdd951e (diff)
downloadservo-3389c497c0ca740dbcd4fd56a4fc8d490f7a8592.tar.gz
servo-3389c497c0ca740dbcd4fd56a4fc8d490f7a8592.zip
Finish hooking up XML parser
added script integration with xml5ever Updated test expectations Removed timeout test expectation Refactors application/xhtml+xml is treated as HTML Updated xml5ever Updated Text Expectations
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs52
1 files changed, 29 insertions, 23 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d21a0f6ce0d..3f574e38995 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1509,23 +1509,22 @@ impl ScriptThread {
headers.get().map(|&LastModified(HttpDate(ref tm))| dom_last_modified(tm))
});
- let content_type = match metadata.content_type {
- Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) => {
- Some(DOMString::from("text/xml"))
+ let content_type = metadata.content_type.as_ref().and_then(|&ContentType(ref mimetype)| {
+ match *mimetype {
+ Mime(TopLevel::Application, SubLevel::Xml, _) |
+ Mime(TopLevel::Application, SubLevel::Ext(_), _) |
+ Mime(TopLevel::Text, SubLevel::Xml, _) |
+ Mime(TopLevel::Text, SubLevel::Plain, _) => Some(DOMString::from(mimetype.to_string())),
+ _ => None,
}
-
- Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) => {
- Some(DOMString::from("text/plain"))
- }
-
- _ => None
- };
+ });
let loader = DocumentLoader::new_with_thread(self.resource_thread.clone(),
Some(page.pipeline()),
Some(incomplete.url.clone()));
let is_html_document = match metadata.content_type {
+ Some(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _))) |
Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) =>
IsHTMLDocument::NonHTMLDocument,
_ => IsHTMLDocument::HTMLDocument,
@@ -1586,19 +1585,26 @@ impl ScriptThread {
document.set_https_state(metadata.https_state);
- match metadata.content_type {
- Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) => {
- parse_xml(document.r(),
- parse_input,
- final_url,
- xml::ParseContext::Owner(Some(incomplete.pipeline_id)));
- }
- _ => {
- parse_html(document.r(),
- parse_input,
- final_url,
- ParseContext::Owner(Some(incomplete.pipeline_id)));
- }
+ let is_xml = match metadata.content_type {
+ Some(ContentType(Mime(TopLevel::Application, SubLevel::Ext(ref sub_level), _)))
+ if sub_level.ends_with("+xml") => true,
+
+ Some(ContentType(Mime(TopLevel::Application, SubLevel::Xml, _))) |
+ Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) => true,
+
+ _ => false,
+ };
+
+ if is_xml {
+ parse_xml(document.r(),
+ parse_input,
+ final_url,
+ xml::ParseContext::Owner(Some(incomplete.pipeline_id)));
+ } else {
+ parse_html(document.r(),
+ parse_input,
+ final_url,
+ ParseContext::Owner(Some(incomplete.pipeline_id)));
}
if incomplete.is_frozen {