diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index 7cff64d5ade..369d08bfdf0 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -26,15 +26,23 @@ DOMInterfaces = { 'Console': {}, 'Document': { 'needsAbstract': [ + 'anchors', + 'applets', 'body', 'createComment', 'createDocumentFragment', 'createElement', 'createProcessingInstruction', 'createTextNode', + 'embeds', + 'forms', 'getElementsByClassName', 'getElementsByTagName', 'getElementsByTagNameNS', + 'images', + 'links', + 'plugins', + 'scripts', 'title', ], }, diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 95de6ab2fac..07660e30e88 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -431,43 +431,49 @@ impl Document { }) } - pub fn Images(&self) -> JS { - self.createHTMLCollection(|elem| "img" == elem.get().tag_name) + pub fn Images(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), ~"img") } - pub fn Embeds(&self) -> JS { - self.createHTMLCollection(|elem| "embed" == elem.get().tag_name) + pub fn Embeds(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), ~"embed") } - pub fn Plugins(&self) -> JS { - self.Embeds() + pub fn Plugins(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + self.Embeds(abstract_self) } - pub fn Links(&self) -> JS { - self.createHTMLCollection(|elem| { + pub fn Links(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), |elem| { ("a" == elem.get().tag_name || "area" == elem.get().tag_name) && elem.get().get_attribute(Null, "href").is_some() }) } - pub fn Forms(&self) -> JS { - self.createHTMLCollection(|elem| "form" == elem.get().tag_name) + pub fn Forms(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), ~"form") } - pub fn Scripts(&self) -> JS { - self.createHTMLCollection(|elem| "script" == elem.get().tag_name) + pub fn Scripts(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), ~"script") } - pub fn Anchors(&self) -> JS { - self.createHTMLCollection(|elem| { - "a" == elem.get().tag_name && - elem.get().get_attribute(Null, "name").is_some() + pub fn Anchors(&self, abstract_self: &JS) -> JS { + // FIXME: https://github.com/mozilla/servo/issues/1847 + HTMLCollection::create(&self.window, &NodeCast::from(abstract_self), |elem| { + "a" == elem.get().tag_name && elem.get().get_attribute(Null, "name").is_some() }) } - pub fn Applets(&self) -> JS { + pub fn Applets(&self, abstract_self: &JS) -> JS { // FIXME: This should be return OBJECT elements containing applets. - self.createHTMLCollection(|elem| "applet" == elem.get().tag_name) + HTMLCollection::by_tag_name(&self.window, &NodeCast::from(abstract_self), ~"applet") } pub fn create_collection(&self, callback: |elem: &JS| -> Option>) -> ~[JS] { @@ -487,21 +493,6 @@ impl Document { nodes } - pub fn createHTMLCollection(&self, callback: |elem: &JS| -> bool) -> JS { - HTMLCollection::new(&self.window, self.create_collection(|node| { - if !node.is_element() { - return None; - } - - let element: JS = ElementCast::to(node); - if !callback(&element) { - return None; - } - - Some(element) - })) - } - pub fn createNodeList(&self, callback: |node: &JS| -> bool) -> JS { NodeList::new_simple_list(&self.window, self.create_collection(|node| { if !callback(node) {