An <area> element remains focusable even though its associated <img> is not rendered.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 18:51:52 +0000 (18:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Mar 2012 18:51:52 +0000 (18:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71788

Patch by Antaryami Pandia <antaryami.pandia@motorola.com> on 2012-03-26
Reviewed by Andy Estes.

Source/WebCore:

HTMLAreaElement::isFocusable() needs to consider the display and
visibility state.

Test: fast/events/tab-test-not-visible-imagemap.html

* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::imageElement):
(WebCore::HTMLAreaElement::isFocusable):
* html/HTMLAreaElement.h: Make imageElement() const.
(HTMLAreaElement):

LayoutTests:

Test sequential focus navigation.

* fast/events/tab-test-not-visible-imagemap-expected.txt: Added.
* fast/events/tab-test-not-visible-imagemap.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/tab-test-not-visible-imagemap-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/tab-test-not-visible-imagemap.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAreaElement.cpp
Source/WebCore/html/HTMLAreaElement.h

index 91b1978..4f2198b 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-26  Antaryami Pandia  <antaryami.pandia@motorola.com>
+
+        An <area> element remains focusable even though its associated <img> is not rendered.
+        https://bugs.webkit.org/show_bug.cgi?id=71788
+
+        Reviewed by Andy Estes.
+
+        Test sequential focus navigation.
+
+        * fast/events/tab-test-not-visible-imagemap-expected.txt: Added.
+        * fast/events/tab-test-not-visible-imagemap.html: Added.
+
 2012-03-26  Ojan Vafai  <ojan@chromium.org>
 
         Trim the set of flaky css3/selectors3/xml tests on SnowLeopard to
diff --git a/LayoutTests/fast/events/tab-test-not-visible-imagemap-expected.txt b/LayoutTests/fast/events/tab-test-not-visible-imagemap-expected.txt
new file mode 100644 (file)
index 0000000..4019a64
--- /dev/null
@@ -0,0 +1,15 @@
+
+
+
+Test that tabbing does not focus area element when its associated image is not rendered.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.activeElement.id is 'input1'
+PASS document.activeElement.id is 'input2'
+PASS document.activeElement.id is 'input3'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/tab-test-not-visible-imagemap.html b/LayoutTests/fast/events/tab-test-not-visible-imagemap.html
new file mode 100644 (file)
index 0000000..88fd5d5
--- /dev/null
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+<body id="body">
+
+<form>
+<table>
+<tbody>
+    <tr><td><input id="input1" type="text"/></td></tr>
+    <tr style="display: none"><td>
+
+    <map name="mymap">
+        <area id="area1" shape="circle" coords="70,84,51" href="1">
+        <area id="area2" shape="rect" coords="25,180,125,280" href="2">
+        <area id="area3" shape="poly" coords="153,106,186,225,340,193,315,81,304,167" href="3">
+        <area id="area4" shape="rect" coords="420,19,478,278" nohref>
+        <area id="area5" shape="circle" coords="220,150,100" href="4">
+        <area id="area6" shape="default" coords="0,0,500,300" href="5">
+        <area id="area7" shape="rect" coords="1, 1, 10, 10" tabindex=-1 href="6">
+    </map>
+
+    <img src="resources/abe.png" width="500" height="300" alt="Image Map" usemap="#mymap" ismap>
+
+    </td></tr>
+    <tr><td><input id ="input2" type="text"/></td></tr>
+
+    <tr style="visibility: hidden"><td>
+
+    <map name="map">
+        <area id="area8" shape="rect" coords=coords="5,48,247,97" href="1">
+    </map>
+
+    <img src="resources/abe.png" width="500" height="300" alt="Image Map" usemap="#map" ismap>
+
+    </td></tr>
+    <tr><td><input id ="input3" type="text"/></td></tr>
+
+</tbody>
+</table>
+</form>
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("Test that tabbing does not focus area element when its associated image is not rendered.");
+
+    eventSender.keyDown('\t');
+    shouldBe("document.activeElement.id", "'input1'");
+
+    eventSender.keyDown('\t');
+    shouldBe("document.activeElement.id", "'input2'");
+
+    eventSender.keyDown('\t');
+    shouldBe("document.activeElement.id", "'input3'");
+
+</script>
+
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index e3e6f1b..43c1158 100644 (file)
@@ -1,3 +1,21 @@
+2012-03-26  Antaryami Pandia  <antaryami.pandia@motorola.com>
+
+        An <area> element remains focusable even though its associated <img> is not rendered.
+        https://bugs.webkit.org/show_bug.cgi?id=71788
+
+        Reviewed by Andy Estes.
+
+        HTMLAreaElement::isFocusable() needs to consider the display and
+        visibility state.
+
+        Test: fast/events/tab-test-not-visible-imagemap.html
+
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::imageElement):
+        (WebCore::HTMLAreaElement::isFocusable):
+        * html/HTMLAreaElement.h: Make imageElement() const.
+        (HTMLAreaElement):
+
 2012-03-26  Anton Muhin  <antonm@chromium.org>
 
         Fix a typo in IDL
index 5cce169..40d45db 100644 (file)
@@ -179,7 +179,7 @@ Path HTMLAreaElement::getRegion(const LayoutSize& size) const
     return path;
 }
 
-HTMLImageElement* HTMLAreaElement::imageElement()
+HTMLImageElement* HTMLAreaElement::imageElement() const
 {
     Node* mapElement = parentNode();
     if (!mapElement || !mapElement->hasTagName(mapTag))
@@ -200,6 +200,10 @@ bool HTMLAreaElement::isMouseFocusable() const
 
 bool HTMLAreaElement::isFocusable() const
 {
+    HTMLImageElement* image = imageElement();
+    if (!image || !image->renderer() || image->renderer()->style()->visibility() != VISIBLE)
+        return false;
+
     return supportsFocus() && Element::tabIndex() >= 0;
 }
     
index 0970af8..ed67bd0 100644 (file)
@@ -45,7 +45,7 @@ public:
     Path computePath(RenderObject*) const;
 
     // The parent map's image.
-    HTMLImageElement* imageElement();
+    HTMLImageElement* imageElement() const;
     
 private:
     HTMLAreaElement(const QualifiedName&, Document*);