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

Side by Side Diff: content/renderer/accessibility/renderer_accessibility.cc

Issue 1365433002: Add setSelection function to automation API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nobrailleautostartintests
Patch Set: Change setDocumentSelection to take named arguments. Created 5 years, 2 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
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/accessibility/renderer_accessibility.h" 5 #include "content/renderer/accessibility/renderer_accessibility.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool RendererAccessibility::OnMessageReceived(const IPC::Message& message) { 95 bool RendererAccessibility::OnMessageReceived(const IPC::Message& message) {
96 bool handled = true; 96 bool handled = true;
97 IPC_BEGIN_MESSAGE_MAP(RendererAccessibility, message) 97 IPC_BEGIN_MESSAGE_MAP(RendererAccessibility, message)
98 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetFocus, OnSetFocus) 98 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetFocus, OnSetFocus)
99 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction, OnDoDefaultAction) 99 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction, OnDoDefaultAction)
100 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, OnEventsAck) 100 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, OnEventsAck)
101 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, 101 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible,
102 OnScrollToMakeVisible) 102 OnScrollToMakeVisible)
103 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, OnScrollToPoint) 103 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, OnScrollToPoint)
104 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetScrollOffset, OnSetScrollOffset) 104 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetScrollOffset, OnSetScrollOffset)
105 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, OnSetTextSelection) 105 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetSelection, OnSetSelection)
106 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetValue, OnSetValue) 106 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetValue, OnSetValue)
107 IPC_MESSAGE_HANDLER(AccessibilityMsg_ShowContextMenu, OnShowContextMenu) 107 IPC_MESSAGE_HANDLER(AccessibilityMsg_ShowContextMenu, OnShowContextMenu)
108 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) 108 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest)
109 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetAccessibilityFocus, 109 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetAccessibilityFocus,
110 OnSetAccessibilityFocus) 110 OnSetAccessibilityFocus)
111 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset) 111 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset)
112 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) 112 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError)
113 IPC_MESSAGE_UNHANDLED(handled = false) 113 IPC_MESSAGE_UNHANDLED(handled = false)
114 IPC_END_MESSAGE_MAP() 114 IPC_END_MESSAGE_MAP()
115 return handled; 115 return handled;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 496
497 // By convention, calling SetFocus on the root of the tree should clear the 497 // By convention, calling SetFocus on the root of the tree should clear the
498 // current focus. Otherwise set the focus to the new node. 498 // current focus. Otherwise set the focus to the new node.
499 if (acc_obj_id == root.axID()) 499 if (acc_obj_id == root.axID())
500 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement(); 500 render_frame_->GetRenderView()->GetWebView()->clearFocusedElement();
501 else 501 else
502 obj.setFocused(true); 502 obj.setFocused(true);
503 } 503 }
504 504
505 void RendererAccessibility::OnSetTextSelection( 505 void RendererAccessibility::OnSetSelection(int anchor_acc_obj_id,
506 int acc_obj_id, int start_offset, int end_offset) { 506 int anchor_offset,
507 int focus_acc_obj_id,
508 int focus_offset) {
507 const WebDocument& document = GetMainDocument(); 509 const WebDocument& document = GetMainDocument();
508 if (document.isNull()) 510 if (document.isNull())
509 return; 511 return;
510 512
511 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id); 513 WebAXObject anchor_obj =
512 if (obj.isDetached()) { 514 document.accessibilityObjectFromID(anchor_acc_obj_id);
515 if (anchor_obj.isDetached()) {
513 #ifndef NDEBUG 516 #ifndef NDEBUG
514 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id; 517 LOG(WARNING) << "SetTextSelection on invalid object id "
518 << anchor_acc_obj_id;
515 #endif 519 #endif
516 return; 520 return;
517 } 521 }
518 522
519 obj.setSelectedTextRange(start_offset, end_offset); 523 WebAXObject focus_obj = document.accessibilityObjectFromID(focus_acc_obj_id);
524 if (focus_obj.isDetached()) {
525 #ifndef NDEBUG
526 LOG(WARNING) << "SetTextSelection on invalid object id "
527 << focus_acc_obj_id;
528 #endif
529 return;
530 }
531
532 anchor_obj.setSelection(anchor_obj, anchor_offset, focus_obj, focus_offset);
520 WebAXObject root = document.accessibilityObject(); 533 WebAXObject root = document.accessibilityObject();
521 if (root.isDetached()) { 534 if (root.isDetached()) {
522 #ifndef NDEBUG 535 #ifndef NDEBUG
523 LOG(WARNING) << "OnSetAccessibilityFocus but root is invalid"; 536 LOG(WARNING) << "OnSetAccessibilityFocus but root is invalid";
524 #endif 537 #endif
525 return; 538 return;
526 } 539 }
527 HandleAXEvent(root, ui::AX_EVENT_LAYOUT_COMPLETE); 540 HandleAXEvent(root, ui::AX_EVENT_LAYOUT_COMPLETE);
528 } 541 }
529 542
(...skipping 26 matching lines...) Expand all
556 #ifndef NDEBUG 569 #ifndef NDEBUG
557 LOG(WARNING) << "ShowContextMenu on invalid object id " << acc_obj_id; 570 LOG(WARNING) << "ShowContextMenu on invalid object id " << acc_obj_id;
558 #endif 571 #endif
559 return; 572 return;
560 } 573 }
561 574
562 obj.showContextMenu(); 575 obj.showContextMenu();
563 } 576 }
564 577
565 } // namespace content 578 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698