Title: [152919] trunk
Revision
152919
Author
[email protected]
Date
2013-07-19 12:21:09 -0700 (Fri, 19 Jul 2013)

Log Message

Spatial Navigation handling of space key in <select> appears to confuse listIndex and optionIndex.
https://bugs.webkit.org/show_bug.cgi?id=99525

Source/WebCore:

HTMLSelect Element inherently contains the logic to focus option node and thus, implementing an explicit logic to find the focus index is not required.

Patch by Abhijeet Kandalkar <[email protected]> on 2013-07-19
Reviewed by Joseph Pecoraro.

Test: fast/spatial-navigation/snav-multiple-select-optgroup.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
* page/SpatialNavigation.cpp:
(WebCore::canScrollInDirection):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::addFocusRingRects):

LayoutTests:

Added testcase to test support of option group within HTMLSelect element.

Patch by Abhijeet Kandalkar <[email protected]> on 2013-07-19
Reviewed by Joseph Pecoraro.

* fast/spatial-navigation/snav-multiple-select-optgroup-expected.txt: Added.
* fast/spatial-navigation/snav-multiple-select-optgroup.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152918 => 152919)


--- trunk/LayoutTests/ChangeLog	2013-07-19 18:56:13 UTC (rev 152918)
+++ trunk/LayoutTests/ChangeLog	2013-07-19 19:21:09 UTC (rev 152919)
@@ -1,3 +1,15 @@
+2013-07-19  Abhijeet Kandalkar  <[email protected]>
+
+        Spatial Navigation handling of space key in <select> appears to confuse listIndex and optionIndex.
+        https://bugs.webkit.org/show_bug.cgi?id=99525
+
+        Added testcase to test support of option group within HTMLSelect element.
+
+        Reviewed by Joseph Pecoraro.
+
+        * fast/spatial-navigation/snav-multiple-select-optgroup-expected.txt: Added.
+        * fast/spatial-navigation/snav-multiple-select-optgroup.html: Added.
+
 2013-07-19  David Hyatt  <[email protected]>
 
         OSX: ePub: Unable to select text in vertical Japanese book

Added: trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup-expected.txt (0 => 152919)


--- trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup-expected.txt	2013-07-19 19:21:09 UTC (rev 152919)
@@ -0,0 +1,53 @@
+2	
+4		6
+8	
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "8"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "2"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "6"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "4"
+PASS gFocusedDocument.activeElement.getAttribute("id") is "start"
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is false
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is false
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is false
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is false
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is true
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is false
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is true
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is false
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is true
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is true
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is true
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is true
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is false
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is true
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is false
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is true
+PASS gFocusedDocument.getElementById("start").options[0].selected is false
+PASS gFocusedDocument.getElementById("start").options[1].selected is true
+PASS gFocusedDocument.getElementById("start").options[2].selected is false
+PASS gFocusedDocument.getElementById("start").options[3].selected is true
+

Added: trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup.html (0 => 152919)


--- trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup.html	                        (rev 0)
+++ trunk/LayoutTests/fast/spatial-navigation/snav-multiple-select-optgroup.html	2013-07-19 19:21:09 UTC (rev 152919)
@@ -0,0 +1,117 @@
+<html>
+  <!--
+    This test ensures the correctness of Spatial Navigation (SNav) algorithm over multiple select element.
+
+    * Pre-conditions:
+    1) TestRunner support for SNav enable/disable.
+
+    * Navigation steps:
+    1) Loads this page, focus goes to "start" automatically.
+    2) Focus moves away from select in 4 different directions to neighbor nodes and back.
+  -->
+  <head>
+    <script src=""
+    <script src=""
+    <script type="application/_javascript_">
+
+    var resultMap = [
+      ["Down", "start"],
+      ["Down", "start"],
+      ["Down", "start"],
+      ["Down", "8"],
+      ["Up", "start"],
+      ["Up", "start"],
+      ["Up", "start"],
+      ["Up", "2"],
+      ["Down", "start"],
+      ["Right", "6"],
+      ["Left", "start"],
+      ["Left", "4"],
+      ["Right", "start"],
+      ["DONE", "DONE"]
+    ];
+
+    if (window.testRunner) {
+      testRunner.dumpAsText();
+      testRunner.setSpatialNavigationEnabled(true);
+      testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
+      testRunner.waitUntilDone();
+    }
+
+    function runTest()
+    {
+      // starting the test itself: get to a known place.
+      document.getElementById("start").focus();
+
+      initTest(resultMap, additionalTest);
+    }
+
+    function sendKeyAndCheckOptions(option0, option1, option2, option3)
+    {
+      shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", option0);
+      shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", option1);
+      shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", option2);
+      shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", option3);
+    }
+
+    function additionalTest()
+    {
+      document.getElementById("start").focus();         //move to 1st item
+      sendKeyAndCheckOptions("false", "false", "false", "false");
+      eventSender.keyDown("downArrow");                 //move to 2nd item
+      sendKeyAndCheckOptions("false", "false", "false", "false");
+      eventSender.keyDown(" ");                         //nothing should change
+      sendKeyAndCheckOptions("false", "true", "false", "false");
+      eventSender.keyDown("downArrow");                 //move to 4th item (3rd item is disabled) 
+      sendKeyAndCheckOptions("false", "true", "false", "false");
+      eventSender.keyDown(" ");                         //nothing should change
+      sendKeyAndCheckOptions("false", "true", "false", "true");
+      eventSender.keyDown("upArrow");                   //move back to 2nd item
+      sendKeyAndCheckOptions("false", "true", "false", "true");
+      eventSender.keyDown(" ");                         //noting should change
+      sendKeyAndCheckOptions("false", "false", "false", "true");
+      eventSender.keyDown("upArrow");                   //move back to 1st item
+      sendKeyAndCheckOptions("false", "false", "false", "true");
+      eventSender.keyDown("downArrow", ["shiftKey"]);   //shift-down to 2nd item
+      sendKeyAndCheckOptions("false", "true", "false", "true");
+
+      testCompleted();
+    }
+
+    function testCompleted()
+    {
+      if (window.testRunner)
+        testRunner.notifyDone();
+    }
+
+    window._onload_ = runTest;
+
+    </script>
+    <script src=""
+  </head>
+  <body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
+    <table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
+      <tbody>
+        <tr>
+          <td style="vertical-align: top; text-align: center;"></td>
+          <td style="vertical-align: top; text-align: center;"><a id="2" href=""
+          <td style="vertical-align: top; text-align: center;"></td>
+        </tr>
+        <tr>
+          <td style="vertical-align: top; text-align: center;"><a id="4" href=""
+          <td style="vertical-align: top; text-align: center;">
+		  <select id="start" multiple><optgroup label="o1"><option>1</option></optgroup><optgroup label="o2"><option>2</option></optgroup><optgroup label="o3"><option disabled>3</option></optgroup><optgroup label="o4"><option>4</option></optgroup>
+		  </select></td>
+          <td style="vertical-align: top; text-align: center;"><a id="6" href=""
+        </tr>
+        <tr>
+          <td style="vertical-align: top; text-align: center;"></td>
+          <td style="vertical-align: top; text-align: center;"><a id="8" href=""
+          <td style="vertical-align: top; text-align: center;"></td>
+        </tr>
+      </tbody>
+    </table>
+    <div id="console"></div>
+  </body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (152918 => 152919)


--- trunk/Source/WebCore/ChangeLog	2013-07-19 18:56:13 UTC (rev 152918)
+++ trunk/Source/WebCore/ChangeLog	2013-07-19 19:21:09 UTC (rev 152919)
@@ -1,3 +1,21 @@
+2013-07-19  Abhijeet Kandalkar  <[email protected]>
+
+        Spatial Navigation handling of space key in <select> appears to confuse listIndex and optionIndex.
+        https://bugs.webkit.org/show_bug.cgi?id=99525
+
+        HTMLSelect Element inherently contains the logic to focus option node and thus, implementing an explicit logic to find the focus index is not required.
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: fast/spatial-navigation/snav-multiple-select-optgroup.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
+        * page/SpatialNavigation.cpp:
+        (WebCore::canScrollInDirection):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::addFocusRingRects):
+
 2013-07-19  David Hyatt  <[email protected]>
 
         OSX: ePub: Unable to select text in vertical Japanese book

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (152918 => 152919)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2013-07-19 18:56:13 UTC (rev 152918)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2013-07-19 19:21:09 UTC (rev 152919)
@@ -1452,7 +1452,10 @@
         } else if (m_multiple && keyCode == ' ' && isSpatialNavigationEnabled(document()->frame())) {
             // Use space to toggle selection change.
             m_activeSelectionState = !m_activeSelectionState;
-            updateSelectedState(listToOptionIndex(m_activeSelectionEndIndex), true /*multi*/, false /*shift*/);
+            ASSERT(m_activeSelectionEndIndex >= 0
+                && m_activeSelectionEndIndex < static_cast<int>(listItems.size())
+                && listItems[m_activeSelectionEndIndex]->hasTagName(optionTag));
+            updateSelectedState(m_activeSelectionEndIndex, true /*multi*/, false /*shift*/);
             listBoxOnChange();
             event->setDefaultHandled();
         }

Modified: trunk/Source/WebCore/page/SpatialNavigation.cpp (152918 => 152919)


--- trunk/Source/WebCore/page/SpatialNavigation.cpp	2013-07-19 18:56:13 UTC (rev 152918)
+++ trunk/Source/WebCore/page/SpatialNavigation.cpp	2013-07-19 19:21:09 UTC (rev 152919)
@@ -448,6 +448,10 @@
 bool canScrollInDirection(const Node* container, FocusDirection direction)
 {
     ASSERT(container);
+
+    if (container->hasTagName(HTMLNames::selectTag))
+        return false;
+
     if (container->isDocumentNode())
         return canScrollInDirection(toDocument(container)->frame(), direction);
 

Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (152918 => 152919)


--- trunk/Source/WebCore/rendering/RenderListBox.cpp	2013-07-19 18:56:13 UTC (rev 152918)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp	2013-07-19 19:21:09 UTC (rev 152919)
@@ -348,6 +348,7 @@
     for (int i = 0; i < size; ++i) {
         HTMLElement* element = listItems[i];
         if (isHTMLOptionElement(element) && !element->isDisabledFormControl()) {
+            select->setActiveSelectionEndIndex(i);
             rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, i)));
             return;
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to