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

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

Issue 681503002: Add Android AX functions to set the value and selection of a text field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@link_text_from_image
Patch Set: Add to supported actions Created 6 years, 1 month 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/renderer/accessibility/renderer_accessibility_complete.h" 5 #include "content/renderer/accessibility/renderer_accessibility_complete.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h"
11 #include "content/renderer/accessibility/blink_ax_enum_conversion.h" 12 #include "content/renderer/accessibility/blink_ax_enum_conversion.h"
12 #include "content/renderer/render_frame_impl.h" 13 #include "content/renderer/render_frame_impl.h"
13 #include "content/renderer/render_view_impl.h" 14 #include "content/renderer/render_view_impl.h"
14 #include "third_party/WebKit/public/web/WebAXObject.h" 15 #include "third_party/WebKit/public/web/WebAXObject.h"
15 #include "third_party/WebKit/public/web/WebDocument.h" 16 #include "third_party/WebKit/public/web/WebDocument.h"
16 #include "third_party/WebKit/public/web/WebFrame.h" 17 #include "third_party/WebKit/public/web/WebFrame.h"
17 #include "third_party/WebKit/public/web/WebInputElement.h" 18 #include "third_party/WebKit/public/web/WebInputElement.h"
18 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
19 #include "third_party/WebKit/public/web/WebNode.h" 20 #include "third_party/WebKit/public/web/WebNode.h"
20 #include "third_party/WebKit/public/web/WebSettings.h" 21 #include "third_party/WebKit/public/web/WebSettings.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction, 74 IPC_MESSAGE_HANDLER(AccessibilityMsg_DoDefaultAction,
74 OnDoDefaultAction) 75 OnDoDefaultAction)
75 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK, 76 IPC_MESSAGE_HANDLER(AccessibilityMsg_Events_ACK,
76 OnEventsAck) 77 OnEventsAck)
77 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible, 78 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToMakeVisible,
78 OnScrollToMakeVisible) 79 OnScrollToMakeVisible)
79 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, 80 IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint,
80 OnScrollToPoint) 81 OnScrollToPoint)
81 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection, 82 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection,
82 OnSetTextSelection) 83 OnSetTextSelection)
84 IPC_MESSAGE_HANDLER(AccessibilityMsg_SetValue, OnSetValue)
83 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest) 85 IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest)
84 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset) 86 IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset)
85 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError) 87 IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError)
86 IPC_MESSAGE_UNHANDLED(handled = false) 88 IPC_MESSAGE_UNHANDLED(handled = false)
87 IPC_END_MESSAGE_MAP() 89 IPC_END_MESSAGE_MAP()
88 return handled; 90 return handled;
89 } 91 }
90 92
91 void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) { 93 void RendererAccessibilityComplete::FocusedNodeChanged(const WebNode& node) {
92 const WebDocument& document = GetMainDocument(); 94 const WebDocument& document = GetMainDocument();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return; 372 return;
371 373
372 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id); 374 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id);
373 if (obj.isDetached()) { 375 if (obj.isDetached()) {
374 #ifndef NDEBUG 376 #ifndef NDEBUG
375 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id; 377 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id;
376 #endif 378 #endif
377 return; 379 return;
378 } 380 }
379 381
380 // TODO(dmazzoni): support elements other than <input>. 382 obj.setSelectedTextRange(start_offset, end_offset);
381 blink::WebNode node = obj.node(); 383 }
382 if (!node.isNull() && node.isElementNode()) { 384
383 blink::WebElement element = node.to<blink::WebElement>(); 385 void RendererAccessibilityComplete::OnSetValue(
384 blink::WebInputElement* input_element = 386 int acc_obj_id, base::string16 value) {
nasko 2014/10/27 17:18:25 Each parameter must be on its own line.
dmazzoni 2014/11/04 23:22:53 Done.
385 blink::toWebInputElement(&element); 387 const WebDocument& document = GetMainDocument();
386 if (input_element && input_element->isTextField()) 388 if (document.isNull())
387 input_element->setSelectionRange(start_offset, end_offset); 389 return;
390
391 WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id);
392 if (obj.isDetached()) {
393 #ifndef NDEBUG
394 LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id;
395 #endif
396 return;
388 } 397 }
398
399 obj.setValue(value);
389 } 400 }
390 401
391 void RendererAccessibilityComplete::OnHitTest(gfx::Point point) { 402 void RendererAccessibilityComplete::OnHitTest(gfx::Point point) {
392 const WebDocument& document = GetMainDocument(); 403 const WebDocument& document = GetMainDocument();
393 if (document.isNull()) 404 if (document.isNull())
394 return; 405 return;
395 WebAXObject root_obj = document.accessibilityObject(); 406 WebAXObject root_obj = document.accessibilityObject();
396 if (!root_obj.updateBackingStoreAndCheckValidity()) 407 if (!root_obj.updateBackingStoreAndCheckValidity())
397 return; 408 return;
398 409
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 const WebDocument& document = GetMainDocument(); 456 const WebDocument& document = GetMainDocument();
446 if (!document.isNull()) 457 if (!document.isNull())
447 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE); 458 HandleAXEvent(document.accessibilityObject(), ui::AX_EVENT_LAYOUT_COMPLETE);
448 } 459 }
449 460
450 void RendererAccessibilityComplete::OnFatalError() { 461 void RendererAccessibilityComplete::OnFatalError() {
451 CHECK(false) << "Invalid accessibility tree."; 462 CHECK(false) << "Invalid accessibility tree.";
452 } 463 }
453 464
454 } // namespace content 465 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698