aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/Cargo.toml3
-rw-r--r--components/script/lib.rs1
-rw-r--r--components/script/parse/html.rs5
-rw-r--r--components/script/parse/xml.rs28
4 files changed, 24 insertions, 13 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml
index 0a1c5f9b6b9..c3754adf3fe 100644
--- a/components/script/Cargo.toml
+++ b/components/script/Cargo.toml
@@ -78,11 +78,10 @@ num = "0.1.24"
websocket = "0.14.0"
uuid = "0.1.16"
smallvec = "0.1"
-html5ever = { version = "0.2.1", features = ["unstable"] }
+html5ever = { version = "0.4", features = ["unstable"] }
selectors = "0.2"
string_cache = { version = "0.2", features = ["unstable"] }
euclid = {version = "0.4", features = ["plugins"]}
-tendril = "0.1.1"
rand = "0.3"
serde = "0.6"
caseless = "0.1.0"
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 0993d090dd5..a776fe2d484 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -66,7 +66,6 @@ extern crate smallvec;
#[macro_use(atom, ns)] extern crate string_cache;
#[macro_use]
extern crate style;
-extern crate tendril;
extern crate time;
extern crate unicase;
extern crate url;
diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs
index dc201402a61..d4ea3cf2093 100644
--- a/components/script/parse/html.rs
+++ b/components/script/parse/html.rs
@@ -29,13 +29,13 @@ use html5ever::Attribute;
use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use html5ever::serialize::{AttrRef, Serializable, Serializer};
+use html5ever::tendril::StrTendril;
use html5ever::tree_builder::{NextParserState, NodeOrText, QuirksMode, TreeSink};
use msg::constellation_msg::PipelineId;
use parse::Parser;
use std::borrow::Cow;
use std::io::{self, Write};
use string_cache::QualName;
-use tendril::StrTendril;
use url::Url;
use util::str::DOMString;
@@ -54,6 +54,9 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<No
}
impl<'a> TreeSink for servohtmlparser::Sink {
+ type Output = Self;
+ fn finish(self) -> Self { self }
+
type Handle = JS<Node>;
fn get_document(&mut self) -> JS<Node> {
diff --git a/components/script/parse/xml.rs b/components/script/parse/xml.rs
index 30cd5138348..6c82e5af358 100644
--- a/components/script/parse/xml.rs
+++ b/components/script/parse/xml.rs
@@ -19,11 +19,11 @@ use dom::text::Text;
use msg::constellation_msg::PipelineId;
use parse::Parser;
use std::borrow::Cow;
-use string_cache::QualName;
-use tendril::StrTendril;
+use string_cache::{Atom, QualName, Namespace};
use url::Url;
use util::str::DOMString;
-use xml5ever::tokenizer::Attribute;
+use xml5ever::tendril::StrTendril;
+use xml5ever::tokenizer::{Attribute, QName};
use xml5ever::tree_builder::{NodeOrText, TreeSink};
impl<'a> TreeSink for servoxmlparser::Sink {
@@ -37,22 +37,32 @@ impl<'a> TreeSink for servoxmlparser::Sink {
JS::from_ref(self.document.upcast())
}
- fn elem_name(&self, target: &JS<Node>) -> QualName {
+ fn elem_name(&self, target: &JS<Node>) -> QName {
let elem = target.downcast::<Element>()
.expect("tried to get name of non-Element in XML parsing");
- QualName {
- ns: elem.namespace().clone(),
+ QName {
+ prefix: elem.prefix().as_ref().map_or(atom!(""), |p| Atom::from(&**p)),
+ namespace_url: elem.namespace().0.clone(),
local: elem.local_name().clone(),
}
}
- fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>)
+ fn create_element(&mut self, name: QName, attrs: Vec<Attribute>)
-> JS<Node> {
- let elem = Element::create(name, None, &*self.document,
+ let prefix = if name.prefix == atom!("") { None } else { Some(name.prefix) };
+ let name = QualName {
+ ns: Namespace(name.namespace_url),
+ local: name.local,
+ };
+ let elem = Element::create(name, prefix, &*self.document,
ElementCreator::ParserCreated);
for attr in attrs {
- elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None);
+ let name = QualName {
+ ns: Namespace(attr.name.namespace_url),
+ local: attr.name.local,
+ };
+ elem.set_attribute_from_parser(name, DOMString::from(String::from(attr.value)), None);
}
JS::from_ref(elem.upcast())