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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 ScopedJavaLocalRef<jobject> WalkAXTreeDepthFirst(JNIEnv* env, | 55 ScopedJavaLocalRef<jobject> WalkAXTreeDepthFirst(JNIEnv* env, |
56 BrowserAccessibilityAndroid* node) { | 56 BrowserAccessibilityAndroid* node) { |
57 | 57 |
58 ScopedJavaLocalRef<jstring> j_text = | 58 ScopedJavaLocalRef<jstring> j_text = |
59 ConvertUTF16ToJavaString(env, node->GetText()); | 59 ConvertUTF16ToJavaString(env, node->GetText()); |
60 ScopedJavaLocalRef<jstring> j_class = | 60 ScopedJavaLocalRef<jstring> j_class = |
61 ConvertUTF8ToJavaString(env, node->GetClassName()); | 61 ConvertUTF8ToJavaString(env, node->GetClassName()); |
62 const gfx::Rect& location = node->GetLocation(); | 62 const gfx::Rect& location = node->GetLocation(); |
| 63 // The style attributes exists and valid if size attribute exists. Otherwise, |
| 64 // they are not. Use a negative size information to indicate the existence |
| 65 // of style information. |
| 66 float size = -1.0; |
| 67 int color = 0; |
| 68 int bgcolor = 0; |
| 69 int text_style = 0; |
| 70 if (node->HasFloatAttribute(ui::AX_ATTR_FONT_SIZE)) { |
| 71 color = node->GetIntAttribute(ui::AX_ATTR_COLOR); |
| 72 bgcolor = node->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR); |
| 73 size = node->GetFloatAttribute(ui::AX_ATTR_FONT_SIZE); |
| 74 text_style = node->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE); |
| 75 } |
| 76 |
63 ScopedJavaLocalRef<jobject> j_node = | 77 ScopedJavaLocalRef<jobject> j_node = |
64 Java_WebContentsImpl_createAccessibilitySnapshotNode(env, | 78 Java_WebContentsImpl_createAccessibilitySnapshotNode(env, |
65 location.x(), location.y(), node->GetScrollX(), | 79 location.x(), location.y(), node->GetScrollX(), |
66 node->GetScrollY(), location.width(), location.height(), | 80 node->GetScrollY(), location.width(), location.height(), |
67 j_text.obj(), j_class.obj()); | 81 j_text.obj(), color, bgcolor, size, text_style, j_class.obj()); |
68 | 82 |
69 for(uint32 i = 0; i < node->PlatformChildCount(); i++) { | 83 for(uint32 i = 0; i < node->PlatformChildCount(); i++) { |
70 BrowserAccessibilityAndroid* child = | 84 BrowserAccessibilityAndroid* child = |
71 static_cast<BrowserAccessibilityAndroid*>( | 85 static_cast<BrowserAccessibilityAndroid*>( |
72 node->PlatformGetChild(i)); | 86 node->PlatformGetChild(i)); |
73 Java_WebContentsImpl_addAccessibilityNodeAsChild(env, | 87 Java_WebContentsImpl_addAccessibilityNodeAsChild(env, |
74 j_node.obj(), WalkAXTreeDepthFirst(env, child).obj()); | 88 j_node.obj(), WalkAXTreeDepthFirst(env, child).obj()); |
75 } | 89 } |
76 return j_node; | 90 return j_node; |
77 } | 91 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 ScopedJavaGlobalRef<jobject> j_callback; | 404 ScopedJavaGlobalRef<jobject> j_callback; |
391 j_callback.Reset(env, callback); | 405 j_callback.Reset(env, callback); |
392 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback = | 406 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback = |
393 base::Bind(&AXTreeSnapshotCallback, j_callback); | 407 base::Bind(&AXTreeSnapshotCallback, j_callback); |
394 | 408 |
395 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot( | 409 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot( |
396 snapshot_callback); | 410 snapshot_callback); |
397 } | 411 } |
398 | 412 |
399 } // namespace content | 413 } // namespace content |
OLD | NEW |