Title: [107548] trunk
Revision
107548
Author
[email protected]
Date
2012-02-13 01:47:40 -0800 (Mon, 13 Feb 2012)

Log Message

<summary> is not keyboard accessible.
https://bugs.webkit.org/show_bug.cgi?id=75478

Patch by Arko Saha <[email protected]> on 2012-02-13
Reviewed by Hajime Morita.

Source/WebCore:

Toggle the content of <details> element on pressing Enter or Spacebar
key on a focused <summary> element.

Test: fast/html/details-keyboard-show-hide.html

* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::supportsFocus):
(WebCore):
(WebCore::HTMLSummaryElement::defaultEventHandler):
* html/HTMLSummaryElement.h:
(HTMLSummaryElement):

LayoutTests:

* fast/html/details-keyboard-show-hide-expected.txt: Added.
* fast/html/details-keyboard-show-hide.html: Added.
* platform/chromium/test_expectations.txt: <summary> is now focusable and clicking
it draws a focus ring. So we need to rebase failed test cases.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107547 => 107548)


--- trunk/LayoutTests/ChangeLog	2012-02-13 09:37:22 UTC (rev 107547)
+++ trunk/LayoutTests/ChangeLog	2012-02-13 09:47:40 UTC (rev 107548)
@@ -1,3 +1,15 @@
+2012-02-13  Arko Saha  <[email protected]>
+
+        <summary> is not keyboard accessible.
+        https://bugs.webkit.org/show_bug.cgi?id=75478
+
+        Reviewed by Hajime Morita.
+
+        * fast/html/details-keyboard-show-hide-expected.txt: Added.
+        * fast/html/details-keyboard-show-hide.html: Added.
+        * platform/chromium/test_expectations.txt: <summary> is now focusable and clicking
+        it draws a focus ring. So we need to rebase failed test cases.
+
 2012-02-13  Csaba Osztrogonác  <[email protected]>
 
         [Qt] REGRESSION(r107518): It broke many tests

Added: trunk/LayoutTests/fast/html/details-keyboard-show-hide-expected.txt (0 => 107548)


--- trunk/LayoutTests/fast/html/details-keyboard-show-hide-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/html/details-keyboard-show-hide-expected.txt	2012-02-13 09:47:40 UTC (rev 107548)
@@ -0,0 +1,16 @@
+This test verifies that pressing the ENTER or SPACEBAR key when the <summary> has focus will toggle the <details> display. On expanding details.open will be true and vice versa.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS openAttribute("details") is false
+Toggle <display> using Enter key:
+PASS openAttribute("details") is true
+PASS openAttribute("details") is false
+Toggle <display> using Spacebar key:
+PASS openAttribute("details") is true
+PASS openAttribute("details") is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/html/details-keyboard-show-hide.html (0 => 107548)


--- trunk/LayoutTests/fast/html/details-keyboard-show-hide.html	                        (rev 0)
+++ trunk/LayoutTests/fast/html/details-keyboard-show-hide.html	2012-02-13 09:47:40 UTC (rev 107548)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<head>
+<script src=""
+</head>
+
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<details id="details"><summary id="summary"></summary><input></details>
+<script>
+    function openAttribute(id) {
+        return document.getElementById(id).open;
+    }
+
+    description("This test verifies that pressing the ENTER or SPACEBAR key when the &lt;summary&gt; has focus will toggle the &lt;details&gt; display. On expanding details.open will be true and vice versa.");
+
+    if (window.eventSender) {
+        var summary = document.getElementById("summary");
+        summary.focus();
+
+        shouldBeFalse('openAttribute("details")');
+        debug("Toggle &lt;display&gt; using Enter key:");
+        eventSender.keyDown("\r");
+        shouldBeTrue('openAttribute("details")');
+        eventSender.keyDown("\r");
+        shouldBeFalse('openAttribute("details")');
+
+        debug("Toggle &lt;display&gt; using Spacebar key:");
+        eventSender.keyDown(" ");
+        shouldBeTrue('openAttribute("details")');
+        eventSender.keyDown(" ");
+        shouldBeFalse('openAttribute("details")');
+    } else {
+        debug('There are tests using eventSender.');
+    }
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (107547 => 107548)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-13 09:37:22 UTC (rev 107547)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2012-02-13 09:47:40 UTC (rev 107548)
@@ -3978,3 +3978,21 @@
 
 BUGWK34147 : fast/css/font-face-synthetic-bold-italic.html = MISSING FAIL
 BUGWK34147 : fast/css/font-face-weight-matching.html = MISSING FAIL
+
+// Needs a rebaseline.
+BUGWK75478 : fast/html/details-add-summary-10-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-8-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-1-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-2-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-6-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-7-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-5-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-5-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-1-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-6-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-4-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-3-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-3-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-4-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-remove-summary-2-and-click.html = IMAGE
+BUGWK75478 : fast/html/details-add-summary-9-and-click.html = IMAGE

Modified: trunk/Source/WebCore/ChangeLog (107547 => 107548)


--- trunk/Source/WebCore/ChangeLog	2012-02-13 09:37:22 UTC (rev 107547)
+++ trunk/Source/WebCore/ChangeLog	2012-02-13 09:47:40 UTC (rev 107548)
@@ -1,3 +1,22 @@
+2012-02-13  Arko Saha  <[email protected]>
+
+        <summary> is not keyboard accessible.
+        https://bugs.webkit.org/show_bug.cgi?id=75478
+
+        Reviewed by Hajime Morita.
+
+        Toggle the content of <details> element on pressing Enter or Spacebar
+        key on a focused <summary> element.
+
+        Test: fast/html/details-keyboard-show-hide.html
+
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::supportsFocus):
+        (WebCore):
+        (WebCore::HTMLSummaryElement::defaultEventHandler):
+        * html/HTMLSummaryElement.h:
+        (HTMLSummaryElement):
+
 2012-02-13  Gavin Barraclough  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=78434

Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (107547 => 107548)


--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2012-02-13 09:37:22 UTC (rev 107547)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp	2012-02-13 09:47:40 UTC (rev 107548)
@@ -26,6 +26,7 @@
 #include "DetailsMarkerControl.h"
 #include "HTMLContentElement.h"
 #include "HTMLDetailsElement.h"
+#include "KeyboardEvent.h"
 #include "HTMLNames.h"
 #include "MouseEvent.h"
 #include "PlatformMouseEvent.h"
@@ -106,20 +107,49 @@
     return host && host->isFormControlElement();
 }
 
+bool HTMLSummaryElement::supportsFocus() const
+{
+    return isMainSummary();
+}
+
 void HTMLSummaryElement::defaultEventHandler(Event* event)
 {
+    if (isMainSummary() && renderer() && renderer()->isSummary()) {
+        if (event->type() == eventNames().DOMActivateEvent && !isClickableControl(event->target()->toNode())) {
+            if (HTMLDetailsElement* details = detailsElement())
+                details->toggleOpen();
+            event->setDefaultHandled();
+            return;
+        }
+
+        if (event->isKeyboardEvent()) {
+            if (event->type() == eventNames().keydownEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+                setActive(true, true);
+                // No setDefaultHandled() - IE dispatches a keypress in this case.
+                return;
+            }
+            if (event->type() == eventNames().keypressEvent) {
+                switch (static_cast<KeyboardEvent*>(event)->charCode()) {
+                case '\r':
+                    dispatchSimulatedClick(event);
+                    event->setDefaultHandled();
+                    return;
+                case ' ':
+                    // Prevent scrolling down the page.
+                    event->setDefaultHandled();
+                    return;
+                }
+            }
+            if (event->type() == eventNames().keyupEvent && static_cast<KeyboardEvent*>(event)->keyIdentifier() == "U+0020") {
+                if (active())
+                    dispatchSimulatedClick(event);
+                event->setDefaultHandled();
+                return;
+            }
+        }
+    }
+
     HTMLElement::defaultEventHandler(event);
-    if (!isMainSummary() || !renderer() || !renderer()->isSummary() || !event->isMouseEvent() || event->type() != eventNames().clickEvent || event->defaultHandled())
-        return;
-    MouseEvent* mouseEvent = static_cast<MouseEvent*>(event);
-    if (mouseEvent->button() != LeftButton)
-        return;
-    if (isClickableControl(event->target()->toNode()))
-        return;
-
-    if (HTMLDetailsElement* details = detailsElement())
-        details->toggleOpen();
-    event->setDefaultHandled();
 }
 
 }

Modified: trunk/Source/WebCore/html/HTMLSummaryElement.h (107547 => 107548)


--- trunk/Source/WebCore/html/HTMLSummaryElement.h	2012-02-13 09:37:22 UTC (rev 107547)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.h	2012-02-13 09:47:40 UTC (rev 107548)
@@ -40,6 +40,8 @@
 
     void createShadowSubtree();
     HTMLDetailsElement* detailsElement() const;
+
+    bool supportsFocus() const OVERRIDE;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to