diff options
author | jsharda <jsharda@ncsu.edu> | 2015-11-25 21:30:36 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2015-12-04 16:32:53 -0500 |
commit | a840a23990fbca4ce9572e729d9f390f3d991390 (patch) | |
tree | bfb7b1e175545f5b730da951ad21349698804f21 /components/script/script_task.rs | |
parent | 2cfcc26d9e5cc732a7594f0c0d96d4174c6b0a8a (diff) | |
download | servo-a840a23990fbca4ce9572e729d9f390f3d991390.tar.gz servo-a840a23990fbca4ce9572e729d9f390f3d991390.zip |
Prepare infrastructure for XML parser.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 736c95b0d2d..374b9ec70a9 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -75,6 +75,7 @@ use net_traits::{AsyncResponseTarget, ControlMsg, LoadConsumer, Metadata, Resour use network_listener::NetworkListener; use page::{Frame, IterablePage, Page}; use parse::html::{ParseContext, parse_html}; +use parse::xml::{self, parse_xml}; use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan}; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent}; @@ -1659,22 +1660,43 @@ impl ScriptTask { }); let content_type = match metadata.content_type { + + Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) => { + Some(DOMString::from("text/xml")) + } + Some(ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) => { Some(DOMString::from("text/plain")) } + _ => None }; let loader = DocumentLoader::new_with_task(self.resource_task.clone(), Some(page.pipeline()), Some(incomplete.url.clone())); - let document = Document::new(window.r(), + let document; + match metadata.content_type { + + Some(ContentType(Mime(TopLevel::Text, SubLevel::Xml, _))) => { + document = Document::new(window.r(), + Some(final_url.clone()), + IsHTMLDocument::NonHTMLDocument, + content_type, + last_modified, + DocumentSource::NotFromParser, + loader); + } + _ => { + document = Document::new(window.r(), Some(final_url.clone()), IsHTMLDocument::HTMLDocument, content_type, last_modified, DocumentSource::FromParser, loader); + } + } let frame_element = frame_element.r().map(Castable::upcast); window.init_browsing_context(document.r(), frame_element); @@ -1724,8 +1746,21 @@ impl ScriptTask { DOMString::new() }; - parse_html(document.r(), parse_input, final_url, - ParseContext::Owner(Some(incomplete.pipeline_id))); + 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))); + } + } page_remover.neuter(); |