| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( | 200 void BrowserAccessibilityManagerAndroid::NotifyAccessibilityEvent( |
| 201 BrowserAccessibilityEvent::Source source, | 201 BrowserAccessibilityEvent::Source source, |
| 202 ui::AXEvent event_type, | 202 ui::AXEvent event_type, |
| 203 BrowserAccessibility* node) { | 203 BrowserAccessibility* node) { |
| 204 JNIEnv* env = AttachCurrentThread(); | 204 JNIEnv* env = AttachCurrentThread(); |
| 205 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); | 205 ScopedJavaLocalRef<jobject> obj = GetJavaRefFromRootManager(); |
| 206 if (obj.is_null()) | 206 if (obj.is_null()) |
| 207 return; | 207 return; |
| 208 | 208 |
| 209 BrowserAccessibilityAndroid* android_node = | |
| 210 static_cast<BrowserAccessibilityAndroid*>(node); | |
| 211 | |
| 212 if (event_type == ui::AX_EVENT_HIDE) | 209 if (event_type == ui::AX_EVENT_HIDE) |
| 213 return; | 210 return; |
| 214 | 211 |
| 215 if (event_type == ui::AX_EVENT_TREE_CHANGED) | 212 if (event_type == ui::AX_EVENT_TREE_CHANGED) |
| 216 return; | 213 return; |
| 217 | 214 |
| 218 // Layout changes are handled in OnLocationChanges and | 215 // Layout changes are handled in OnLocationChanges and |
| 219 // SendLocationChangeEvents. | 216 // SendLocationChangeEvents. |
| 220 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE) | 217 if (event_type == ui::AX_EVENT_LAYOUT_COMPLETE) |
| 221 return; | 218 return; |
| 222 | 219 |
| 223 if (event_type == ui::AX_EVENT_HOVER) { | 220 if (event_type == ui::AX_EVENT_HOVER) { |
| 224 HandleHoverEvent(node); | 221 HandleHoverEvent(node); |
| 225 return; | 222 return; |
| 226 } | 223 } |
| 227 | 224 |
| 225 // Sometimes we get events on nodes in our internal accessibility tree |
| 226 // that aren't exposed on Android. Walk up the ancestors and update |node| |
| 227 // to point to the highest ancestor that's a leaf node. |
| 228 BrowserAccessibility* parent = node->GetParent(); |
| 229 while (parent) { |
| 230 if (parent->PlatformChildCount() == 0) |
| 231 node = parent; |
| 232 parent = parent->GetParent(); |
| 233 } |
| 234 |
| 228 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify | 235 // Always send AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED to notify |
| 229 // the Android system that the accessibility hierarchy rooted at this | 236 // the Android system that the accessibility hierarchy rooted at this |
| 230 // node has changed. | 237 // node has changed. |
| 231 Java_BrowserAccessibilityManager_handleContentChanged( | 238 Java_BrowserAccessibilityManager_handleContentChanged( |
| 232 env, obj.obj(), node->unique_id()); | 239 env, obj.obj(), node->unique_id()); |
| 233 | 240 |
| 234 // Ignore load complete events on iframes. | 241 // Ignore load complete events on iframes. |
| 235 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && | 242 if (event_type == ui::AX_EVENT_LOAD_COMPLETE && |
| 236 node->manager() != GetRootManager()) { | 243 node->manager() != GetRootManager()) { |
| 237 return; | 244 return; |
| 238 } | 245 } |
| 239 | 246 |
| 247 BrowserAccessibilityAndroid* android_node = |
| 248 static_cast<BrowserAccessibilityAndroid*>(node); |
| 240 switch (event_type) { | 249 switch (event_type) { |
| 241 case ui::AX_EVENT_LOAD_COMPLETE: | 250 case ui::AX_EVENT_LOAD_COMPLETE: |
| 242 Java_BrowserAccessibilityManager_handlePageLoaded( | 251 Java_BrowserAccessibilityManager_handlePageLoaded( |
| 243 env, obj.obj(), GetFocus()->unique_id()); | 252 env, obj.obj(), GetFocus()->unique_id()); |
| 244 break; | 253 break; |
| 245 case ui::AX_EVENT_FOCUS: | 254 case ui::AX_EVENT_FOCUS: |
| 246 Java_BrowserAccessibilityManager_handleFocusChanged( | 255 Java_BrowserAccessibilityManager_handleFocusChanged( |
| 247 env, obj.obj(), node->unique_id()); | 256 env, obj.obj(), node->unique_id()); |
| 248 break; | 257 break; |
| 249 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 258 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 971 |
| 963 JNIEnv* env = AttachCurrentThread(); | 972 JNIEnv* env = AttachCurrentThread(); |
| 964 return root_manager->java_ref().get(env); | 973 return root_manager->java_ref().get(env); |
| 965 } | 974 } |
| 966 | 975 |
| 967 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { | 976 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { |
| 968 return RegisterNativesImpl(env); | 977 return RegisterNativesImpl(env); |
| 969 } | 978 } |
| 970 | 979 |
| 971 } // namespace content | 980 } // namespace content |
| OLD | NEW |