diff options
3 files changed, 29 insertions, 1 deletions
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc index 017afd1..d928258 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.cc +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc @@ -379,6 +379,13 @@ void BrowserAccessibilityManagerAndroid::Blur(JNIEnv* env, jobject obj) { SetFocus(root_, true); } +void BrowserAccessibilityManagerAndroid::ScrollToMakeNodeVisible( + JNIEnv* env, jobject obj, jint id) { + BrowserAccessibility* node = GetFromRendererID(id); + if (node) + ScrollToMakeVisible(*node, gfx::Rect(node->location().size())); +} + BrowserAccessibility* BrowserAccessibilityManagerAndroid::FuzzyHitTest( int x, int y, BrowserAccessibility* start_node) { BrowserAccessibility* nearest_node = NULL; diff --git a/content/browser/accessibility/browser_accessibility_manager_android.h b/content/browser/accessibility/browser_accessibility_manager_android.h index 921ca3a..53cb617 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.h +++ b/content/browser/accessibility/browser_accessibility_manager_android.h @@ -55,6 +55,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerAndroid void Click(JNIEnv* env, jobject obj, jint id); void Focus(JNIEnv* env, jobject obj, jint id); void Blur(JNIEnv* env, jobject obj); + void ScrollToMakeNodeVisible(JNIEnv* env, jobject obj, int id); protected: virtual void NotifyRootChanged() OVERRIDE; diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java index 1a58d45..2327316 100644 --- a/content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java +++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java @@ -46,6 +46,7 @@ public class BrowserAccessibilityManager { 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 @@ -168,6 +169,12 @@ public class BrowserAccessibilityManager { 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) { @@ -201,7 +208,18 @@ public class BrowserAccessibilityManager { 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(); @@ -617,4 +635,6 @@ public class BrowserAccessibilityManager { 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); } |