REGRESSION (r53857): AREA tag with tabindex="-1" displays focus ring after multiple...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Oct 2010 22:09:04 +0000 (22:09 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Oct 2010 22:09:04 +0000 (22:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=45832

Reviewed by Beth Dakin.

WebCore:

Test: fast/events/mouse-focus-imagemap.html

* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::isKeyboardFocusable):
(WebCore::HTMLAreaElement::isMouseFocusable):
(WebCore::HTMLAreaElement::isFocusable):
(WebCore::HTMLAreaElement::updateFocusAppearance):
* html/HTMLAreaElement.h:

LayoutTests:

* fast/events/mouse-focus-imagemap-expected.txt: Added.
* fast/events/mouse-focus-imagemap.html: Added.
* fast/events/resources/tabindex-focus-blur-all.js:
(testProgrammaticFocus):
* fast/events/tabindex-focus-blur-all-expected.txt:
    Update test to reflect that AREA with tabindex=-1 should not be focusable.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/mouse-focus-imagemap-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mouse-focus-imagemap.html [new file with mode: 0644]
LayoutTests/fast/events/resources/tabindex-focus-blur-all.js
LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt
WebCore/ChangeLog
WebCore/html/HTMLAreaElement.cpp
WebCore/html/HTMLAreaElement.h

index 3fbe309875254e967bb96f48d37453b1b1498de3..a0db19b14c6e29bcd6206b5cb66490f153eb32bb 100644 (file)
@@ -1,3 +1,17 @@
+2010-10-06  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        REGRESSION (r53857): AREA tag with tabindex="-1" displays focus ring after multiple mouse clicks.
+        https://bugs.webkit.org/show_bug.cgi?id=45832
+
+        * fast/events/mouse-focus-imagemap-expected.txt: Added.
+        * fast/events/mouse-focus-imagemap.html: Added.
+        * fast/events/resources/tabindex-focus-blur-all.js:
+        (testProgrammaticFocus):
+        * fast/events/tabindex-focus-blur-all-expected.txt:
+            Update test to reflect that AREA with tabindex=-1 should not be focusable.
+
 2010-10-06  Albert J. Wong  <ajwong@chromium.org>
 
         [chromium] Unreviewed. Rebaseline layout tests.
 2010-10-06  Albert J. Wong  <ajwong@chromium.org>
 
         [chromium] Unreviewed. Rebaseline layout tests.
diff --git a/LayoutTests/fast/events/mouse-focus-imagemap-expected.txt b/LayoutTests/fast/events/mouse-focus-imagemap-expected.txt
new file mode 100644 (file)
index 0000000..84d497f
--- /dev/null
@@ -0,0 +1,12 @@
+
+This tests that a link in an image map with tabindex < 0 is not mouse focusable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.activeElement.id is 'focusable-area'
+PASS document.activeElement.id is 'focusable-area'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/events/mouse-focus-imagemap.html b/LayoutTests/fast/events/mouse-focus-imagemap.html
new file mode 100644 (file)
index 0000000..f1fac56
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../js/resources/js-test-pre.js"></script>
+<body id="body">
+
+<img id="image" usemap="#map" src="data:image/gif;base64,R0lGODlhAQABAIAAAOTm7AAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" width="1000" height="1000" alt="" style="border:1px solid black;">
+<map name="map" id="map">
+
+    <area id="focusable-area" tabindex="0" shape="rect" coords="0,0,500,500" href="#" role="img" title="Example 1">
+    <area id="nonfocusable-area" tabindex="-1" shape="rect" coords="500,500,1000,1000" href="#" role="img" title="Example 2">
+</map>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that a link in an image map with tabindex < 0 is not mouse focusable.");
+
+    // First try to focus on the <area> that is focusable.
+    eventSender.mouseMoveTo(100, 100);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+
+    shouldBe("document.activeElement.id", "'focusable-area'");
+
+    // Try to focus on the <area> that is NOT focusable. Focus should still remain on focusable-area.
+    eventSender.mouseMoveTo(700, 700);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    shouldBe("document.activeElement.id", "'focusable-area'");
+
+    successfullyParsed = true;
+</script>
+
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 3355630ee679a0ecbeff2328e6ed42d7b0f501b8..1589e352b723d67678241401c44e1af358c22e9b 100644 (file)
@@ -52,7 +52,7 @@ function test()
     var homeBase = window.frames[1].document.getElementsByClassName('homebase');
     homeBase[0].focus();
 
     var homeBase = window.frames[1].document.getElementsByClassName('homebase');
     homeBase[0].focus();
 
-    var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 337 / 337 ";
+    var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 331 / 331 ";
     resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
     resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
     if (failedTestCount)
     resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
     resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
     if (failedTestCount)
@@ -110,6 +110,10 @@ function testProgrammaticFocus(elem)
     if (document.defaultView.getComputedStyle(elem).display == "none" && !noDisplayTagNamesWithFocus.find(elem.tagName))
         elemThatShouldFocus = null;
 
     if (document.defaultView.getComputedStyle(elem).display == "none" && !noDisplayTagNamesWithFocus.find(elem.tagName))
         elemThatShouldFocus = null;
 
+    // AREA elements with tabindex = -1 should not be focusable.
+    if (elem.tabIndex == -1 && elem.tagName == "AREA")
+        elemThatShouldFocus = null;
+
     if (tagNamesTransferFocused.find(elem.tagName)) {
         elemThatShouldFocus = null;
         OKtoFocusOtherElement = true;
     if (tagNamesTransferFocused.find(elem.tagName)) {
         elemThatShouldFocus = null;
         OKtoFocusOtherElement = true;
index 720f6b710222fb8c23b89305b15b71b3e330e67e..ecf1276151e2881985aa92ceeac462aa3a555851 100644 (file)
@@ -1,2 +1,2 @@
-333 focus / 333 blur events dispatched, and should be 337 / 337 PASSED
+331 focus / 331 blur events dispatched, and should be 331 / 331 PASSED
 Total of 0 focus test(s) failed. PASSED
 Total of 0 focus test(s) failed. PASSED
index a99d1c051ae95f867f81da339c0b89bbe6178b3a..de13397e7ee5b1c09a5aa862b2c6903d8b67d147 100644 (file)
@@ -1,3 +1,19 @@
+2010-10-06  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        REGRESSION (r53857): AREA tag with tabindex="-1" displays focus ring after multiple mouse clicks.
+        https://bugs.webkit.org/show_bug.cgi?id=45832
+
+        Test: fast/events/mouse-focus-imagemap.html
+
+        * html/HTMLAreaElement.cpp:
+        (WebCore::HTMLAreaElement::isKeyboardFocusable):
+        (WebCore::HTMLAreaElement::isMouseFocusable):
+        (WebCore::HTMLAreaElement::isFocusable):
+        (WebCore::HTMLAreaElement::updateFocusAppearance):
+        * html/HTMLAreaElement.h:
+
 2010-10-06  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Dan Bernstein.
 2010-10-06  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Dan Bernstein.
index 3547cd9d3d1320b8d021e4f06e77318b58788c65..d808fb1b4d15622f13394852ca39f04a937c8505 100644 (file)
@@ -174,12 +174,17 @@ HTMLImageElement* HTMLAreaElement::imageElement() const
 
 bool HTMLAreaElement::isKeyboardFocusable(KeyboardEvent*) const
 {
 
 bool HTMLAreaElement::isKeyboardFocusable(KeyboardEvent*) const
 {
-    return supportsFocus();
+    return isFocusable();
+}
+    
+bool HTMLAreaElement::isMouseFocusable() const
+{
+    return isFocusable();
 }
 
 bool HTMLAreaElement::isFocusable() const
 {
 }
 
 bool HTMLAreaElement::isFocusable() const
 {
-    return supportsFocus();
+    return supportsFocus() && Element::tabIndex() >= 0;
 }
     
 void HTMLAreaElement::dispatchBlurEvent()
 }
     
 void HTMLAreaElement::dispatchBlurEvent()
@@ -192,6 +197,9 @@ void HTMLAreaElement::dispatchBlurEvent()
     
 void HTMLAreaElement::updateFocusAppearance(bool restorePreviousSelection)
 {
     
 void HTMLAreaElement::updateFocusAppearance(bool restorePreviousSelection)
 {
+    if (!isFocusable())
+        return;
+    
     Node* parent = parentNode();
     if (!parent || !parent->hasTagName(mapTag))
         return;
     Node* parent = parentNode();
     if (!parent || !parent->hasTagName(mapTag))
         return;
index 10784c3b61483198473c218ebc0ce6287475d766..42d4198ed47b31d97ed0a288d52878149531d726 100644 (file)
@@ -54,6 +54,7 @@ private:
     virtual bool supportsFocus() const;
     virtual String target() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
     virtual bool supportsFocus() const;
     virtual String target() const;
     virtual bool isKeyboardFocusable(KeyboardEvent*) const;
+    virtual bool isMouseFocusable() const;
     virtual bool isFocusable() const;
     virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
     virtual void dispatchBlurEvent();
     virtual bool isFocusable() const;
     virtual void updateFocusAppearance(bool /*restorePreviousSelection*/);
     virtual void dispatchBlurEvent();