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
5 changes: 5 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,8 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPlug
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterPluginRegistrarMacOS.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Info.plist
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/AccessibilityBridgeMacDelegate.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterAppDelegate.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm
Expand Down Expand Up @@ -1132,6 +1134,9 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMouse
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm
Expand Down
7 changes: 7 additions & 0 deletions shell/platform/common/accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ const ui::AXTreeData& AccessibilityBridge::GetAXTreeData() const {
return tree_.data();
}

const std::vector<ui::AXEventGenerator::TargetedEvent>
AccessibilityBridge::GetPendingEvents() {
std::vector<ui::AXEventGenerator::TargetedEvent> result(
event_generator_.begin(), event_generator_.end());
return result;
}

void AccessibilityBridge::OnNodeWillBeDeleted(ui::AXTree* tree,
ui::AXNode* node) {}

Expand Down
15 changes: 12 additions & 3 deletions shell/platform/common/accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class AccessibilityBridge
/// @param[in] action The generated flutter semantics action.
/// @param[in] data Additional data associated with the
/// action.
virtual void DispatchAccessibilityAction(AccessibilityNodeId target,
FlutterSemanticsAction action,
std::vector<uint8_t> data) = 0;
virtual void DispatchAccessibilityAction(
AccessibilityNodeId target,
FlutterSemanticsAction action,
const std::vector<uint8_t>& data) = 0;

//---------------------------------------------------------------------------
/// @brief Creates a platform specific FlutterPlatformNodeDelegate.
Expand Down Expand Up @@ -154,6 +155,14 @@ class AccessibilityBridge
/// has the keyboard focus or the text selection range.
const ui::AXTreeData& GetAXTreeData() const;

//------------------------------------------------------------------------------
/// @brief Gets all pending accessibility events generated during
/// semantics updates. This is useful when deciding how to handle
/// events in AccessibilityBridgeDelegate::OnAccessibilityEvent in
/// case one may decide to handle an event differently based on
/// all pending events.
const std::vector<ui::AXEventGenerator::TargetedEvent> GetPendingEvents();

private:
// See FlutterSemanticsNode in embedder.h
typedef struct {
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/common/flutter_platform_node_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FlutterPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
/// delegate.
class OwnerBridge {
public:
~OwnerBridge() = default;
virtual ~OwnerBridge() = default;

protected:
friend class FlutterPlatformNodeDelegate;
Expand Down Expand Up @@ -96,7 +96,7 @@ class FlutterPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
FlutterPlatformNodeDelegate();

// |ui::AXPlatformNodeDelegateBase|
~FlutterPlatformNodeDelegate() override;
virtual ~FlutterPlatformNodeDelegate() override;

// |ui::AXPlatformNodeDelegateBase|
const ui::AXNodeData& GetData() const override;
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/common/test_accessibility_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void TestAccessibilityBridgeDelegate::OnAccessibilityEvent(
void TestAccessibilityBridgeDelegate::DispatchAccessibilityAction(
AccessibilityNodeId target,
FlutterSemanticsAction action,
std::vector<uint8_t> data) {
const std::vector<uint8_t>& data) {
performed_actions.push_back(action);
}

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/common/test_accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TestAccessibilityBridgeDelegate
ui::AXEventGenerator::TargetedEvent targeted_event) override;
void DispatchAccessibilityAction(AccessibilityNodeId target,
FlutterSemanticsAction action,
std::vector<uint8_t> data) override;
const std::vector<uint8_t>& data) override;
std::unique_ptr<FlutterPlatformNodeDelegate>
CreateFlutterPlatformNodeDelegate();

Expand Down
7 changes: 7 additions & 0 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ source_set("flutter_framework_source") {
visibility = [ ":*" ]

sources = [
"framework/Source/AccessibilityBridgeMacDelegate.h",
"framework/Source/AccessibilityBridgeMacDelegate.mm",
"framework/Source/FlutterAppDelegate.mm",
"framework/Source/FlutterBackingStore.h",
"framework/Source/FlutterBackingStore.mm",
Expand Down Expand Up @@ -81,6 +83,8 @@ source_set("flutter_framework_source") {
"framework/Source/FlutterMouseCursorPlugin.mm",
"framework/Source/FlutterOpenGLRenderer.h",
"framework/Source/FlutterOpenGLRenderer.mm",
"framework/Source/FlutterPlatformNodeDelegateMac.h",
"framework/Source/FlutterPlatformNodeDelegateMac.mm",
"framework/Source/FlutterRenderer.h",
"framework/Source/FlutterRenderingBackend.h",
"framework/Source/FlutterRenderingBackend.mm",
Expand Down Expand Up @@ -108,6 +112,7 @@ source_set("flutter_framework_source") {
":macos_gpu_configuration",
"//flutter/flow:flow",
"//flutter/fml",
"//flutter/shell/platform/common:common_cpp_accessibility",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/common:common_cpp_switches",
"//flutter/shell/platform/darwin/common:framework_shared",
Expand Down Expand Up @@ -159,6 +164,7 @@ executable("flutter_desktop_darwin_unittests") {
"framework/Source/FlutterMetalRendererTest.mm",
"framework/Source/FlutterMetalSurfaceManagerTest.mm",
"framework/Source/FlutterOpenGLRendererTest.mm",
"framework/Source/FlutterPlatformNodeDelegateMacTest.mm",
"framework/Source/FlutterViewControllerTest.mm",
"framework/Source/FlutterViewControllerTestUtils.h",
"framework/Source/FlutterViewControllerTestUtils.mm",
Expand All @@ -171,6 +177,7 @@ executable("flutter_desktop_darwin_unittests") {
deps = [
":flutter_desktop_darwin_fixtures",
":flutter_framework_source",
"//flutter/shell/platform/common:common_cpp_accessibility",
"//flutter/shell/platform/darwin/common:framework_shared",
"//flutter/shell/platform/darwin/graphics",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// 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_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMACDELEGATE_H_
#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMACDELEGATE_H_

#import <Cocoa/Cocoa.h>

#include "flutter/shell/platform/common/accessibility_bridge.h"

@class FlutterEngine;

namespace flutter {

//------------------------------------------------------------------------------
/// The macOS implementation of AccessibilityBridge::AccessibilityBridgeDelegate.
/// This delegate is used to create AccessibilityBridge in the macOS embedding.
class AccessibilityBridgeMacDelegate : public AccessibilityBridge::AccessibilityBridgeDelegate {
public:
//---------------------------------------------------------------------------
/// @brief Creates an AccessibilityBridgeMacDelegate.
/// @param[in] flutterEngine The weak reference to the FlutterEngine.
explicit AccessibilityBridgeMacDelegate(__weak FlutterEngine* flutter_engine);
virtual ~AccessibilityBridgeMacDelegate() = default;

// |AccessibilityBridge::AccessibilityBridgeDelegate|
void OnAccessibilityEvent(ui::AXEventGenerator::TargetedEvent targeted_event) override;

// |AccessibilityBridge::AccessibilityBridgeDelegate|
void DispatchAccessibilityAction(AccessibilityNodeId target,
FlutterSemanticsAction action,
const std::vector<uint8_t>& data) override;

// |AccessibilityBridge::AccessibilityBridgeDelegate|
std::unique_ptr<FlutterPlatformNodeDelegate> CreateFlutterPlatformNodeDelegate() override;

private:
/// A wrapper structure to wraps macOS native accessibility events.
struct NSAccessibilityEvent {
NSAccessibilityNotificationName name;
gfx::NativeViewAccessible target;
NSDictionary* user_info;
};

//---------------------------------------------------------------------------
/// @brief Posts the given event against the given node to the macOS
/// accessibility notification system.
/// @param[in] native_node The event target, must not be nil.
/// @param[in] mac_notification The event name, must not be nil.
void DispatchMacOSNotification(gfx::NativeViewAccessible native_node,
NSAccessibilityNotificationName mac_notification);

//---------------------------------------------------------------------------
/// @brief Posts the given event against the given node with the
/// additional attributes to the macOS accessibility notification
/// system.
/// @param[in] native_node The event target, must not be nil.
/// @param[in] mac_notification The event name, must not be nil.
/// @param[in] user_info The additional attributes, must not be nil.
void DispatchMacOSNotificationWithUserInfo(gfx::NativeViewAccessible native_node,
NSAccessibilityNotificationName mac_notification,
NSDictionary* user_info);

//---------------------------------------------------------------------------
/// @brief Whether the given event is in current pending events.
/// @param[in] event_type The event you would like to look up.
bool HasPendingEvent(ui::AXEventGenerator::Event event) const;

//---------------------------------------------------------------------------
/// @brief Converts the give ui::AXEventGenerator::Event into
/// macOS native accessibility event[s]
/// @param[in] event_type The original event type.
/// @param[in] ax_node The original event target.
std::vector<NSAccessibilityEvent> MacOSEventsFromAXEvent(ui::AXEventGenerator::Event event_type,
const ui::AXNode& ax_node) const;

__weak FlutterEngine* flutter_engine_;
};

} // namespace flutter

#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_ACCESSIBILITYBRIDGEMACDELEGATE_H_
Loading