Commit 4081180c authored by Mark Schillaci's avatar Mark Schillaci Committed by Commit Bot

Remove KitKat accessibility support on Android

This CL removes KitKatWebContentsAccessibility.java and moves all
the logic from that class into the parent/base class of
WebContentsAccessibilityImpl.java.

We will no longer support KitKat going forward, so we can move
the KitKat specific code to our parent class since we can be
certain that any user is at least at that API level.

Bug: 1073117
Change-Id: I862a6c39bd618cc7bbc80d9ac5c13e5d590cb3b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2159418Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarMark Schillaci <mschillaci@google.com>
Reviewed-by: default avatarBo <boliu@chromium.org>
Auto-Submit: Mark Schillaci <mschillaci@google.com>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763517}
parent b40d7d6e
......@@ -188,7 +188,6 @@ android_library("content_java") {
"java/src/org/chromium/content/browser/WindowEventObserverManager.java",
"java/src/org/chromium/content/browser/accessibility/AccessibilityEventDispatcher.java",
"java/src/org/chromium/content/browser/accessibility/BrowserAccessibilityState.java",
"java/src/org/chromium/content/browser/accessibility/KitKatWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/LollipopWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/OWebContentsAccessibility.java",
"java/src/org/chromium/content/browser/accessibility/PieWebContentsAccessibility.java",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.content.browser.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.accessibility.AccessibilityNodeInfo;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.content_public.browser.WebContents;
/**
* Subclass of WebContentsAccessibility for KitKat.
*/
@JNINamespace("content")
@TargetApi(Build.VERSION_CODES.KITKAT)
public class KitKatWebContentsAccessibility extends WebContentsAccessibilityImpl {
private String mSupportedHtmlElementTypes;
KitKatWebContentsAccessibility(WebContents webContents) {
super(webContents);
}
@Override
protected void onNativeInit() {
super.onNativeInit();
mSupportedHtmlElementTypes =
WebContentsAccessibilityImplJni.get().getSupportedHtmlElementTypes(
mNativeObj, KitKatWebContentsAccessibility.this);
}
@Override
protected void setAccessibilityNodeInfoKitKatAttributes(AccessibilityNodeInfo node,
boolean isRoot, boolean isEditableText, String role, String roleDescription,
String hint, int selectionStartIndex, int selectionEndIndex, boolean hasImage,
boolean contentInvalid, String targetUrl) {
Bundle bundle = node.getExtras();
bundle.putCharSequence("AccessibilityNodeInfo.chromeRole", role);
bundle.putCharSequence("AccessibilityNodeInfo.roleDescription", roleDescription);
bundle.putCharSequence("AccessibilityNodeInfo.hint", hint);
if (!targetUrl.isEmpty()) {
bundle.putCharSequence("AccessibilityNodeInfo.targetUrl", targetUrl);
}
if (hasImage) bundle.putCharSequence("AccessibilityNodeInfo.hasImage", "true");
if (isRoot) {
bundle.putCharSequence(
"ACTION_ARGUMENT_HTML_ELEMENT_STRING_VALUES", mSupportedHtmlElementTypes);
}
if (isEditableText) {
node.setEditable(true);
node.setTextSelection(selectionStartIndex, selectionEndIndex);
}
node.setContentInvalid(contentInvalid);
}
@Override
protected int getAccessibilityServiceCapabilitiesMask() {
int capabilitiesMask = 0;
for (AccessibilityServiceInfo service :
mAccessibilityManager.getEnabledAccessibilityServiceList(
AccessibilityServiceInfo.FEEDBACK_ALL_MASK)) {
capabilitiesMask |= service.getCapabilities();
}
return capabilitiesMask;
}
}
......@@ -30,7 +30,7 @@ import java.util.Locale;
*/
@JNINamespace("content")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LollipopWebContentsAccessibility extends KitKatWebContentsAccessibility {
public class LollipopWebContentsAccessibility extends WebContentsAccessibilityImpl {
private static SparseArray<AccessibilityAction> sAccessibilityActionMap =
new SparseArray<AccessibilityAction>();
private String mSystemLanguageTag;
......
......@@ -138,6 +138,7 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
private boolean mIsCurrentlyExtendingSelection;
private int mSelectionStart;
private int mCursorIndex;
private String mSupportedHtmlElementTypes;
// Whether or not the next selection event should be fired. We only want to sent one traverse
// and one selection event per granularity move, this ensures no double events while still
......@@ -183,8 +184,6 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
return new OWebContentsAccessibility(webContents);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new LollipopWebContentsAccessibility(webContents);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return new KitKatWebContentsAccessibility(webContents);
} else {
return new WebContentsAccessibilityImpl(webContents);
}
......@@ -253,6 +252,10 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
mSelectionNodeId = View.NO_ID;
mIsHovering = false;
mCurrentRootId = View.NO_ID;
mSupportedHtmlElementTypes =
WebContentsAccessibilityImplJni.get().getSupportedHtmlElementTypes(
mNativeObj, WebContentsAccessibilityImpl.this);
}
@CalledByNative
......@@ -1536,7 +1539,24 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
boolean isRoot, boolean isEditableText, String role, String roleDescription,
String hint, int selectionStartIndex, int selectionEndIndex, boolean hasImage,
boolean contentInvalid, String targetUrl) {
// Requires KitKat or higher.
Bundle bundle = node.getExtras();
bundle.putCharSequence("AccessibilityNodeInfo.chromeRole", role);
bundle.putCharSequence("AccessibilityNodeInfo.roleDescription", roleDescription);
bundle.putCharSequence("AccessibilityNodeInfo.hint", hint);
if (!targetUrl.isEmpty()) {
bundle.putCharSequence("AccessibilityNodeInfo.targetUrl", targetUrl);
}
if (hasImage) bundle.putCharSequence("AccessibilityNodeInfo.hasImage", "true");
if (isRoot) {
bundle.putCharSequence(
"ACTION_ARGUMENT_HTML_ELEMENT_STRING_VALUES", mSupportedHtmlElementTypes);
}
if (isEditableText) {
node.setEditable(true);
node.setTextSelection(selectionStartIndex, selectionEndIndex);
}
node.setContentInvalid(contentInvalid);
}
@CalledByNative
......@@ -1769,8 +1789,13 @@ public class WebContentsAccessibilityImpl extends AccessibilityNodeProvider
*/
@CalledByNative
protected int getAccessibilityServiceCapabilitiesMask() {
// Implemented in KitKatWebContentsAccessibility.
return 0;
int capabilitiesMask = 0;
for (AccessibilityServiceInfo service :
mAccessibilityManager.getEnabledAccessibilityServiceList(
AccessibilityServiceInfo.FEEDBACK_ALL_MASK)) {
capabilitiesMask |= service.getCapabilities();
}
return capabilitiesMask;
}
@NativeMethods
......
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