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/web_contents/web_contents_android.h" | 5 #include "content/browser/web_contents/web_contents_android.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
12 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
13 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
15 #include "content/browser/accessibility/browser_accessibility_android.h" | 17 #include "content/browser/accessibility/browser_accessibility_android.h" |
16 #include "content/browser/accessibility/browser_accessibility_manager_android.h" | 18 #include "content/browser/accessibility/browser_accessibility_manager_android.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 has_tree_data(false), | 78 has_tree_data(false), |
77 should_select_leaf_nodes(false) {} | 79 should_select_leaf_nodes(false) {} |
78 | 80 |
79 float scale_factor; | 81 float scale_factor; |
80 float x_scroll; | 82 float x_scroll; |
81 float y_offset; | 83 float y_offset; |
82 bool has_tree_data; | 84 bool has_tree_data; |
83 // The current text selection within this tree, if any, expressed as the | 85 // The current text selection within this tree, if any, expressed as the |
84 // node ID and character offset of the anchor (selection start) and focus | 86 // node ID and character offset of the anchor (selection start) and focus |
85 // (selection end). | 87 // (selection end). |
86 int32 sel_anchor_object_id; | 88 int32_t sel_anchor_object_id; |
87 int32 sel_anchor_offset; | 89 int32_t sel_anchor_offset; |
88 int32 sel_focus_object_id; | 90 int32_t sel_focus_object_id; |
89 int32 sel_focus_offset; | 91 int32_t sel_focus_offset; |
90 // if the flag is true, mark the leaf node as selected. | 92 // if the flag is true, mark the leaf node as selected. |
91 bool should_select_leaf_nodes; | 93 bool should_select_leaf_nodes; |
92 }; | 94 }; |
93 | 95 |
94 ScopedJavaLocalRef<jobject> WalkAXTreeDepthFirst( | 96 ScopedJavaLocalRef<jobject> WalkAXTreeDepthFirst( |
95 JNIEnv* env, | 97 JNIEnv* env, |
96 BrowserAccessibilityAndroid* node, | 98 BrowserAccessibilityAndroid* node, |
97 AccessibilitySnapshotParams* params) { | 99 AccessibilitySnapshotParams* params) { |
98 ScopedJavaLocalRef<jstring> j_text = | 100 ScopedJavaLocalRef<jstring> j_text = |
99 ConvertUTF16ToJavaString(env, node->GetText()); | 101 ConvertUTF16ToJavaString(env, node->GetText()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 138 |
137 if (params->sel_focus_object_id == node->GetId()) { | 139 if (params->sel_focus_object_id == node->GetId()) { |
138 end_selection = params->sel_focus_offset; | 140 end_selection = params->sel_focus_offset; |
139 params->should_select_leaf_nodes = false; | 141 params->should_select_leaf_nodes = false; |
140 } | 142 } |
141 if (end_selection > 0) | 143 if (end_selection > 0) |
142 Java_WebContentsImpl_setAccessibilitySnapshotSelection( | 144 Java_WebContentsImpl_setAccessibilitySnapshotSelection( |
143 env, j_node.obj(), start_selection, end_selection); | 145 env, j_node.obj(), start_selection, end_selection); |
144 } | 146 } |
145 | 147 |
146 for(uint32 i = 0; i < node->PlatformChildCount(); i++) { | 148 for (uint32_t i = 0; i < node->PlatformChildCount(); i++) { |
147 BrowserAccessibilityAndroid* child = | 149 BrowserAccessibilityAndroid* child = |
148 static_cast<BrowserAccessibilityAndroid*>( | 150 static_cast<BrowserAccessibilityAndroid*>( |
149 node->PlatformGetChild(i)); | 151 node->PlatformGetChild(i)); |
150 Java_WebContentsImpl_addAccessibilityNodeAsChild( | 152 Java_WebContentsImpl_addAccessibilityNodeAsChild( |
151 env, j_node.obj(), WalkAXTreeDepthFirst(env, child, params).obj()); | 153 env, j_node.obj(), WalkAXTreeDepthFirst(env, child, params).obj()); |
152 } | 154 } |
153 return j_node; | 155 return j_node; |
154 } | 156 } |
155 | 157 |
156 // Walks over the AXTreeUpdate and creates a light weight snapshot. | 158 // Walks over the AXTreeUpdate and creates a light weight snapshot. |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 if (response == READBACK_SUCCESS) | 693 if (response == READBACK_SUCCESS) |
692 java_bitmap = gfx::ConvertToJavaBitmap(&bitmap); | 694 java_bitmap = gfx::ConvertToJavaBitmap(&bitmap); |
693 Java_WebContentsImpl_onGetContentBitmapFinished(env, | 695 Java_WebContentsImpl_onGetContentBitmapFinished(env, |
694 obj->obj(), | 696 obj->obj(), |
695 callback->obj(), | 697 callback->obj(), |
696 java_bitmap.obj(), | 698 java_bitmap.obj(), |
697 response); | 699 response); |
698 } | 700 } |
699 | 701 |
700 } // namespace content | 702 } // namespace content |
OLD | NEW |