Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,10 @@ FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_texture_regi
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_value.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_view.h
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/flutter_linux.h
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_win32.cc
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_win32.h
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_winuwp.cc
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_winuwp.h
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.cc
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.h
FILE: ../../../flutter/shell/platform/windows/client_wrapper/dart_project_unittests.cc
Expand All @@ -1717,6 +1721,10 @@ FILE: ../../../flutter/shell/platform/windows/dpi_utils_win32_unittests.cc
FILE: ../../../flutter/shell/platform/windows/external_texture_gl.cc
FILE: ../../../flutter/shell/platform/windows/external_texture_gl.h
FILE: ../../../flutter/shell/platform/windows/flutter_key_map.cc
FILE: ../../../flutter/shell/platform/windows/flutter_platform_node_delegate_win32.cc
FILE: ../../../flutter/shell/platform/windows/flutter_platform_node_delegate_win32.h
FILE: ../../../flutter/shell/platform/windows/flutter_platform_node_delegate_winuwp.cc
FILE: ../../../flutter/shell/platform/windows/flutter_platform_node_delegate_winuwp.h
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.cc
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle.h
FILE: ../../../flutter/shell/platform/windows/flutter_project_bundle_unittests.cc
Expand Down
14 changes: 12 additions & 2 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ source_set("flutter_windows_source") {
# Target-specific sources.
if (target_os == "winuwp") {
sources += [
"accessibility_bridge_delegate_winuwp.cc",
"accessibility_bridge_delegate_winuwp.h",
"display_helper_winuwp.cc",
"display_helper_winuwp.h",
"flutter_platform_node_delegate_winuwp.cc",
"flutter_platform_node_delegate_winuwp.h",
"flutter_window_winuwp.cc",
"flutter_window_winuwp.h",
"flutter_windows_winuwp.cc",
Expand All @@ -106,8 +110,12 @@ source_set("flutter_windows_source") {
]
} else {
sources += [
"accessibility_bridge_delegate_win32.cc",
"accessibility_bridge_delegate_win32.h",
"dpi_utils_win32.cc",
"dpi_utils_win32.h",
"flutter_platform_node_delegate_win32.cc",
"flutter_platform_node_delegate_win32.h",
"flutter_window_win32.cc",
"flutter_window_win32.h",
"flutter_windows_win32.cc",
Expand Down Expand Up @@ -153,7 +161,10 @@ source_set("flutter_windows_source") {
defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
}

public_deps = [ ":string_conversion" ]
public_deps = [
":string_conversion",
"//flutter/shell/platform/common:common_cpp_accessibility",
]

deps = [
":flutter_windows_headers",
Expand All @@ -163,7 +174,6 @@ source_set("flutter_windows_source") {
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows",
"//flutter/third_party/accessibility",
"//third_party/angle:libEGL_static", # the order of libEGL_static and
# libGLESv2_static is important.. if
# reversed, will cause a linker error
Expand Down
36 changes: 36 additions & 0 deletions shell/platform/windows/accessibility_bridge_delegate_win32.cc
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 shell/platform/windows/accessibility_bridge_delegate_win32.h
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 shell/platform/windows/accessibility_bridge_delegate_winuwp.cc
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 shell/platform/windows/accessibility_bridge_delegate_winuwp.h
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 shell/platform/windows/flutter_platform_node_delegate_win32.cc
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);
Copy link
Contributor

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?

Copy link
Member Author

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.

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 shell/platform/windows/flutter_platform_node_delegate_win32.h
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_
Loading