private final int[] mTempLocation = new int[2];
private final View mView;
private boolean mUserHasTouchExplored;
+ private boolean mPendingScrollToMakeNodeVisible;
private boolean mFrameInfoInitialized;
- // If this is true, enables an experimental feature that focuses the web page after it
- // finishes loading. Disabled for now because it can be confusing if the user was
- // trying to do something when this happens.
- private boolean mFocusPageOnLoad;
-
/**
* Create a BrowserAccessibilityManager object, which is owned by the C++
* BrowserAccessibilityManagerAndroid instance, and connects to the content view.
mAccessibilityFocusId = virtualViewId;
sendAccessibilityEvent(mAccessibilityFocusId,
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
+ if (mCurrentHoverId == View.NO_ID) {
+ nativeScrollToMakeNodeVisible(
+ mNativeObj, mAccessibilityFocusId);
+ } else {
+ mPendingScrollToMakeNodeVisible = true;
+ }
return true;
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
if (mAccessibilityFocusId == virtualViewId) {
return false;
}
- if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) return true;
+ if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
+ if (mCurrentHoverId != View.NO_ID) {
+ sendAccessibilityEvent(mCurrentHoverId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
+ mCurrentHoverId = View.NO_ID;
+ }
+ if (mPendingScrollToMakeNodeVisible) {
+ nativeScrollToMakeNodeVisible(
+ mNativeObj, mAccessibilityFocusId);
+ }
+ mPendingScrollToMakeNodeVisible = false;
+ return true;
+ }
mUserHasTouchExplored = true;
float x = event.getX();
private void handlePageLoaded(int id) {
if (mUserHasTouchExplored) return;
- if (mFocusPageOnLoad) {
- // Focus the natively focused node (usually document),
- // if this feature is enabled.
- mAccessibilityFocusId = id;
- sendAccessibilityEvent(id, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
- }
+ mAccessibilityFocusId = id;
+ sendAccessibilityEvent(id, AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
}
@CalledByNative
private native void nativeClick(long nativeBrowserAccessibilityManagerAndroid, int id);
private native void nativeFocus(long nativeBrowserAccessibilityManagerAndroid, int id);
private native void nativeBlur(long nativeBrowserAccessibilityManagerAndroid);
+ private native void nativeScrollToMakeNodeVisible(
+ long nativeBrowserAccessibilityManagerAndroid, int id);
}