M1503 - Integrate XML parse -Initial Steps

This commit is contained in:
jsharda 2015-10-30 16:50:15 -04:00
parent 50e0c36eeb
commit dca4e3730b
8 changed files with 81 additions and 6 deletions

View file

@ -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"

View file

@ -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)
}
}
}

View file

@ -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;

View file

@ -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() {
}
}

View file

@ -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 {
};

View file

@ -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);

View file

@ -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) {
}