Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f39c9e3

Browse files
Use AccessibilityBridgeWindows for AXFragmentRootDelegateWin
1 parent 94eb751 commit f39c9e3

File tree

5 files changed

+27
-49
lines changed

5 files changed

+27
-49
lines changed

shell/platform/windows/accessibility_bridge_windows.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,16 @@ void AccessibilityBridgeWindows::SetFocus(
173173
node_delegate->SetFocus();
174174
}
175175

176+
gfx::NativeViewAccessible AccessibilityBridgeWindows::GetChildOfAXFragmentRoot() {
177+
return view_->GetNativeViewAccessible();
178+
}
179+
180+
gfx::NativeViewAccessible AccessibilityBridgeWindows::GetParentOfAXFragmentRoot() {
181+
return nullptr;
182+
}
183+
184+
bool AccessibilityBridgeWindows::IsAXFragmentRootAControlElement() {
185+
return true;
186+
}
187+
176188
} // namespace flutter

shell/platform/windows/accessibility_bridge_windows.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_WINDOWS_H_
77

88
#include "flutter/shell/platform/common/accessibility_bridge.h"
9+
#include "flutter/third_party/accessibility/ax/platform/ax_fragment_root_delegate_win.h"
910

1011
namespace flutter {
1112

@@ -22,7 +23,8 @@ class FlutterPlatformNodeDelegateWindows;
2223
///
2324
/// AccessibilityBridgeWindows must be created as a shared_ptr, since some
2425
/// methods acquires its weak_ptr.
25-
class AccessibilityBridgeWindows : public AccessibilityBridge {
26+
class AccessibilityBridgeWindows : public AccessibilityBridge,
27+
public ui::AXFragmentRootDelegateWin {
2628
public:
2729
AccessibilityBridgeWindows(FlutterWindowsEngine* engine,
2830
FlutterWindowsView* view);
@@ -48,6 +50,15 @@ class AccessibilityBridgeWindows : public AccessibilityBridge {
4850
virtual void SetFocus(
4951
std::shared_ptr<FlutterPlatformNodeDelegateWindows> node_delegate);
5052

53+
// |AXFragmentRootDelegateWin|
54+
gfx::NativeViewAccessible GetChildOfAXFragmentRoot() override;
55+
56+
// |AXFragmentRootDelegateWin|
57+
gfx::NativeViewAccessible GetParentOfAXFragmentRoot() override;
58+
59+
// |AXFragmentRootDelegateWin|
60+
bool IsAXFragmentRootAControlElement() override;
61+
5162
protected:
5263
// |AccessibilityBridge|
5364
void OnAccessibilityEvent(

shell/platform/windows/flutter_windows_view.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,7 @@ void FlutterWindowsView::NotifyWinEventWrapper(DWORD event,
678678
}
679679

680680
ui::AXFragmentRootDelegateWin* FlutterWindowsView::GetAxFragmentRootDelegate() {
681-
// TODO(schectman): implement
682-
return nullptr;
681+
return engine_->accessibility_bridge().lock().get();
683682
}
684683

685684
} // namespace flutter

shell/platform/windows/window.cc

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,10 @@ LRESULT Window::OnGetObject(UINT const message,
204204
// TODO(schectman): UIA is currently disabled by default.
205205
// https://github.com/flutter/flutter/issues/114547
206206
if (is_uia_request && root_view) {
207-
#ifndef FLUTTER_ENGINE_USE_UIA
207+
#ifdef FLUTTER_ENGINE_USE_UIA
208208
if (!ax_fragment_root_) {
209-
if (!ax_fragment_delegate_) {
210-
ax_fragment_delegate_ =
211-
std::make_unique<WindowAXFragmentRootDelegate>(*this);
212-
}
213209
ax_fragment_root_ = std::make_unique<ui::AXFragmentRootWin>(
214-
window_handle_, ax_fragment_delegate_.get());
210+
window_handle_, GetAxFragmentRootDelegate());
215211
}
216212

217213
// Retrieve UIA object for the root view.
@@ -680,21 +676,4 @@ void Window::CreateAccessibilityRootNode() {
680676
accessibility_root_ = AccessibilityRootNode::Create();
681677
}
682678

683-
gfx::NativeViewAccessible
684-
WindowAXFragmentRootDelegate::GetChildOfAXFragmentRoot() {
685-
return window_.GetNativeViewAccessible();
686-
}
687-
688-
gfx::NativeViewAccessible
689-
WindowAXFragmentRootDelegate::GetParentOfAXFragmentRoot() {
690-
return nullptr;
691-
}
692-
693-
bool WindowAXFragmentRootDelegate::IsAXFragmentRootAControlElement() {
694-
return true;
695-
}
696-
697-
WindowAXFragmentRootDelegate::WindowAXFragmentRootDelegate(Window& window)
698-
: window_(window) {}
699-
700679
} // namespace flutter

shell/platform/windows/window.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
namespace flutter {
2828

29-
class WindowAXFragmentRootDelegate;
30-
3129
// A class abstraction for a high DPI aware Win32 Window. Intended to be
3230
// inherited from by classes that wish to specialize with custom
3331
// rendering and input handling.
@@ -310,31 +308,10 @@ class Window : public KeyboardManager::WindowDelegate {
310308
// Implements IRawElementProviderFragmentRoot when UIA is enabled.
311309
std::unique_ptr<ui::AXFragmentRootWin> ax_fragment_root_;
312310

313-
// Delegate for Fragment.
314-
std::unique_ptr<WindowAXFragmentRootDelegate> ax_fragment_delegate_;
315-
316311
// Allow WindowAXFragmentRootDelegate to access protected method.
317312
friend class WindowAXFragmentRootDelegate;
318313
};
319314

320-
// A delegate class to the window.
321-
class WindowAXFragmentRootDelegate : public ui::AXFragmentRootDelegateWin {
322-
public:
323-
// | AXFragmentRootDelegateWin |
324-
gfx::NativeViewAccessible GetChildOfAXFragmentRoot() override;
325-
326-
// | AXFragmentRootDelegateWin |
327-
gfx::NativeViewAccessible GetParentOfAXFragmentRoot() override;
328-
329-
// | AXFragmentRootDelegateWin |
330-
bool IsAXFragmentRootAControlElement() override;
331-
332-
WindowAXFragmentRootDelegate(Window& window);
333-
334-
private:
335-
Window& window_;
336-
};
337-
338315
} // namespace flutter
339316

340317
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WIN32_WINDOW_H_

0 commit comments

Comments
 (0)