Skip to content

Commit

Permalink
Remove unneeded accessibility methods in Android
Browse files Browse the repository at this point in the history
This CL removes some methods that are not serving a purpose in the
code base, and will not in the future. These are methods that
always returned false, and so code paths can be simplified. The
methods are not necessary, as the WebContentsAccessibilityImpl class
supports all actions, and will perform all actions as long as it is
not null. They are likely an artifact of past impls / history.

The Android FW calls performAccessibilityAction on a View when
the AccessibilityNodeProvider (ANP) for that view is null. Chrome's
ANP is WebContentsAccessibilityImpl. In some cases, classes are
overriding performAccessibilityAction to have it call WCAI's
performAction (which always returns false), unless the node provider
from WCAI is null. If the framework called performAccessibilityAction,
it is because WCAI returned null in the first place, so the action
would not be passed to WCAI and the super method invoked instead.


AX-Relnotes: N/A
Bug: 1362100
Change-Id: I8e176282246ca02eeaf8c78d91405ecae7ac0119
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4204909
Commit-Queue: Mark Schillaci <mschillaci@google.com>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098884}
  • Loading branch information
mschillaci authored and Chromium LUCI CQ committed Jan 30, 2023
1 parent 14a9ce8 commit 25fb150
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2118,9 +2118,6 @@ public Boolean call() {
});
return ret;
}
if (mAwContents.supportsAccessibilityAction(action)) {
return mAwContents.performAccessibilityAction(action, arguments);
}
return mWebViewPrivate.super_performAccessibilityAction(action, arguments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3406,10 +3406,6 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
return mAwViewMethods.getAccessibilityNodeProvider();
}

public boolean supportsAccessibilityAction(int action) {
return isDestroyed(WARN) ? false : getWebContentsAccessibility().supportsAction(action);
}

/**
* @see android.webkit.WebView#performAccessibilityAction(int, Bundle)
*/
Expand Down Expand Up @@ -4344,9 +4340,7 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {

@Override
public boolean performAccessibilityAction(final int action, final Bundle arguments) {
if (isDestroyed(NO_WARN)) return false;
WebContentsAccessibility wcax = getWebContentsAccessibility();
return wcax != null ? wcax.performAction(action, arguments) : false;
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.DragEvent;
import android.view.KeyEvent;
Expand Down Expand Up @@ -157,14 +156,6 @@ public void setIsObscuredForAccessibility(boolean isObscured) {
wcax.setObscuredByAnotherView(mIsObscuredForAccessibility);
}

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
WebContentsAccessibility wcax = getWebContentsAccessibility();
return wcax != null && wcax.supportsAction(action)
? wcax.performAction(action, arguments)
: super.performAccessibilityAction(action, arguments);
}

/**
* Instructs the ContentView to defer (or stop deferring) the application of changes to its
* KeepScreenOn flag. If deferring is being turned off, super.setKeepScreenOn will be called
Expand Down Expand Up @@ -314,9 +305,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
WebContentsAccessibility wcax = getWebContentsAccessibility();
AccessibilityNodeProvider provider =
(wcax != null) ? wcax.getAccessibilityNodeProvider() : null;
return (provider != null) ? provider : super.getAccessibilityNodeProvider();
return (wcax != null) ? wcax.getAccessibilityNodeProvider() : null;
}

// Needed by ViewEventSink.InternalAccessDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.Size;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -167,13 +166,6 @@ private void layoutSubFrames() {
}
}

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
return mWebContentsAccessibility != null && mWebContentsAccessibility.supportsAction(action)
? mWebContentsAccessibility.performAction(action, arguments)
: super.performAccessibilityAction(action, arguments);
}

@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
AccessibilityNodeProvider provider = (mWebContentsAccessibility != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,18 +882,6 @@ public void setIsImageDescriptionsCandidate(boolean isImageDescriptionsCandidate
mIsImageDescriptionsCandidate = isImageDescriptionsCandidate;
}

@Override
public boolean supportsAction(int action) {
// TODO(dmazzoni): implement this.
return false;
}

@Override
public boolean performAction(int action, Bundle arguments) {
// TODO(dmazzoni): implement this.
return false;
}

@Override
public void onProvideVirtualStructure(
final ViewStructure structure, final boolean ignoreScrollOffset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.
package org.chromium.content_public.browser;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewStructure;
Expand All @@ -28,13 +27,6 @@ static WebContentsAccessibility fromWebContents(WebContents webContents) {
return WebContentsAccessibilityImpl.fromWebContents(webContents);
}

/**
* Determines whether or not the given accessibility action can be handled.
* @param action The action to perform.
* @return Whether or not this action is supported.
*/
boolean supportsAction(int action);

/**
* Determines if a11y enabled.
* @return {@code true} if a11y is enabled.
Expand All @@ -59,18 +51,6 @@ static WebContentsAccessibility fromWebContents(WebContents webContents) {
@VisibleForTesting
void addSpellingErrorForTesting(int virtualViewId, int startOffset, int endOffset);

/**
* Attempts to perform an accessibility action on the web content. If the accessibility action
* cannot be processed, it returns {@code null}, allowing the caller to know to call the
* super {@link View#performAccessibilityAction(int, Bundle)} method and use that return value.
* Otherwise the return value from this method should be used.
* @param action The action to perform.
* @param arguments Optional action arguments.
* @return Whether the action was performed or {@code null} if the call should be delegated to
* the super {@link View} class.
*/
boolean performAction(int action, Bundle arguments);

/**
* If native accessibility is enabled and no other views are temporarily
* obscuring this one, returns an AccessibilityNodeProvider that
Expand Down

0 comments on commit 25fb150

Please sign in to comment.