diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-06-10 14:46:43 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-06-11 19:51:07 +0200 |
commit | d230077f9f269d8f46af07004dd659496f701044 (patch) | |
tree | 39edd01a2530e9dc27c2667c87f6a9e0bff89010 /src/components/script/html/hubbub_html_parser.rs | |
parent | 6df6a7d51246307dddc314861a7e1e31963018b2 (diff) | |
download | servo-d230077f9f269d8f46af07004dd659496f701044.tar.gz servo-d230077f9f269d8f46af07004dd659496f701044.zip |
Stop mutating Element::namespace.
Diffstat (limited to 'src/components/script/html/hubbub_html_parser.rs')
-rw-r--r-- | src/components/script/html/hubbub_html_parser.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index fac27f299b1..23247341325 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -17,10 +17,10 @@ use html::cssparse::{StylesheetProvenance, UrlProvenance, spawn_css_parser}; use script_task::Page; use hubbub::hubbub; -use hubbub::hubbub::{NullNs, XLinkNs, XmlNs, XmlNsNs}; +use hubbub::hubbub::{NullNs, HtmlNs, MathMlNs, SvgNs, XLinkNs, XmlNs, XmlNsNs}; use servo_net::resource_task::{Load, LoadData, Payload, Done, ResourceTask, load_whole_resource}; use servo_util::namespace; -use servo_util::namespace::Null; +use servo_util::namespace::{Namespace, Null}; use servo_util::str::{DOMString, HTML_SPACE_CHARACTERS}; use servo_util::task::spawn_named; use servo_util::url::parse_url; @@ -158,7 +158,11 @@ fn js_script_listener(to_parent: Sender<HtmlDiscoveryMessage>, // Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized // via atomization (issue #85). -pub fn build_element_from_tag(tag: DOMString, document: &JSRef<Document>) -> Temporary<Element> { +pub fn build_element_from_tag(tag: DOMString, ns: Namespace, document: &JSRef<Document>) -> Temporary<Element> { + if ns != namespace::HTML { + return Element::new(tag, ns, None, document); + } + // TODO (Issue #85): use atoms handle_element!(document, tag, "a", HTMLAnchorElement); handle_element!(document, tag, "abbr", HTMLElement); @@ -369,7 +373,13 @@ pub fn parse_html(page: &Page, // NOTE: tmp vars are workaround for lifetime issues. Both required. let tmp_borrow = doc_cell.borrow(); let tmp = &*tmp_borrow; - let mut element: Root<Element> = build_element_from_tag(tag.name.clone(), *tmp).root(); + let namespace = match tag.ns { + HtmlNs => namespace::HTML, + MathMlNs => namespace::MathML, + SvgNs => namespace::SVG, + ns => fail!("Not expecting namespace {:?}", ns), + }; + let mut element: Root<Element> = build_element_from_tag(tag.name.clone(), namespace, *tmp).root(); debug!("-- attach attrs"); for attr in tag.attributes.iter() { |