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

Side by Side Diff: chrome/browser/ui/views/accessibility_event_router_views.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/accessibility_event_router_views.h" 5 #include "chrome/browser/ui/views/accessibility_event_router_views.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void AccessibilityEventRouterViews::FindView( 118 void AccessibilityEventRouterViews::FindView(
119 views::View* view, Profile** profile, bool* is_accessible) { 119 views::View* view, Profile** profile, bool* is_accessible) {
120 *is_accessible = false; 120 *is_accessible = false;
121 121
122 // First see if it's a descendant of an accessible view. 122 // First see if it's a descendant of an accessible view.
123 for (base::hash_map<views::View*, Profile*>::const_iterator iter = 123 for (base::hash_map<views::View*, Profile*>::const_iterator iter =
124 view_tree_profile_map_.begin(); 124 view_tree_profile_map_.begin();
125 iter != view_tree_profile_map_.end(); 125 iter != view_tree_profile_map_.end();
126 ++iter) { 126 ++iter) {
127 if (iter->first->IsParentOf(view)) { 127 if (iter->first->Contains(view)) {
128 *is_accessible = true; 128 *is_accessible = true;
129 if (profile) 129 if (profile)
130 *profile = iter->second; 130 *profile = iter->second;
131 break; 131 break;
132 } 132 }
133 } 133 }
134 134
135 if (!*is_accessible) 135 if (!*is_accessible)
136 return; 136 return;
137 137
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 views::View* view, NotificationType type, Profile* profile) { 225 views::View* view, NotificationType type, Profile* profile) {
226 std::string name = GetViewName(view); 226 std::string name = GetViewName(view);
227 227
228 bool has_submenu = false; 228 bool has_submenu = false;
229 int index = -1; 229 int index = -1;
230 int count = -1; 230 int count = -1;
231 231
232 if (view->GetClassName() == views::MenuItemView::kViewClassName) 232 if (view->GetClassName() == views::MenuItemView::kViewClassName)
233 has_submenu = static_cast<views::MenuItemView*>(view)->HasSubmenu(); 233 has_submenu = static_cast<views::MenuItemView*>(view)->HasSubmenu();
234 234
235 views::View* parent_menu = view->GetParent(); 235 views::View* parent_menu = view->parent();
236 while (parent_menu != NULL && parent_menu->GetClassName() != 236 while (parent_menu != NULL && parent_menu->GetClassName() !=
237 views::SubmenuView::kViewClassName) { 237 views::SubmenuView::kViewClassName) {
238 parent_menu = parent_menu->GetParent(); 238 parent_menu = parent_menu->parent();
239 } 239 }
240 if (parent_menu) { 240 if (parent_menu) {
241 count = 0; 241 count = 0;
242 RecursiveGetMenuItemIndexAndCount(parent_menu, view, &index, &count); 242 RecursiveGetMenuItemIndexAndCount(parent_menu, view, &index, &count);
243 } 243 }
244 244
245 AccessibilityMenuItemInfo info(profile, name, has_submenu, index, count); 245 AccessibilityMenuItemInfo info(profile, name, has_submenu, index, count);
246 SendAccessibilityNotification(type, &info); 246 SendAccessibilityNotification(type, &info);
247 } 247 }
248 248
249 void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( 249 void AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount(
250 views::View* menu, views::View* item, int* index, int* count) { 250 views::View* menu, views::View* item, int* index, int* count) {
251 for (int i = 0; i < menu->GetChildViewCount(); ++i) { 251 for (size_t i = 0; i < menu->child_count(); ++i) {
252 views::View* child = menu->GetChildViewAt(i); 252 views::View* child = menu->GetChildViewAt(i);
253 int previous_count = *count; 253 int previous_count = *count;
254 RecursiveGetMenuItemIndexAndCount(child, item, index, count); 254 RecursiveGetMenuItemIndexAndCount(child, item, index, count);
255 if (child->GetClassName() == views::MenuItemView::kViewClassName && 255 if (child->GetClassName() == views::MenuItemView::kViewClassName &&
256 *count == previous_count) { 256 *count == previous_count) {
257 if (item == child) 257 if (item == child)
258 *index = *count; 258 *index = *count;
259 (*count)++; 259 (*count)++;
260 } else if (child->GetClassName() == views::TextButton::kViewClassName) { 260 } else if (child->GetClassName() == views::TextButton::kViewClassName) {
261 if (item == child) 261 if (item == child)
262 *index = *count; 262 *index = *count;
263 (*count)++; 263 (*count)++;
264 } 264 }
265 } 265 }
266 } 266 }
267 267
268 bool AccessibilityEventRouterViews::IsMenuEvent( 268 bool AccessibilityEventRouterViews::IsMenuEvent(
269 views::View* view, NotificationType type) { 269 views::View* view, NotificationType type) {
270 if (type == NotificationType::ACCESSIBILITY_MENU_OPENED || 270 if (type == NotificationType::ACCESSIBILITY_MENU_OPENED ||
271 type == NotificationType::ACCESSIBILITY_MENU_CLOSED) 271 type == NotificationType::ACCESSIBILITY_MENU_CLOSED)
272 return true; 272 return true;
273 273
274 while (view) { 274 while (view) {
275 AccessibilityTypes::Role role = view->GetAccessibleRole(); 275 AccessibilityTypes::Role role = view->GetAccessibleRole();
276 if (role == AccessibilityTypes::ROLE_MENUITEM || 276 if (role == AccessibilityTypes::ROLE_MENUITEM ||
277 role == AccessibilityTypes::ROLE_MENUPOPUP) { 277 role == AccessibilityTypes::ROLE_MENUPOPUP) {
278 return true; 278 return true;
279 } 279 }
280 view = view->GetParent(); 280 view = view->parent();
281 } 281 }
282 282
283 return false; 283 return false;
284 } 284 }
285 285
286 void AccessibilityEventRouterViews::SendLocationBarNotification( 286 void AccessibilityEventRouterViews::SendLocationBarNotification(
287 views::View* view, NotificationType type, Profile* profile) { 287 views::View* view, NotificationType type, Profile* profile) {
288 #if defined(OS_WIN) 288 #if defined(OS_WIN)
289 // This particular method isn't needed on Linux/Views, we get text 289 // This particular method isn't needed on Linux/Views, we get text
290 // notifications directly from GTK. 290 // notifications directly from GTK.
291 std::string name = GetViewName(view); 291 std::string name = GetViewName(view);
292 LocationBarView* location_bar = static_cast<LocationBarView*>(view); 292 LocationBarView* location_bar = static_cast<LocationBarView*>(view);
293 AutocompleteEditViewWin* location_entry = 293 AutocompleteEditViewWin* location_entry =
294 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry()); 294 static_cast<AutocompleteEditViewWin*>(location_bar->location_entry());
295 295
296 std::string value = WideToUTF8(location_entry->GetText()); 296 std::string value = WideToUTF8(location_entry->GetText());
297 std::wstring::size_type selection_start; 297 std::wstring::size_type selection_start;
298 std::wstring::size_type selection_end; 298 std::wstring::size_type selection_end;
299 location_entry->GetSelectionBounds(&selection_start, &selection_end); 299 location_entry->GetSelectionBounds(&selection_start, &selection_end);
300 300
301 AccessibilityTextBoxInfo info(profile, name, false); 301 AccessibilityTextBoxInfo info(profile, name, false);
302 info.SetValue(value, selection_start, selection_end); 302 info.SetValue(value, selection_start, selection_end);
303 SendAccessibilityNotification(type, &info); 303 SendAccessibilityNotification(type, &info);
304 #endif 304 #endif
305 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698