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

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: 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 (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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.id = 0; 136 empty_document.id = 0;
137 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 137 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
138 empty_document.state = 138 empty_document.AddState(ui::AX_STATE_READ_ONLY);
139 1 << ui::AX_STATE_READ_ONLY;
140 ui::AXTreeUpdate update; 139 ui::AXTreeUpdate update;
141 update.root_id = empty_document.id; 140 update.root_id = empty_document.id;
142 update.nodes.push_back(empty_document); 141 update.nodes.push_back(empty_document);
143 return update; 142 return update;
144 } 143 }
145 144
146 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() { 145 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() {
147 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus(); 146 BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus();
148 147
149 // On Mac, list boxes should always get focus on the whole list, otherwise 148 // 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 363
365 // Starting from OS X 10.11, if the user has edited some text we need to 364 // 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. 365 // 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. 366 // We run this code on all OS X versions to get the highest test coverage.
368 base::string16 old_text, new_text; 367 base::string16 old_text, new_text;
369 ui::AXRole role = new_node_data.role; 368 ui::AXRole role = new_node_data.role;
370 if (role == ui::AX_ROLE_COMBO_BOX || role == ui::AX_ROLE_SEARCH_BOX || 369 if (role == ui::AX_ROLE_COMBO_BOX || role == ui::AX_ROLE_SEARCH_BOX ||
371 role == ui::AX_ROLE_TEXT_FIELD) { 370 role == ui::AX_ROLE_TEXT_FIELD) {
372 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_VALUE); 371 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_VALUE);
373 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_VALUE); 372 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_VALUE);
374 } else if (new_node_data.state & (1 << ui::AX_STATE_EDITABLE)) { 373 } else if (new_node_data.HasState(ui::AX_STATE_EDITABLE)) {
375 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_NAME); 374 old_text = old_node_data.GetString16Attribute(ui::AX_ATTR_NAME);
376 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_NAME); 375 new_text = new_node_data.GetString16Attribute(ui::AX_ATTR_NAME);
377 } 376 }
378 377
379 if ((old_text.empty() && new_text.empty()) || 378 if ((old_text.empty() && new_text.empty()) ||
380 old_text.length() == new_text.length()) { 379 old_text.length() == new_text.length()) {
381 return; 380 return;
382 } 381 }
383 382
384 if (old_text.length() < new_text.length()) { 383 if (old_text.length() < new_text.length()) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 NSAccessibilityTextChangeValues : changes, 478 NSAccessibilityTextChangeValues : changes,
480 NSAccessibilityTextChangeElement : native_node 479 NSAccessibilityTextChangeElement : native_node
481 }; 480 };
482 } 481 }
483 482
484 NSView* BrowserAccessibilityManagerMac::GetParentView() { 483 NSView* BrowserAccessibilityManagerMac::GetParentView() {
485 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr; 484 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr;
486 } 485 }
487 486
488 } // namespace content 487 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698