Skip to content

Commit 01952cb

Browse files
Corresponds to changes by reverted PR flutter#36966.
1 parent 624b132 commit 01952cb

19 files changed

+943
-3
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,9 +3067,13 @@ FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_texture_regi
30673067
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_value.h
30683068
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/fl_view.h
30693069
FILE: ../../../flutter/shell/platform/linux/public/flutter_linux/flutter_linux.h
3070+
FILE: ../../../flutter/shell/platform/windows/accessibility_alert.cc
3071+
FILE: ../../../flutter/shell/platform/windows/accessibility_alert.h
30703072
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_windows.cc
30713073
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_windows.h
30723074
FILE: ../../../flutter/shell/platform/windows/accessibility_bridge_delegate_windows_unittests.cc
3075+
FILE: ../../../flutter/shell/platform/windows/accessibility_root_node.cc
3076+
FILE: ../../../flutter/shell/platform/windows/accessibility_root_node.h
30733077
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.cc
30743078
FILE: ../../../flutter/shell/platform/windows/angle_surface_manager.h
30753079
FILE: ../../../flutter/shell/platform/windows/client_wrapper/dart_project_unittests.cc

shell/platform/windows/BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ source_set("flutter_windows_headers") {
3838
source_set("flutter_windows_source") {
3939
# Common Windows sources.
4040
sources = [
41+
"accessibility_alert.cc",
42+
"accessibility_alert.h",
4143
"accessibility_bridge_delegate_windows.cc",
4244
"accessibility_bridge_delegate_windows.h",
45+
"accessibility_root_node.cc",
46+
"accessibility_root_node.h",
4347
"angle_surface_manager.cc",
4448
"angle_surface_manager.h",
4549
"cursor_handler.cc",
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "flutter/shell/platform/windows/accessibility_alert.h"
6+
7+
#include "flutter/shell/platform/windows/accessibility_root_node.h"
8+
9+
namespace flutter {
10+
11+
AccessibilityAlert::AccessibilityAlert() : text_(L""), parent_(nullptr) {}
12+
13+
// IAccessible methods.
14+
15+
IFACEMETHODIMP AccessibilityAlert::accHitTest(LONG screen_physical_pixel_x,
16+
LONG screen_physical_pixel_y,
17+
VARIANT* child) {
18+
child->vt = VT_EMPTY;
19+
return S_FALSE;
20+
}
21+
22+
// Performs the object's default action.
23+
IFACEMETHODIMP AccessibilityAlert::accDoDefaultAction(VARIANT var_id) {
24+
return E_FAIL;
25+
}
26+
27+
// Retrieves an IDispatch interface pointer for the specified child.
28+
IFACEMETHODIMP AccessibilityAlert::get_accChild(VARIANT var_child,
29+
IDispatch** disp_child) {
30+
if (V_VT(&var_child) == VT_I4 && V_I4(&var_child) == CHILDID_SELF) {
31+
*disp_child = this;
32+
AddRef();
33+
return S_OK;
34+
}
35+
*disp_child = nullptr;
36+
return E_FAIL;
37+
}
38+
39+
// Retrieves the number of accessible children.
40+
IFACEMETHODIMP AccessibilityAlert::get_accChildCount(LONG* child_count) {
41+
*child_count = 0;
42+
return S_OK;
43+
}
44+
45+
// Retrieves the tooltip description.
46+
IFACEMETHODIMP AccessibilityAlert::get_accDescription(VARIANT var_id,
47+
BSTR* desc) {
48+
*desc = SysAllocString(text_.c_str());
49+
return S_OK;
50+
}
51+
52+
// Retrieves the name of the specified object.
53+
IFACEMETHODIMP AccessibilityAlert::get_accName(VARIANT var_id, BSTR* name) {
54+
*name = SysAllocString(text_.c_str());
55+
return S_OK;
56+
}
57+
58+
// Retrieves the IDispatch interface of the object's parent.
59+
IFACEMETHODIMP AccessibilityAlert::get_accParent(IDispatch** disp_parent) {
60+
*disp_parent = parent_;
61+
if (*disp_parent) {
62+
(*disp_parent)->AddRef();
63+
return S_OK;
64+
}
65+
return S_FALSE;
66+
}
67+
68+
// Retrieves information describing the role of the specified object.
69+
IFACEMETHODIMP AccessibilityAlert::get_accRole(VARIANT var_id, VARIANT* role) {
70+
*role = {.vt = VT_I4, .lVal = ROLE_SYSTEM_ALERT};
71+
return S_OK;
72+
}
73+
74+
// Retrieves the current state of the specified object.
75+
IFACEMETHODIMP AccessibilityAlert::get_accState(VARIANT var_id,
76+
VARIANT* state) {
77+
*state = {.vt = VT_I4, .lVal = STATE_SYSTEM_DEFAULT};
78+
return S_OK;
79+
}
80+
81+
// Gets the help string for the specified object.
82+
IFACEMETHODIMP AccessibilityAlert::get_accHelp(VARIANT var_id, BSTR* help) {
83+
*help = SysAllocString(L"");
84+
return S_OK;
85+
}
86+
87+
// Retrieve or set the string value associated with the specified object.
88+
// Setting the value is not typically used by screen readers, but it's
89+
// used frequently by automation software.
90+
IFACEMETHODIMP AccessibilityAlert::get_accValue(VARIANT var_id, BSTR* value) {
91+
*value = SysAllocString(text_.c_str());
92+
return S_OK;
93+
}
94+
95+
// IAccessible methods not implemented.
96+
IFACEMETHODIMP AccessibilityAlert::get_accSelection(VARIANT* selected) {
97+
selected->vt = VT_EMPTY;
98+
return E_NOTIMPL;
99+
}
100+
101+
IFACEMETHODIMP AccessibilityAlert::accSelect(LONG flags_sel, VARIANT var_id) {
102+
return E_NOTIMPL;
103+
}
104+
105+
IFACEMETHODIMP AccessibilityAlert::put_accValue(VARIANT var_id,
106+
BSTR new_value) {
107+
return E_NOTIMPL;
108+
}
109+
110+
IFACEMETHODIMP AccessibilityAlert::get_accFocus(VARIANT* focus_child) {
111+
focus_child->vt = VT_EMPTY;
112+
return E_NOTIMPL;
113+
}
114+
115+
IFACEMETHODIMP AccessibilityAlert::get_accHelpTopic(BSTR* help_file,
116+
VARIANT var_id,
117+
LONG* topic_id) {
118+
if (help_file) {
119+
*help_file = nullptr;
120+
}
121+
if (topic_id) {
122+
*topic_id = 0;
123+
}
124+
return E_NOTIMPL;
125+
}
126+
127+
IFACEMETHODIMP AccessibilityAlert::put_accName(VARIANT var_id, BSTR put_name) {
128+
return E_NOTIMPL;
129+
}
130+
131+
IFACEMETHODIMP AccessibilityAlert::get_accKeyboardShortcut(VARIANT var_id,
132+
BSTR* access_key) {
133+
*access_key = nullptr;
134+
return E_NOTIMPL;
135+
}
136+
137+
IFACEMETHODIMP AccessibilityAlert::accLocation(LONG* physical_pixel_left,
138+
LONG* physical_pixel_top,
139+
LONG* width,
140+
LONG* height,
141+
VARIANT var_id) {
142+
return E_NOTIMPL;
143+
}
144+
145+
IFACEMETHODIMP AccessibilityAlert::accNavigate(LONG nav_dir,
146+
VARIANT start,
147+
VARIANT* end) {
148+
end->vt = VT_EMPTY;
149+
return E_NOTIMPL;
150+
}
151+
152+
IFACEMETHODIMP AccessibilityAlert::get_accDefaultAction(VARIANT var_id,
153+
BSTR* default_action) {
154+
*default_action = nullptr;
155+
return E_NOTIMPL;
156+
}
157+
158+
// End of IAccessible methods.
159+
160+
void AccessibilityAlert::SetText(const std::wstring& text) {
161+
text_ = text;
162+
}
163+
164+
void AccessibilityAlert::SetParent(AccessibilityRootNode* parent) {
165+
parent_ = parent;
166+
}
167+
168+
} // namespace flutter
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_ALERT_H_
6+
#define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_ALERT_H_
7+
8+
#include <atlbase.h>
9+
#include <atlcom.h>
10+
#include <oleacc.h>
11+
12+
#include <string>
13+
14+
namespace flutter {
15+
16+
class AccessibilityRootNode;
17+
18+
// An IAccessible node representing an alert read to the screen reader.
19+
// When an announcement is requested by the framework, an instance of
20+
// this class, if none exists already, is created and made a child of
21+
// the root AccessibilityRootNode node, and is therefore also a sibling
22+
// of the window's root node.
23+
// This node is not interactable to the user.
24+
class AccessibilityAlert : public CComObjectRootEx<CComMultiThreadModel>,
25+
public IDispatchImpl<IAccessible> {
26+
public:
27+
BEGIN_COM_MAP(AccessibilityAlert)
28+
COM_INTERFACE_ENTRY(IAccessible)
29+
END_COM_MAP()
30+
//
31+
// IAccessible methods.
32+
//
33+
34+
// Retrieves the child element or child object at a given point on the screen.
35+
IFACEMETHODIMP accHitTest(LONG screen_physical_pixel_x,
36+
LONG screen_physical_pixel_y,
37+
VARIANT* child) override;
38+
39+
// Retrieves an IDispatch interface pointer for the specified child.
40+
IFACEMETHODIMP get_accChild(VARIANT var_child,
41+
IDispatch** disp_child) override;
42+
43+
// Retrieves the number of accessible children.
44+
IFACEMETHODIMP get_accChildCount(LONG* child_count) override;
45+
46+
// Retrieves a string that describes the object's default action.
47+
IFACEMETHODIMP get_accDefaultAction(VARIANT var_id,
48+
BSTR* default_action) override;
49+
50+
// Retrieves the tooltip description.
51+
IFACEMETHODIMP get_accDescription(VARIANT var_id, BSTR* desc) override;
52+
53+
// Retrieves the name of the specified object.
54+
IFACEMETHODIMP get_accName(VARIANT var_id, BSTR* name) override;
55+
56+
// Retrieves the IDispatch interface of the object's parent.
57+
IFACEMETHODIMP get_accParent(IDispatch** disp_parent) override;
58+
59+
// Retrieves information describing the role of the specified object.
60+
IFACEMETHODIMP get_accRole(VARIANT var_id, VARIANT* role) override;
61+
62+
// Retrieves the current state of the specified object.
63+
IFACEMETHODIMP get_accState(VARIANT var_id, VARIANT* state) override;
64+
65+
// Gets the help string for the specified object.
66+
IFACEMETHODIMP get_accHelp(VARIANT var_id, BSTR* help) override;
67+
68+
// Retrieve the string value associated with the specified object.
69+
IFACEMETHODIMP get_accValue(VARIANT var_id, BSTR* value) override;
70+
71+
// IAccessible methods not implemented.
72+
IFACEMETHODIMP accLocation(LONG* physical_pixel_left,
73+
LONG* physical_pixel_top,
74+
LONG* width,
75+
LONG* height,
76+
VARIANT var_id) override;
77+
IFACEMETHODIMP accNavigate(LONG nav_dir,
78+
VARIANT start,
79+
VARIANT* end) override;
80+
IFACEMETHODIMP accDoDefaultAction(VARIANT var_id) override;
81+
IFACEMETHODIMP get_accFocus(VARIANT* focus_child) override;
82+
IFACEMETHODIMP get_accKeyboardShortcut(VARIANT var_id,
83+
BSTR* access_key) override;
84+
IFACEMETHODIMP get_accSelection(VARIANT* selected) override;
85+
IFACEMETHODIMP accSelect(LONG flags_sel, VARIANT var_id) override;
86+
IFACEMETHODIMP get_accHelpTopic(BSTR* help_file,
87+
VARIANT var_id,
88+
LONG* topic_id) override;
89+
IFACEMETHODIMP put_accName(VARIANT var_id, BSTR put_name) override;
90+
IFACEMETHODIMP put_accValue(VARIANT var_id, BSTR new_value) override;
91+
92+
// End of IAccessible methods.
93+
94+
AccessibilityAlert();
95+
~AccessibilityAlert() = default;
96+
97+
// Sets the text of this alert to the provided message.
98+
void SetText(const std::wstring& text);
99+
100+
void SetParent(AccessibilityRootNode* parent);
101+
102+
private:
103+
std::wstring text_;
104+
105+
AccessibilityRootNode* parent_;
106+
};
107+
108+
} // namespace flutter
109+
110+
#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_ALERT_H_

0 commit comments

Comments
 (0)