Move HTMLDocument members to Document.

This commit is contained in:
Ms2ger 2014-02-22 13:49:56 +01:00
parent 2c8107e811
commit 7190feb5e3
4 changed files with 48 additions and 52 deletions

View file

@ -431,6 +431,44 @@ impl Document {
})
}
pub fn Images(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| "img" == elem.tag_name)
}
pub fn Embeds(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| "embed" == elem.tag_name)
}
pub fn Plugins(&self) -> JS<HTMLCollection> {
self.Embeds()
}
pub fn Links(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| {
("a" == elem.tag_name || "area" == elem.tag_name) &&
elem.get_attribute(Null, "href").is_some()
})
}
pub fn Forms(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| "form" == elem.tag_name)
}
pub fn Scripts(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| "script" == elem.tag_name)
}
pub fn Anchors(&self) -> JS<HTMLCollection> {
self.createHTMLCollection(|elem| {
"a" == elem.tag_name && elem.get_attribute(Null, "name").is_some()
})
}
pub fn Applets(&self) -> JS<HTMLCollection> {
// FIXME: This should be return OBJECT elements containing applets.
self.createHTMLCollection(|elem| "applet" == elem.tag_name)
}
pub fn createHTMLCollection(&self, callback: |elem: &Element| -> bool) -> JS<HTMLCollection> {
let mut elements = ~[];
match self.GetDocumentElement() {