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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/accessibility/renderer_accessibility_complete.cc
diff --git a/content/renderer/accessibility/renderer_accessibility_complete.cc b/content/renderer/accessibility/renderer_accessibility_complete.cc
index 28536b03649a14acd8ad1699150069d160bcf8b6..8cab05a1bfeb62dda8bde452b6d7f418e31fe838 100644
--- a/content/renderer/accessibility/renderer_accessibility_complete.cc
+++ b/content/renderer/accessibility/renderer_accessibility_complete.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/strings/utf_string_conversions.h"
#include "content/renderer/accessibility/blink_ax_enum_conversion.h"
#include "content/renderer/render_frame_impl.h"
#include "content/renderer/render_view_impl.h"
@@ -80,6 +81,7 @@ bool RendererAccessibilityComplete::OnMessageReceived(
OnScrollToPoint)
IPC_MESSAGE_HANDLER(AccessibilityMsg_SetTextSelection,
OnSetTextSelection)
+ IPC_MESSAGE_HANDLER(AccessibilityMsg_SetValue, OnSetValue)
IPC_MESSAGE_HANDLER(AccessibilityMsg_HitTest, OnHitTest)
IPC_MESSAGE_HANDLER(AccessibilityMsg_Reset, OnReset)
IPC_MESSAGE_HANDLER(AccessibilityMsg_FatalError, OnFatalError)
@@ -377,15 +379,24 @@ void RendererAccessibilityComplete::OnSetTextSelection(
return;
}
- // TODO(dmazzoni): support elements other than <input>.
- blink::WebNode node = obj.node();
- if (!node.isNull() && node.isElementNode()) {
- blink::WebElement element = node.to<blink::WebElement>();
- blink::WebInputElement* input_element =
- blink::toWebInputElement(&element);
- if (input_element && input_element->isTextField())
- input_element->setSelectionRange(start_offset, end_offset);
+ obj.setSelectedTextRange(start_offset, end_offset);
+}
+
+void RendererAccessibilityComplete::OnSetValue(
+ 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.
+ const WebDocument& document = GetMainDocument();
+ if (document.isNull())
+ return;
+
+ WebAXObject obj = document.accessibilityObjectFromID(acc_obj_id);
+ if (obj.isDetached()) {
+#ifndef NDEBUG
+ LOG(WARNING) << "SetTextSelection on invalid object id " << acc_obj_id;
+#endif
+ return;
}
+
+ obj.setValue(value);
}
void RendererAccessibilityComplete::OnHitTest(gfx::Point point) {

Powered by Google App Engine
This is Rietveld 408576698