Skip to content

Commit 2657a59

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Add support for NEXT_HTML_ELEMENT to WebViewClassic." into jb-dev
2 parents 0777558 + 8bab6de commit 2657a59

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

core/java/android/webkit/AccessibilityInjector.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,19 @@ private boolean sendActionToAndroidVox(int action, Bundle arguments) {
483483
switch (action) {
484484
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
485485
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
486-
final int granularity = arguments.getInt(
487-
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
488-
mAccessibilityJSONObject.accumulate("granularity", granularity);
486+
if (arguments != null) {
487+
final int granularity = arguments.getInt(
488+
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT);
489+
mAccessibilityJSONObject.accumulate("granularity", granularity);
490+
}
489491
break;
490492
case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
491493
case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
492-
final String element = arguments.getString(
493-
AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING);
494-
mAccessibilityJSONObject.accumulate("element", element);
494+
if (arguments != null) {
495+
final String element = arguments.getString(
496+
AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING);
497+
mAccessibilityJSONObject.accumulate("element", element);
498+
}
495499
break;
496500
}
497501
} catch (JSONException e) {

core/java/android/webkit/AccessibilityInjectorFallback.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,19 @@ private boolean traverseCurrentAxis(int direction, boolean sendEvent,
272272
boolean performAccessibilityAction(int action, Bundle arguments) {
273273
switch (action) {
274274
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
275-
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
275+
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: {
276276
final int direction = getDirectionForAction(action);
277277
final int axis = getAxisForGranularity(arguments.getInt(
278278
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT));
279279
return traverseGivenAxis(direction, axis, true, null);
280+
}
281+
case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
282+
case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT: {
283+
final int direction = getDirectionForAction(action);
284+
// TODO: Add support for moving by object.
285+
final int axis = NAVIGATION_AXIS_SENTENCE;
286+
return traverseGivenAxis(direction, axis, true, null);
287+
}
280288
default:
281289
return false;
282290
}
@@ -291,8 +299,10 @@ boolean performAccessibilityAction(int action, Bundle arguments) {
291299
*/
292300
private static int getDirectionForAction(int action) {
293301
switch (action) {
302+
case AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT:
294303
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
295304
return NAVIGATION_DIRECTION_FORWARD;
305+
case AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT:
296306
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
297307
return NAVIGATION_DIRECTION_BACKWARD;
298308
default:
@@ -316,8 +326,8 @@ private static int getAxisForGranularity(int granularity) {
316326
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE:
317327
return NAVIGATION_AXIS_SENTENCE;
318328
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH:
319-
// TODO: Figure out what nextSibling() actually means.
320-
return NAVIGATION_AXIS_SIBLING;
329+
// TODO: This should map to object once we implement it.
330+
return NAVIGATION_AXIS_SENTENCE;
321331
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE:
322332
return NAVIGATION_AXIS_DOCUMENT;
323333
default:

0 commit comments

Comments
 (0)