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

Unified Diff: content/renderer/accessibility/renderer_accessibility.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: Fix compile 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/accessibility/renderer_accessibility.cc
diff --git a/content/renderer/accessibility/renderer_accessibility.cc b/content/renderer/accessibility/renderer_accessibility.cc
index 18fb07f1c3cdf35d4ee8333356379c7a43eecfae..e8da448b84628e8daf4fb045281531d56580bf18 100644
--- a/content/renderer/accessibility/renderer_accessibility.cc
+++ b/content/renderer/accessibility/renderer_accessibility.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"
@@ -71,6 +72,7 @@ bool RendererAccessibility::OnMessageReceived(const IPC::Message& message) {
OnScrollToMakeVisible)
IPC_MESSAGE_HANDLER(AccessibilityMsg_ScrollToPoint, 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)
@@ -425,15 +427,25 @@ void RendererAccessibility::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 RendererAccessibility::OnSetValue(
+ int acc_obj_id,
+ base::string16 value) {
+ 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);
}
} // namespace content
« 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