diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-04-27 07:50:54 -0700 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-04-27 07:50:54 -0700 |
commit | daa1a2a0a82d336205dae340d705ea6c0bed4ed2 (patch) | |
tree | ded5df5b12c75a906b8cad8d8ac2cfcc4c772ae3 /components/script/script_thread.rs | |
parent | ce5423426270a3f3adbe12178f42e90903d66029 (diff) | |
parent | 3389c497c0ca740dbcd4fd56a4fc8d490f7a8592 (diff) | |
download | servo-daa1a2a0a82d336205dae340d705ea6c0bed4ed2.tar.gz servo-daa1a2a0a82d336205dae340d705ea6c0bed4ed2.zip |
Auto merge of #10647 - ConnorGBrewster:parse_xml, r=jdm
Finish hooking up XML parser
This is a work in progress PR for #10581. I just want to make sure I am headed in the right direction.
cc @jdm
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10647)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index a082c6bdaab..2aac608df13 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1510,23 +1510,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, @@ -1587,19 +1586,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 { |