Title: [248932] trunk/Source/WebCore
Revision
248932
Author
rn...@webkit.org
Date
2019-08-20 18:41:51 -0700 (Tue, 20 Aug 2019)

Log Message

nextElementWithGreaterTabIndex should use shadowAdjustedTabIndex
https://bugs.webkit.org/show_bug.cgi?id=200943

Reviewed by Wenson Hsieh.

Use shadowAdjustedTabIndex instead of tabIndexForElement in nextElementWithGreaterTabIndex.

Because nextElementWithGreaterTabIndex is only called to find an element with a tab index
set to a greater value than the argument tabIndex, which is always a positive integer,
whether we call shadowAdjustedTabIndex or tabIndexForElement has no effect on an element
with a shadow root or on a slot element. Furthermore, none of the elements with
an isKeyboardFocusable override can have a author defined shadow root attached either.

As a result, this refactoring will have no observable behavioral change.

No new tests since there should be no observable behavior change.

* page/FocusController.cpp:
(WebCore::tabIndexForElement): Merged into shadowAdjustedTabIndex.
(WebCore::shadowAdjustedTabIndex):
(WebCore::nextElementWithGreaterTabIndex):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248931 => 248932)


--- trunk/Source/WebCore/ChangeLog	2019-08-21 01:39:54 UTC (rev 248931)
+++ trunk/Source/WebCore/ChangeLog	2019-08-21 01:41:51 UTC (rev 248932)
@@ -1,5 +1,29 @@
 2019-08-20  Ryosuke Niwa  <rn...@webkit.org>
 
+        nextElementWithGreaterTabIndex should use shadowAdjustedTabIndex
+        https://bugs.webkit.org/show_bug.cgi?id=200943
+
+        Reviewed by Wenson Hsieh.
+
+        Use shadowAdjustedTabIndex instead of tabIndexForElement in nextElementWithGreaterTabIndex.
+
+        Because nextElementWithGreaterTabIndex is only called to find an element with a tab index
+        set to a greater value than the argument tabIndex, which is always a positive integer,
+        whether we call shadowAdjustedTabIndex or tabIndexForElement has no effect on an element
+        with a shadow root or on a slot element. Furthermore, none of the elements with
+        an isKeyboardFocusable override can have a author defined shadow root attached either.
+
+        As a result, this refactoring will have no observable behavioral change.
+
+        No new tests since there should be no observable behavior change.
+
+        * page/FocusController.cpp:
+        (WebCore::tabIndexForElement): Merged into shadowAdjustedTabIndex.
+        (WebCore::shadowAdjustedTabIndex):
+        (WebCore::nextElementWithGreaterTabIndex):
+
+2019-08-20  Ryosuke Niwa  <rn...@webkit.org>
+
         Remove MathMLElement::defaultTabIndex()
         https://bugs.webkit.org/show_bug.cgi?id=200944
 

Modified: trunk/Source/WebCore/page/FocusController.cpp (248931 => 248932)


--- trunk/Source/WebCore/page/FocusController.cpp	2019-08-21 01:39:54 UTC (rev 248931)
+++ trunk/Source/WebCore/page/FocusController.cpp	2019-08-21 01:41:51 UTC (rev 248932)
@@ -325,12 +325,6 @@
     return element.isKeyboardFocusable(event) && isFocusScopeOwner(element);
 }
 
-// FIXME: This function should be merged into shadowAdjustedTabIndex.
-static inline int tabIndexForElement(const Element& element)
-{
-    return element.shouldBeIgnoredInSequentialFocusNavigation() ? -1 : element.tabIndexSetExplicitly().valueOr(0);
-}
-
 static inline int shadowAdjustedTabIndex(Element& element, KeyboardEvent* event)
 {
     if (isNonFocusableScopeOwner(element, event)) {
@@ -337,7 +331,7 @@
         if (!element.tabIndexSetExplicitly())
             return 0; // Treat a shadow host without tabindex if it has tabindex=0 even though HTMLElement::tabIndex returns -1 on such an element.
     }
-    return tabIndexForElement(element);
+    return element.shouldBeIgnoredInSequentialFocusNavigation() ? -1 : element.tabIndexSetExplicitly().valueOr(0);
 }
 
 FocusController::FocusController(Page& page, OptionSet<ActivityState::Flag> activityState)
@@ -626,8 +620,7 @@
         if (!is<Element>(*node))
             continue;
         Element& candidate = downcast<Element>(*node);
-        // FIXME: We should be calling shadowAdjustedTabIndex instead.
-        int candidateTabIndex = tabIndexForElement(candidate);
+        int candidateTabIndex = shadowAdjustedTabIndex(candidate, event);
         if (isFocusableElementOrScopeOwner(candidate, event) && candidateTabIndex > tabIndex && (!winner || candidateTabIndex < winningTabIndex)) {
             winner = &candidate;
             winningTabIndex = candidateTabIndex;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to