diff options
-rw-r--r-- | components/script/Cargo.toml | 4 | ||||
-rw-r--r-- | components/script/dom/domparser.rs | 15 | ||||
-rw-r--r-- | components/script/dom/mod.rs | 1 | ||||
-rw-r--r-- | components/script/dom/servoxmlparser.rs | 16 | ||||
-rw-r--r-- | components/script/dom/webidls/ServoXMLParser.webidl | 12 | ||||
-rw-r--r-- | components/script/parse/mod.rs | 1 | ||||
-rw-r--r-- | components/script/parse/xml.rs | 20 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 18 |
8 files changed, 81 insertions, 6 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 72992af9e8b..b2b96d04f72 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -70,6 +70,10 @@ git = "https://github.com/pcwalton/ipc-channel" version = "0.6" features = [ "serde-serialization" ] +[dependencies.xml5ever] +git = "https://github.com/Ygg01/xml5ever" +features = ["unstable"] + [dependencies] app_units = {version = "0.1", features = ["plugins"]} log = "0.3" diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index 386c2e1ab4a..f11f92ba6e6 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -16,6 +16,7 @@ use dom::document::DocumentSource; use dom::document::{Document, IsHTMLDocument}; use dom::window::Window; use parse::html::{ParseContext, parse_html}; +use parse::xml::{self, parse_xml}; use std::borrow::ToOwned; use util::str::DOMString; @@ -68,12 +69,14 @@ impl DOMParserMethods for DOMParser { } Text_xml => { //FIXME: this should probably be FromParser when we actually parse the string (#3756). - Ok(Document::new(&self.window, Some(url.clone()), - IsHTMLDocument::NonHTMLDocument, - Some(content_type), - None, - DocumentSource::NotFromParser, - loader)) + let document = Document::new(&self.window, Some(url.clone()), + IsHTMLDocument::NonHTMLDocument, + Some(content_type), + None, + DocumentSource::NotFromParser, + loader); + parse_xml(document.r(), s, url, xml::ParseContext::Owner(None)); + Ok(document) } } } diff --git a/components/script/dom/mod.rs b/components/script/dom/mod.rs index bacc88834f9..46b61834f73 100644 --- a/components/script/dom/mod.rs +++ b/components/script/dom/mod.rs @@ -338,6 +338,7 @@ pub mod progressevent; pub mod range; pub mod screen; pub mod servohtmlparser; +pub mod servoxmlparser; pub mod storage; pub mod storageevent; pub mod testbinding; diff --git a/components/script/dom/servoxmlparser.rs b/components/script/dom/servoxmlparser.rs new file mode 100644 index 00000000000..9de29cb392d --- /dev/null +++ b/components/script/dom/servoxmlparser.rs @@ -0,0 +1,16 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use dom::bindings::reflector::Reflector; + +#[must_root] +#[dom_struct] +pub struct ServoXMLParser { + reflector_: Reflector, +} + +impl ServoXMLParser { + pub fn new() { + } +} diff --git a/components/script/dom/webidls/ServoXMLParser.webidl b/components/script/dom/webidls/ServoXMLParser.webidl new file mode 100644 index 00000000000..0b5a20addd3 --- /dev/null +++ b/components/script/dom/webidls/ServoXMLParser.webidl @@ -0,0 +1,12 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// This interface is entirely internal to Servo, and should not be accessible to +// web pages. + +[NoInterfaceObject] +interface ServoXMLParser { +}; + diff --git a/components/script/parse/mod.rs b/components/script/parse/mod.rs index fa93dbc157f..dc09d34853a 100644 --- a/components/script/parse/mod.rs +++ b/components/script/parse/mod.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ pub mod html; +pub mod xml; pub trait Parser { fn parse_chunk(self, input: String); diff --git a/components/script/parse/xml.rs b/components/script/parse/xml.rs new file mode 100644 index 00000000000..c741fd03306 --- /dev/null +++ b/components/script/parse/xml.rs @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#![allow(unrooted_must_root)] + +use dom::document::Document; +use url::Url; +use util::str::DOMString; + +pub enum ParseContext { + Owner(Option<i32>) +} + + +pub fn parse_xml(document: &Document, + input: DOMString, + url: Url, + context: ParseContext) { +} diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index d44696b29a0..b169fee31f9 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -1538,6 +1538,7 @@ dependencies = [ "util 0.0.1", "uuid 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "xml5ever 0.1.0 (git+https://github.com/Ygg01/xml5ever)", ] [[package]] @@ -2058,3 +2059,20 @@ dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "xml5ever" +version = "0.1.0" +source = "git+https://github.com/Ygg01/xml5ever#0c36f2d93532b2d7b1ccfbd6019a6d53a1fcac69" +dependencies = [ + "log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "mac 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "phf 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_codegen 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "string_cache_plugin 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tendril 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", +] + |