This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Limit selection change to focused node on Windows #38634
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15f9811
Limit selection change to focused node on Windows
yaakovschectman 6ff2b0f
Focus fix
yaakovschectman 22a7a52
Test document selection change
yaakovschectman 53a07d8
Comment
yaakovschectman ea0ccec
Formatting
yaakovschectman 1fd98a6
Update shell/platform/windows/accessibility_bridge_windows.cc
yaakovschectman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,10 +41,23 @@ void AccessibilityBridgeWindows::OnAccessibilityEvent( | |
DispatchWinAccessibilityEvent(win_delegate, | ||
ax::mojom::Event::kChildrenChanged); | ||
break; | ||
case ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED: | ||
case ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED: { | ||
// An event indicating a change in document selection should be fired | ||
// only for the focused node whose selection has changed. If a valid | ||
// caret and selection exist in the app tree, they must both be within | ||
// the focus node. | ||
ui::AXNode::AXID focus_id = GetAXTreeData().sel_focus_object_id; | ||
auto focus_delegate = | ||
GetFlutterPlatformNodeDelegateFromID(focus_id).lock(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we guaranteed to get a focus delegate? I see the corresponding Chromium logic checks if it was able to find a focus object: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/accessibility/browser_accessibility_manager_win.cc;l=235-237?q=case%20ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED&ss=chromium There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a test for this scenario? If no, can we add one? |
||
if (!focus_delegate) { | ||
win_delegate = | ||
std::static_pointer_cast<FlutterPlatformNodeDelegateWindows>( | ||
focus_delegate); | ||
} | ||
DispatchWinAccessibilityEvent( | ||
win_delegate, ax::mojom::Event::kDocumentSelectionChanged); | ||
break; | ||
} | ||
case ui::AXEventGenerator::Event::FOCUS_CHANGED: | ||
DispatchWinAccessibilityEvent(win_delegate, ax::mojom::Event::kFocus); | ||
SetFocus(win_delegate); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a comment similar to Chromium's comment? https://source.chromium.org/chromium/chromium/src/+/main:content/browser/accessibility/browser_accessibility_manager_win.cc;l=230-234?q=case%20ui::AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED&ss=chromium
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this part of the comment make sense for us too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think so, as we do not have the carat as its own node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm misunderstanding, but my reading of that comment is that both the selection & the caret - if they exist - must be on the focus node.