未验证 提交 26010cf4 编写于 作者: M Michael Goderbauer 提交者: GitHub

Add SemanticsFlag.isDisabled (#4503)

上级 37789650
......@@ -145,6 +145,7 @@ class SemanticsFlags {
static const int _kIsButtonIndex = 1 << 3;
static const int _kIsTextFieldIndex = 1 << 4;
static const int _kIsFocusedIndex = 1 << 5;
static const int _kIsDisabledIndex = 1 << 6;
const SemanticsFlags._(this.index);
......@@ -193,6 +194,16 @@ class SemanticsFlags {
/// The focused element is usually the current receiver of keyboard inputs.
static const SemanticsFlags isFocused = const SemanticsFlags._(_kIsFocusedIndex);
/// Whether the semantic node is currently disabled.
///
/// A disabled element does not respond to user interaction. For example, a
/// button that currently does not respond to user interaction should be
/// marked as disabled.
///
/// Elements, that never respond to user interactions (e.g. static text)
/// should not be marked as disabled.
static const SemanticsFlags isDisabled = const SemanticsFlags._(_kIsDisabledIndex);
/// The possible semantics flags.
///
/// The map's key is the [index] of the flag and the value is the flag itself.
......@@ -203,6 +214,7 @@ class SemanticsFlags {
_kIsButtonIndex: isButton,
_kIsTextFieldIndex: isTextField,
_kIsFocusedIndex: isFocused,
_kIsDisabledIndex: isDisabled,
};
@override
......@@ -220,6 +232,8 @@ class SemanticsFlags {
return 'SemanticsFlags.isTextField';
case _kIsFocusedIndex:
return 'SemanticsFlags.isFocused';
case _kIsDisabledIndex:
return 'SemanticsFlags.isDisabled';
}
return null;
}
......
......@@ -41,6 +41,7 @@ enum class SemanticsFlags : int32_t {
kIsButton = 1 << 3,
kIsTextField = 1 << 4,
kIsFocused = 1 << 5,
kIsDisabled = 1 << 6,
};
struct SemanticsNode {
......
......@@ -65,7 +65,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
IS_SELECTED(1 << 2),
IS_BUTTON(1 << 3),
IS_TEXT_FIELD(1 << 4),
IS_FOCUSED(1 << 5);
IS_FOCUSED(1 << 5),
IS_DISABLED(1 << 6);
Flag(int value) {
this.value = value;
......@@ -157,7 +158,7 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
}
result.setBoundsInScreen(bounds);
result.setVisibleToUser(true);
result.setEnabled(true); // TODO(ianh): Expose disabled subtrees
result.setEnabled(!object.hasFlag(Flag.IS_DISABLED));
if (object.hasAction(Action.TAP)) {
result.addAction(AccessibilityNodeInfo.ACTION_CLICK);
......
......@@ -194,6 +194,9 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) {
if (_node.HasFlag(blink::SemanticsFlags::kIsButton)) {
traits |= UIAccessibilityTraitButton;
}
if (_node.HasFlag(blink::SemanticsFlags::kIsDisabled)) {
traits |= UIAccessibilityTraitNotEnabled;
}
return traits;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册