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

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

Issue 1899823002: Uses the activedescendant_changed event received from Blink to fire the right focus event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test expectations. Created 4 years, 8 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.h" 5 #include "content/browser/accessibility/browser_accessibility_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // Find the node corresponding to the id that's the target of the 375 // Find the node corresponding to the id that's the target of the
376 // event (which may not be the root of the update tree). 376 // event (which may not be the root of the update tree).
377 ui::AXNode* node = tree_->GetFromId(detail.id); 377 ui::AXNode* node = tree_->GetFromId(detail.id);
378 if (!node) 378 if (!node)
379 continue; 379 continue;
380 380
381 ui::AXEvent event_type = detail.event_type; 381 ui::AXEvent event_type = detail.event_type;
382 if (event_type == ui::AX_EVENT_FOCUS || 382 if (event_type == ui::AX_EVENT_FOCUS ||
383 event_type == ui::AX_EVENT_BLUR) { 383 event_type == ui::AX_EVENT_BLUR) {
384 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN && 384 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN &&
385 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) 385 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) {
386 osk_state_ = OSK_ALLOWED; 386 osk_state_ = OSK_ALLOWED;
387 387 }
388 bool is_menu_list_option =
389 node->data().role == ui::AX_ROLE_MENU_LIST_OPTION;
390
391 // Skip all focus events other than ones on menu list options;
392 // we've already handled them, above. Menu list options are a weird
393 // exception because the menu list itself has focus but we need to fire
394 // focus events on the individual options.
395 if (!is_menu_list_option)
396 continue;
397 } 388 }
398 389
399 // Fire the native event. 390 // Fire the native event.
400 NotifyAccessibilityEvent(event_type, GetFromAXNode(node)); 391 NotifyAccessibilityEvent(event_type, GetFromAXNode(node));
401 } 392 }
402 } 393 }
403 394
404 void BrowserAccessibilityManager::OnLocationChanges( 395 void BrowserAccessibilityManager::OnLocationChanges(
405 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 396 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
406 for (size_t i = 0; i < params.size(); ++i) { 397 for (size_t i = 0; i < params.size(); ++i) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 462 }
472 463
473 // The "scrolled to anchor" notification is a great way to get a 464 // The "scrolled to anchor" notification is a great way to get a
474 // screen reader to jump directly to a specific location in a document. 465 // screen reader to jump directly to a specific location in a document.
475 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node); 466 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node);
476 } 467 }
477 468
478 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus( 469 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus(
479 BrowserAccessibility* focus) { 470 BrowserAccessibility* focus) {
480 if (!focus) 471 if (!focus)
481 return NULL; 472 return nullptr;
482 473
483 int active_descendant_id; 474 int32_t active_descendant_id;
484 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 475 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID,
485 &active_descendant_id)) { 476 &active_descendant_id)) {
486 BrowserAccessibility* active_descendant = 477 BrowserAccessibility* active_descendant =
487 focus->manager()->GetFromID(active_descendant_id); 478 focus->manager()->GetFromID(active_descendant_id);
488 if (active_descendant) 479 if (active_descendant)
489 return active_descendant; 480 return active_descendant;
490 } 481 }
491 return focus; 482 return focus;
492 } 483 }
493 484
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 tree_source(tree_->CreateTreeSource()); 866 tree_source(tree_->CreateTreeSource());
876 ui::AXTreeSerializer<const ui::AXNode*, 867 ui::AXTreeSerializer<const ui::AXNode*,
877 ui::AXNodeData, 868 ui::AXNodeData,
878 ui::AXTreeData> serializer(tree_source.get()); 869 ui::AXTreeData> serializer(tree_source.get());
879 ui::AXTreeUpdate update; 870 ui::AXTreeUpdate update;
880 serializer.SerializeChanges(tree_->root(), &update); 871 serializer.SerializeChanges(tree_->root(), &update);
881 return update; 872 return update;
882 } 873 }
883 874
884 } // namespace content 875 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698