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

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

Issue 505423002: Re-focus node with Android accessibility focus when it moves (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_accessibility_focus_3b
Patch Set: Rebase Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_android.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityManager.java
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 da8ff8fa8bfc826b2132b7ff048ab888467af06e..644652b3e5a133eb54458a48d99d2f174b8c81f4 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
@@ -45,6 +45,7 @@ public class BrowserAccessibilityManager {
private final RenderCoordinates mRenderCoordinates;
private long mNativeObj;
private int mAccessibilityFocusId;
+ private Rect mAccessibilityFocusRect;
private boolean mIsHovering;
private int mLastHoverId = View.NO_ID;
private int mCurrentRootId;
@@ -178,6 +179,7 @@ public class BrowserAccessibilityManager {
sendAccessibilityEvent(mAccessibilityFocusId,
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
mAccessibilityFocusId = View.NO_ID;
+ mAccessibilityFocusRect = null;
}
return true;
case AccessibilityNodeInfo.ACTION_CLICK:
@@ -283,6 +285,7 @@ public class BrowserAccessibilityManager {
return false;
mAccessibilityFocusId = newAccessibilityFocusId;
+ mAccessibilityFocusRect = null;
sendAccessibilityEvent(mAccessibilityFocusId,
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
@@ -426,6 +429,7 @@ public class BrowserAccessibilityManager {
@CalledByNative
private void handleNavigate() {
mAccessibilityFocusId = View.NO_ID;
+ mAccessibilityFocusRect = null;
mUserHasTouchExplored = false;
// Invalidate the host, since its child is now gone.
mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
@@ -526,6 +530,7 @@ public class BrowserAccessibilityManager {
@CalledByNative
private void setAccessibilityNodeInfoLocation(AccessibilityNodeInfo node,
+ final int virtualViewId,
int absoluteLeft, int absoluteTop, int parentRelativeLeft, int parentRelativeTop,
int width, int height, boolean isRootNode) {
// First set the bounds in parent.
@@ -560,6 +565,20 @@ public class BrowserAccessibilityManager {
rect.offset(viewLocation[0], viewLocation[1]);
node.setBoundsInScreen(rect);
+
+ // Work around a bug in the Android framework where if the object with accessibility
+ // focus moves, the accessibility focus rect is not updated - both the visual highlight,
+ // and the location on the screen that's clicked if you double-tap. To work around this,
+ // when we know the object with accessibility focus moved, move focus away and then
+ // move focus right back to it, which tricks Android into updating its bounds.
+ if (virtualViewId == mAccessibilityFocusId && virtualViewId != mCurrentRootId) {
+ if (mAccessibilityFocusRect == null) {
+ mAccessibilityFocusRect = rect;
+ } else if (!mAccessibilityFocusRect.equals(rect)) {
+ mAccessibilityFocusRect = rect;
+ moveAccessibilityFocusToIdAndRefocusIfNeeded(virtualViewId);
+ }
+ }
}
@CalledByNative
« no previous file with comments | « content/browser/accessibility/browser_accessibility_manager_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698