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
Merge AccessibilityBridge and AccessibilityBridgeDelegate #36597
Merged
auto-submit
merged 26 commits into
flutter:main
from
dkwingsmt:a11y-bridge-merge-with-delegate
Nov 4, 2022
Merged
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a639113
Impl
dkwingsmt 7283373
FlutterPlatformNodeDelegateMac
dkwingsmt 2d4f6f5
Format
dkwingsmt e8aff9a
Rename file
dkwingsmt 2100c48
Merge remote-tracking branch 'origin/main' into a11y-bridge-merge-wit…
dkwingsmt 18b133f
Windows: Compile
dkwingsmt 3182505
Merge remote-tracking branch 'dkwingsmt/a11y-bridge-merge-with-delega…
dkwingsmt 406f330
format
dkwingsmt 0086ebf
Fix tests
dkwingsmt 9896019
Merge branch 'a11y-bridge-merge-with-delegate' of https://github.com/…
dkwingsmt d654a87
Fix doc
dkwingsmt 05a7fcd
More doc
dkwingsmt 82f89f5
More comments
dkwingsmt ce02096
Format
dkwingsmt faf0508
Merge remote-tracking branch 'origin/main' into a11y-bridge-merge-wit…
dkwingsmt 8f09b51
Update names
dkwingsmt 67be29b
Format
dkwingsmt 1551acf
Compile
dkwingsmt 2ea8661
Change to unique
dkwingsmt 5d371cf
Merge remote-tracking branch 'origin/main' into a11y-bridge-merge-wit…
dkwingsmt 827824f
Revert as shared
dkwingsmt ec932f3
Doc fixes
dkwingsmt 2a0cac1
Make windows bridge weak
dkwingsmt 1aa23a1
Fix win compile
dkwingsmt c9b1e0a
Format
dkwingsmt 803b6e2
move weak
dkwingsmt 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
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 |
|---|---|---|
|
|
@@ -31,85 +31,37 @@ namespace flutter { | |
| /// FlutterPlatformNodeDelegate to wrap each AXNode in order to provide | ||
| /// an accessibility tree in the native format. | ||
| /// | ||
| /// This class takes in a AccessibilityBridgeDelegate instance and is in charge | ||
| /// of its lifecycle. The delegate are used to handle the accessibility events | ||
| /// and actions. | ||
| /// | ||
| /// To use this class, you must provide your own implementation of | ||
| /// FlutterPlatformNodeDelegate and AccessibilityBridgeDelegate. | ||
| /// To use this class, you must implement this class and provide your own | ||
| /// implementation of FlutterPlatformNodeDelegate. | ||
| class AccessibilityBridge | ||
| : public std::enable_shared_from_this<AccessibilityBridge>, | ||
| public FlutterPlatformNodeDelegate::OwnerBridge, | ||
| private ui::AXTreeObserver { | ||
| public: | ||
| //----------------------------------------------------------------------------- | ||
| /// Delegate to handle requests from the accessibility bridge. The requests | ||
| /// include sending accessibility event to native accessibility system, | ||
| /// routing accessibility action to the Flutter framework, and creating | ||
| /// platform specific FlutterPlatformNodeDelegate. | ||
| /// | ||
| /// The accessibility events are generated when accessibility tree changes. | ||
| /// These events must be sent to the native accessibility system through | ||
| /// the native API for the system to pick up the changes | ||
| /// (e.g. NSAccessibilityPostNotification in MacOS). | ||
| /// | ||
| /// The accessibility actions are generated by the native accessibility system | ||
| /// when users interacted with the assistive technologies. Those actions | ||
| /// needed to be sent to the Flutter framework. | ||
| /// | ||
| /// Each platform needs to implement the FlutterPlatformNodeDelegate and | ||
| /// returns its platform specific instance of FlutterPlatformNodeDelegate | ||
| /// in this delegate. | ||
| class AccessibilityBridgeDelegate { | ||
| public: | ||
| virtual ~AccessibilityBridgeDelegate() = default; | ||
| //--------------------------------------------------------------------------- | ||
| /// @brief Handle accessibility events generated due to accessibility | ||
| /// tree changes. These events are generated in accessibility | ||
| /// bridge and needed to be sent to native accessibility system. | ||
| /// See ui::AXEventGenerator::Event for possible events. | ||
| /// | ||
| /// @param[in] targeted_event The object that contains both the | ||
| /// generated event and the event target. | ||
| virtual void OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) = 0; | ||
|
|
||
| //--------------------------------------------------------------------------- | ||
| /// @brief Dispatch accessibility action back to the Flutter framework. | ||
| /// These actions are generated in the native accessibility | ||
| /// system when users interact with the assistive technologies. | ||
| /// For example, a | ||
| /// FlutterSemanticsAction::kFlutterSemanticsActionTap is | ||
| /// fired when user click or touch the screen. | ||
| /// | ||
| /// @param[in] target The semantics node id of the action | ||
| /// target. | ||
| /// @param[in] action The generated flutter semantics action. | ||
| /// @param[in] data Additional data associated with the | ||
| /// action. | ||
| virtual void DispatchAccessibilityAction(AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) = 0; | ||
|
|
||
| //--------------------------------------------------------------------------- | ||
| /// @brief Creates a platform specific FlutterPlatformNodeDelegate. | ||
| /// Ownership passes to the caller. This method will be called | ||
| /// by accessibility bridge whenever a new AXNode is created in | ||
| /// AXTree. Each platform needs to implement this method in | ||
| /// order to inject its subclass into the accessibility bridge. | ||
| virtual std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| CreateFlutterPlatformNodeDelegate() = 0; | ||
| }; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// @brief Creates a new instance of a accessibility bridge. | ||
| AccessibilityBridge(); | ||
| virtual ~AccessibilityBridge(); | ||
|
|
||
| //--------------------------------------------------------------------------- | ||
| /// @brief Handle accessibility events generated due to accessibility | ||
| /// tree changes. These events are generated in accessibility | ||
| /// bridge and needed to be sent to native accessibility system. | ||
| /// See ui::AXEventGenerator::Event for possible events. | ||
| /// | ||
| /// @param[in] user_data A custom pointer to the data of your | ||
| /// choice. This pointer can be retrieve later | ||
| /// through GetUserData(). | ||
| explicit AccessibilityBridge( | ||
| std::unique_ptr<AccessibilityBridgeDelegate> delegate); | ||
| ~AccessibilityBridge(); | ||
| /// @param[in] targeted_event The object that contains both the | ||
| /// generated event and the event target. | ||
| virtual void OnAccessibilityEvent( | ||
| ui::AXEventGenerator::TargetedEvent targeted_event) = 0; | ||
|
|
||
| //--------------------------------------------------------------------------- | ||
| /// @brief Creates a platform specific FlutterPlatformNodeDelegate. | ||
| /// Ownership passes to the caller. This method will be called | ||
| /// whenever a new AXNode is created in AXTree. Each platform | ||
| /// needs to implement this method in order to inject its | ||
| /// subclass into the accessibility bridge. | ||
| virtual std::shared_ptr<FlutterPlatformNodeDelegate> | ||
| CreateFlutterPlatformNodeDelegate() = 0; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| /// @brief The ID of the root node in the accessibility tree. In Flutter, | ||
|
|
@@ -168,12 +120,14 @@ class AccessibilityBridge | |
| /// 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(); | ||
| const std::vector<ui::AXEventGenerator::TargetedEvent> GetPendingEvents() | ||
| const; | ||
|
|
||
| protected: | ||
| //------------------------------------------------------------------------------ | ||
| /// @brief Update the AccessibilityBridgeDelegate stored in the | ||
| /// accessibility bridge to a new one. | ||
| void UpdateDelegate(std::unique_ptr<AccessibilityBridgeDelegate> delegate); | ||
| void Reset(); | ||
|
||
|
|
||
| private: | ||
| // See FlutterSemanticsNode in embedder.h | ||
|
|
@@ -220,7 +174,6 @@ class AccessibilityBridge | |
| std::unordered_map<int32_t, SemanticsCustomAction> | ||
| pending_semantics_custom_action_updates_; | ||
| AccessibilityNodeId last_focused_id_ = ui::AXNode::kInvalidAXID; | ||
| std::unique_ptr<AccessibilityBridgeDelegate> delegate_; | ||
|
|
||
| void InitAXTree(const ui::AXTreeUpdate& initial_state); | ||
|
|
||
|
|
@@ -295,11 +248,6 @@ class AccessibilityBridge | |
| gfx::NativeViewAccessible GetNativeAccessibleFromId( | ||
| AccessibilityNodeId id) override; | ||
|
|
||
| // |FlutterPlatformNodeDelegate::OwnerBridge| | ||
| void DispatchAccessibilityAction(AccessibilityNodeId target, | ||
| FlutterSemanticsAction action, | ||
| fml::MallocMapping data) override; | ||
|
|
||
| // |FlutterPlatformNodeDelegate::OwnerBridge| | ||
| gfx::RectF RelativeToGlobalBounds(const ui::AXNode* node, | ||
| bool& offscreen, | ||
|
|
||
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.
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.
should it also mention the onaccessibilityevent?
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm not sure. If you think it's worthwhile, can you help me write it?