Cleanup build_element_from_tag's signature.

This commit is contained in:
Ms2ger 2013-11-02 21:13:37 +01:00
parent b4559334bb
commit 7700a892fc
2 changed files with 5 additions and 6 deletions

View file

@ -235,13 +235,12 @@ impl Document {
} }
pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible<AbstractNode<ScriptView>> { pub fn CreateElement(&self, abstract_self: AbstractDocument, local_name: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
let cx = self.get_cx();
let local_name = null_str_as_empty(local_name); let local_name = null_str_as_empty(local_name);
if !is_valid_element_name(local_name) { if !is_valid_element_name(local_name) {
return Err(InvalidCharacter); return Err(InvalidCharacter);
} }
let local_name = local_name.to_ascii_lower(); 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<ScriptView> { pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode<ScriptView> {

View file

@ -39,7 +39,7 @@ macro_rules! handle_newable_element(
$ctor: ident $ctor: ident
$(, $arg:expr )*) => ( $(, $arg:expr )*) => (
if eq_slice($localName, $string) { 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<HtmlDiscoveryMessage>,
// Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized // Silly macros to handle constructing DOM nodes. This produces bad code and should be optimized
// via atomization (issue #85). // via atomization (issue #85).
pub fn build_element_from_tag(_cx: *JSContext, tag: &str, document: AbstractDocument) -> AbstractNode<ScriptView> { pub fn build_element_from_tag(tag: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> {
// TODO (Issue #85): use atoms // TODO (Issue #85): use atoms
handle_newable_element!(document, tag, "a", HTMLAnchorElement); handle_newable_element!(document, tag, "a", HTMLAnchorElement);
handle_newable_element!(document, tag, "applet", HTMLAppletElement); 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, "ul", HTMLUListElement);
handle_newable_element!(document, tag, "video", HTMLVideoElement); 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, pub fn parse_html(cx: *JSContext,
@ -336,7 +336,7 @@ pub fn parse_html(cx: *JSContext,
}, },
create_element: |tag: ~hubbub::Tag| { create_element: |tag: ~hubbub::Tag| {
debug!("create element"); 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"); debug!("-- attach attrs");
do node.as_mut_element |element| { do node.as_mut_element |element| {