| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 BrowserAccessibilityAndroid* android_node = | 192 BrowserAccessibilityAndroid* android_node = |
| 193 static_cast<BrowserAccessibilityAndroid*>(node); | 193 static_cast<BrowserAccessibilityAndroid*>(node); |
| 194 | 194 |
| 195 if (event_type == ui::AX_EVENT_HIDE) | 195 if (event_type == ui::AX_EVENT_HIDE) |
| 196 return; | 196 return; |
| 197 | 197 |
| 198 if (event_type == ui::AX_EVENT_TREE_CHANGED) | 198 if (event_type == ui::AX_EVENT_TREE_CHANGED) |
| 199 return; | 199 return; |
| 200 | 200 |
| 201 // Layout changes are handled in OnLocationChanges. | 201 // Layout changes are handled in OnLocationChanges and |
| 202 // SendLocationChangeEvents. |
| 202 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE) | 203 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE) |
| 203 return; | 204 return; |
| 204 | 205 |
| 205 if (event_type == ui::AX_EVENT_HOVER) { | 206 if (event_type == ui::AX_EVENT_HOVER) { |
| 206 HandleHoverEvent(node); | 207 HandleHoverEvent(node); |
| 207 return; | 208 return; |
| 208 } | 209 } |
| 209 | 210 |
| 210 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify | 211 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify |
| 211 // the Android system that the accessibility hierarchy rooted at this | 212 // the Android system that the accessibility hierarchy rooted at this |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 env, obj.obj(), node->unique_id()); | 265 env, obj.obj(), node->unique_id()); |
| 265 } | 266 } |
| 266 break; | 267 break; |
| 267 default: | 268 default: |
| 268 // There are some notifications that aren't meaningful on Android. | 269 // There are some notifications that aren't meaningful on Android. |
| 269 // It's okay to skip them. | 270 // It's okay to skip them. |
| 270 break; | 271 break; |
| 271 } | 272 } |
| 272 } | 273 } |
| 273 | 274 |
| 274 void BrowserAccessibilityManagerAndroid::OnLocationChanges( | 275 void BrowserAccessibilityManagerAndroid::SendLocationChangeEvents( |
| 275 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { | 276 const std::vector<AccessibilityHostMsg_LocationChangeParams>& params) { |
| 276 // Android is not very efficient at handling notifications, and location | 277 // Android is not very efficient at handling notifications, and location |
| 277 // changes in particular are frequent and not time-critical. If a lot of | 278 // changes in particular are frequent and not time-critical. If a lot of |
| 278 // nodes changed location, just send a single notification after a short | 279 // nodes changed location, just send a single notification after a short |
| 279 // delay (to batch them), rather than lots of individual notifications. | 280 // delay (to batch them), rather than lots of individual notifications. |
| 280 if (params.size() > 3) { | 281 if (params.size() > 3) { |
| 281 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); | 282 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); |
| 282 JNIEnv* env = AttachCurrentThread(); | 283 JNIEnv* env = AttachCurrentThread(); |
| 283 if (obj.is_null()) | 284 if (obj.is_null()) |
| 284 return; | 285 return; |
| 285 Java_BrowserAccessibilityManager_sendDelayedWindowContentChangedEvent( | 286 Java_BrowserAccessibilityManager_sendDelayedWindowContentChangedEvent( |
| 286 env, obj.obj()); | 287 env, obj.obj()); |
| 287 return; | 288 return; |
| 288 } | 289 } |
| 289 | 290 |
| 290 BrowserAccessibilityManager::OnLocationChanges(params); | 291 BrowserAccessibilityManager::SendLocationChangeEvents(params); |
| 291 } | 292 } |
| 292 | 293 |
| 293 base::android::ScopedJavaLocalRef<jstring> | 294 base::android::ScopedJavaLocalRef<jstring> |
| 294 BrowserAccessibilityManagerAndroid::GetSupportedHtmlElementTypes( | 295 BrowserAccessibilityManagerAndroid::GetSupportedHtmlElementTypes( |
| 295 JNIEnv* env, | 296 JNIEnv* env, |
| 296 const JavaParamRef<jobject>& obj) { | 297 const JavaParamRef<jobject>& obj) { |
| 297 InitSearchKeyToPredicateMapIfNeeded(); | 298 InitSearchKeyToPredicateMapIfNeeded(); |
| 298 return base::android::ConvertUTF16ToJavaString(env, g_all_search_keys.Get()); | 299 return base::android::ConvertUTF16ToJavaString(env, g_all_search_keys.Get()); |
| 299 } | 300 } |
| 300 | 301 |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 944 |
| 944 JNIEnv* env = AttachCurrentThread(); | 945 JNIEnv* env = AttachCurrentThread(); |
| 945 return root_manager->java_ref().get(env); | 946 return root_manager->java_ref().get(env); |
| 946 } | 947 } |
| 947 | 948 |
| 948 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { | 949 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { |
| 949 return RegisterNativesImpl(env); | 950 return RegisterNativesImpl(env); |
| 950 } | 951 } |
| 951 | 952 |
| 952 } // namespace content | 953 } // namespace content |
| OLD | NEW |