Split SemanticsFlags.isDisabled into two (flutter/engine#4517)
This commit is contained in:
committed by
GitHub
parent
0362c79542
commit
ff69f13eb3
@@ -145,7 +145,8 @@ 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;
|
||||
static const int _kHasEnabledStateIndex = 1 << 6;
|
||||
static const int _kIsEnabledIndex = 1 << 7;
|
||||
|
||||
const SemanticsFlags._(this.index);
|
||||
|
||||
@@ -194,15 +195,20 @@ 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.
|
||||
/// The semantics node has the quality of either being "enabled" or
|
||||
/// "disabled".
|
||||
///
|
||||
/// For example, a button can be enabled or disabled and therefore has an
|
||||
/// "enabled" state. Static text is usually neither enabled nor disabled and
|
||||
/// therefore does not have an "enabled" state.
|
||||
static const SemanticsFlags hasEnabledState = const SemanticsFlags._(_kHasEnabledStateIndex);
|
||||
|
||||
/// Whether a semantic node that [hasEnabledState] is currently enabled.
|
||||
///
|
||||
/// 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);
|
||||
static const SemanticsFlags isEnabled = const SemanticsFlags._(_kIsEnabledIndex);
|
||||
|
||||
/// The possible semantics flags.
|
||||
///
|
||||
@@ -214,7 +220,8 @@ class SemanticsFlags {
|
||||
_kIsButtonIndex: isButton,
|
||||
_kIsTextFieldIndex: isTextField,
|
||||
_kIsFocusedIndex: isFocused,
|
||||
_kIsDisabledIndex: isDisabled,
|
||||
_kHasEnabledStateIndex: hasEnabledState,
|
||||
_kIsEnabledIndex: isEnabled,
|
||||
};
|
||||
|
||||
@override
|
||||
@@ -232,8 +239,10 @@ class SemanticsFlags {
|
||||
return 'SemanticsFlags.isTextField';
|
||||
case _kIsFocusedIndex:
|
||||
return 'SemanticsFlags.isFocused';
|
||||
case _kIsDisabledIndex:
|
||||
return 'SemanticsFlags.isDisabled';
|
||||
case _kHasEnabledStateIndex:
|
||||
return 'SemanticsFlags.hasEnabledState';
|
||||
case _kIsEnabledIndex:
|
||||
return 'SemanticsFlags.isEnabled';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,8 @@ enum class SemanticsFlags : int32_t {
|
||||
kIsButton = 1 << 3,
|
||||
kIsTextField = 1 << 4,
|
||||
kIsFocused = 1 << 5,
|
||||
kIsDisabled = 1 << 6,
|
||||
kHasEnabledState = 1 << 6,
|
||||
kIsEnabled = 1 << 7,
|
||||
};
|
||||
|
||||
struct SemanticsNode {
|
||||
|
||||
@@ -66,7 +66,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
IS_BUTTON(1 << 3),
|
||||
IS_TEXT_FIELD(1 << 4),
|
||||
IS_FOCUSED(1 << 5),
|
||||
IS_DISABLED(1 << 6);
|
||||
HAS_ENABLED_STATE(1 << 6),
|
||||
IS_ENABLED(1 << 7);
|
||||
|
||||
Flag(int value) {
|
||||
this.value = value;
|
||||
@@ -158,7 +159,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
|
||||
}
|
||||
result.setBoundsInScreen(bounds);
|
||||
result.setVisibleToUser(true);
|
||||
result.setEnabled(!object.hasFlag(Flag.IS_DISABLED));
|
||||
result.setEnabled(!object.hasFlag(Flag.HAS_ENABLED_STATE) ||
|
||||
object.hasFlag(Flag.IS_ENABLED));
|
||||
|
||||
if (object.hasAction(Action.TAP)) {
|
||||
result.addAction(AccessibilityNodeInfo.ACTION_CLICK);
|
||||
|
||||
@@ -194,7 +194,8 @@ bool GeometryComparator(SemanticsObject* a, SemanticsObject* b) {
|
||||
if (_node.HasFlag(blink::SemanticsFlags::kIsButton)) {
|
||||
traits |= UIAccessibilityTraitButton;
|
||||
}
|
||||
if (_node.HasFlag(blink::SemanticsFlags::kIsDisabled)) {
|
||||
if (_node.HasFlag(blink::SemanticsFlags::kHasEnabledState) &&
|
||||
!_node.HasFlag(blink::SemanticsFlags::kIsEnabled)) {
|
||||
traits |= UIAccessibilityTraitNotEnabled;
|
||||
}
|
||||
return traits;
|
||||
|
||||
Reference in New Issue
Block a user