Title: [197835] trunk
Revision
197835
Author
[email protected]
Date
2016-03-08 22:27:54 -0800 (Tue, 08 Mar 2016)

Log Message

Element with maximum tabIndex cannot be returned by nextElementWithGreaterTabIndex()
https://bugs.webkit.org/show_bug.cgi?id=155215

Reviewed by Ryosuke Niwa.

Source/WebCore:

Element with maximum tabIndex cannot be returned by nextElementWithGreaterTabIndex()
due to a bug in r197726. This patch fixes the issue by only comparing
candidate.tabIndex to winningTabIndex if winner is non-null.

Test: fast/events/max-tabindex-focus.html

* page/FocusController.cpp:
(WebCore::nextElementWithGreaterTabIndex):

LayoutTests:

Add test to make sure that an Element with a tabIndex equal to
2147483647 (maximum tabIndex) can be focused.

* fast/events/max-tabindex-focus-expected.txt: Added.
* fast/events/max-tabindex-focus.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (197834 => 197835)


--- trunk/LayoutTests/ChangeLog	2016-03-09 05:53:54 UTC (rev 197834)
+++ trunk/LayoutTests/ChangeLog	2016-03-09 06:27:54 UTC (rev 197835)
@@ -1,3 +1,16 @@
+2016-03-08  Chris Dumez  <[email protected]>
+
+        Element with maximum tabIndex cannot be returned by nextElementWithGreaterTabIndex()
+        https://bugs.webkit.org/show_bug.cgi?id=155215
+
+        Reviewed by Ryosuke Niwa.
+
+        Add test to make sure that an Element with a tabIndex equal to
+        2147483647 (maximum tabIndex) can be focused.
+
+        * fast/events/max-tabindex-focus-expected.txt: Added.
+        * fast/events/max-tabindex-focus.html: Added.
+
 2016-03-08  Filip Pizlo  <[email protected]>
 
         DFG should be able to constant-fold strings

Added: trunk/LayoutTests/fast/events/max-tabindex-focus-expected.txt (0 => 197835)


--- trunk/LayoutTests/fast/events/max-tabindex-focus-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/max-tabindex-focus-expected.txt	2016-03-09 06:27:54 UTC (rev 197835)
@@ -0,0 +1,10 @@
+Tests that an element with the maximum tabIndex value can be focused.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Element with the maximum tabIndex was focused.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ 

Added: trunk/LayoutTests/fast/events/max-tabindex-focus.html (0 => 197835)


--- trunk/LayoutTests/fast/events/max-tabindex-focus.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/max-tabindex-focus.html	2016-03-09 06:27:54 UTC (rev 197835)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<script src=""
+<script>
+description("Tests that an element with the maximum tabIndex value can be focused.");
+jsTestIsAsync = true;
+
+function success()
+{
+    testPassed("Element with the maximum tabIndex was focused.");
+    finishJSTest();
+}
+
+function runTest()
+{
+    if (!window.testRunner)
+        return;
+ 
+    var element = document.getElementById('focusMe')
+    element.focus();
+
+    document.getElementById("elementWithMaxTabIndex")._onfocus_ = success;
+    eventSender.keyDown("\t"); 
+}
+</script>
+<body _onload_="runTest()">
+<input id="focusMe" tabindex="1">
+<input id="elementWithMaxTabIndex" tabindex="2147483647">
+<script src=""
+</body>

Modified: trunk/Source/WebCore/ChangeLog (197834 => 197835)


--- trunk/Source/WebCore/ChangeLog	2016-03-09 05:53:54 UTC (rev 197834)
+++ trunk/Source/WebCore/ChangeLog	2016-03-09 06:27:54 UTC (rev 197835)
@@ -1,3 +1,19 @@
+2016-03-08  Chris Dumez  <[email protected]>
+
+        Element with maximum tabIndex cannot be returned by nextElementWithGreaterTabIndex()
+        https://bugs.webkit.org/show_bug.cgi?id=155215
+
+        Reviewed by Ryosuke Niwa.
+
+        Element with maximum tabIndex cannot be returned by nextElementWithGreaterTabIndex()
+        due to a bug in r197726. This patch fixes the issue by only comparing
+        candidate.tabIndex to winningTabIndex if winner is non-null.
+
+        Test: fast/events/max-tabindex-focus.html
+
+        * page/FocusController.cpp:
+        (WebCore::nextElementWithGreaterTabIndex):
+
 2016-03-08  Sam Weinig  <[email protected]>
 
         Stop using the UserContentController for injecting the override style sheet from CaptionUserPreferences

Modified: trunk/Source/WebCore/page/FocusController.cpp (197834 => 197835)


--- trunk/Source/WebCore/page/FocusController.cpp	2016-03-09 05:53:54 UTC (rev 197834)
+++ trunk/Source/WebCore/page/FocusController.cpp	2016-03-09 06:27:54 UTC (rev 197835)
@@ -495,10 +495,13 @@
     for (Node* node = &scope.rootNode(); node; node = scope.nextInScope(node)) {
         if (!is<Element>(*node))
             continue;
-        Element& element = downcast<Element>(*node);
-        if (isFocusableOrHasShadowTreeWithoutCustomFocusLogic(element, event) && element.tabIndex() > tabIndex && element.tabIndex() < winningTabIndex) {
-            winner = &element;
-            winningTabIndex = element.tabIndex();
+        Element& candidate = downcast<Element>(*node);
+        int candidateTabIndex = candidate.tabIndex();
+        if (isFocusableOrHasShadowTreeWithoutCustomFocusLogic(candidate, event) && candidateTabIndex > tabIndex) {
+            if (!winner || candidateTabIndex < winningTabIndex) {
+                winner = &candidate;
+                winningTabIndex = candidateTabIndex;
+            }
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to