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
Win32 a11y bridge and platform node delegates #29829
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9715492
Win32 a11y bridge and platform node delegates
cbracken 512013c
review: return weak_ptr
cbracken b23e78b
Add custom action update
cbracken 3ab733c
Implement FlutterPlatformNodeDelegateWin32::GetBoundsRect
cbracken 384f0a0
Add UIA COM object lookup
cbracken d58c4c7
Formatting
cbracken 1d04059
Eliminate ctor TODOs
cbracken c405bf4
Formatting
cbracken c687518
Add unittest to verify axtree construction
cbracken 2c8b6cc
Test value as well
cbracken 147081e
Check role
cbracken 51b18c2
Minor cleanup/clarification for readability
cbracken 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
36 changes: 36 additions & 0 deletions
36
shell/platform/windows/accessibility_bridge_delegate_win32.cc
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/platform/windows/accessibility_bridge_delegate_win32.h" | ||
|
|
||
| #include "flutter/shell/platform/windows/flutter_platform_node_delegate_win32.h" | ||
| #include "flutter/shell/platform/windows/flutter_windows_view.h" | ||
| #include "flutter/third_party/accessibility/ax/platform/ax_platform_node_delegate_base.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| AccessibilityBridgeDelegateWin32::AccessibilityBridgeDelegateWin32( | ||
| FlutterWindowsEngine* engine) | ||
| : engine_(engine) { | ||
| assert(engine_); | ||
| } | ||
|
|
||
| void AccessibilityBridgeDelegateWin32::OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) { | ||
| // TODO(cbracken): https://github.com/flutter/flutter/issues/77838 | ||
| } | ||
|
|
||
| void AccessibilityBridgeDelegateWin32::DispatchAccessibilityAction( | ||
| AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) { | ||
| // TODO(cbracken): https://github.com/flutter/flutter/issues/77838 | ||
| } | ||
|
|
||
| std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| AccessibilityBridgeDelegateWin32::CreateFlutterPlatformNodeDelegate() { | ||
| return std::make_shared<FlutterPlatformNodeDelegateWin32>(engine_); | ||
| } | ||
|
|
||
| } // namespace flutter |
47 changes: 47 additions & 0 deletions
47
shell/platform/windows/accessibility_bridge_delegate_win32.h
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ | ||
|
|
||
| #include "flutter/shell/platform/common/accessibility_bridge.h" | ||
| #include "flutter/shell/platform/windows/flutter_windows_engine.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class FlutterWindowsEngine; | ||
|
|
||
| // The Win32 implementation of AccessibilityBridgeDelegate. | ||
| // | ||
| // Handles requests from the accessibility bridge to interact with Windows | ||
| // accessibility APIs. This includes routing accessibility events fired from | ||
| // the framework to Windows, routing native Windows accessibility events to the | ||
| // framework, and creating Windows-specific FlutterPlatformNodeDelegate objects | ||
| // for each node in the semantics tree. | ||
| class AccessibilityBridgeDelegateWin32 | ||
| : public AccessibilityBridge::AccessibilityBridgeDelegate { | ||
| public: | ||
| explicit AccessibilityBridgeDelegateWin32(FlutterWindowsEngine* engine); | ||
| virtual ~AccessibilityBridgeDelegateWin32() = default; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| void OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) override; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| void DispatchAccessibilityAction(AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) override; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| CreateFlutterPlatformNodeDelegate() override; | ||
|
|
||
| private: | ||
| FlutterWindowsEngine* engine_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ |
37 changes: 37 additions & 0 deletions
37
shell/platform/windows/accessibility_bridge_delegate_winuwp.cc
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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/platform/windows/accessibility_bridge_delegate_winuwp.h" | ||
|
|
||
| #include "flutter/shell/platform/windows/flutter_platform_node_delegate_winuwp.h" | ||
| #include "flutter/shell/platform/windows/flutter_windows_view.h" | ||
| #include "flutter/third_party/accessibility/ax/platform/ax_platform_node_delegate_base.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| AccessibilityBridgeDelegateWinUWP::AccessibilityBridgeDelegateWinUWP( | ||
| FlutterWindowsEngine* engine) | ||
| : engine_(engine) { | ||
| // TODO(cbracken): https://github.com/flutter/flutter/issues/93928 | ||
| assert(engine_); | ||
| } | ||
|
|
||
| void AccessibilityBridgeDelegateWinUWP::OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) { | ||
| // TODO(cbracken): https://github.com/flutter/flutter/issues/93928 | ||
| } | ||
|
|
||
| void AccessibilityBridgeDelegateWinUWP::DispatchAccessibilityAction( | ||
| AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) { | ||
| // TODO(cbracken): https://github.com/flutter/flutter/issues/93928 | ||
| } | ||
|
|
||
| std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| AccessibilityBridgeDelegateWinUWP::CreateFlutterPlatformNodeDelegate() { | ||
| return std::make_shared<FlutterPlatformNodeDelegateWinUWP>(engine_); | ||
| } | ||
|
|
||
| } // namespace flutter |
47 changes: 47 additions & 0 deletions
47
shell/platform/windows/accessibility_bridge_delegate_winuwp.h
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ | ||
|
|
||
| #include "flutter/shell/platform/common/accessibility_bridge.h" | ||
| #include "flutter/shell/platform/windows/flutter_windows_engine.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class FlutterWindowsEngine; | ||
|
|
||
| // The Windows UWP implementation of AccessibilityBridgeDelegate. | ||
| // | ||
| // Handles requests from the accessibility bridge to interact with Windows | ||
| // accessibility APIs. This includes routing accessibility events fired from | ||
| // the framework to Windows, routing native Windows accessibility events to the | ||
| // framework, and creating Windows-specific FlutterPlatformNodeDelegate objects | ||
| // for each node in the semantics tree. | ||
| class AccessibilityBridgeDelegateWinUWP | ||
| : public AccessibilityBridge::AccessibilityBridgeDelegate { | ||
| public: | ||
| explicit AccessibilityBridgeDelegateWinUWP(FlutterWindowsEngine* engine); | ||
| virtual ~AccessibilityBridgeDelegateWinUWP() = default; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| void OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) override; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| void DispatchAccessibilityAction(AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) override; | ||
|
|
||
| // |AccessibilityBridge::AccessibilityBridgeDelegate| | ||
| std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| CreateFlutterPlatformNodeDelegate() override; | ||
|
|
||
| private: | ||
| FlutterWindowsEngine* engine_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_DELEGATE_H_ |
80 changes: 80 additions & 0 deletions
80
shell/platform/windows/flutter_platform_node_delegate_win32.cc
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 |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <oleacc.h> | ||
|
|
||
| #include "flutter/shell/platform/windows/flutter_platform_node_delegate_win32.h" | ||
|
|
||
| #include "flutter/shell/platform/windows/flutter_windows_view.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| FlutterPlatformNodeDelegateWin32::FlutterPlatformNodeDelegateWin32( | ||
| FlutterWindowsEngine* engine) | ||
| : engine_(engine) { | ||
| assert(engine_); | ||
| } | ||
|
|
||
| FlutterPlatformNodeDelegateWin32::~FlutterPlatformNodeDelegateWin32() { | ||
| if (ax_platform_node_) { | ||
| ax_platform_node_->Destroy(); | ||
| } | ||
| } | ||
|
|
||
| // |ui::AXPlatformNodeDelegate| | ||
| void FlutterPlatformNodeDelegateWin32::Init(std::weak_ptr<OwnerBridge> bridge, | ||
| ui::AXNode* node) { | ||
| FlutterPlatformNodeDelegate::Init(bridge, node); | ||
| ax_platform_node_ = ui::AXPlatformNode::Create(this); | ||
| assert(ax_platform_node_); | ||
| } | ||
|
|
||
| // |ui::AXPlatformNodeDelegate| | ||
| gfx::NativeViewAccessible | ||
| FlutterPlatformNodeDelegateWin32::GetNativeViewAccessible() { | ||
| assert(ax_platform_node_); | ||
| return ax_platform_node_->GetNativeViewAccessible(); | ||
| } | ||
|
|
||
| // |FlutterPlatformNodeDelegate| | ||
| gfx::NativeViewAccessible FlutterPlatformNodeDelegateWin32::GetParent() { | ||
| gfx::NativeViewAccessible parent = FlutterPlatformNodeDelegate::GetParent(); | ||
| if (parent) { | ||
| return parent; | ||
| } | ||
| assert(engine_); | ||
| FlutterWindowsView* view = engine_->view(); | ||
| if (!view) { | ||
| return nullptr; | ||
| } | ||
| HWND hwnd = view->GetPlatformWindow(); | ||
| if (!hwnd) { | ||
| return nullptr; | ||
| } | ||
|
|
||
| IAccessible* iaccessible_parent; | ||
| if (SUCCEEDED(::AccessibleObjectFromWindow( | ||
| hwnd, OBJID_WINDOW, IID_IAccessible, | ||
| reinterpret_cast<void**>(&iaccessible_parent)))) { | ||
| return iaccessible_parent; | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| // |FlutterPlatformNodeDelegate| | ||
| gfx::Rect FlutterPlatformNodeDelegateWin32::GetBoundsRect( | ||
| const ui::AXCoordinateSystem coordinate_system, | ||
| const ui::AXClippingBehavior clipping_behavior, | ||
| ui::AXOffscreenResult* offscreen_result) const { | ||
| gfx::Rect bounds = FlutterPlatformNodeDelegate::GetBoundsRect( | ||
| coordinate_system, clipping_behavior, offscreen_result); | ||
| POINT origin{bounds.x(), bounds.y()}; | ||
| POINT extent{bounds.x() + bounds.width(), bounds.y() + bounds.height()}; | ||
| ClientToScreen(engine_->view()->GetPlatformWindow(), &origin); | ||
| ClientToScreen(engine_->view()->GetPlatformWindow(), &extent); | ||
| return gfx::Rect(origin.x, origin.y, extent.x - origin.x, | ||
| extent.y - origin.y); | ||
| } | ||
|
|
||
| } // namespace flutter | ||
47 changes: 47 additions & 0 deletions
47
shell/platform/windows/flutter_platform_node_delegate_win32.h
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PLATFORM_NODE_DELEGATE_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PLATFORM_NODE_DELEGATE_H_ | ||
|
|
||
| #include "flutter/shell/platform/common/flutter_platform_node_delegate.h" | ||
| #include "flutter/shell/platform/windows/flutter_windows_engine.h" | ||
| #include "flutter/third_party/accessibility/ax/platform/ax_platform_node.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class FlutterWindowsEngine; | ||
|
|
||
| // The Win32 implementation of FlutterPlatformNodeDelegate. | ||
| // | ||
| // This class implements a wrapper around the Win32 accessibility objects that | ||
| // compose the accessibility tree. | ||
| class FlutterPlatformNodeDelegateWin32 : public FlutterPlatformNodeDelegate { | ||
| public: | ||
| explicit FlutterPlatformNodeDelegateWin32(FlutterWindowsEngine* engine); | ||
| virtual ~FlutterPlatformNodeDelegateWin32(); | ||
|
|
||
| // |ui::AXPlatformNodeDelegate| | ||
| void Init(std::weak_ptr<OwnerBridge> bridge, ui::AXNode* node) override; | ||
|
|
||
| // |ui::AXPlatformNodeDelegate| | ||
| gfx::NativeViewAccessible GetNativeViewAccessible() override; | ||
|
|
||
| // |FlutterPlatformNodeDelegate| | ||
| gfx::NativeViewAccessible GetParent() override; | ||
|
|
||
| // |FlutterPlatformNodeDelegate| | ||
| gfx::Rect GetBoundsRect( | ||
| const ui::AXCoordinateSystem coordinate_system, | ||
| const ui::AXClippingBehavior clipping_behavior, | ||
| ui::AXOffscreenResult* offscreen_result) const override; | ||
|
|
||
| private: | ||
| ui::AXPlatformNode* ax_platform_node_; | ||
| FlutterWindowsEngine* engine_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PLATFORM_NODE_DELEGATE_H_ |
Oops, something went wrong.
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.
Where is the fragment root created? Is it in a later patch?
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.
Fragment roots are only needed if we implement UIA, which is the newer a11y API. Talked to @clarkezone who mentioned we're safe with sticking with MSAA for the time being.