[KeyboardFocusableScrollers] Make scrollers not mouse focusable by default [chromium/src : main]

0 views
Skip to first unread message

Di Zhang (Gerrit)

unread,
Aug 21, 2024, 4:23:48 PM8/21/24
to chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org

Di Zhang voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I7c3728da5705bcc7e87a249f91c38db0609d9815
Gerrit-Change-Number: 5800927
Gerrit-PatchSet: 7
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
Gerrit-CC: Kevin Babbitt <kbab...@microsoft.com>
Gerrit-CC: Nektarios Paisios <nek...@chromium.org>
Gerrit-Comment-Date: Wed, 21 Aug 2024 20:23:39 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Aug 21, 2024, 5:25:30 PM8/21/24
to Mason Freed, Aaron Leventhal, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org
Attention needed from Aaron Leventhal and Mason Freed

Di Zhang voted and added 2 comments

Votes added by Di Zhang

Commit-Queue+1

2 comments

File third_party/blink/renderer/core/dom/element.cc
Line 6698, Patchset 7 (Latest): IsKeyboardFocusableScroller(UpdateBehavior::kNoneForIsFocused));
Di Zhang . unresolved

This is to make sure we don't make cases like 1) tabindex=-1 and 2) textarea (with default hidden tabindex=0) not mouse focusable when they should be.

File third_party/blink/renderer/modules/accessibility/ax_object.cc
Line 7142, Patchset 7 (Latest): Element::UpdateBehavior::kNoneForAccessibility) &&
Di Zhang . unresolved

We can keep this as IsFocusable if we want AX behavior to still make click focus on scroller.

Open in Gerrit

Related details

Attention is currently required from:
  • Aaron Leventhal
  • Mason Freed
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I7c3728da5705bcc7e87a249f91c38db0609d9815
    Gerrit-Change-Number: 5800927
    Gerrit-PatchSet: 7
    Gerrit-Owner: Di Zhang <dizh...@chromium.org>
    Gerrit-Reviewer: Aaron Leventhal <aleve...@chromium.org>
    Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
    Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
    Gerrit-CC: Kevin Babbitt <kbab...@microsoft.com>
    Gerrit-CC: Nektarios Paisios <nek...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: Aaron Leventhal <aleve...@chromium.org>
    Gerrit-Comment-Date: Wed, 21 Aug 2024 21:25:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Aaron Leventhal (Gerrit)

    unread,
    Aug 21, 2024, 5:44:06 PM8/21/24
    to Di Zhang, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org
    Attention needed from Di Zhang and Mason Freed

    Aaron Leventhal added 2 comments

    Patchset-level comments
    File-level comment, Patchset 7 (Latest):
    Aaron Leventhal . resolved

    Did we implement everything in the list from chat? Does clicking in the area still allow scrolling, even though it's not focused?

    File third_party/blink/renderer/modules/accessibility/ax_object.cc
    Line 7142, Patchset 7 (Latest): Element::UpdateBehavior::kNoneForAccessibility) &&
    Di Zhang . unresolved

    We can keep this as IsFocusable if we want AX behavior to still make click focus on scroller.

    Aaron Leventhal

    Yes, please keep as IsFocusable().

    It should also return true for CanSetFocusAttribute().

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Di Zhang
    • Mason Freed
    Gerrit-Attention: Di Zhang <dizh...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Wed, 21 Aug 2024 21:43:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Di Zhang <dizh...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Aaron Leventhal (Gerrit)

    unread,
    Aug 21, 2024, 5:44:28 PM8/21/24
    to Di Zhang, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org
    Attention needed from Di Zhang and Mason Freed

    Aaron Leventhal added 1 comment

    Patchset-level comments
    Aaron Leventhal . unresolved

    Did we implement everything in the list from chat? Does clicking in the area still allow scrolling, even though it's not focused?

    Aaron Leventhal

    Unresolved.

    Gerrit-Comment-Date: Wed, 21 Aug 2024 21:44:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Aaron Leventhal <aleve...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Aug 21, 2024, 6:54:45 PM8/21/24
    to Di Zhang, Aaron Leventhal, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org
    Attention needed from Di Zhang

    Mason Freed added 4 comments

    File third_party/blink/renderer/core/dom/element.h
    Line 971, Patchset 7 (Latest): // with no default/adjusted tabindex. Avoid overwriting this function as
    Mason Freed . unresolved

    In that case, don't make the function `virtual` at all.

    File third_party/blink/renderer/core/dom/element.cc
    Line 6698, Patchset 7 (Latest): IsKeyboardFocusableScroller(UpdateBehavior::kNoneForIsFocused));
    Di Zhang . unresolved

    This is to make sure we don't make cases like 1) tabindex=-1 and 2) textarea (with default hidden tabindex=0) not mouse focusable when they should be.

    Mason Freed

    Maybe

    ```
    if (!Element::IsFocusable(update_behavior)) {
    return false;
    }
    // Any element with tabindex is mouse focusable.
    if (HasElementFlag(ElementFlags::kTabIndexWasSetExplicitly)) {
    return true;
    }
    DCHECK_EQ(tabIndex(),DefaultTabIndex());
    // If the element's default tabindex is >=0, it should be click focusable.
    return DefaultTabIndex() >= 0;
    ```

    Just a little easier to follow.

    NOTE: this is a question. Note that I removed the `IsKeyboardFocusableScroller` check, because I don't think it should be there. Your existing logic here says that an element should be mouse focusable if:
    1. it has an explicit tabindex, OR
    2. it has a default tabindex >= 0, OR
    3. it is NOT a keyboard focusable scroller.

    But I don't know why #3 is there. I don't think we should make all `<div>`'s mouse focusable. Maybe I'm missing something though, because I would have thought there'd be a test that fails if I'm right about the logic.
    File third_party/blink/web_tests/shadow-dom/focus-navigation/focus-scroller-activeElement-on-event.html
    Line 49, Patchset 7 (Latest): await navigateFocusForward();
    assert_equals(document.activeElement, childButton, 'navigate forward by tab does not focus scroller');
    Mason Freed . unresolved

    Maybe add one more `navigateFocusForward()` and make sure `activeElement` keeps going past the scroller?

    Line 52, Patchset 7 (Latest): scroller.removeChild(childButton);
    Mason Freed . unresolved

    It's a little cleaner if you add this at the top of the test instead:

    ```
    promise_test(async (t) => {
    const childButton = document.createElement('button');
    t.add_cleanup(() => childButton.remove());
    ```
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Di Zhang
    Gerrit-Comment-Date: Wed, 21 Aug 2024 22:54:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Di Zhang <dizh...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Di Zhang (Gerrit)

    unread,
    Aug 21, 2024, 8:04:52 PM8/21/24
    to Mason Freed, Aaron Leventhal, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org
    Attention needed from Aaron Leventhal and Mason Freed

    Di Zhang voted and added 7 comments

    Votes added by Di Zhang

    Commit-Queue+1

    7 comments

    Patchset-level comments
    Aaron Leventhal . unresolved

    Did we implement everything in the list from chat? Does clicking in the area still allow scrolling, even though it's not focused?

    Aaron Leventhal

    Unresolved.

    Di Zhang

    Points raised in chat:
    1. Disconnect keyboard focusability from click focusability => Implemented in Element.cc by adding IsMouseFocusable.
    2. Make scrollers just keyboard focusable. In both cases, IsFocusable() will be true. => Covered because we don't touch IsFocusable and IsKeyboardFocusable
    3. Make sure the area is still scrollable with the keyboard after a click, as it used to be, even if it is not focused => Testing in shadow-dom/focus-navigation/focus-scroller-activeElement-on-event.html.
    4. Make sure AXObject::OnNativeClickAction() still sets the focus for scrollable areas. => Covered because we are not modifying AXObject and not changing IsFocusable/IsFocusableStyle.
    5. Determine what to do for scrollableArea.focus() => Tested in shadow-dom/focus-navigation/focus-scroller-activeElement-on-event.html. This matches behavior in Gecko.

    File third_party/blink/renderer/core/dom/element.h
    Line 971, Patchset 7: // with no default/adjusted tabindex. Avoid overwriting this function as
    Mason Freed . resolved

    In that case, don't make the function `virtual` at all.

    Di Zhang

    Done

    File third_party/blink/renderer/core/dom/element.cc
    Line 6691, Patchset 8 (Latest): return GetIntegralAttribute(html_names::kTabindexAttr, 0) >= 0;
    Di Zhang . unresolved

    Should this be `return DefaultTabIndex() >= 0;` too?

    Not sure if this change should be in this CL.

    Line 6698, Patchset 7: IsKeyboardFocusableScroller(UpdateBehavior::kNoneForIsFocused));
    Di Zhang . unresolved

    This is to make sure we don't make cases like 1) tabindex=-1 and 2) textarea (with default hidden tabindex=0) not mouse focusable when they should be.

    Mason Freed

    Maybe

    ```
    if (!Element::IsFocusable(update_behavior)) {
    return false;
    }
    // Any element with tabindex is mouse focusable.
    if (HasElementFlag(ElementFlags::kTabIndexWasSetExplicitly)) {
    return true;
    }
    DCHECK_EQ(tabIndex(),DefaultTabIndex());
    // If the element's default tabindex is >=0, it should be click focusable.
    return DefaultTabIndex() >= 0;
    ```

    Just a little easier to follow.

    NOTE: this is a question. Note that I removed the `IsKeyboardFocusableScroller` check, because I don't think it should be there. Your existing logic here says that an element should be mouse focusable if:
    1. it has an explicit tabindex, OR
    2. it has a default tabindex >= 0, OR
    3. it is NOT a keyboard focusable scroller.

    But I don't know why #3 is there. I don't think we should make all `<div>`'s mouse focusable. Maybe I'm missing something though, because I would have thought there'd be a test that fails if I'm right about the logic.
    Di Zhang

    Oh, I think you might be right and IsKeyboardFocusableScroller() is not necessary.

    I thought it was necessary because for a default scroller case:

    • IsFocusable <- returns true
    • !Has tabindex <- returns true
    • tabindex < 0 <- might return true if an Element such as div has default tabindex -1

    But with your changes:

    • !IsFocusable, continue
    • Has tabindex <- false, continue
    • If default tabindex is negative, will return false. As desired

    Will test it out.

    File third_party/blink/renderer/modules/accessibility/ax_object.cc
    Line 7142, Patchset 7: Element::UpdateBehavior::kNoneForAccessibility) &&
    Di Zhang . resolved

    We can keep this as IsFocusable if we want AX behavior to still make click focus on scroller.

    Aaron Leventhal

    Yes, please keep as IsFocusable().

    It should also return true for CanSetFocusAttribute().

    Di Zhang

    Ok, sounds good. Call stack for CanSetFocusAttribute includes:
    CanSetFocusAttribute()
    > UpdateCachedAttributeValuesIfNeeded()
    -> ComputeCanSetFocusAttribute()
    --> IsFocusableStyle() <- will return true for scroller

    We end up not touching any calls in ax_object so everything is focusable the same way as before.

    File third_party/blink/web_tests/shadow-dom/focus-navigation/focus-scroller-activeElement-on-event.html
    Line 49, Patchset 7: await navigateFocusForward();

    assert_equals(document.activeElement, childButton, 'navigate forward by tab does not focus scroller');
    Mason Freed . resolved

    Maybe add one more `navigateFocusForward()` and make sure `activeElement` keeps going past the scroller?

    Di Zhang

    Done

    Line 52, Patchset 7: scroller.removeChild(childButton);
    Mason Freed . resolved

    It's a little cleaner if you add this at the top of the test instead:

    ```
    promise_test(async (t) => {
    const childButton = document.createElement('button');
    t.add_cleanup(() => childButton.remove());
    ```
    Di Zhang

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Aaron Leventhal
    • Mason Freed
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I7c3728da5705bcc7e87a249f91c38db0609d9815
    Gerrit-Change-Number: 5800927
    Gerrit-PatchSet: 8
    Gerrit-Owner: Di Zhang <dizh...@chromium.org>
    Gerrit-Reviewer: Aaron Leventhal <aleve...@chromium.org>
    Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: (Julie)Jeongeun Kim <je_jul...@chromium.org>
    Gerrit-CC: Akihiro Ota <akihi...@chromium.org>
    Gerrit-CC: Kevin Babbitt <kbab...@microsoft.com>
    Gerrit-CC: Nektarios Paisios <nek...@chromium.org>
    Gerrit-Attention: Aaron Leventhal <aleve...@chromium.org>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Thu, 22 Aug 2024 00:04:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Di Zhang <dizh...@chromium.org>
    Comment-In-Reply-To: Aaron Leventhal <aleve...@chromium.org>
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    Aug 26, 2024, 6:07:41 PM8/26/24
    to Di Zhang, Aaron Leventhal, Chromium LUCI CQ, chromium...@chromium.org, (Julie)Jeongeun Kim, Kevin Babbitt, Tricium, AyeAye, abigailbk...@google.com, aleventhal...@chromium.org, blink-rev...@chromium.org, dtseng...@chromium.org, francisjp...@google.com, hirokisa...@chromium.org, josiah...@chromium.org, kyungjunle...@google.com, nektar...@chromium.org, yuzo+...@chromium.org, blink-rev...@chromium.org, dtapuska+...@chromium.org, blink-...@chromium.org, blink-re...@chromium.org

    Mason Freed abandoned this change

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: abandon
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages