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

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

Issue 2981083002: Migrate BrowserAccessibility windows unique id handling to AXPlatformNodeWin. (Closed)
Patch Set: Use after free no more Created 3 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
6 6
7 #include "base/i18n/char_iterator.h" 7 #include "base/i18n/char_iterator.h"
8 #include "content/browser/accessibility/browser_accessibility_android.h" 8 #include "content/browser/accessibility/browser_accessibility_android.h"
9 #include "content/browser/accessibility/web_contents_accessibility_android.h" 9 #include "content/browser/accessibility/web_contents_accessibility_android.h"
10 #include "content/common/accessibility_messages.h" 10 #include "content/common/accessibility_messages.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // fire an event for those changes, but we do want to make sure our internal 106 // fire an event for those changes, but we do want to make sure our internal
107 // state is correct, so we call OnDataChanged() and then return. 107 // state is correct, so we call OnDataChanged() and then return.
108 if (android_node->IsPassword() && original_node != node) { 108 if (android_node->IsPassword() && original_node != node) {
109 android_node->OnDataChanged(); 109 android_node->OnDataChanged();
110 return; 110 return;
111 } 111 }
112 112
113 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify 113 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify
114 // the Android system that the accessibility hierarchy rooted at this 114 // the Android system that the accessibility hierarchy rooted at this
115 // node has changed. 115 // node has changed.
116 wcax->HandleContentChanged(node->unique_id()); 116 wcax->HandleContentChanged(android_node->unique_id());
117 117
118 // Ignore load complete events on iframes. 118 // Ignore load complete events on iframes.
119 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && 119 if (event_type == ui::AX_EVENT_LOAD_COMPLETE &&
120 node->manager() != GetRootManager()) { 120 node->manager() != GetRootManager()) {
121 return; 121 return;
122 } 122 }
123 123
124 switch (event_type) { 124 switch (event_type) {
125 case ui::AX_EVENT_LOAD_COMPLETE: 125 case ui::AX_EVENT_LOAD_COMPLETE: {
126 wcax->HandlePageLoaded(GetFocus()->unique_id()); 126 auto* android_focused =
127 break; 127 static_cast<BrowserAccessibilityAndroid*>(GetFocus());
128 wcax->HandlePageLoaded(android_focused->unique_id());
129 } break;
128 case ui::AX_EVENT_FOCUS: 130 case ui::AX_EVENT_FOCUS:
129 wcax->HandleFocusChanged(node->unique_id()); 131 wcax->HandleFocusChanged(android_node->unique_id());
130 break; 132 break;
131 case ui::AX_EVENT_CHECKED_STATE_CHANGED: 133 case ui::AX_EVENT_CHECKED_STATE_CHANGED:
132 wcax->HandleCheckStateChanged(node->unique_id()); 134 wcax->HandleCheckStateChanged(android_node->unique_id());
133 break; 135 break;
134 case ui::AX_EVENT_CLICKED: 136 case ui::AX_EVENT_CLICKED:
135 wcax->HandleClicked(node->unique_id()); 137 wcax->HandleClicked(android_node->unique_id());
136 break; 138 break;
137 case ui::AX_EVENT_SCROLL_POSITION_CHANGED: 139 case ui::AX_EVENT_SCROLL_POSITION_CHANGED:
138 wcax->HandleScrollPositionChanged(node->unique_id()); 140 wcax->HandleScrollPositionChanged(android_node->unique_id());
139 break; 141 break;
140 case ui::AX_EVENT_SCROLLED_TO_ANCHOR: 142 case ui::AX_EVENT_SCROLLED_TO_ANCHOR:
141 wcax->HandleScrolledToAnchor(node->unique_id()); 143 wcax->HandleScrolledToAnchor(android_node->unique_id());
142 break; 144 break;
143 case ui::AX_EVENT_ALERT: 145 case ui::AX_EVENT_ALERT:
144 // An alert is a special case of live region. Fall through to the 146 // An alert is a special case of live region. Fall through to the
145 // next case to handle it. 147 // next case to handle it.
146 case ui::AX_EVENT_SHOW: { 148 case ui::AX_EVENT_SHOW: {
147 // This event is fired when an object appears in a live region. 149 // This event is fired when an object appears in a live region.
148 // Speak its text. 150 // Speak its text.
149 base::string16 text = android_node->GetText(); 151 base::string16 text = android_node->GetText();
150 wcax->AnnounceLiveRegionText(text); 152 wcax->AnnounceLiveRegionText(text);
151 break; 153 break;
152 } 154 }
153 case ui::AX_EVENT_TEXT_SELECTION_CHANGED: 155 case ui::AX_EVENT_TEXT_SELECTION_CHANGED:
154 wcax->HandleTextSelectionChanged(node->unique_id()); 156 wcax->HandleTextSelectionChanged(android_node->unique_id());
155 break; 157 break;
156 case ui::AX_EVENT_TEXT_CHANGED: 158 case ui::AX_EVENT_TEXT_CHANGED:
157 case ui::AX_EVENT_VALUE_CHANGED: 159 case ui::AX_EVENT_VALUE_CHANGED:
158 if (android_node->IsEditableText() && GetFocus() == node) { 160 if (android_node->IsEditableText() && GetFocus() == node) {
159 wcax->HandleEditableTextChanged(node->unique_id()); 161 wcax->HandleEditableTextChanged(android_node->unique_id());
160 } else if (android_node->IsSlider()) { 162 } else if (android_node->IsSlider()) {
161 wcax->HandleSliderChanged(node->unique_id()); 163 wcax->HandleSliderChanged(android_node->unique_id());
162 } 164 }
163 break; 165 break;
164 default: 166 default:
165 // There are some notifications that aren't meaningful on Android. 167 // There are some notifications that aren't meaningful on Android.
166 // It's okay to skip them. 168 // It's okay to skip them.
167 break; 169 break;
168 } 170 }
169 } 171 }
170 172
171 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents( 173 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 BrowserAccessibility* parent_node = GetParentNodeFromParentTree(); 338 BrowserAccessibility* parent_node = GetParentNodeFromParentTree();
337 if (!parent_node) 339 if (!parent_node)
338 return web_contents_accessibility_; 340 return web_contents_accessibility_;
339 341
340 auto* parent_manager = 342 auto* parent_manager =
341 static_cast<BrowserAccessibilityManagerAndroid*>(parent_node->manager()); 343 static_cast<BrowserAccessibilityManagerAndroid*>(parent_node->manager());
342 return parent_manager->GetWebContentsAXFromRootManager(); 344 return parent_manager->GetWebContentsAXFromRootManager();
343 } 345 }
344 346
345 } // namespace content 347 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698