[fuchsia][a11y] Adds isKeyboardKey semantics flag. (flutter/engine#25167)

This change introduces a semantics flag to indicate whether a node
represents a virtual keyboard key.
This commit is contained in:
Alexander Brusher
2021-03-30 13:26:56 -07:00
committed by GitHub
parent 5bfee3449a
commit 3ebaf4f764
5 changed files with 17 additions and 2 deletions

View File

@@ -313,6 +313,7 @@ class SemanticsFlag {
static const int _kIsFocusableIndex = 1 << 21;
static const int _kIsLinkIndex = 1 << 22;
static const int _kIsSliderIndex = 1 << 23;
static const int _kIsKeyboardKeyIndex = 1 << 24;
// READ THIS: if you add a flag here, you MUST update the numSemanticsFlags
// value in testing/dart/semantics_test.dart, or tests will fail. Also,
// please update the Flag enum in
@@ -374,6 +375,9 @@ class SemanticsFlag {
/// Whether the semantic node represents a slider.
static const SemanticsFlag isSlider = SemanticsFlag._(_kIsSliderIndex);
/// Whether the semantic node represents a keyboard key.
static const SemanticsFlag isKeyboardKey = SemanticsFlag._(_kIsKeyboardKeyIndex);
/// Whether the semantic node is read only.
///
/// Only applicable when [isTextField] is true.
@@ -575,6 +579,7 @@ class SemanticsFlag {
_kIsFocusableIndex: isFocusable,
_kIsLinkIndex: isLink,
_kIsSliderIndex: isSlider,
_kIsKeyboardKeyIndex: isKeyboardKey,
};
@override
@@ -628,6 +633,8 @@ class SemanticsFlag {
return 'SemanticsFlag.isLink';
case _kIsSliderIndex:
return 'SemanticsFlag.isSlider';
case _kIsKeyboardKeyIndex:
return 'SemanticsFlag.isKeyboardKey';
}
assert(false, 'Unhandled index: $index');
return '';

View File

@@ -80,6 +80,7 @@ enum class SemanticsFlags : int32_t {
kIsFocusable = 1 << 21,
kIsLink = 1 << 22,
kIsSlider = 1 << 23,
kIsKeyboardKey = 1 << 24,
};
const int kScrollableSemanticsFlags =

View File

@@ -162,6 +162,7 @@ class SemanticsFlag {
static const int _kIsFocusableIndex = 1 << 21;
static const int _kIsLinkIndex = 1 << 22;
static const int _kIsSliderIndex = 1 << 23;
static const int _kIsKeyboardKeyIndex = 1 << 24;
const SemanticsFlag._(this.index) : assert(index != null); // ignore: unnecessary_null_comparison
final int index;
@@ -189,6 +190,7 @@ class SemanticsFlag {
static const SemanticsFlag hasImplicitScrolling = SemanticsFlag._(_kHasImplicitScrollingIndex);
static const SemanticsFlag isMultiline = SemanticsFlag._(_kIsMultilineIndex);
static const SemanticsFlag isSlider = SemanticsFlag._(_kIsSliderIndex);
static const SemanticsFlag isKeyboardKey = SemanticsFlag._(_kIsKeyboardKeyIndex);
static const Map<int, SemanticsFlag> values = <int, SemanticsFlag>{
_kHasCheckedStateIndex: hasCheckedState,
_kIsCheckedIndex: isChecked,
@@ -214,6 +216,7 @@ class SemanticsFlag {
_kHasImplicitScrollingIndex: hasImplicitScrolling,
_kIsMultilineIndex: isMultiline,
_kIsReadOnlyIndex: isReadOnly,
_kIsKeyboardKeyIndex: isKeyboardKey,
};
@override
@@ -265,6 +268,8 @@ class SemanticsFlag {
return 'SemanticsFlag.isMultiline';
case _kIsReadOnlyIndex:
return 'SemanticsFlag.isReadOnly';
case _kIsKeyboardKeyIndex:
return 'SemanticsFlag.isKeyboardKey';
}
assert(false, 'Unhandled index: $index');
return '';

View File

@@ -1910,7 +1910,9 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
// IS_MULTILINE(1 << 19);
IS_READ_ONLY(1 << 20),
IS_FOCUSABLE(1 << 21),
IS_LINK(1 << 22);
IS_LINK(1 << 22),
IS_SLIDER(1 << 23),
IS_KEYBOARD_KEY(1 << 24);
final int value;

View File

@@ -9,7 +9,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
/// Verifies Semantics flags and actions.
void main() {
// This must match the number of flags in lib/ui/semantics.dart
const int numSemanticsFlags = 24;
const int numSemanticsFlags = 25;
test('SemanticsFlag.values refers to all flags.', () async {
expect(SemanticsFlag.values.length, equals(numSemanticsFlags));
for (int index = 0; index < numSemanticsFlags; ++index) {