Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Delete AXNodeData::Init() and clear bitfields in AXNodeData() instead. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h" 5 #include "chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou ter.h" 9 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou ter.h"
10 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" 10 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 std::string text; 158 std::string text;
159 GetStringProperty(node, arc::mojom::AccessibilityStringProperty::TEXT, &text); 159 GetStringProperty(node, arc::mojom::AccessibilityStringProperty::TEXT, &text);
160 if (!text.empty()) 160 if (!text.empty())
161 out_data->role = ui::AX_ROLE_STATIC_TEXT; 161 out_data->role = ui::AX_ROLE_STATIC_TEXT;
162 else 162 else
163 out_data->role = ui::AX_ROLE_DIV; 163 out_data->role = ui::AX_ROLE_DIV;
164 } 164 }
165 165
166 void PopulateAXState(arc::mojom::AccessibilityNodeInfoData* node, 166 void PopulateAXState(arc::mojom::AccessibilityNodeInfoData* node,
167 ui::AXNodeData* out_data) { 167 ui::AXNodeData* out_data) {
168 out_data->state = 0;
169
170 #define MAP_STATE(android_boolean_property, chrome_state) \ 168 #define MAP_STATE(android_boolean_property, chrome_state) \
171 if (GetBooleanProperty(node, android_boolean_property)) \ 169 if (GetBooleanProperty(node, android_boolean_property)) \
172 out_data->AddStateFlag(chrome_state); 170 out_data->AddState(chrome_state);
173 171
174 using AXBooleanProperty = arc::mojom::AccessibilityBooleanProperty; 172 using AXBooleanProperty = arc::mojom::AccessibilityBooleanProperty;
175 173
176 // These mappings were taken from accessibility utils (Android -> Chrome) and 174 // These mappings were taken from accessibility utils (Android -> Chrome) and
177 // BrowserAccessibilityAndroid. They do not completely match the above two 175 // BrowserAccessibilityAndroid. They do not completely match the above two
178 // sources. 176 // sources.
179 // The FOCUSABLE state is not mapped because Android places focusability on 177 // The FOCUSABLE state is not mapped because Android places focusability on
180 // many ancestor nodes. 178 // many ancestor nodes.
181 MAP_STATE(AXBooleanProperty::EDITABLE, ui::AX_STATE_EDITABLE); 179 MAP_STATE(AXBooleanProperty::EDITABLE, ui::AX_STATE_EDITABLE);
182 MAP_STATE(AXBooleanProperty::MULTI_LINE, ui::AX_STATE_MULTILINE); 180 MAP_STATE(AXBooleanProperty::MULTI_LINE, ui::AX_STATE_MULTILINE);
183 MAP_STATE(AXBooleanProperty::PASSWORD, ui::AX_STATE_PROTECTED); 181 MAP_STATE(AXBooleanProperty::PASSWORD, ui::AX_STATE_PROTECTED);
184 MAP_STATE(AXBooleanProperty::SELECTED, ui::AX_STATE_SELECTED); 182 MAP_STATE(AXBooleanProperty::SELECTED, ui::AX_STATE_SELECTED);
185 183
186 #undef MAP_STATE 184 #undef MAP_STATE
187 185
188 if (GetBooleanProperty(node, AXBooleanProperty::CHECKABLE)) { 186 if (GetBooleanProperty(node, AXBooleanProperty::CHECKABLE)) {
189 const bool is_checked = 187 const bool is_checked =
190 GetBooleanProperty(node, AXBooleanProperty::CHECKED); 188 GetBooleanProperty(node, AXBooleanProperty::CHECKED);
191 const ui::AXCheckedState checked_state = 189 const ui::AXCheckedState checked_state =
192 is_checked ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; 190 is_checked ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE;
193 out_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state); 191 out_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state);
194 } 192 }
195 193
196 if (!GetBooleanProperty(node, AXBooleanProperty::ENABLED)) 194 if (!GetBooleanProperty(node, AXBooleanProperty::ENABLED))
197 out_data->AddStateFlag(ui::AX_STATE_DISABLED); 195 out_data->AddState(ui::AX_STATE_DISABLED);
198 } 196 }
199 197
200 } // namespace 198 } // namespace
201 199
202 namespace arc { 200 namespace arc {
203 201
204 AXTreeSourceArc::AXTreeSourceArc(int32_t id) 202 AXTreeSourceArc::AXTreeSourceArc(int32_t id)
205 : tree_id_(id), 203 : tree_id_(id),
206 current_tree_serializer_(new AXTreeArcSerializer(this)), 204 current_tree_serializer_(new AXTreeArcSerializer(this)),
207 root_id_(-1), 205 root_id_(-1),
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 parent_map_.clear(); 363 parent_map_.clear();
366 current_tree_serializer_.reset(new AXTreeArcSerializer(this)); 364 current_tree_serializer_.reset(new AXTreeArcSerializer(this));
367 root_id_ = -1; 365 root_id_ = -1;
368 focused_node_id_ = -1; 366 focused_node_id_ = -1;
369 extensions::AutomationEventRouter* router = 367 extensions::AutomationEventRouter* router =
370 extensions::AutomationEventRouter::GetInstance(); 368 extensions::AutomationEventRouter::GetInstance();
371 router->DispatchTreeDestroyedEvent(tree_id_, nullptr); 369 router->DispatchTreeDestroyedEvent(tree_id_, nullptr);
372 } 370 }
373 371
374 } // namespace arc 372 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698