OLD | NEW |
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent( | 246 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent( |
247 env, obj, info, node->GetParent()->GetId()); | 247 env, obj, info, node->GetParent()->GetId()); |
248 } | 248 } |
249 for (unsigned i = 0; i < node->PlatformChildCount(); ++i) { | 249 for (unsigned i = 0; i < node->PlatformChildCount(); ++i) { |
250 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( | 250 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( |
251 env, obj, info, node->InternalGetChild(i)->GetId()); | 251 env, obj, info, node->InternalGetChild(i)->GetId()); |
252 } | 252 } |
253 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes( | 253 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes( |
254 env, obj, info, | 254 env, obj, info, |
255 id, | 255 id, |
256 node->CanScrollForward(), | |
257 node->CanScrollBackward(), | |
258 node->IsCheckable(), | 256 node->IsCheckable(), |
259 node->IsChecked(), | 257 node->IsChecked(), |
260 node->IsClickable(), | 258 node->IsClickable(), |
261 node->IsEditableText(), | |
262 node->IsEnabled(), | 259 node->IsEnabled(), |
263 node->IsFocusable(), | 260 node->IsFocusable(), |
264 node->IsFocused(), | 261 node->IsFocused(), |
265 node->IsPassword(), | 262 node->IsPassword(), |
266 node->IsScrollable(), | 263 node->IsScrollable(), |
267 node->IsSelected(), | 264 node->IsSelected(), |
268 node->IsVisibleToUser()); | 265 node->IsVisibleToUser()); |
| 266 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoActions( |
| 267 env, obj, info, |
| 268 id, |
| 269 node->CanScrollForward(), |
| 270 node->CanScrollBackward(), |
| 271 node->IsClickable(), |
| 272 node->IsEditableText(), |
| 273 node->IsEnabled(), |
| 274 node->IsFocusable(), |
| 275 node->IsFocused()); |
269 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName( | 276 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoClassName( |
270 env, obj, info, | 277 env, obj, info, |
271 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj()); | 278 base::android::ConvertUTF8ToJavaString(env, node->GetClassName()).obj()); |
272 if (!node->IsPassword() || | 279 if (!node->IsPassword() || |
273 Java_BrowserAccessibilityManager_shouldExposePasswordText(env, obj)) { | 280 Java_BrowserAccessibilityManager_shouldExposePasswordText(env, obj)) { |
274 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoContentDescription( | 281 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoContentDescription( |
275 env, obj, info, | 282 env, obj, info, |
276 base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj(), | 283 base::android::ConvertUTF16ToJavaString(env, node->GetText()).obj(), |
277 node->IsLink()); | 284 node->IsLink()); |
278 } | 285 } |
279 | 286 |
280 gfx::Rect absolute_rect = node->GetLocalBoundsRect(); | 287 gfx::Rect absolute_rect = node->GetLocalBoundsRect(); |
281 gfx::Rect parent_relative_rect = absolute_rect; | 288 gfx::Rect parent_relative_rect = absolute_rect; |
282 if (node->GetParent()) { | 289 if (node->GetParent()) { |
283 gfx::Rect parent_rect = node->GetParent()->GetLocalBoundsRect(); | 290 gfx::Rect parent_rect = node->GetParent()->GetLocalBoundsRect(); |
284 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); | 291 parent_relative_rect.Offset(-parent_rect.OffsetFromOrigin()); |
285 } | 292 } |
286 bool is_root = node->GetParent() == NULL; | 293 bool is_root = node->GetParent() == NULL; |
287 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( | 294 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( |
288 env, obj, info, | 295 env, obj, info, |
289 id, | 296 id, |
290 absolute_rect.x(), absolute_rect.y(), | 297 absolute_rect.x(), absolute_rect.y(), |
291 parent_relative_rect.x(), parent_relative_rect.y(), | 298 parent_relative_rect.x(), parent_relative_rect.y(), |
292 absolute_rect.width(), absolute_rect.height(), | 299 absolute_rect.width(), absolute_rect.height(), |
293 is_root); | 300 is_root); |
294 | 301 |
295 // New KitKat APIs | 302 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLollipopAttributes( |
296 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes( | |
297 env, obj, info, | 303 env, obj, info, |
298 node->CanOpenPopup(), | 304 node->CanOpenPopup(), |
299 node->IsContentInvalid(), | 305 node->IsContentInvalid(), |
300 node->IsDismissable(), | 306 node->IsDismissable(), |
301 node->IsMultiLine(), | 307 node->IsMultiLine(), |
302 node->AndroidInputType(), | 308 node->AndroidInputType(), |
303 node->AndroidLiveRegionType()); | 309 node->AndroidLiveRegionType()); |
304 if (node->IsCollection()) { | 310 if (node->IsCollection()) { |
305 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoCollectionInfo( | 311 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoCollectionInfo( |
306 env, obj, info, | 312 env, obj, info, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 node->GetSelectionStart(), | 391 node->GetSelectionStart(), |
386 node->GetSelectionEnd(), | 392 node->GetSelectionEnd(), |
387 node->GetEditableTextLength(), | 393 node->GetEditableTextLength(), |
388 base::android::ConvertUTF16ToJavaString(env, text).obj()); | 394 base::android::ConvertUTF16ToJavaString(env, text).obj()); |
389 break; | 395 break; |
390 } | 396 } |
391 default: | 397 default: |
392 break; | 398 break; |
393 } | 399 } |
394 | 400 |
395 // Backwards-compatible fallback for new KitKat APIs. | 401 Java_BrowserAccessibilityManager_setAccessibilityEventLollipopAttributes( |
396 Java_BrowserAccessibilityManager_setAccessibilityEventKitKatAttributes( | |
397 env, obj, event, | 402 env, obj, event, |
398 node->CanOpenPopup(), | 403 node->CanOpenPopup(), |
399 node->IsContentInvalid(), | 404 node->IsContentInvalid(), |
400 node->IsDismissable(), | 405 node->IsDismissable(), |
401 node->IsMultiLine(), | 406 node->IsMultiLine(), |
402 node->AndroidInputType(), | 407 node->AndroidInputType(), |
403 node->AndroidLiveRegionType()); | 408 node->AndroidLiveRegionType()); |
404 if (node->IsCollection()) { | 409 if (node->IsCollection()) { |
405 Java_BrowserAccessibilityManager_setAccessibilityEventCollectionInfo( | 410 Java_BrowserAccessibilityManager_setAccessibilityEventCollectionInfo( |
406 env, obj, event, | 411 env, obj, event, |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { | 745 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { |
741 // The Java layer handles the root scroll offset. | 746 // The Java layer handles the root scroll offset. |
742 return false; | 747 return false; |
743 } | 748 } |
744 | 749 |
745 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { | 750 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { |
746 return RegisterNativesImpl(env); | 751 return RegisterNativesImpl(env); |
747 } | 752 } |
748 | 753 |
749 } // namespace content | 754 } // namespace content |
OLD | NEW |