From 7700a892fcae8f153885f38a81bbc44d4d4b7510 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 2 Nov 2013 21:13:37 +0100 Subject: [PATCH] Cleanup build_element_from_tag's signature. --- src/components/script/dom/document.rs | 3 +-- src/components/script/html/hubbub_html_parser.rs | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 251da394cf5..f889c5ddde2 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -235,13 +235,12 @@ impl Document { } pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible> { - let cx = self.get_cx(); let local_name = null_str_as_empty(local_name); if !is_valid_element_name(local_name) { return Err(InvalidCharacter); } let local_name = local_name.to_ascii_lower(); - Ok(build_element_from_tag(cx, local_name, abstract_self)) + Ok(build_element_from_tag(local_name, abstract_self)) } pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode { diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 21b18b69577..de87a13134e 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -39,7 +39,7 @@ macro_rules! handle_newable_element( $ctor: ident $(, $arg:expr )*) => ( if eq_slice($localName, $string) { - return $ctor::new(($localName).to_str(), $document $(, $arg)*); + return $ctor::new($localName, $document $(, $arg)*); } ) ) @@ -162,7 +162,7 @@ fn js_script_listener(to_parent: SharedChan, // 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(_cx: *JSContext, tag: &str, document: AbstractDocument) -> AbstractNode { +pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode { // TODO (Issue #85): use atoms handle_newable_element!(document, tag, "a", HTMLAnchorElement); handle_newable_element!(document, tag, "applet", HTMLAppletElement); @@ -242,7 +242,7 @@ pub fn build_element_from_tag(_cx: *JSContext, tag: &str, document: AbstractDocu handle_newable_element!(document, tag, "ul", HTMLUListElement); handle_newable_element!(document, tag, "video", HTMLVideoElement); - return HTMLUnknownElement::new(tag.to_str(), document); + return HTMLUnknownElement::new(tag, document); } pub fn parse_html(cx: *JSContext, @@ -336,7 +336,7 @@ pub fn parse_html(cx: *JSContext, }, create_element: |tag: ~hubbub::Tag| { debug!("create element"); - let node = build_element_from_tag(cx, tag.name, document); + let node = build_element_from_tag(tag.name.clone(), document); debug!("-- attach attrs"); do node.as_mut_element |element| {