Move is_void() Element method together with the other struct methods,

it becomes part of ElementHelpers.
This commit is contained in:
Adenilson Cavalcanti 2014-09-19 12:00:31 -07:00
parent 249638da8f
commit 7581335232
3 changed files with 18 additions and 19 deletions

View file

@ -242,6 +242,7 @@ pub trait ElementHelpers {
fn get_local_name<'a>(&'a self) -> &'a Atom;
fn get_namespace<'a>(&'a self) -> &'a Namespace;
fn summarize(&self) -> Vec<AttrInfo>;
fn is_void(&self) -> bool;
}
impl<'a> ElementHelpers for JSRef<'a, Element> {
@ -269,6 +270,20 @@ impl<'a> ElementHelpers for JSRef<'a, Element> {
}
summarized
}
fn is_void(&self) -> bool {
if self.namespace != namespace::HTML {
return false
}
match self.local_name.as_slice() {
/* List of void elements from
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm */
"area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" |
"frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" |
"meta" | "param" | "source" | "track" | "wbr" => true,
_ => false
}
}
}
pub trait AttributeHandlers {
@ -489,22 +504,6 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
}
impl Element {
pub fn is_void(&self) -> bool {
if self.namespace != namespace::HTML {
return false
}
match self.local_name.as_slice() {
/* List of void elements from
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#html-fragment-serialization-algorithm */
"area" | "base" | "basefont" | "bgsound" | "br" | "col" | "embed" |
"frame" | "hr" | "img" | "input" | "keygen" | "link" | "menuitem" |
"meta" | "param" | "source" | "track" | "wbr" => true,
_ => false
}
}
}
impl<'a> ElementMethods for JSRef<'a, Element> {
// http://dom.spec.whatwg.org/#dom-element-namespaceuri
fn GetNamespaceURI(&self) -> Option<DOMString> {