servo/components/script/dom/htmlmapelement.rs
SendilKumar N 31dafcc5f3 making image element areas good at finding areas
linting errors

replaced with map

fixes comments

moving to document

added test cases

linting and updating manifest

changing test cases

linting fixes

manifest update

linting fixes

splitting the test cases into two
2017-04-04 23:11:44 +08:00

45 lines
1.5 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::HTMLMapElementBinding;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::htmlareaelement::HTMLAreaElement;
use dom::htmlelement::HTMLElement;
use dom::node::Node;
use dom_struct::dom_struct;
use html5ever_atoms::LocalName;
#[dom_struct]
pub struct HTMLMapElement {
htmlelement: HTMLElement
}
impl HTMLMapElement {
fn new_inherited(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> HTMLMapElement {
HTMLMapElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(local_name: LocalName,
prefix: Option<DOMString>,
document: &Document) -> Root<HTMLMapElement> {
Node::reflect_node(box HTMLMapElement::new_inherited(local_name, prefix, document),
document,
HTMLMapElementBinding::Wrap)
}
pub fn get_area_elements(&self) -> Vec<Root<HTMLAreaElement>> {
self.upcast::<Node>()
.traverse_preorder()
.filter_map(Root::downcast::<HTMLAreaElement>).collect()
}
}