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

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

Issue 2900893003: Don't store raw pointers in BrowserAccessibilityManager::tree_changes_ (Closed)
Patch Set: 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
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "content/browser/accessibility/browser_accessibility_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 ui::AX_EVENT_CHILDREN_CHANGED, 382 ui::AX_EVENT_CHILDREN_CHANGED,
383 parent); 383 parent);
384 connected_to_parent_tree_node_ = true; 384 connected_to_parent_tree_node_ = true;
385 } 385 }
386 } else { 386 } else {
387 connected_to_parent_tree_node_ = false; 387 connected_to_parent_tree_node_ = false;
388 } 388 }
389 389
390 // Fire any events related to changes to the tree. 390 // Fire any events related to changes to the tree.
391 for (auto& event : tree_events_) { 391 for (auto& event : tree_events_) {
392 BrowserAccessibility* event_target = GetFromID(event.second);
393 if (!event_target)
394 continue;
392 NotifyAccessibilityEvent(BrowserAccessibilityEvent::FromTreeChange, 395 NotifyAccessibilityEvent(BrowserAccessibilityEvent::FromTreeChange,
393 event.first, event.second); 396 event.first, event_target);
394 } 397 }
395 tree_events_.clear(); 398 tree_events_.clear();
396 399
397 // Based on the changes to the tree, first fire focus events if needed. 400 // Based on the changes to the tree, first fire focus events if needed.
398 // Screen readers might not do the right thing if they're not aware of what 401 // Screen readers might not do the right thing if they're not aware of what
399 // has focus, so always try that first. Nothing will be fired if the window 402 // has focus, so always try that first. Nothing will be fired if the window
400 // itself isn't focused or if focus hasn't changed. 403 // itself isn't focused or if focus hasn't changed.
401 GetRootManager()->FireFocusEventsIfNeeded( 404 GetRootManager()->FireFocusEventsIfNeeded(
402 BrowserAccessibilityEvent::FromBlink); 405 BrowserAccessibilityEvent::FromBlink);
403 406
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1186
1184 // Notify ATs if any live regions have been created. 1187 // Notify ATs if any live regions have been created.
1185 for (auto& change : changes) { 1188 for (auto& change : changes) {
1186 if (change.type != NODE_CREATED && change.type != SUBTREE_CREATED) 1189 if (change.type != NODE_CREATED && change.type != SUBTREE_CREATED)
1187 continue; 1190 continue;
1188 1191
1189 const ui::AXNode* created_node = change.node; 1192 const ui::AXNode* created_node = change.node;
1190 DCHECK(created_node); 1193 DCHECK(created_node);
1191 BrowserAccessibility* object = GetFromAXNode(created_node); 1194 BrowserAccessibility* object = GetFromAXNode(created_node);
1192 if (object && object->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) { 1195 if (object && object->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) {
1196 int32_t id = object->GetId();
1193 if (object->GetRole() == ui::AX_ROLE_ALERT) { 1197 if (object->GetRole() == ui::AX_ROLE_ALERT) {
1194 tree_events_.push_back(std::make_pair(ui::AX_EVENT_ALERT, object)); 1198 tree_events_.push_back(std::make_pair(ui::AX_EVENT_ALERT, id));
1195 } else { 1199 } else {
1196 tree_events_.push_back( 1200 tree_events_.push_back(
1197 std::make_pair(ui::AX_EVENT_LIVE_REGION_CREATED, object)); 1201 std::make_pair(ui::AX_EVENT_LIVE_REGION_CREATED, id));
1198 } 1202 }
1199 } 1203 }
1200 } 1204 }
1201 } 1205 }
1202 1206
1203 BrowserAccessibilityManager* BrowserAccessibilityManager::GetRootManager() { 1207 BrowserAccessibilityManager* BrowserAccessibilityManager::GetRootManager() {
1204 BrowserAccessibility* parent = GetParentNodeFromParentTree(); 1208 BrowserAccessibility* parent = GetParentNodeFromParentTree();
1205 if (!parent) 1209 if (!parent)
1206 return this; 1210 return this;
1207 1211
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 hit_test_result = parent; 1288 hit_test_result = parent;
1285 parent = parent->PlatformGetParent(); 1289 parent = parent->PlatformGetParent();
1286 } 1290 }
1287 1291
1288 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id(); 1292 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id();
1289 last_hover_node_id_ = hit_test_result->GetId(); 1293 last_hover_node_id_ = hit_test_result->GetId();
1290 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect(); 1294 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect();
1291 } 1295 }
1292 1296
1293 } // namespace content 1297 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698