1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import java.util.Map;
18
19 import org.apache.commons.lang3.StringUtils;
20 import org.htmlunit.SgmlPage;
21
22
23
24
25
26
27
28
29
30
31
32 public class HtmlMap extends HtmlElement {
33
34
35 public static final String TAG_NAME = "map";
36
37
38
39
40
41
42
43
44 HtmlMap(final String qualifiedName, final SgmlPage page,
45 final Map<String, DomAttr> attributes) {
46 super(qualifiedName, page, attributes);
47 }
48
49
50
51
52
53
54
55
56
57 public final String getNameAttribute() {
58 return getAttributeDirect(NAME_ATTRIBUTE);
59 }
60
61
62
63
64 @Override
65 public DisplayStyle getDefaultStyleDisplay() {
66 return DisplayStyle.INLINE;
67 }
68
69 @Override
70 public boolean isDisplayed() {
71 final HtmlImage image = findReferencingImage();
72 if (null != image) {
73 return image.isDisplayed();
74 }
75 return false;
76 }
77
78 private HtmlImage findReferencingImage() {
79 final HtmlPage page = getHtmlPageOrNull();
80 String name = getNameAttribute();
81 if (null != page && StringUtils.isNotBlank(name)) {
82 name = "#" + name.trim();
83 for (final HtmlElement elem : page.getDocumentElement().getStaticElementsByTagName("img")) {
84 final HtmlImage image = (HtmlImage) elem;
85 if (name.equals(image.getUseMapAttribute())) {
86 return image;
87 }
88 }
89 }
90 return null;
91 }
92 }