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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_mac.mm

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Review comments. 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_manager_mac.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #import "base/mac/sdk_forward_declarations.h" 10 #import "base/mac/sdk_forward_declarations.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 : BrowserAccessibilityManager(delegate, factory) { 126 : BrowserAccessibilityManager(delegate, factory) {
127 Initialize(initial_tree); 127 Initialize(initial_tree);
128 } 128 }
129 129
130 BrowserAccessibilityManagerMac::~BrowserAccessibilityManagerMac() {} 130 BrowserAccessibilityManagerMac::~BrowserAccessibilityManagerMac() {}
131 131
132 // static 132 // static
133 ui::AXTreeUpdate 133 ui::AXTreeUpdate
134 BrowserAccessibilityManagerMac::GetEmptyDocument() { 134 BrowserAccessibilityManagerMac::GetEmptyDocument() {
135 ui::AXNodeData empty_document; 135 ui::AXNodeData empty_document;
136 empty_document.Init();
136 empty_document.id = 0; 137 empty_document.id = 0;
137 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 138 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
138 empty_document.state = 139 empty_document.AddState(ui::AX_STATE_READ_ONLY);
139 1 << ui::AX_STATE_READ_ONLY;
140 ui::AXTreeUpdate update; 140 ui::AXTreeUpdate update;
141 update.root_id = empty_document.id; 141 update.root_id = empty_document.id;
142 update.nodes.push_back(empty_document); 142 update.nodes.push_back(empty_document);
143 return update; 143 return update;
144 } 144 }
145 145
146 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() { 146 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() {
147 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus(); 147 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus();
148 148
149 // On Mac, list boxes should always get focus on the whole list, otherwise 149 // On Mac, list boxes should always get focus on the whole list, otherwise
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 // Starting from OS X 10.11, if the user has edited some text we need to 365 // Starting from OS X 10.11, if the user has edited some text we need to
366 // dispatch the actual text that changed on the value changed notification. 366 // dispatch the actual text that changed on the value changed notification.
367 // We run this code on all OS X versions to get the highest test coverage. 367 // We run this code on all OS X versions to get the highest test coverage.
368 base::string16 old_text, new_text; 368 base::string16 old_text, new_text;
369 ui::AXRole role = new_node_data.role; 369 ui::AXRole role = new_node_data.role;
370 if (role == ui::AX_ROLE_COMBO_BOX || role == ui::AX_ROLE_SEARCH_BOX || 370 if (role == ui::AX_ROLE_COMBO_BOX || role == ui::AX_ROLE_SEARCH_BOX ||
371 role == ui::AX_ROLE_TEXT_FIELD) { 371 role == ui::AX_ROLE_TEXT_FIELD) {
372 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_VALUE); 372 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_VALUE);
373 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_VALUE); 373 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_VALUE);
374 } else if (new_node_data.state & (1 << ui::AX_STATE_EDITABLE)) { 374 } else if (new_node_data.HasState(ui::AX_STATE_EDITABLE)) {
375 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_NAME); 375 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_NAME);
376 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_NAME); 376 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_NAME);
377 } 377 }
378 378
379 if ((old_text.empty() && new_text.empty()) || 379 if ((old_text.empty() && new_text.empty()) ||
380 old_text.length() == new_text.length()) { 380 old_text.length() == new_text.length()) {
381 return; 381 return;
382 } 382 }
383 383
384 if (old_text.length() < new_text.length()) { 384 if (old_text.length() < new_text.length()) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 NSAccessibilityTextChangeValues : changes, 479 NSAccessibilityTextChangeValues : changes,
480 NSAccessibilityTextChangeElement : native_node 480 NSAccessibilityTextChangeElement : native_node
481 }; 481 };
482 } 482 }
483 483
484 NSView* BrowserAccessibilityManagerMac::GetParentView() { 484 NSView* BrowserAccessibilityManagerMac::GetParentView() {
485 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr; 485 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr;
486 } 486 }
487 487
488 } // namespace content 488 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698