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

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: Removed extraneous focus events. 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 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
388 bool is_menu_list_option = 389 // We already handled all focus events above.
389 node->data().role == ui::AX_ROLE_MENU_LIST_OPTION; 390 continue;
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 } 391 }
398 392
399 // Fire the native event. 393 // Fire the native event.
400 NotifyAccessibilityEvent(event_type, GetFromAXNode(node)); 394 NotifyAccessibilityEvent(event_type, GetFromAXNode(node));
401 } 395 }
402 } 396 }
403 397
404 void BrowserAccessibilityManager::OnLocationChanges( 398 void BrowserAccessibilityManager::OnLocationChanges(
405 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { 399 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) {
406 for (size_t i = 0; i < params.size(); ++i) { 400 for (size_t i = 0; i < params.size(); ++i) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 } 465 }
472 466
473 // The "scrolled to anchor" notification is a great way to get a 467 // 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. 468 // screen reader to jump directly to a specific location in a document.
475 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node); 469 NotifyAccessibilityEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node);
476 } 470 }
477 471
478 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus( 472 BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendantFocus(
479 BrowserAccessibility* focus) { 473 BrowserAccessibility* focus) {
480 if (!focus) 474 if (!focus)
481 return NULL; 475 return nullptr;
482 476
483 int active_descendant_id; 477 int32_t active_descendant_id;
484 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 478 if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID,
485 &active_descendant_id)) { 479 &active_descendant_id)) {
486 BrowserAccessibility* active_descendant = 480 BrowserAccessibility* active_descendant =
487 focus->manager()->GetFromID(active_descendant_id); 481 focus->manager()->GetFromID(active_descendant_id);
488 if (active_descendant) 482 if (active_descendant)
489 return active_descendant; 483 return active_descendant;
490 } 484 }
491 return focus; 485 return focus;
492 } 486 }
493 487
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 tree_source(tree_->CreateTreeSource()); 869 tree_source(tree_->CreateTreeSource());
876 ui::AXTreeSerializer<const ui::AXNode*, 870 ui::AXTreeSerializer<const ui::AXNode*,
877 ui::AXNodeData, 871 ui::AXNodeData,
878 ui::AXTreeData> serializer(tree_source.get()); 872 ui::AXTreeData> serializer(tree_source.get());
879 ui::AXTreeUpdate update; 873 ui::AXTreeUpdate update;
880 serializer.SerializeChanges(tree_->root(), &update); 874 serializer.SerializeChanges(tree_->root(), &update);
881 return update; 875 return update;
882 } 876 }
883 877
884 } // namespace content 878 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698