Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ class AccessibilityFeatures {
static const int _kAccessibleNavigation = 1 << 0;
static const int _kInvertColorsIndex = 1 << 1;
static const int _kDisableAnimationsIndex = 1 << 2;
static const int _kBoldTextIndex = 1 << 3;

// A bitfield which represents each enabled feature.
final int _index;
Expand All @@ -778,6 +779,11 @@ class AccessibilityFeatures {
/// The platform is requesting that animations be disabled or simplified.
bool get disableAnimations => _kDisableAnimationsIndex & _index != 0;

/// The platform is requesting that text be rendered at a bold font weight.
///
/// Only supported on iOS.
bool get boldText => _kBoldTextIndex & _index != 0;

@override
String toString() {
final List<String> features = <String>[];
Expand All @@ -787,6 +793,8 @@ class AccessibilityFeatures {
features.add('invertColors');
if (disableAnimations)
features.add('disableAnimations');
if (boldText)
features.add('boldText');
return 'AccessibilityFeatures$features';
}

Expand Down
1 change: 1 addition & 0 deletions lib/ui/window/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum class AccessibilityFeatureFlag : int32_t {
kAccessibleNavigation = 1 << 0,
kInvertColors = 1 << 1,
kDisableAnimations = 1 << 2,
kBoldText = 1 << 3,
};

class WindowClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ - (void)setupNotificationCenterObservers {
name:UIAccessibilityReduceMotionStatusDidChangeNotification
object:nil];

[center addObserver:self
selector:@selector(onAccessibilityStatusChanged:)
name:UIAccessibilityBoldTextStatusDidChangeNotification
object:nil];

[center addObserver:self
selector:@selector(onMemoryWarning:)
name:UIApplicationDidReceiveMemoryWarningNotification
Expand Down Expand Up @@ -811,6 +816,8 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification {
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kInvertColors);
if (UIAccessibilityIsReduceMotionEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kDisableAnimations);
if (UIAccessibilityIsBoldTextEnabled())
flags ^= static_cast<int32_t>(blink::AccessibilityFeatureFlag::kBoldText);
#if TARGET_OS_SIMULATOR
// There doesn't appear to be any way to determine whether the accessibility
// inspector is enabled on the simulator. We conservatively always turn on the
Expand Down