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

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: Fixed Mac compilation issue. Created 4 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
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // Find the node corresponding to the id that's the target of the 376 // Find the node corresponding to the id that's the target of the
377 // event (which may not be the root of the update tree). 377 // event (which may not be the root of the update tree).
378 ui::AXNode* node = tree_->GetFromId(detail.id); 378 ui::AXNode* node = tree_->GetFromId(detail.id);
379 if (!node) 379 if (!node)
380 continue; 380 continue;
381 381
382 ui::AXEvent event_type = detail.event_type; 382 ui::AXEvent event_type = detail.event_type;
383 if (event_type == ui::AX_EVENT_FOCUS || 383 if (event_type == ui::AX_EVENT_FOCUS ||
384 event_type == ui::AX_EVENT_BLUR) { 384 event_type == ui::AX_EVENT_BLUR) {
385 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN && 385 if (osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_HIDDEN &&
386 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) 386 osk_state_ != OSK_DISALLOWED_BECAUSE_TAB_JUST_APPEARED) {
387 osk_state_ = OSK_ALLOWED; 387 osk_state_ = OSK_ALLOWED;
388 }
388 389
389 bool is_menu_list_option = 390 // We already handled all focus events above.
390 node->data().role == ui::AX_ROLE_MENU_LIST_OPTION; 391 continue;
391
392 // Skip all focus events other than ones on menu list options;
393 // we've already handled them, above. Menu list options are a weird
394 // exception because the menu list itself has focus but we need to fire
395 // focus events on the individual options.
396 if (!is_menu_list_option)
397 continue;
398 } 392 }
399 393
400 // Fire the native event. 394 // Fire the native event.
401 NotifyAccessibilityEvent(event_type, GetFromAXNode(node)); 395 NotifyAccessibilityEvent(event_type, GetFromAXNode(node));
402 } 396 }
403 } 397 }
404 398
405 void BrowserAccessibilityManager::OnLocationChanges( 399 void BrowserAccessibilityManager::OnLocationChanges(
406 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 400 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
407 for (size_t i = 0; i < params.size(); ++i) { 401 for (size_t i = 0; i < params.size(); ++i) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 466 }
473 467
474 // The "scrolled to anchor" notification is a great way to get a 468 // The "scrolled to anchor" notification is a great way to get a
475 // screen reader to jump directly to a specific location in a document. 469 // screen reader to jump directly to a specific location in a document.
476 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node); 470 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node);
477 } 471 }
478 472
479 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus( 473 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus(
480 BrowserAccessibility* focus) { 474 BrowserAccessibility* focus) {
481 if (!focus) 475 if (!focus)
482 return NULL; 476 return nullptr;
483 477
484 int active_descendant_id; 478 int32_t active_descendant_id;
485 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 479 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID,
486 &active_descendant_id)) { 480 &active_descendant_id)) {
487 BrowserAccessibility* active_descendant = 481 BrowserAccessibility* active_descendant =
488 focus->manager()->GetFromID(active_descendant_id); 482 focus->manager()->GetFromID(active_descendant_id);
489 if (active_descendant) 483 if (active_descendant)
490 return active_descendant; 484 return active_descendant;
491 } 485 }
492 return focus; 486 return focus;
493 } 487 }
494 488
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 tree_source(tree_->CreateTreeSource()); 870 tree_source(tree_->CreateTreeSource());
877 ui::AXTreeSerializer<const ui::AXNode*, 871 ui::AXTreeSerializer<const ui::AXNode*,
878 ui::AXNodeData, 872 ui::AXNodeData,
879 ui::AXTreeData> serializer(tree_source.get()); 873 ui::AXTreeData> serializer(tree_source.get());
880 ui::AXTreeUpdate update; 874 ui::AXTreeUpdate update;
881 serializer.SerializeChanges(tree_->root(), &update); 875 serializer.SerializeChanges(tree_->root(), &update);
882 return update; 876 return update;
883 } 877 }
884 878
885 } // namespace content 879 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698