| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (content_view_core.is_null()) | 204 if (content_view_core.is_null()) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 JNIEnv* env = AttachCurrentThread(); | 207 JNIEnv* env = AttachCurrentThread(); |
| 208 java_ref_ = JavaObjectWeakGlobalRef( | 208 java_ref_ = JavaObjectWeakGlobalRef( |
| 209 env, Java_BrowserAccessibilityManager_create( | 209 env, Java_BrowserAccessibilityManager_create( |
| 210 env, reinterpret_cast<intptr_t>(this), content_view_core) | 210 env, reinterpret_cast<intptr_t>(this), content_view_core) |
| 211 .obj()); | 211 .obj()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 bool BrowserAccessibilityManagerAndroid::ShouldRespectDisplayedPasswordText() { |
| 215 JNIEnv* env = AttachCurrentThread(); |
| 216 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); |
| 217 if (obj.is_null()) |
| 218 return false; |
| 219 |
| 220 return Java_BrowserAccessibilityManager_shouldRespectDisplayedPasswordText( |
| 221 env, obj); |
| 222 } |
| 223 |
| 214 bool BrowserAccessibilityManagerAndroid::ShouldExposePasswordText() { | 224 bool BrowserAccessibilityManagerAndroid::ShouldExposePasswordText() { |
| 215 JNIEnv* env = AttachCurrentThread(); | 225 JNIEnv* env = AttachCurrentThread(); |
| 216 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); | 226 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); |
| 217 if (obj.is_null()) | 227 if (obj.is_null()) |
| 218 return false; | 228 return false; |
| 219 | 229 |
| 220 return Java_BrowserAccessibilityManager_shouldExposePasswordText(env, obj); | 230 return Java_BrowserAccessibilityManager_shouldExposePasswordText(env, obj); |
| 221 } | 231 } |
| 222 | 232 |
| 223 BrowserAccessibility* BrowserAccessibilityManagerAndroid::GetFocus() { | 233 BrowserAccessibility* BrowserAccessibilityManagerAndroid::GetFocus() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 246 return; | 256 return; |
| 247 | 257 |
| 248 if (event_type == ui::AX_EVENT_HOVER) { | 258 if (event_type == ui::AX_EVENT_HOVER) { |
| 249 HandleHoverEvent(node); | 259 HandleHoverEvent(node); |
| 250 return; | 260 return; |
| 251 } | 261 } |
| 252 | 262 |
| 253 // Sometimes we get events on nodes in our internal accessibility tree | 263 // Sometimes we get events on nodes in our internal accessibility tree |
| 254 // that aren't exposed on Android. Update |node| to point to the highest | 264 // that aren't exposed on Android. Update |node| to point to the highest |
| 255 // ancestor that's a leaf node. | 265 // ancestor that's a leaf node. |
| 266 BrowserAccessibility* original_node = node; |
| 256 node = node->GetClosestPlatformObject(); | 267 node = node->GetClosestPlatformObject(); |
| 268 BrowserAccessibilityAndroid* android_node = |
| 269 static_cast<BrowserAccessibilityAndroid*>(node); |
| 270 |
| 271 // If the closest platform object is a password field, the event we're |
| 272 // getting is doing something in the shadow dom, for example replacing a |
| 273 // character with a dot after a short pause. On Android we don't want to |
| 274 // fire an event for those changes, but we do want to make sure our internal |
| 275 // state is correct, so we call OnDataChanged() and then return. |
| 276 if (android_node->IsPassword() && original_node != node) { |
| 277 android_node->OnDataChanged(); |
| 278 return; |
| 279 } |
| 257 | 280 |
| 258 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify | 281 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify |
| 259 // the Android system that the accessibility hierarchy rooted at this | 282 // the Android system that the accessibility hierarchy rooted at this |
| 260 // node has changed. | 283 // node has changed. |
| 261 Java_BrowserAccessibilityManager_handleContentChanged(env, obj, | 284 Java_BrowserAccessibilityManager_handleContentChanged(env, obj, |
| 262 node->unique_id()); | 285 node->unique_id()); |
| 263 | 286 |
| 264 // Ignore load complete events on iframes. | 287 // Ignore load complete events on iframes. |
| 265 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && | 288 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && |
| 266 node->manager() != GetRootManager()) { | 289 node->manager() != GetRootManager()) { |
| 267 return; | 290 return; |
| 268 } | 291 } |
| 269 | 292 |
| 270 BrowserAccessibilityAndroid* android_node = | |
| 271 static_cast<BrowserAccessibilityAndroid*>(node); | |
| 272 switch (event_type) { | 293 switch (event_type) { |
| 273 case ui::AX_EVENT_LOAD_COMPLETE: | 294 case ui::AX_EVENT_LOAD_COMPLETE: |
| 274 Java_BrowserAccessibilityManager_handlePageLoaded( | 295 Java_BrowserAccessibilityManager_handlePageLoaded( |
| 275 env, obj, GetFocus()->unique_id()); | 296 env, obj, GetFocus()->unique_id()); |
| 276 break; | 297 break; |
| 277 case ui::AX_EVENT_FOCUS: | 298 case ui::AX_EVENT_FOCUS: |
| 278 Java_BrowserAccessibilityManager_handleFocusChanged(env, obj, | 299 Java_BrowserAccessibilityManager_handleFocusChanged(env, obj, |
| 279 node->unique_id()); | 300 node->unique_id()); |
| 280 break; | 301 break; |
| 281 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 302 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( | 513 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLocation( |
| 493 env, obj, info, | 514 env, obj, info, |
| 494 id, | 515 id, |
| 495 absolute_rect.x(), absolute_rect.y(), | 516 absolute_rect.x(), absolute_rect.y(), |
| 496 parent_relative_rect.x(), parent_relative_rect.y(), | 517 parent_relative_rect.x(), parent_relative_rect.y(), |
| 497 absolute_rect.width(), absolute_rect.height(), | 518 absolute_rect.width(), absolute_rect.height(), |
| 498 is_root); | 519 is_root); |
| 499 | 520 |
| 500 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes( | 521 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoKitKatAttributes( |
| 501 env, obj, info, is_root, node->IsEditableText(), | 522 env, obj, info, is_root, node->IsEditableText(), |
| 502 base::android::ConvertUTF16ToJavaString(env, node->GetRoleDescription())); | 523 base::android::ConvertUTF16ToJavaString(env, node->GetRoleDescription()), |
| 524 node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START), |
| 525 node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END)); |
| 503 | 526 |
| 504 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLollipopAttributes( | 527 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoLollipopAttributes( |
| 505 env, obj, info, | 528 env, obj, info, |
| 506 node->CanOpenPopup(), | 529 node->CanOpenPopup(), |
| 507 node->IsContentInvalid(), | 530 node->IsContentInvalid(), |
| 508 node->IsDismissable(), | 531 node->IsDismissable(), |
| 509 node->IsMultiLine(), | 532 node->IsMultiLine(), |
| 510 node->AndroidInputType(), | 533 node->AndroidInputType(), |
| 511 node->AndroidLiveRegionType()); | 534 node->AndroidLiveRegionType()); |
| 512 if (node->IsCollection()) { | 535 if (node->IsCollection()) { |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 | 1103 |
| 1081 JNIEnv* env = AttachCurrentThread(); | 1104 JNIEnv* env = AttachCurrentThread(); |
| 1082 return root_manager->java_ref().get(env); | 1105 return root_manager->java_ref().get(env); |
| 1083 } | 1106 } |
| 1084 | 1107 |
| 1085 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { | 1108 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { |
| 1086 return RegisterNativesImpl(env); | 1109 return RegisterNativesImpl(env); |
| 1087 } | 1110 } |
| 1088 | 1111 |
| 1089 } // namespace content | 1112 } // namespace content |
| OLD | NEW |