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

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

Powered by Google App Engine
This is Rietveld 408576698