Add SemanticsFlag for Header (flutter/engine#4752)

This commit is contained in:
Michael Goderbauer
2018-03-06 15:43:13 -08:00
committed by GitHub
parent e35e882ceb
commit ba8941f861
4 changed files with 18 additions and 1 deletions

View File

@@ -223,6 +223,7 @@ class SemanticsFlag {
static const int _kHasEnabledStateIndex = 1 << 6;
static const int _kIsEnabledIndex = 1 << 7;
static const int _kIsInMutuallyExclusiveGroupIndex = 1 << 8;
static const int _kIsHeaderIndex = 1 << 9;
const SemanticsFlag._(this.index);
@@ -292,6 +293,13 @@ class SemanticsFlag {
/// only one radio button in that group can be marked as [isChecked].
static const SemanticsFlag isInMutuallyExclusiveGroup = const SemanticsFlag._(_kIsInMutuallyExclusiveGroupIndex);
/// Whether a semantic node is a header that divides content into sections.
///
/// For example, headers can be used to divide a list of alphabetically
/// sorted words into the sections A, B, C, etc. as can be found in many
/// address book applications.
static const SemanticsFlag isHeader = const SemanticsFlag._(_kIsHeaderIndex);
/// The possible semantics flags.
///
/// The map's key is the [index] of the flag and the value is the flag itself.
@@ -305,6 +313,7 @@ class SemanticsFlag {
_kHasEnabledStateIndex: hasEnabledState,
_kIsEnabledIndex: isEnabled,
_kIsInMutuallyExclusiveGroupIndex: isInMutuallyExclusiveGroup,
_kIsHeaderIndex: isHeader,
};
@override
@@ -328,6 +337,8 @@ class SemanticsFlag {
return 'SemanticsFlag.isEnabled';
case _kIsInMutuallyExclusiveGroupIndex:
return 'SemanticsFlag.isInMutuallyExclusiveGroup';
case _kIsHeaderIndex:
return 'SemanticsFlag.isHeader';
}
return null;
}

View File

@@ -53,6 +53,8 @@ enum class SemanticsFlags : int32_t {
kIsFocused = 1 << 5,
kHasEnabledState = 1 << 6,
kIsEnabled = 1 << 7,
kIsInMutuallyExclusiveGroup = 1 << 8,
kIsHeader = 1 << 9,
};
struct SemanticsNode {

View File

@@ -83,7 +83,8 @@ class AccessibilityBridge extends AccessibilityNodeProvider implements BasicMess
IS_FOCUSED(1 << 5),
HAS_ENABLED_STATE(1 << 6),
IS_ENABLED(1 << 7),
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(1 << 8);
IS_IN_MUTUALLY_EXCLUSIVE_GROUP(1 << 8),
IS_HEADER(1 << 9);
Flag(int value) {
this.value = value;

View File

@@ -318,6 +318,9 @@ NSComparisonResult IntToComparisonResult(int32_t value) {
![self node].HasFlag(blink::SemanticsFlags::kIsEnabled)) {
traits |= UIAccessibilityTraitNotEnabled;
}
if ([self node].HasFlag(blink::SemanticsFlags::kIsHeader)) {
traits |= UIAccessibilityTraitHeader;
}
return traits;
}