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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java

Issue 67473013: Support KitKat accessibility APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add dummy Mac and Win expectations Created 7 years 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 package org.chromium.content.browser.accessibility; 5 package org.chromium.content.browser.accessibility;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Rect; 8 import android.graphics.Rect;
9 import android.os.Build; 9 import android.os.Build;
10 import android.os.Bundle; 10 import android.os.Bundle;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 /** 54 /**
55 * Create a BrowserAccessibilityManager object, which is owned by the C++ 55 * Create a BrowserAccessibilityManager object, which is owned by the C++
56 * BrowserAccessibilityManagerAndroid instance, and connects to the content view. 56 * BrowserAccessibilityManagerAndroid instance, and connects to the content view.
57 * @param nativeBrowserAccessibilityManagerAndroid A pointer to the counterp art native 57 * @param nativeBrowserAccessibilityManagerAndroid A pointer to the counterp art native
58 * C++ object that owns this object. 58 * C++ object that owns this object.
59 * @param contentViewCore The content view that this object provides accessi bility for. 59 * @param contentViewCore The content view that this object provides accessi bility for.
60 */ 60 */
61 @CalledByNative 61 @CalledByNative
62 private static BrowserAccessibilityManager create(long nativeBrowserAccessib ilityManagerAndroid, 62 private static BrowserAccessibilityManager create(long nativeBrowserAccessib ilityManagerAndroid,
63 ContentViewCore contentViewCore) { 63 ContentViewCore contentViewCore) {
64 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 64 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
65 return new KitKatBrowserAccessibilityManager(
66 nativeBrowserAccessibilityManagerAndroid, contentViewCore);
67 } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
65 return new JellyBeanBrowserAccessibilityManager( 68 return new JellyBeanBrowserAccessibilityManager(
66 nativeBrowserAccessibilityManagerAndroid, contentViewCore); 69 nativeBrowserAccessibilityManagerAndroid, contentViewCore);
67 } else { 70 } else {
68 return new BrowserAccessibilityManager( 71 return new BrowserAccessibilityManager(
69 nativeBrowserAccessibilityManagerAndroid, contentViewCore); 72 nativeBrowserAccessibilityManagerAndroid, contentViewCore);
70 } 73 }
71 } 74 }
72 75
73 protected BrowserAccessibilityManager(long nativeBrowserAccessibilityManager Android, 76 protected BrowserAccessibilityManager(long nativeBrowserAccessibilityManager Android,
74 ContentViewCore contentViewCore) { 77 ContentViewCore contentViewCore) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 236
234 // This is currently needed if we want Android to draw the yellow box ar ound 237 // This is currently needed if we want Android to draw the yellow box ar ound
235 // the item that has accessibility focus. In practice, this doesn't seem to slow 238 // the item that has accessibility focus. In practice, this doesn't seem to slow
236 // things down, because it's only called when the accessibility focus mo ves. 239 // things down, because it's only called when the accessibility focus mo ves.
237 // TODO(dmazzoni): remove this if/when Android framework fixes bug. 240 // TODO(dmazzoni): remove this if/when Android framework fixes bug.
238 mContentViewCore.getContainerView().postInvalidate(); 241 mContentViewCore.getContainerView().postInvalidate();
239 242
240 mContentViewCore.getContainerView().requestSendAccessibilityEvent(mView, event); 243 mContentViewCore.getContainerView().requestSendAccessibilityEvent(mView, event);
241 } 244 }
242 245
246 private Bundle getOrCreateBundleForAccessibilityEvent(AccessibilityEvent eve nt) {
247 Bundle bundle = (Bundle) event.getParcelableData();
248 if (bundle == null) {
249 bundle = new Bundle();
250 event.setParcelableData(bundle);
251 }
252 return bundle;
253 }
254
243 @CalledByNative 255 @CalledByNative
244 private void handlePageLoaded(int id) { 256 private void handlePageLoaded(int id) {
245 if (mUserHasTouchExplored) return; 257 if (mUserHasTouchExplored) return;
246 258
247 if (mFocusPageOnLoad) { 259 if (mFocusPageOnLoad) {
248 // Focus the natively focused node (usually document), 260 // Focus the natively focused node (usually document),
249 // if this feature is enabled. 261 // if this feature is enabled.
250 mAccessibilityFocusId = id; 262 mAccessibilityFocusId = id;
251 sendAccessibilityEvent(id, AccessibilityEvent.TYPE_VIEW_FOCUSED); 263 sendAccessibilityEvent(id, AccessibilityEvent.TYPE_VIEW_FOCUSED);
252 } 264 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 400
389 // Finally offset by the location of the view within the screen. 401 // Finally offset by the location of the view within the screen.
390 final int[] viewLocation = new int[2]; 402 final int[] viewLocation = new int[2];
391 mView.getLocationOnScreen(viewLocation); 403 mView.getLocationOnScreen(viewLocation);
392 rect.offset(viewLocation[0], viewLocation[1]); 404 rect.offset(viewLocation[0], viewLocation[1]);
393 405
394 node.setBoundsInScreen(rect); 406 node.setBoundsInScreen(rect);
395 } 407 }
396 408
397 @CalledByNative 409 @CalledByNative
410 protected void setAccessibilityNodeInfoKitKatAttributes(AccessibilityNodeInf o node,
411 boolean canOpenPopup,
412 boolean contentInvalid,
413 boolean dismissable,
414 boolean multiLine,
415 int inputType,
416 int liveRegion) {
417 // Requires KitKat or higher.
418 }
419
420 @CalledByNative
421 protected void setAccessibilityNodeInfoCollectionInfo(AccessibilityNodeInfo node,
422 int rowCount, int columnCount, boolean hierarchical) {
423 // Requires KitKat or higher.
424 }
425
426 @CalledByNative
427 protected void setAccessibilityNodeInfoCollectionItemInfo(AccessibilityNodeI nfo node,
428 int rowIndex, int rowSpan, int columnIndex, int columnSpan, boolean heading) {
429 // Requires KitKat or higher.
430 }
431
432 @CalledByNative
433 protected void setAccessibilityNodeInfoRangeInfo(AccessibilityNodeInfo node,
434 int rangeType, float min, float max, float current) {
435 // Requires KitKat or higher.
436 }
437
438 @CalledByNative
398 private void setAccessibilityEventBooleanAttributes(AccessibilityEvent event , 439 private void setAccessibilityEventBooleanAttributes(AccessibilityEvent event ,
399 boolean checked, boolean enabled, boolean password, boolean scrollab le) { 440 boolean checked, boolean enabled, boolean password, boolean scrollab le) {
400 event.setChecked(checked); 441 event.setChecked(checked);
401 event.setEnabled(enabled); 442 event.setEnabled(enabled);
402 event.setPassword(password); 443 event.setPassword(password);
403 event.setScrollable(scrollable); 444 event.setScrollable(scrollable);
404 } 445 }
405 446
406 @CalledByNative 447 @CalledByNative
407 private void setAccessibilityEventClassName(AccessibilityEvent event, String className) { 448 private void setAccessibilityEventClassName(AccessibilityEvent event, String className) {
(...skipping 28 matching lines...) Expand all
436 477
437 @CalledByNative 478 @CalledByNative
438 private void setAccessibilityEventSelectionAttrs(AccessibilityEvent event, 479 private void setAccessibilityEventSelectionAttrs(AccessibilityEvent event,
439 int fromIndex, int addedCount, int itemCount, String text) { 480 int fromIndex, int addedCount, int itemCount, String text) {
440 event.setFromIndex(fromIndex); 481 event.setFromIndex(fromIndex);
441 event.setAddedCount(addedCount); 482 event.setAddedCount(addedCount);
442 event.setItemCount(itemCount); 483 event.setItemCount(itemCount);
443 event.getText().add(text); 484 event.getText().add(text);
444 } 485 }
445 486
487 @CalledByNative
488 protected void setAccessibilityEventKitKatAttributes(AccessibilityEvent even t,
489 boolean canOpenPopup,
490 boolean contentInvalid,
491 boolean dismissable,
492 boolean multiLine,
493 int inputType,
494 int liveRegion) {
495 // Backwards compatibility for KitKat AccessibilityNodeInfo fields.
496 Bundle bundle = getOrCreateBundleForAccessibilityEvent(event);
497 bundle.putBoolean("AccessibilityNodeInfo.canOpenPopup", canOpenPopup);
498 bundle.putBoolean("AccessibilityNodeInfo.contentInvalid", contentInvalid );
499 bundle.putBoolean("AccessibilityNodeInfo.dismissable", dismissable);
500 bundle.putBoolean("AccessibilityNodeInfo.multiLine", multiLine);
501 bundle.putInt("AccessibilityNodeInfo.inputType", inputType);
502 bundle.putInt("AccessibilityNodeInfo.liveRegion", liveRegion);
503 }
504
505 @CalledByNative
506 protected void setAccessibilityEventCollectionInfo(AccessibilityEvent event,
507 int rowCount, int columnCount, boolean hierarchical) {
508 // Backwards compatibility for KitKat AccessibilityNodeInfo fields.
509 Bundle bundle = getOrCreateBundleForAccessibilityEvent(event);
510 bundle.putInt("AccessibilityNodeInfo.CollectionInfo.rowCount", rowCount) ;
511 bundle.putInt("AccessibilityNodeInfo.CollectionInfo.columnCount", column Count);
512 bundle.putBoolean("AccessibilityNodeInfo.CollectionInfo.hierarchical", h ierarchical);
513 }
514
515 @CalledByNative
516 protected void setAccessibilityEventCollectionItemInfo(AccessibilityEvent ev ent,
517 int rowIndex, int rowSpan, int columnIndex, int columnSpan, boolean heading) {
518 // Backwards compatibility for KitKat AccessibilityNodeInfo fields.
519 Bundle bundle = getOrCreateBundleForAccessibilityEvent(event);
520 bundle.putInt("AccessibilityNodeInfo.CollectionItemInfo.rowIndex", rowIn dex);
521 bundle.putInt("AccessibilityNodeInfo.CollectionItemInfo.rowSpan", rowSpa n);
522 bundle.putInt("AccessibilityNodeInfo.CollectionItemInfo.columnIndex", co lumnIndex);
523 bundle.putInt("AccessibilityNodeInfo.CollectionItemInfo.columnSpan", col umnSpan);
524 bundle.putBoolean("AccessibilityNodeInfo.CollectionItemInfo.heading", he ading);
525 }
526
527 @CalledByNative
528 protected void setAccessibilityEventRangeInfo(AccessibilityEvent event,
529 int rangeType, float min, float max, float current) {
530 // Backwards compatibility for KitKat AccessibilityNodeInfo fields.
531 Bundle bundle = getOrCreateBundleForAccessibilityEvent(event);
532 bundle.putInt("AccessibilityNodeInfo.RangeInfo.type", rangeType);
533 bundle.putFloat("AccessibilityNodeInfo.RangeInfo.min", min);
534 bundle.putFloat("AccessibilityNodeInfo.RangeInfo.max", max);
535 bundle.putFloat("AccessibilityNodeInfo.RangeInfo.current", current);
536 }
537
446 private native int nativeGetRootId(long nativeBrowserAccessibilityManagerAnd roid); 538 private native int nativeGetRootId(long nativeBrowserAccessibilityManagerAnd roid);
447 private native int nativeHitTest(long nativeBrowserAccessibilityManagerAndro id, int x, int y); 539 private native int nativeHitTest(long nativeBrowserAccessibilityManagerAndro id, int x, int y);
448 private native boolean nativePopulateAccessibilityNodeInfo( 540 private native boolean nativePopulateAccessibilityNodeInfo(
449 long nativeBrowserAccessibilityManagerAndroid, AccessibilityNodeInfo inf o, int id); 541 long nativeBrowserAccessibilityManagerAndroid, AccessibilityNodeInfo inf o, int id);
450 private native boolean nativePopulateAccessibilityEvent( 542 private native boolean nativePopulateAccessibilityEvent(
451 long nativeBrowserAccessibilityManagerAndroid, AccessibilityEvent event, int id, 543 long nativeBrowserAccessibilityManagerAndroid, AccessibilityEvent event, int id,
452 int eventType); 544 int eventType);
453 private native void nativeClick(long nativeBrowserAccessibilityManagerAndroi d, int id); 545 private native void nativeClick(long nativeBrowserAccessibilityManagerAndroi d, int id);
454 private native void nativeFocus(long nativeBrowserAccessibilityManagerAndroi d, int id); 546 private native void nativeFocus(long nativeBrowserAccessibilityManagerAndroi d, int id);
455 private native void nativeBlur(long nativeBrowserAccessibilityManagerAndroid ); 547 private native void nativeBlur(long nativeBrowserAccessibilityManagerAndroid );
456 } 548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698