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

Add SemanticsFlag.isDisabled (#4503)

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