From ba8941f86120b12f4bec0934a7666bcc725e1171 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 6 Mar 2018 15:43:13 -0800 Subject: [PATCH] Add SemanticsFlag for Header (flutter/engine#4752) --- engine/src/flutter/lib/ui/semantics.dart | 11 +++++++++++ engine/src/flutter/lib/ui/semantics/semantics_node.h | 2 ++ .../android/io/flutter/view/AccessibilityBridge.java | 3 ++- .../ios/framework/Source/accessibility_bridge.mm | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/ui/semantics.dart b/engine/src/flutter/lib/ui/semantics.dart index 28a14c9225..3fb8ecbeb1 100644 --- a/engine/src/flutter/lib/ui/semantics.dart +++ b/engine/src/flutter/lib/ui/semantics.dart @@ -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; } diff --git a/engine/src/flutter/lib/ui/semantics/semantics_node.h b/engine/src/flutter/lib/ui/semantics/semantics_node.h index ca416c1385..30ea6423b9 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_node.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_node.h @@ -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 { diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java index 6a31b5872d..3af34e91f0 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java @@ -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; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index adf3dc401c..54992d7ba7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -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; }