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

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: Revert comment. 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; 168 out_data->ClearBitfields();
169 169
170 #define MAP_STATE(android_boolean_property, chrome_state) \ 170 #define MAP_STATE(android_boolean_property, chrome_state) \
171 if (GetBooleanProperty(node, android_boolean_property)) \ 171 if (GetBooleanProperty(node, android_boolean_property)) \
172 out_data->AddStateFlag(chrome_state); 172 out_data->AddState(chrome_state);
173 173
174 using AXBooleanProperty = arc::mojom::AccessibilityBooleanProperty; 174 using AXBooleanProperty = arc::mojom::AccessibilityBooleanProperty;
175 175
176 // These mappings were taken from accessibility utils (Android -> Chrome) and 176 // These mappings were taken from accessibility utils (Android -> Chrome) and
177 // BrowserAccessibilityAndroid. They do not completely match the above two 177 // BrowserAccessibilityAndroid. They do not completely match the above two
178 // sources. 178 // sources.
179 // The FOCUSABLE state is not mapped because Android places focusability on 179 // The FOCUSABLE state is not mapped because Android places focusability on
180 // many ancestor nodes. 180 // many ancestor nodes.
181 MAP_STATE(AXBooleanProperty::EDITABLE, ui::AX_STATE_EDITABLE); 181 MAP_STATE(AXBooleanProperty::EDITABLE, ui::AX_STATE_EDITABLE);
182 MAP_STATE(AXBooleanProperty::MULTI_LINE, ui::AX_STATE_MULTILINE); 182 MAP_STATE(AXBooleanProperty::MULTI_LINE, ui::AX_STATE_MULTILINE);
183 MAP_STATE(AXBooleanProperty::PASSWORD, ui::AX_STATE_PROTECTED); 183 MAP_STATE(AXBooleanProperty::PASSWORD, ui::AX_STATE_PROTECTED);
184 MAP_STATE(AXBooleanProperty::SELECTED, ui::AX_STATE_SELECTED); 184 MAP_STATE(AXBooleanProperty::SELECTED, ui::AX_STATE_SELECTED);
185 185
186 #undef MAP_STATE 186 #undef MAP_STATE
187 187
188 if (GetBooleanProperty(node, AXBooleanProperty::CHECKABLE)) { 188 if (GetBooleanProperty(node, AXBooleanProperty::CHECKABLE)) {
189 const bool is_checked = 189 const bool is_checked =
190 GetBooleanProperty(node, AXBooleanProperty::CHECKED); 190 GetBooleanProperty(node, AXBooleanProperty::CHECKED);
191 const ui::AXCheckedState checked_state = 191 const ui::AXCheckedState checked_state =
192 is_checked ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; 192 is_checked ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE;
193 out_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state); 193 out_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state);
194 } 194 }
195 195
196 if (!GetBooleanProperty(node, AXBooleanProperty::ENABLED)) 196 if (!GetBooleanProperty(node, AXBooleanProperty::ENABLED))
197 out_data->AddStateFlag(ui::AX_STATE_DISABLED); 197 out_data->AddState(ui::AX_STATE_DISABLED);
198 } 198 }
199 199
200 } // namespace 200 } // namespace
201 201
202 namespace arc { 202 namespace arc {
203 203
204 AXTreeSourceArc::AXTreeSourceArc(int32_t id) 204 AXTreeSourceArc::AXTreeSourceArc(int32_t id)
205 : tree_id_(id), 205 : tree_id_(id),
206 current_tree_serializer_(new AXTreeArcSerializer(this)), 206 current_tree_serializer_(new AXTreeArcSerializer(this)),
207 root_id_(-1), 207 root_id_(-1),
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 parent_map_.clear(); 365 parent_map_.clear();
366 current_tree_serializer_.reset(new AXTreeArcSerializer(this)); 366 current_tree_serializer_.reset(new AXTreeArcSerializer(this));
367 root_id_ = -1; 367 root_id_ = -1;
368 focused_node_id_ = -1; 368 focused_node_id_ = -1;
369 extensions::AutomationEventRouter* router = 369 extensions::AutomationEventRouter* router =
370 extensions::AutomationEventRouter::GetInstance(); 370 extensions::AutomationEventRouter::GetInstance();
371 router->DispatchTreeDestroyedEvent(tree_id_, nullptr); 371 router->DispatchTreeDestroyedEvent(tree_id_, nullptr);
372 } 372 }
373 373
374 } // namespace arc 374 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698