Search in sources :

Example 1 with HtmlArea

use of com.gargoylesoftware.htmlunit.html.HtmlArea in project htmlunit by HtmlUnit.

the class HTMLMapElement method getAreas.

/**
 * Returns the value of the JavaScript attribute {@code areas}.
 * @return the value of this attribute
 */
@JsxGetter
public HTMLCollection getAreas() {
    if (areas_ == null) {
        final HtmlMap map = (HtmlMap) getDomNodeOrDie();
        areas_ = new HTMLCollection(map, false) {

            @Override
            protected List<DomNode> computeElements() {
                final List<DomNode> list = new ArrayList<>();
                for (final DomNode node : map.getChildElements()) {
                    if (node instanceof HtmlArea) {
                        list.add(node);
                    }
                }
                return list;
            }
        };
    }
    return areas_;
}
Also used : HtmlArea(com.gargoylesoftware.htmlunit.html.HtmlArea) DomNode(com.gargoylesoftware.htmlunit.html.DomNode) HtmlMap(com.gargoylesoftware.htmlunit.html.HtmlMap) ArrayList(java.util.ArrayList) List(java.util.List) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Example 2 with HtmlArea

use of com.gargoylesoftware.htmlunit.html.HtmlArea in project htmlunit by HtmlUnit.

the class HTMLAreaElement method focus.

/**
 * Sets the focus to this element.
 */
@Override
public void focus() {
    // in reality this depends also on the visibility of the area itself
    final HtmlArea area = (HtmlArea) getDomNodeOrDie();
    final String hrefAttr = area.getHrefAttribute();
    if (ATTRIBUTE_NOT_DEFINED != hrefAttr || getBrowserVersion().hasFeature(JS_AREA_WITHOUT_HREF_FOCUSABLE)) {
        area.focus();
    }
}
Also used : HtmlArea(com.gargoylesoftware.htmlunit.html.HtmlArea)

Aggregations

HtmlArea (com.gargoylesoftware.htmlunit.html.HtmlArea)2 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1 HtmlMap (com.gargoylesoftware.htmlunit.html.HtmlMap)1 JsxGetter (com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1