mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move HTMLDocument members to Document.
This commit is contained in:
parent
2c8107e811
commit
7190feb5e3
4 changed files with 48 additions and 52 deletions
|
@ -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() {
|
||||
|
|
|
@ -8,10 +8,8 @@ use dom::bindings::js::JS;
|
|||
use dom::bindings::utils::{Reflectable, Reflector};
|
||||
use dom::document::{Document, HTML, HTMLDocumentTypeId};
|
||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::node::DocumentNodeTypeId;
|
||||
use dom::window::Window;
|
||||
use servo_util::namespace::Null;
|
||||
|
||||
use extra::url::Url;
|
||||
|
||||
|
@ -42,46 +40,6 @@ impl HTMLDocument {
|
|||
}
|
||||
}
|
||||
|
||||
impl HTMLDocument {
|
||||
pub fn Images(&self) -> JS<HTMLCollection> {
|
||||
self.parent.createHTMLCollection(|elem| "img" == elem.tag_name)
|
||||
}
|
||||
|
||||
pub fn Embeds(&self) -> JS<HTMLCollection> {
|
||||
self.parent.createHTMLCollection(|elem| "embed" == elem.tag_name)
|
||||
}
|
||||
|
||||
pub fn Plugins(&self) -> JS<HTMLCollection> {
|
||||
self.Embeds()
|
||||
}
|
||||
|
||||
pub fn Links(&self) -> JS<HTMLCollection> {
|
||||
self.parent.createHTMLCollection(|elem| {
|
||||
("a" == elem.tag_name || "area" == elem.tag_name) &&
|
||||
elem.get_attribute(Null, "href").is_some()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn Forms(&self) -> JS<HTMLCollection> {
|
||||
self.parent.createHTMLCollection(|elem| "form" == elem.tag_name)
|
||||
}
|
||||
|
||||
pub fn Scripts(&self) -> JS<HTMLCollection> {
|
||||
self.parent.createHTMLCollection(|elem| "script" == elem.tag_name)
|
||||
}
|
||||
|
||||
pub fn Anchors(&self) -> JS<HTMLCollection> {
|
||||
self.parent.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.parent.createHTMLCollection(|elem| "applet" == elem.tag_name)
|
||||
}
|
||||
}
|
||||
|
||||
impl Reflectable for HTMLDocument {
|
||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||
self.parent.reflector()
|
||||
|
|
|
@ -45,4 +45,13 @@ partial interface Document {
|
|||
attribute HTMLElement? body;
|
||||
readonly attribute HTMLHeadElement? head;
|
||||
/*NodeList*/ HTMLCollection getElementsByName(DOMString elementName);
|
||||
|
||||
readonly attribute HTMLCollection images;
|
||||
readonly attribute HTMLCollection embeds;
|
||||
readonly attribute HTMLCollection plugins;
|
||||
readonly attribute HTMLCollection links;
|
||||
readonly attribute HTMLCollection forms;
|
||||
readonly attribute HTMLCollection scripts;
|
||||
readonly attribute HTMLCollection anchors;
|
||||
readonly attribute HTMLCollection applets;
|
||||
};
|
||||
|
|
|
@ -5,13 +5,4 @@
|
|||
*/
|
||||
|
||||
/* http://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
|
||||
interface HTMLDocument : Document {
|
||||
readonly attribute HTMLCollection images;
|
||||
readonly attribute HTMLCollection embeds;
|
||||
readonly attribute HTMLCollection plugins;
|
||||
readonly attribute HTMLCollection links;
|
||||
readonly attribute HTMLCollection forms;
|
||||
readonly attribute HTMLCollection scripts;
|
||||
readonly attribute HTMLCollection anchors;
|
||||
readonly attribute HTMLCollection applets;
|
||||
};
|
||||
interface HTMLDocument : Document {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue