-
Notifications
You must be signed in to change notification settings - Fork 6k
Merge MSAA alert functionality with UIA #38745
Changes from 22 commits
3be3387
3465272
1a7171b
0a20b2f
7f78a69
8982f08
77ee7b9
6352acd
bfa0289
5aa4c77
2970345
ae7ea18
463b74b
4abf2a1
2dfe876
0ab2478
efe2657
42d7721
cfedb56
5373390
48f0315
111ad30
d32c151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // 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 "alert_platform_node_delegate.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| AlertPlatformNodeDelegate::AlertPlatformNodeDelegate( | ||
| ui::AXPlatformNodeDelegate& parent_delegate) | ||
| : parent_delegate_(parent_delegate) { | ||
| data_.role = ax::mojom::Role::kAlert; | ||
| data_.id = id_.Get(); | ||
| } | ||
|
|
||
| AlertPlatformNodeDelegate::~AlertPlatformNodeDelegate() {} | ||
|
|
||
| gfx::AcceleratedWidget | ||
| AlertPlatformNodeDelegate::GetTargetForNativeAccessibilityEvent() { | ||
| return parent_delegate_.GetTargetForNativeAccessibilityEvent(); | ||
| } | ||
|
|
||
| gfx::NativeViewAccessible AlertPlatformNodeDelegate::GetParent() { | ||
| return parent_delegate_.GetNativeViewAccessible(); | ||
| } | ||
|
|
||
| const ui::AXUniqueId& AlertPlatformNodeDelegate::GetUniqueId() const { | ||
| return id_; | ||
| } | ||
|
|
||
| const ui::AXNodeData& AlertPlatformNodeDelegate::GetData() const { | ||
| return data_; | ||
| } | ||
|
|
||
| void AlertPlatformNodeDelegate::SetText(const std::u16string& text) { | ||
| data_.SetName(text); | ||
| data_.SetDescription(text); | ||
| data_.SetValue(text); | ||
| } | ||
|
|
||
| } // namespace flutter |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // 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_COMMON_ALERT_PLATFORM_NODE_DELEGATE_H_ | ||
| #define FLUTTER_SHELL_PLATFORM_COMMON_ALERT_PLATFORM_NODE_DELEGATE_H_ | ||
|
|
||
| #include "flutter/third_party/accessibility/ax/ax_node_data.h" | ||
| #include "flutter/third_party/accessibility/ax/platform/ax_platform_node_delegate_base.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| // A delegate for a node that holds the text of an a11y alert that a | ||
| // screen-reader should announce. The delegate is used to construct an | ||
| // AXPlatformNode, and in order to serve as an alert, only needs to be able to | ||
| // hold a text announcement and make that text available to the platform node. | ||
| class AlertPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase { | ||
| public: | ||
| explicit AlertPlatformNodeDelegate( | ||
| ui::AXPlatformNodeDelegate& parent_delegate); | ||
| ~AlertPlatformNodeDelegate(); | ||
|
|
||
| AlertPlatformNodeDelegate(const AlertPlatformNodeDelegate& other) = delete; | ||
| AlertPlatformNodeDelegate operator=(const AlertPlatformNodeDelegate& other) = | ||
| delete; | ||
|
|
||
| // Set the alert text of the node for which this is the delegate. | ||
| void SetText(const std::u16string& text); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also leaning towards keeping this a string reference, but, the string reference is also copied when
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes - to benefit from this, you'd need any methods this gets passed to to also take a view rather than a string ref. If the current implementation is doing so, then leave as-is; at some point we can do a sweep of the codebase to clean these up across the board. |
||
|
|
||
| // |AXPlatformNodeDelegate| | ||
| gfx::NativeViewAccessible GetParent() override; | ||
|
|
||
| private: | ||
| // AXPlatformNodeDelegate overrides. | ||
| gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override; | ||
| const ui::AXUniqueId& GetUniqueId() const override; | ||
| const ui::AXNodeData& GetData() const override; | ||
|
|
||
| // Delegate of the parent of this node. Returned by GetParent. | ||
| ui::AXPlatformNodeDelegate& parent_delegate_; | ||
|
|
||
| // Node Data that contains the alert text. Returned by GetData. | ||
| ui::AXNodeData data_; | ||
|
|
||
| // A unique ID used to identify this node. Returned by GetUniqueId. | ||
| ui::AXUniqueId id_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_COMMON_ALERT_PLATFORM_NODE_DELEGATE_H_ | ||
This file was deleted.
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.
Add a doc comment. (True, we lack a lot in existing code but good to remedy in new code)
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.
Please do a pass, there's several other fields that are also missing comments