1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.html;
16
17 import java.io.Serializable;
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.function.Supplier;
21
22 import org.htmlunit.html.DomElement;
23 import org.htmlunit.html.DomNode;
24 import org.htmlunit.html.HtmlArea;
25 import org.htmlunit.html.HtmlMap;
26 import org.htmlunit.javascript.configuration.JsxClass;
27 import org.htmlunit.javascript.configuration.JsxConstructor;
28 import org.htmlunit.javascript.configuration.JsxGetter;
29 import org.htmlunit.javascript.configuration.JsxSetter;
30
31
32
33
34
35
36
37 @JsxClass(domClass = HtmlMap.class)
38 public class HTMLMapElement extends HTMLElement {
39
40 private HTMLCollection areas_;
41
42
43
44
45 @Override
46 @JsxConstructor
47 public void jsConstructor() {
48 super.jsConstructor();
49 }
50
51
52
53
54
55 @JsxGetter
56 public HTMLCollection getAreas() {
57 if (areas_ == null) {
58 final HtmlMap map = (HtmlMap) getDomNodeOrDie();
59 areas_ = new HTMLCollection(map, false);
60 areas_.setElementsSupplier(
61 (Supplier<List<DomNode>> & Serializable)
62 () -> {
63 final List<DomNode> list = new ArrayList<>();
64 for (final DomNode node : map.getChildElements()) {
65 if (node instanceof HtmlArea) {
66 list.add(node);
67 }
68 }
69 return list;
70 });
71 }
72 return areas_;
73 }
74
75
76
77
78
79 @JsxGetter
80 @Override
81 public String getName() {
82 return getDomNodeOrDie().getAttributeDirect(DomElement.NAME_ATTRIBUTE);
83 }
84
85
86
87
88
89 @JsxSetter
90 @Override
91 public void setName(final String name) {
92 getDomNodeOrDie().setAttribute(DomElement.NAME_ATTRIBUTE, name);
93 }
94
95 }