Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: content/browser/web_contents/web_contents_android.cc

Issue 1137393003: Add style information to the snapshot node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address code review (dependency and non-existent style) Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
Ted C 2015/05/29 17:04:29 can you add a DCHECK above each one of these using
dmazzoni 2015/05/29 17:06:01 No, we deliberately filter out zero values and emp
Ted C 2015/05/29 17:10:37 Huh? So HasFloatAttribute returns false if the va
sgurun-gerrit only 2015/05/29 17:23:19 I will add a todo and a crbug and we can discuss h
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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 ScopedJavaGlobalRef<jobject> j_callback; 580 ScopedJavaGlobalRef<jobject> j_callback;
567 j_callback.Reset(env, callback); 581 j_callback.Reset(env, callback);
568 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback = 582 WebContentsImpl::AXTreeSnapshotCallback snapshot_callback =
569 base::Bind(&AXTreeSnapshotCallback, j_callback); 583 base::Bind(&AXTreeSnapshotCallback, j_callback);
570 584
571 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot( 585 static_cast<WebContentsImpl*>(web_contents_)->RequestAXTreeSnapshot(
572 snapshot_callback); 586 snapshot_callback);
573 } 587 }
574 588
575 } // namespace content 589 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698