mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Move is_void() Element method together with the other struct methods,
it becomes part of ElementHelpers.
This commit is contained in:
parent
249638da8f
commit
7581335232
3 changed files with 18 additions and 19 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue