Commit b0bf9b92 authored by Mark Schillaci's avatar Mark Schillaci Committed by Commit Bot

Disabling accessibility event throttling and node caching on Android

This CL disables AccessibiliEvent throttling, and disables the
AccessibilityNodeInfo caching on Android.

This CL leaves all the code in place but does not leverage it so that
we know M83 will be cut without regressions. We can then revert this
change and land them in M84 or later.

Change-Id: I405e712431a4b114ab4bebe7924bb7e75d98e989
RelNotes: N/A
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132927
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarMark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755558}
parent 4a472c4d
...@@ -51,7 +51,6 @@ import org.chromium.content_public.browser.WebContentsAccessibility; ...@@ -51,7 +51,6 @@ import org.chromium.content_public.browser.WebContentsAccessibility;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -168,8 +167,8 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -168,8 +167,8 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
// Unordered list of event types we will throttle if multiple events of the given type are sent // Unordered list of event types we will throttle if multiple events of the given type are sent
// in quick succession. // in quick succession.
private Set<Integer> mEventsToThrottle = new HashSet<Integer>(Arrays.asList( // TODO (mschillaci) - No event types added in M83 to disable all throttling.
AccessibilityEvent.TYPE_VIEW_SCROLLED, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED)); private Set<Integer> mEventsToThrottle = new HashSet<Integer>();
// For events being throttled (see: |mEventsToThrottle|), this array will map the eventType // For events being throttled (see: |mEventsToThrottle|), this array will map the eventType
// to the last time (long in milliseconds) such an event has been sent. // to the last time (long in milliseconds) such an event has been sent.
...@@ -181,8 +180,13 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -181,8 +180,13 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
// This array maps a given virtualViewId to an |AccessibilityNodeInfo| for that view. We use // This array maps a given virtualViewId to an |AccessibilityNodeInfo| for that view. We use
// this to update a node quickly rather than building from one scratch each time. // this to update a node quickly rather than building from one scratch each time.
// TODO (mschillaci) - Nothing is added to the cache in M83, it is disabled.
private SparseArray<AccessibilityNodeInfo> mNodeInfoCache = new SparseArray<>(); private SparseArray<AccessibilityNodeInfo> mNodeInfoCache = new SparseArray<>();
// TODO (mschillaci) - Revert this change to re-enable throttling.
private Runnable mSendWindowContentChangedRunnable;
private static final int WINDOW_CONTENT_CHANGED_DELAY_MS = 500;
/** /**
* Create a WebContentsAccessibilityImpl object. * Create a WebContentsAccessibilityImpl object.
*/ */
...@@ -374,7 +378,8 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -374,7 +378,8 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
if (WebContentsAccessibilityImplJni.get().populateAccessibilityNodeInfo( if (WebContentsAccessibilityImplJni.get().populateAccessibilityNodeInfo(
mNativeObj, WebContentsAccessibilityImpl.this, info, virtualViewId)) { mNativeObj, WebContentsAccessibilityImpl.this, info, virtualViewId)) {
// After successfully populating this node, add it to our cache then return. // After successfully populating this node, add it to our cache then return.
mNodeInfoCache.put(virtualViewId, AccessibilityNodeInfo.obtain(info)); // TODO (mschillaci) - Uncomment this line to re-enable caching.
// mNodeInfoCache.put(virtualViewId, AccessibilityNodeInfo.obtain(info));
return info; return info;
} else { } else {
info.recycle(); info.recycle();
...@@ -412,7 +417,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -412,7 +417,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
public void setObscuredByAnotherView(boolean isObscured) { public void setObscuredByAnotherView(boolean isObscured) {
if (isObscured != mIsObscuredByAnotherView) { if (isObscured != mIsObscuredByAnotherView) {
mIsObscuredByAnotherView = isObscured; mIsObscuredByAnotherView = isObscured;
sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
// sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
} }
} }
...@@ -791,7 +798,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -791,7 +798,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
// Invalidate the container view, since the chrome accessibility tree is now // Invalidate the container view, since the chrome accessibility tree is now
// ready and listed as the child of the container view. // ready and listed as the child of the container view.
sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
// sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
sendWindowContentChangedOnView();
// (Re-) focus focused element, since we weren't able to create an // (Re-) focus focused element, since we weren't able to create an
// AccessibilityNodeInfo for this element before. // AccessibilityNodeInfo for this element before.
...@@ -1060,7 +1069,30 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -1060,7 +1069,30 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
*/ */
@CalledByNative @CalledByNative
private void sendDelayedWindowContentChangedEvent() { private void sendDelayedWindowContentChangedEvent() {
sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
if (mSendWindowContentChangedRunnable != null) return;
mSendWindowContentChangedRunnable = new Runnable() {
@Override
public void run() {
sendWindowContentChangedOnView();
}
};
mView.postDelayed(mSendWindowContentChangedRunnable, WINDOW_CONTENT_CHANGED_DELAY_MS);
}
private void sendWindowContentChangedOnView() {
if (mSendWindowContentChangedRunnable != null) {
mView.removeCallbacks(mSendWindowContentChangedRunnable);
mSendWindowContentChangedRunnable = null;
}
mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
private void sendWindowContentChangedOnVirtualView(int virtualViewId) {
sendAccessibilityEvent(virtualViewId, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
// sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
} }
private void sendAccessibilityEvent(int virtualViewId, int eventType) { private void sendAccessibilityEvent(int virtualViewId, int eventType) {
...@@ -1079,6 +1111,7 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -1079,6 +1111,7 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
} }
// Check whether this type of event is one we want to throttle, and if not then send it // Check whether this type of event is one we want to throttle, and if not then send it
// TODO (mschillaci) - Will always return true until we enable throttling (see line: 171).
if (!mEventsToThrottle.contains(eventType)) { if (!mEventsToThrottle.contains(eventType)) {
AccessibilityEvent event = buildAccessibilityEvent(virtualViewId, eventType); AccessibilityEvent event = buildAccessibilityEvent(virtualViewId, eventType);
if (event == null) return; if (event == null) return;
...@@ -1282,9 +1315,13 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -1282,9 +1315,13 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
mNativeObj, WebContentsAccessibilityImpl.this); mNativeObj, WebContentsAccessibilityImpl.this);
if (rootId != mCurrentRootId) { if (rootId != mCurrentRootId) {
mCurrentRootId = rootId; mCurrentRootId = rootId;
sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
// sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
sendWindowContentChangedOnView();
} else { } else {
sendAccessibilityEvent(id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
// sendAccessibilityEvent(id, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
sendWindowContentChangedOnVirtualView(id);
} }
} }
...@@ -1294,7 +1331,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider ...@@ -1294,7 +1331,9 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
mAccessibilityFocusRect = null; mAccessibilityFocusRect = null;
mUserHasTouchExplored = false; mUserHasTouchExplored = false;
// Invalidate the host, since its child is now gone. // Invalidate the host, since its child is now gone.
sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); // TODO (mschillaci) - Revert this change to re-enable throttling.
// sendAccessibilityEvent(View.NO_ID, AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
sendWindowContentChangedOnView();
} }
@CalledByNative @CalledByNative
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment