| 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 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
| 9 #include "content/browser/accessibility/browser_accessibility_manager.h" | 9 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 10 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // Implementation of BrowserAccessibilityManager. | 74 // Implementation of BrowserAccessibilityManager. |
| 75 void NotifyAccessibilityEvent(ui::AXEvent event_type, | 75 void NotifyAccessibilityEvent(ui::AXEvent event_type, |
| 76 BrowserAccessibility* node) override; | 76 BrowserAccessibility* node) override; |
| 77 | 77 |
| 78 // -------------------------------------------------------------------------- | 78 // -------------------------------------------------------------------------- |
| 79 // Methods called from Java via JNI | 79 // Methods called from Java via JNI |
| 80 // -------------------------------------------------------------------------- | 80 // -------------------------------------------------------------------------- |
| 81 | 81 |
| 82 // Tree methods. | 82 // Tree methods. |
| 83 jint GetRootId(JNIEnv* env, jobject obj); | 83 jint GetRootId(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 84 jboolean IsNodeValid(JNIEnv* env, jobject obj, jint id); | 84 jboolean IsNodeValid(JNIEnv* env, |
| 85 void HitTest(JNIEnv* env, jobject obj, jint x, jint y); | 85 const base::android::JavaParamRef<jobject>& obj, |
| 86 jint id); |
| 87 void HitTest(JNIEnv* env, |
| 88 const base::android::JavaParamRef<jobject>& obj, |
| 89 jint x, |
| 90 jint y); |
| 86 | 91 |
| 87 // Methods to get information about a specific node. | 92 // Methods to get information about a specific node. |
| 88 jboolean IsEditableText(JNIEnv* env, jobject obj, jint id); | 93 jboolean IsEditableText(JNIEnv* env, |
| 89 jint GetEditableTextSelectionStart(JNIEnv* env, jobject obj, jint id); | 94 const base::android::JavaParamRef<jobject>& obj, |
| 90 jint GetEditableTextSelectionEnd(JNIEnv* env, jobject obj, jint id); | 95 jint id); |
| 96 jint GetEditableTextSelectionStart( |
| 97 JNIEnv* env, |
| 98 const base::android::JavaParamRef<jobject>& obj, |
| 99 jint id); |
| 100 jint GetEditableTextSelectionEnd( |
| 101 JNIEnv* env, |
| 102 const base::android::JavaParamRef<jobject>& obj, |
| 103 jint id); |
| 91 | 104 |
| 92 // Populate Java accessibility data structures with info about a node. | 105 // Populate Java accessibility data structures with info about a node. |
| 93 jboolean PopulateAccessibilityNodeInfo( | 106 jboolean PopulateAccessibilityNodeInfo( |
| 94 JNIEnv* env, jobject obj, jobject info, jint id); | 107 JNIEnv* env, |
| 108 const base::android::JavaParamRef<jobject>& obj, |
| 109 const base::android::JavaParamRef<jobject>& info, |
| 110 jint id); |
| 95 jboolean PopulateAccessibilityEvent( | 111 jboolean PopulateAccessibilityEvent( |
| 96 JNIEnv* env, jobject obj, jobject event, jint id, jint event_type); | 112 JNIEnv* env, |
| 113 const base::android::JavaParamRef<jobject>& obj, |
| 114 const base::android::JavaParamRef<jobject>& event, |
| 115 jint id, |
| 116 jint event_type); |
| 97 | 117 |
| 98 // Perform actions. | 118 // Perform actions. |
| 99 void Click(JNIEnv* env, jobject obj, jint id); | 119 void Click(JNIEnv* env, |
| 100 void Focus(JNIEnv* env, jobject obj, jint id); | 120 const base::android::JavaParamRef<jobject>& obj, |
| 101 void Blur(JNIEnv* env, jobject obj); | 121 jint id); |
| 102 void ScrollToMakeNodeVisible(JNIEnv* env, jobject obj, jint id); | 122 void Focus(JNIEnv* env, |
| 103 void SetTextFieldValue(JNIEnv* env, jobject obj, jint id, jstring value); | 123 const base::android::JavaParamRef<jobject>& obj, |
| 104 void SetSelection(JNIEnv* env, jobject obj, jint id, jint start, jint end); | 124 jint id); |
| 105 jboolean AdjustSlider(JNIEnv* env, jobject obj, jint id, jboolean increment); | 125 void Blur(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 126 void ScrollToMakeNodeVisible(JNIEnv* env, |
| 127 const base::android::JavaParamRef<jobject>& obj, |
| 128 jint id); |
| 129 void SetTextFieldValue(JNIEnv* env, |
| 130 const base::android::JavaParamRef<jobject>& obj, |
| 131 jint id, |
| 132 const base::android::JavaParamRef<jstring>& value); |
| 133 void SetSelection(JNIEnv* env, |
| 134 const base::android::JavaParamRef<jobject>& obj, |
| 135 jint id, |
| 136 jint start, |
| 137 jint end); |
| 138 jboolean AdjustSlider(JNIEnv* env, |
| 139 const base::android::JavaParamRef<jobject>& obj, |
| 140 jint id, |
| 141 jboolean increment); |
| 106 | 142 |
| 107 // Return the id of the next node in tree order in the direction given by | 143 // Return the id of the next node in tree order in the direction given by |
| 108 // |forwards|, starting with |start_id|, that matches |element_type|, | 144 // |forwards|, starting with |start_id|, that matches |element_type|, |
| 109 // where |element_type| is a special uppercase string from TalkBack or | 145 // where |element_type| is a special uppercase string from TalkBack or |
| 110 // BrailleBack indicating general categories of web content like | 146 // BrailleBack indicating general categories of web content like |
| 111 // "SECTION" or "CONTROL". Return 0 if not found. | 147 // "SECTION" or "CONTROL". Return 0 if not found. |
| 112 jint FindElementType(JNIEnv* env, jobject obj, jint start_id, | 148 jint FindElementType(JNIEnv* env, |
| 113 jstring element_type, jboolean forwards); | 149 const base::android::JavaParamRef<jobject>& obj, |
| 150 jint start_id, |
| 151 const base::android::JavaParamRef<jstring>& element_type, |
| 152 jboolean forwards); |
| 114 | 153 |
| 115 // Respond to a ACTION_[NEXT/PREVIOUS]_AT_MOVEMENT_GRANULARITY action | 154 // Respond to a ACTION_[NEXT/PREVIOUS]_AT_MOVEMENT_GRANULARITY action |
| 116 // and move the cursor/selection within the given node id. We keep track | 155 // and move the cursor/selection within the given node id. We keep track |
| 117 // of our own selection in BrowserAccessibilityManager.java for static | 156 // of our own selection in BrowserAccessibilityManager.java for static |
| 118 // text, but if this is an editable text node, updates the selected text | 157 // text, but if this is an editable text node, updates the selected text |
| 119 // in Blink, too, and either way calls | 158 // in Blink, too, and either way calls |
| 120 // Java_BrowserAccessibilityManager_finishGranularityMove with the | 159 // Java_BrowserAccessibilityManager_finishGranularityMove with the |
| 121 // result. | 160 // result. |
| 122 jboolean NextAtGranularity(JNIEnv* env, jobject obj, | 161 jboolean NextAtGranularity(JNIEnv* env, |
| 123 jint granularity, jboolean extend_selection, | 162 const base::android::JavaParamRef<jobject>& obj, |
| 124 jint id, jint cursor_index); | 163 jint granularity, |
| 125 jboolean PreviousAtGranularity(JNIEnv* env, jobject obj, | 164 jboolean extend_selection, |
| 126 jint granularity, jboolean extend_selection, | 165 jint id, |
| 127 jint id, jint cursor_index); | 166 jint cursor_index); |
| 167 jboolean PreviousAtGranularity( |
| 168 JNIEnv* env, |
| 169 const base::android::JavaParamRef<jobject>& obj, |
| 170 jint granularity, |
| 171 jboolean extend_selection, |
| 172 jint id, |
| 173 jint cursor_index); |
| 128 | 174 |
| 129 // Helper functions to compute the next start and end index when moving | 175 // Helper functions to compute the next start and end index when moving |
| 130 // forwards or backwards by character, word, or line. This part is | 176 // forwards or backwards by character, word, or line. This part is |
| 131 // unit-tested; the Java interfaces above are just wrappers. Both of these | 177 // unit-tested; the Java interfaces above are just wrappers. Both of these |
| 132 // take a single cursor index as input and return the boundaries surrounding | 178 // take a single cursor index as input and return the boundaries surrounding |
| 133 // the next word or line. If moving by character, the output start and | 179 // the next word or line. If moving by character, the output start and |
| 134 // end index will be the same. | 180 // end index will be the same. |
| 135 bool NextAtGranularity( | 181 bool NextAtGranularity( |
| 136 int32 granularity, int cursor_index, | 182 int32 granularity, int cursor_index, |
| 137 BrowserAccessibilityAndroid* node, int32* start_index, int32* end_index); | 183 BrowserAccessibilityAndroid* node, int32* start_index, int32* end_index); |
| 138 bool PreviousAtGranularity( | 184 bool PreviousAtGranularity( |
| 139 int32 granularity, int cursor_index, | 185 int32 granularity, int cursor_index, |
| 140 BrowserAccessibilityAndroid* node, int32* start_index, int32* end_index); | 186 BrowserAccessibilityAndroid* node, int32* start_index, int32* end_index); |
| 141 | 187 |
| 142 // Set accessibility focus. This sends a message to the renderer to | 188 // Set accessibility focus. This sends a message to the renderer to |
| 143 // asynchronously load inline text boxes for this node only, enabling more | 189 // asynchronously load inline text boxes for this node only, enabling more |
| 144 // accurate movement by granularities on this node. | 190 // accurate movement by granularities on this node. |
| 145 void SetAccessibilityFocus(JNIEnv* env, jobject obj, jint id); | 191 void SetAccessibilityFocus(JNIEnv* env, |
| 192 const base::android::JavaParamRef<jobject>& obj, |
| 193 jint id); |
| 146 | 194 |
| 147 // Returns true if the object is a slider. | 195 // Returns true if the object is a slider. |
| 148 bool IsSlider(JNIEnv* env, jobject obj, jint id); | 196 bool IsSlider(JNIEnv* env, |
| 197 const base::android::JavaParamRef<jobject>& obj, |
| 198 jint id); |
| 149 | 199 |
| 150 // Scrolls any scrollable container by about 80% of one page in the | 200 // Scrolls any scrollable container by about 80% of one page in the |
| 151 // given direction. | 201 // given direction. |
| 152 bool Scroll(JNIEnv* env, jobject obj, jint id, int direction); | 202 bool Scroll(JNIEnv* env, |
| 203 const base::android::JavaParamRef<jobject>& obj, |
| 204 jint id, |
| 205 int direction); |
| 153 | 206 |
| 154 protected: | 207 protected: |
| 155 // AXTreeDelegate overrides. | 208 // AXTreeDelegate overrides. |
| 156 void OnAtomicUpdateFinished( | 209 void OnAtomicUpdateFinished( |
| 157 ui::AXTree* tree, | 210 ui::AXTree* tree, |
| 158 bool root_changed, | 211 bool root_changed, |
| 159 const std::vector<ui::AXTreeDelegate::Change>& changes) override; | 212 const std::vector<ui::AXTreeDelegate::Change>& changes) override; |
| 160 | 213 |
| 161 bool UseRootScrollOffsetsWhenComputingBounds() override; | 214 bool UseRootScrollOffsetsWhenComputingBounds() override; |
| 162 | 215 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 179 bool prune_tree_for_screen_reader_; | 232 bool prune_tree_for_screen_reader_; |
| 180 | 233 |
| 181 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerAndroid); | 234 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerAndroid); |
| 182 }; | 235 }; |
| 183 | 236 |
| 184 bool RegisterBrowserAccessibilityManager(JNIEnv* env); | 237 bool RegisterBrowserAccessibilityManager(JNIEnv* env); |
| 185 | 238 |
| 186 } | 239 } |
| 187 | 240 |
| 188 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H
_ | 241 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H
_ |
| OLD | NEW |