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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_android.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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 for (unsigned i = 0; i < node->PlatformChildCount(); ++i) { 217 for (unsigned i = 0; i < node->PlatformChildCount(); ++i) {
218 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( 218 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild(
219 env, obj, info, node->InternalGetChild(i)->GetId()); 219 env, obj, info, node->InternalGetChild(i)->GetId());
220 } 220 }
221 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes( 221 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes(
222 env, obj, info, 222 env, obj, info,
223 id, 223 id,
224 node->IsCheckable(), 224 node->IsCheckable(),
225 node->IsChecked(), 225 node->IsChecked(),
226 node->IsClickable(), 226 node->IsClickable(),
227 node->IsEditableText(),
227 node->IsEnabled(), 228 node->IsEnabled(),
228 node->IsFocusable(), 229 node->IsFocusable(),
229 node->IsFocused(), 230 node->IsFocused(),
230 node->IsPassword(), 231 node->IsPassword(),
231 node->IsScrollable(), 232 node->IsScrollable(),
232 node->IsSelected(), 233 node->IsSelected(),
233 node->IsVisibleToUser()); 234 node->IsVisibleToUser());
234 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName( 235 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName(
235 env, obj, info, 236 env, obj, info,
236 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj()); 237 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 SetFocus(GetRoot(), true); 400 SetFocus(GetRoot(), true);
400 } 401 }
401 402
402 void BrowserAccessibilityManagerAndroid::ScrollToMakeNodeVisible( 403 void BrowserAccessibilityManagerAndroid::ScrollToMakeNodeVisible(
403 JNIEnv* env, jobject obj, jint id) { 404 JNIEnv* env, jobject obj, jint id) {
404 BrowserAccessibility* node = GetFromID(id); 405 BrowserAccessibility* node = GetFromID(id);
405 if (node) 406 if (node)
406 ScrollToMakeVisible(*node, gfx::Rect(node->GetLocation().size())); 407 ScrollToMakeVisible(*node, gfx::Rect(node->GetLocation().size()));
407 } 408 }
408 409
410 void BrowserAccessibilityManagerAndroid::SetTextFieldValue(
411 JNIEnv* env, jobject obj, jint id, jstring value) {
412 BrowserAccessibility* node = GetFromID(id);
413 if (node) {
414 BrowserAccessibilityManager::SetValue(
415 *node, base::android::ConvertJavaStringToUTF16(env, value));
416 }
417 }
418
419 void BrowserAccessibilityManagerAndroid::SetSelection(
420 JNIEnv* env, jobject obj, jint id, jint start, jint end) {
421 BrowserAccessibility* node = GetFromID(id);
422 if (node)
423 SetTextSelection(*node, start, end);
424 }
425
409 void BrowserAccessibilityManagerAndroid::HandleHoverEvent( 426 void BrowserAccessibilityManagerAndroid::HandleHoverEvent(
410 BrowserAccessibility* node) { 427 BrowserAccessibility* node) {
411 JNIEnv* env = AttachCurrentThread(); 428 JNIEnv* env = AttachCurrentThread();
412 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 429 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
413 if (obj.is_null()) 430 if (obj.is_null())
414 return; 431 return;
415 432
416 BrowserAccessibilityAndroid* ancestor = 433 BrowserAccessibilityAndroid* ancestor =
417 static_cast<BrowserAccessibilityAndroid*>(node->GetParent()); 434 static_cast<BrowserAccessibilityAndroid*>(node->GetParent());
418 while (ancestor && ancestor != GetRoot()) { 435 while (ancestor && ancestor != GetRoot()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { 516 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() {
500 // The Java layer handles the root scroll offset. 517 // The Java layer handles the root scroll offset.
501 return false; 518 return false;
502 } 519 }
503 520
504 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { 521 bool RegisterBrowserAccessibilityManager(JNIEnv* env) {
505 return RegisterNativesImpl(env); 522 return RegisterNativesImpl(env);
506 } 523 }
507 524
508 } // namespace content 525 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698