aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
authorDaniel Glazman <daniel@glazman.org>2013-12-09 15:01:47 +0100
committerDaniel Glazman <daniel@glazman.org>2013-12-09 15:55:51 +0100
commit28575c20bfc0cf8040333428451fdecd32a4bca5 (patch)
treea87225bccc7759a6168d7a15f27d8c8ba169a692 /src/components/script
parent76e3b34c758fc732414ae2e3008f4c57b7b94c90 (diff)
downloadservo-28575c20bfc0cf8040333428451fdecd32a4bca5.tar.gz
servo-28575c20bfc0cf8040333428451fdecd32a4bca5.zip
add namespaces to elements
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/element.rs8
-rw-r--r--src/components/script/dom/htmlelement.rs3
2 files changed, 9 insertions, 2 deletions
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 955c52a8845..82cd7207f8e 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -30,6 +30,7 @@ use std::ascii::StrAsciiExt;
pub struct Element {
node: Node<ScriptView>,
tag_name: ~str, // TODO: This should be an atom, not a ~str.
+ namespace: Namespace,
attrs: HashMap<~str, ~[@mut Attr]>,
attrs_insert_order: ~[(~str, Namespace)], // store an order of attributes.
style_attribute: Option<style::PropertyDeclarationBlock>,
@@ -128,6 +129,10 @@ impl ElementLike for Element {
self.tag_name.as_slice()
}
+ fn get_namespace<'a>(&'a self) -> ~str {
+ self.namespace.to_str().unwrap_or(~"")
+ }
+
fn get_attr(&self, name: &str) -> Option<~str> {
self.get_attribute(None, name).map(|attr| attr.value.clone())
}
@@ -146,10 +151,11 @@ impl ElementLike for Element {
}
impl<'self> Element {
- pub fn new(type_id: ElementTypeId, tag_name: ~str, document: AbstractDocument) -> Element {
+ pub fn new(type_id: ElementTypeId, tag_name: ~str, namespace: Namespace, document: AbstractDocument) -> Element {
Element {
node: Node::new(ElementNodeTypeId(type_id), document),
tag_name: tag_name,
+ namespace: namespace,
attrs: HashMap::new(),
attrs_insert_order: ~[],
attr_list: None,
diff --git a/src/components/script/dom/htmlelement.rs b/src/components/script/dom/htmlelement.rs
index cdffbae1611..4d966720428 100644
--- a/src/components/script/dom/htmlelement.rs
+++ b/src/components/script/dom/htmlelement.rs
@@ -9,6 +9,7 @@ use dom::element::{Element, ElementTypeId, HTMLElementTypeId};
use dom::node::{AbstractNode, Node, ScriptView};
use js::jsapi::{JSContext, JSVal};
use js::JSVAL_NULL;
+use dom::namespace;
pub struct HTMLElement {
element: Element
@@ -17,7 +18,7 @@ pub struct HTMLElement {
impl HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, document: AbstractDocument) -> HTMLElement {
HTMLElement {
- element: Element::new(type_id, tag_name, document)
+ element: Element::new(type_id, tag_name, namespace::HTML, document)
}
}