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

Commit

Permalink
Use AccessibilityBridgeWindows for AXFragmentRootDelegateWin
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakovschectman committed Nov 28, 2022
1 parent 1ba0a21 commit 854e2b4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 49 deletions.
12 changes: 12 additions & 0 deletions shell/platform/windows/accessibility_bridge_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,16 @@ void AccessibilityBridgeWindows::SetFocus(
node_delegate->SetFocus();
}

gfx::NativeViewAccessible AccessibilityBridgeWindows::GetChildOfAXFragmentRoot() {
return view_->GetNativeViewAccessible();
}

gfx::NativeViewAccessible AccessibilityBridgeWindows::GetParentOfAXFragmentRoot() {
return nullptr;
}

bool AccessibilityBridgeWindows::IsAXFragmentRootAControlElement() {
return true;
}

} // namespace flutter
13 changes: 12 additions & 1 deletion shell/platform/windows/accessibility_bridge_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_WINDOWS_H_

#include "flutter/shell/platform/common/accessibility_bridge.h"
#include "flutter/third_party/accessibility/ax/platform/ax_fragment_root_delegate_win.h"

namespace flutter {

Expand All @@ -22,7 +23,8 @@ class FlutterPlatformNodeDelegateWindows;
///
/// AccessibilityBridgeWindows must be created as a shared_ptr, since some
/// methods acquires its weak_ptr.
class AccessibilityBridgeWindows : public AccessibilityBridge {
class AccessibilityBridgeWindows : public AccessibilityBridge,
public ui::AXFragmentRootDelegateWin {
public:
AccessibilityBridgeWindows(FlutterWindowsEngine* engine,
FlutterWindowsView* view);
Expand All @@ -48,6 +50,15 @@ class AccessibilityBridgeWindows : public AccessibilityBridge {
virtual void SetFocus(
std::shared_ptr<FlutterPlatformNodeDelegateWindows> node_delegate);

// |AXFragmentRootDelegateWin|
gfx::NativeViewAccessible GetChildOfAXFragmentRoot() override;

// |AXFragmentRootDelegateWin|
gfx::NativeViewAccessible GetParentOfAXFragmentRoot() override;

// |AXFragmentRootDelegateWin|
bool IsAXFragmentRootAControlElement() override;

protected:
// |AccessibilityBridge|
void OnAccessibilityEvent(
Expand Down
3 changes: 1 addition & 2 deletions shell/platform/windows/flutter_windows_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,7 @@ void FlutterWindowsView::NotifyWinEventWrapper(DWORD event,
}

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

} // namespace flutter
25 changes: 2 additions & 23 deletions shell/platform/windows/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,10 @@ LRESULT Window::OnGetObject(UINT const message,
// TODO(schectman): UIA is currently disabled by default.
// https://github.com/flutter/flutter/issues/114547
if (is_uia_request && root_view) {
#ifndef FLUTTER_ENGINE_USE_UIA
#ifdef FLUTTER_ENGINE_USE_UIA
if (!ax_fragment_root_) {
if (!ax_fragment_delegate_) {
ax_fragment_delegate_ =
std::make_unique<WindowAXFragmentRootDelegate>(*this);
}
ax_fragment_root_ = std::make_unique<ui::AXFragmentRootWin>(
window_handle_, ax_fragment_delegate_.get());
window_handle_, GetAxFragmentRootDelegate());
}

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

gfx::NativeViewAccessible
WindowAXFragmentRootDelegate::GetChildOfAXFragmentRoot() {
return window_.GetNativeViewAccessible();
}

gfx::NativeViewAccessible
WindowAXFragmentRootDelegate::GetParentOfAXFragmentRoot() {
return nullptr;
}

bool WindowAXFragmentRootDelegate::IsAXFragmentRootAControlElement() {
return true;
}

WindowAXFragmentRootDelegate::WindowAXFragmentRootDelegate(Window& window)
: window_(window) {}

} // namespace flutter
23 changes: 0 additions & 23 deletions shell/platform/windows/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

namespace flutter {

class WindowAXFragmentRootDelegate;

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

// Delegate for Fragment.
std::unique_ptr<WindowAXFragmentRootDelegate> ax_fragment_delegate_;

// Allow WindowAXFragmentRootDelegate to access protected method.
friend class WindowAXFragmentRootDelegate;
};

// A delegate class to the window.
class WindowAXFragmentRootDelegate : public ui::AXFragmentRootDelegateWin {
public:
// | AXFragmentRootDelegateWin |
gfx::NativeViewAccessible GetChildOfAXFragmentRoot() override;

// | AXFragmentRootDelegateWin |
gfx::NativeViewAccessible GetParentOfAXFragmentRoot() override;

// | AXFragmentRootDelegateWin |
bool IsAXFragmentRootAControlElement() override;

WindowAXFragmentRootDelegate(Window& window);

private:
Window& window_;
};

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WIN32_WINDOW_H_

0 comments on commit 854e2b4

Please sign in to comment.