Title: [271523] trunk
Revision
271523
Author
[email protected]
Date
2021-01-15 08:53:46 -0800 (Fri, 15 Jan 2021)

Log Message

When non-integer tabindex is set, the behavior of element should be same as the tabindex is omitted.
https://bugs.webkit.org/show_bug.cgi?id=220648

Reviewed by Antti Koivisto.

Source/WebCore:

When non-integer tabindex is specified, the element should behave the same way as the tabindex is omitted.
https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex

WebKit didn't overwrite the internal tabindex value when the new value is non-integer.

Test: LayoutTests\fast\html\tabindex-overwrite-with-non-integer.html

* html/HTMLElement.cpp:
(WebCore::HTMLElement::parseAttribute): If the new value cannot be parsed as the integer, clear the existing tabindex.

LayoutTests:

Add LayoutTest case for tabindex which is overwritten by non-integers.
When non-integer tabindex is specified, the element should behave the same way as the tabindex is omitted.
https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex

* fast/html/tabindex-overwrite-with-non-integer-expected.txt: Added.
* fast/html/tabindex-overwrite-with-non-integer.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271522 => 271523)


--- trunk/LayoutTests/ChangeLog	2021-01-15 15:24:47 UTC (rev 271522)
+++ trunk/LayoutTests/ChangeLog	2021-01-15 16:53:46 UTC (rev 271523)
@@ -1,3 +1,17 @@
+2021-01-15  Tomoki Imai  <[email protected]>
+
+        When non-integer tabindex is set, the behavior of element should be same as the tabindex is omitted.
+        https://bugs.webkit.org/show_bug.cgi?id=220648
+
+        Reviewed by Antti Koivisto.
+
+        Add LayoutTest case for tabindex which is overwritten by non-integers.
+        When non-integer tabindex is specified, the element should behave the same way as the tabindex is omitted.
+        https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex
+
+        * fast/html/tabindex-overwrite-with-non-integer-expected.txt: Added.
+        * fast/html/tabindex-overwrite-with-non-integer.html: Added.
+
 2021-01-15  Zalan Bujtas  <[email protected]>
 
         [LFC][Integration] REGRESSION (r270123) facebook.com birthday dropdown do not work when creating new account

Added: trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer-expected.txt (0 => 271523)


--- trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer-expected.txt	2021-01-15 16:53:46 UTC (rev 271523)
@@ -0,0 +1 @@
+PASS

Added: trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer.html (0 => 271523)


--- trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer.html	                        (rev 0)
+++ trunk/LayoutTests/fast/html/tabindex-overwrite-with-non-integer.html	2021-01-15 16:53:46 UTC (rev 271523)
@@ -0,0 +1,27 @@
+<div id="a" tabindex="1">PASS</div>
+
+<script>
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+    }
+    var a = document.getElementById('a');
+    a.addEventListener('focus', function (e) {
+        a.innerText = 'FAIL';
+    }, false);
+
+    a.setAttribute('tabindex', 1);
+    a.setAttribute('tabindex', null);
+    a.focus();
+
+    a.setAttribute('tabindex', 1);
+    a.setAttribute('tabindex', undefined);
+    a.focus();
+
+    a.setAttribute('tabindex', 1);
+    a.setAttribute('tabindex', "string");
+    a.focus();
+
+    a.setAttribute('tabindex', 1);
+    a.setAttribute('tabindex', "");
+    a.focus();
+</script>

Modified: trunk/Source/WebCore/ChangeLog (271522 => 271523)


--- trunk/Source/WebCore/ChangeLog	2021-01-15 15:24:47 UTC (rev 271522)
+++ trunk/Source/WebCore/ChangeLog	2021-01-15 16:53:46 UTC (rev 271523)
@@ -1,3 +1,20 @@
+2021-01-15  Tomoki Imai  <[email protected]>
+
+        When non-integer tabindex is set, the behavior of element should be same as the tabindex is omitted.
+        https://bugs.webkit.org/show_bug.cgi?id=220648
+
+        Reviewed by Antti Koivisto.
+
+        When non-integer tabindex is specified, the element should behave the same way as the tabindex is omitted.
+        https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex
+
+        WebKit didn't overwrite the internal tabindex value when the new value is non-integer.
+
+        Test: LayoutTests\fast\html\tabindex-overwrite-with-non-integer.html
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::parseAttribute): If the new value cannot be parsed as the integer, clear the existing tabindex.
+
 2021-01-15  Rob Buis  <[email protected]>
 
         Mark only child for layout

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (271522 => 271523)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2021-01-15 15:24:47 UTC (rev 271522)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2021-01-15 16:53:46 UTC (rev 271523)
@@ -452,10 +452,10 @@
     }
 
     if (name == tabindexAttr) {
-        if (value.isEmpty())
+        if (auto optionalTabIndex = parseHTMLInteger(value))
+            setTabIndexExplicitly(optionalTabIndex.value());
+        else
             setTabIndexExplicitly(WTF::nullopt);
-        else if (auto optionalTabIndex = parseHTMLInteger(value))
-            setTabIndexExplicitly(optionalTabIndex.value());
         return;
     }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to