summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplundblad@chromium.org <plundblad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 21:06:21 +0000
committerplundblad@chromium.org <plundblad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-28 21:06:21 +0000
commit82d3777f5efefc0ed406ba2680240493eedee3e4 (patch)
tree394a8be6df934b1f161d4fff82c9bfc093a11aca
parenta343f085d7bfe400075d6f511407235953c55a1b (diff)
downloadchromium_src-82d3777f5efefc0ed406ba2680240493eedee3e4.zip
chromium_src-82d3777f5efefc0ed406ba2680240493eedee3e4.tar.gz
chromium_src-82d3777f5efefc0ed406ba2680240493eedee3e4.tar.bz2
Scroll accessibility focused nodes to make them visible.
Since nodes must be (at least partially) visible on screen for double taps to work when touch exploration is enabled, we scroll the content whenever accessibility focus is set. During touch exploration, we delay scrolling until the pointer goes up to avoid scrolling when the user is actually exploring the screen. BUG=335630 Review URL: https://codereview.chromium.org/137533014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247500 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/accessibility/browser_accessibility_manager_android.cc7
-rw-r--r--content/browser/accessibility/browser_accessibility_manager_android.h1
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java22
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);
}