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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_win.cc

Issue 642313003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Including id in the AUTHORS file. Created 6 years, 2 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_win.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/win/scoped_comptr.h" 8 #include "base/win/scoped_comptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 10 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
(...skipping 15 matching lines...) Expand all
26 BrowserAccessibilityManagerWin* 26 BrowserAccessibilityManagerWin*
27 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { 27 BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() {
28 return static_cast<BrowserAccessibilityManagerWin*>(this); 28 return static_cast<BrowserAccessibilityManagerWin*>(this);
29 } 29 }
30 30
31 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin( 31 BrowserAccessibilityManagerWin::BrowserAccessibilityManagerWin(
32 const ui::AXTreeUpdate& initial_tree, 32 const ui::AXTreeUpdate& initial_tree,
33 BrowserAccessibilityDelegate* delegate, 33 BrowserAccessibilityDelegate* delegate,
34 BrowserAccessibilityFactory* factory) 34 BrowserAccessibilityFactory* factory)
35 : BrowserAccessibilityManager(delegate, factory), 35 : BrowserAccessibilityManager(delegate, factory),
36 tracked_scroll_object_(NULL), 36 tracked_scroll_object_(nullptr),
37 focus_event_on_root_needed_(false) { 37 focus_event_on_root_needed_(false) {
38 ui::win::CreateATLModuleIfNeeded(); 38 ui::win::CreateATLModuleIfNeeded();
39 Initialize(initial_tree); 39 Initialize(initial_tree);
40 } 40 }
41 41
42 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() { 42 BrowserAccessibilityManagerWin::~BrowserAccessibilityManagerWin() {
43 if (tracked_scroll_object_) { 43 if (tracked_scroll_object_) {
44 tracked_scroll_object_->Release(); 44 tracked_scroll_object_->Release();
45 tracked_scroll_object_ = NULL; 45 tracked_scroll_object_ = nullptr;
46 } 46 }
47 } 47 }
48 48
49 // static 49 // static
50 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() { 50 ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() {
51 ui::AXNodeData empty_document; 51 ui::AXNodeData empty_document;
52 empty_document.id = 0; 52 empty_document.id = 0;
53 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 53 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
54 empty_document.state = 54 empty_document.state =
55 (1 << ui::AX_STATE_ENABLED) | 55 (1 << ui::AX_STATE_ENABLED) |
56 (1 << ui::AX_STATE_READ_ONLY) | 56 (1 << ui::AX_STATE_READ_ONLY) |
57 (1 << ui::AX_STATE_BUSY); 57 (1 << ui::AX_STATE_BUSY);
58 58
59 ui::AXTreeUpdate update; 59 ui::AXTreeUpdate update;
60 update.nodes.push_back(empty_document); 60 update.nodes.push_back(empty_document);
61 return update; 61 return update;
62 } 62 }
63 63
64 HWND BrowserAccessibilityManagerWin::GetParentHWND() { 64 HWND BrowserAccessibilityManagerWin::GetParentHWND() {
65 if (!delegate_) 65 if (!delegate_)
66 return NULL; 66 return nullptr;
67 return delegate_->AccessibilityGetAcceleratedWidget(); 67 return delegate_->AccessibilityGetAcceleratedWidget();
68 } 68 }
69 69
70 IAccessible* BrowserAccessibilityManagerWin::GetParentIAccessible() { 70 IAccessible* BrowserAccessibilityManagerWin::GetParentIAccessible() {
71 if (!delegate_) 71 if (!delegate_)
72 return NULL; 72 return nullptr;
73 return delegate_->AccessibilityGetNativeViewAccessible(); 73 return delegate_->AccessibilityGetNativeViewAccessible();
74 } 74 }
75 75
76 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event, 76 void BrowserAccessibilityManagerWin::MaybeCallNotifyWinEvent(DWORD event,
77 LONG child_id) { 77 LONG child_id) {
78 if (!delegate_) 78 if (!delegate_)
79 return; 79 return;
80 80
81 HWND hwnd = delegate_->AccessibilityGetAcceleratedWidget(); 81 HWND hwnd = delegate_->AccessibilityGetAcceleratedWidget();
82 if (!hwnd) 82 if (!hwnd)
(...skipping 12 matching lines...) Expand all
95 95
96 void BrowserAccessibilityManagerWin::OnNodeWillBeDeleted(ui::AXNode* node) { 96 void BrowserAccessibilityManagerWin::OnNodeWillBeDeleted(ui::AXNode* node) {
97 BrowserAccessibilityManager::OnNodeWillBeDeleted(node); 97 BrowserAccessibilityManager::OnNodeWillBeDeleted(node);
98 BrowserAccessibility* obj = GetFromAXNode(node); 98 BrowserAccessibility* obj = GetFromAXNode(node);
99 if (!obj) 99 if (!obj)
100 return; 100 return;
101 unique_id_to_ax_id_map_.erase( 101 unique_id_to_ax_id_map_.erase(
102 obj->ToBrowserAccessibilityWin()->unique_id_win()); 102 obj->ToBrowserAccessibilityWin()->unique_id_win());
103 if (obj == tracked_scroll_object_) { 103 if (obj == tracked_scroll_object_) {
104 tracked_scroll_object_->Release(); 104 tracked_scroll_object_->Release();
105 tracked_scroll_object_ = NULL; 105 tracked_scroll_object_ = nullptr;
106 } 106 }
107 } 107 }
108 108
109 void BrowserAccessibilityManagerWin::OnWindowFocused() { 109 void BrowserAccessibilityManagerWin::OnWindowFocused() {
110 // This is called either when this web frame gets focused, or when 110 // This is called either when this web frame gets focused, or when
111 // the root of the accessibility tree changes. In both cases, we need 111 // the root of the accessibility tree changes. In both cases, we need
112 // to fire a focus event on the root and then on the focused element 112 // to fire a focus event on the root and then on the focused element
113 // within the page, if different. 113 // within the page, if different.
114 114
115 // Set this flag so that we'll keep trying to fire these focus events 115 // Set this flag so that we'll keep trying to fire these focus events
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // If this is a layout complete notification (sent when a container scrolls) 251 // If this is a layout complete notification (sent when a container scrolls)
252 // and there is a descendant tracked object, send a notification on it. 252 // and there is a descendant tracked object, send a notification on it.
253 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed. 253 // TODO(dmazzoni): remove once http://crbug.com/113483 is fixed.
254 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE && 254 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE &&
255 tracked_scroll_object_ && 255 tracked_scroll_object_ &&
256 tracked_scroll_object_->IsDescendantOf(node)) { 256 tracked_scroll_object_->IsDescendantOf(node)) {
257 MaybeCallNotifyWinEvent( 257 MaybeCallNotifyWinEvent(
258 IA2_EVENT_VISIBLE_DATA_CHANGED, 258 IA2_EVENT_VISIBLE_DATA_CHANGED,
259 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win()); 259 tracked_scroll_object_->ToBrowserAccessibilityWin()->unique_id_win());
260 tracked_scroll_object_->Release(); 260 tracked_scroll_object_->Release();
261 tracked_scroll_object_ = NULL; 261 tracked_scroll_object_ = nullptr;
262 } 262 }
263 } 263 }
264 264
265 void BrowserAccessibilityManagerWin::OnRootChanged(ui::AXNode* new_root) { 265 void BrowserAccessibilityManagerWin::OnRootChanged(ui::AXNode* new_root) {
266 // In order to make screen readers aware of the new accessibility root, 266 // In order to make screen readers aware of the new accessibility root,
267 // we need to fire a focus event on it. 267 // we need to fire a focus event on it.
268 OnWindowFocused(); 268 OnWindowFocused();
269 } 269 }
270 270
271 void BrowserAccessibilityManagerWin::TrackScrollingObject( 271 void BrowserAccessibilityManagerWin::TrackScrollingObject(
272 BrowserAccessibilityWin* node) { 272 BrowserAccessibilityWin* node) {
273 if (tracked_scroll_object_) 273 if (tracked_scroll_object_)
274 tracked_scroll_object_->Release(); 274 tracked_scroll_object_->Release();
275 tracked_scroll_object_ = node; 275 tracked_scroll_object_ = node;
276 tracked_scroll_object_->AddRef(); 276 tracked_scroll_object_->AddRef();
277 } 277 }
278 278
279 BrowserAccessibilityWin* BrowserAccessibilityManagerWin::GetFromUniqueIdWin( 279 BrowserAccessibilityWin* BrowserAccessibilityManagerWin::GetFromUniqueIdWin(
280 LONG unique_id_win) { 280 LONG unique_id_win) {
281 base::hash_map<LONG, int32>::iterator iter = 281 base::hash_map<LONG, int32>::iterator iter =
282 unique_id_to_ax_id_map_.find(unique_id_win); 282 unique_id_to_ax_id_map_.find(unique_id_win);
283 if (iter != unique_id_to_ax_id_map_.end()) { 283 if (iter != unique_id_to_ax_id_map_.end()) {
284 BrowserAccessibility* result = GetFromID(iter->second); 284 BrowserAccessibility* result = GetFromID(iter->second);
285 if (result) 285 if (result)
286 return result->ToBrowserAccessibilityWin(); 286 return result->ToBrowserAccessibilityWin();
287 } 287 }
288 return NULL; 288 return nullptr;
289 } 289 }
290 290
291 } // namespace content 291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698