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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_android.cc

Issue 25943003: Support accessible inline text boxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 7 years, 1 month 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 | Annotate | Revision Log
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/accessibility/browser_accessibility_manager_android.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 JNIEnv* env, jobject obj, jobject info, jint id) { 175 JNIEnv* env, jobject obj, jobject info, jint id) {
176 BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>( 176 BrowserAccessibilityAndroid* node = static_cast<BrowserAccessibilityAndroid*>(
177 GetFromRendererID(id)); 177 GetFromRendererID(id));
178 if (!node) 178 if (!node)
179 return false; 179 return false;
180 180
181 if (node->parent()) { 181 if (node->parent()) {
182 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent( 182 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoParent(
183 env, obj, info, node->parent()->renderer_id()); 183 env, obj, info, node->parent()->renderer_id());
184 } 184 }
185 if (!node->IsLeaf()) { 185 for (unsigned i = 0; i < node->PlatformChildCount(); ++i) {
186 for (unsigned i = 0; i < node->child_count(); ++i) { 186 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild(
187 Java_BrowserAccessibilityManager_addAccessibilityNodeInfoChild( 187 env, obj, info, node->children()[i]->renderer_id());
188 env, obj, info, node->children()[i]->renderer_id());
189 }
190 } 188 }
191 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes( 189 Java_BrowserAccessibilityManager_setAccessibilityNodeInfoBooleanAttributes(
192 env, obj, info, 190 env, obj, info,
193 id, 191 id,
194 node->IsCheckable(), 192 node->IsCheckable(),
195 node->IsChecked(), 193 node->IsChecked(),
196 node->IsClickable(), 194 node->IsClickable(),
197 node->IsEnabled(), 195 node->IsEnabled(),
198 node->IsFocusable(), 196 node->IsFocusable(),
199 node->IsFocused(), 197 node->IsFocused(),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 319 }
322 320
323 if (!node->GetText().empty()) { 321 if (!node->GetText().empty()) {
324 if (distance < *nearest_distance) { 322 if (distance < *nearest_distance) {
325 *nearest_candidate = node; 323 *nearest_candidate = node;
326 *nearest_distance = distance; 324 *nearest_distance = distance;
327 } 325 }
328 return; 326 return;
329 } 327 }
330 328
331 if (!node->IsLeaf()) { 329 for (uint32 i = 0; i < node->PlatformChildCount(); i++) {
332 for (uint32 i = 0; i < node->child_count(); i++) { 330 BrowserAccessibility* child = node->PlatformGetChild(i);
333 BrowserAccessibility* child = node->GetChild(i); 331 FuzzyHitTestImpl(x, y, child, nearest_candidate, nearest_distance);
334 FuzzyHitTestImpl(x, y, child, nearest_candidate, nearest_distance);
335 }
336 } 332 }
337 } 333 }
338 334
339 // static 335 // static
340 int BrowserAccessibilityManagerAndroid::CalculateDistanceSquared( 336 int BrowserAccessibilityManagerAndroid::CalculateDistanceSquared(
341 int x, int y, BrowserAccessibility* node) { 337 int x, int y, BrowserAccessibility* node) {
342 gfx::Rect node_bounds = node->GetLocalBoundsRect(); 338 gfx::Rect node_bounds = node->GetLocalBoundsRect();
343 int nearest_x = Clamp(x, node_bounds.x(), node_bounds.right()); 339 int nearest_x = Clamp(x, node_bounds.x(), node_bounds.right());
344 int nearest_y = Clamp(y, node_bounds.y(), node_bounds.bottom()); 340 int nearest_y = Clamp(y, node_bounds.y(), node_bounds.bottom());
345 int dx = std::abs(x - nearest_x); 341 int dx = std::abs(x - nearest_x);
(...skipping 14 matching lines...) Expand all
360 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() { 356 BrowserAccessibilityManagerAndroid::UseRootScrollOffsetsWhenComputingBounds() {
361 // The Java layer handles the root scroll offset. 357 // The Java layer handles the root scroll offset.
362 return false; 358 return false;
363 } 359 }
364 360
365 bool RegisterBrowserAccessibilityManager(JNIEnv* env) { 361 bool RegisterBrowserAccessibilityManager(JNIEnv* env) {
366 return RegisterNativesImpl(env); 362 return RegisterNativesImpl(env);
367 } 363 }
368 364
369 } // namespace content 365 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698