Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semantics framework updates #5601

Merged
merged 43 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
eb006ca
initial implementation of a live region for Android and addition of s…
jonahwilliams Jun 12, 2018
5329a88
Update semantics.dart
jonahwilliams Jun 13, 2018
446621b
Add image flag for semantics
jonahwilliams Jun 23, 2018
87b2b01
Merge branch 'master' of github.com:flutter/engine into live_region
jonahwilliams Jun 27, 2018
f53d5e3
update doc comment
jonahwilliams Jun 27, 2018
e3a3c58
merge with origin
jonahwilliams Jun 27, 2018
fa7b778
add dismiss action
jonahwilliams Jul 1, 2018
65d55f1
merge with live region change
jonahwilliams Jul 1, 2018
cd9fa47
wip
jonahwilliams Jul 2, 2018
a82dd2f
Address comments
jonahwilliams Jul 2, 2018
38c62ae
remove unused live region code from ios
jonahwilliams Jul 2, 2018
91ea4f3
remove for real
jonahwilliams Jul 2, 2018
fca700a
Address review comments and fix compile error in xcode beta
jonahwilliams Jul 4, 2018
e5cec1c
Update FlutterAppDelegate.mm
jonahwilliams Jul 10, 2018
8915945
Merge branch 'master' of github.com:flutter/engine into image_flag
jonahwilliams Jul 10, 2018
61e4617
add toggleable flags
jonahwilliams Jul 10, 2018
7e060d2
Add toggle semantics flags and support in android, mapping to checked…
jonahwilliams Jul 10, 2018
37380f7
fix typos in semantics
jonahwilliams Jul 10, 2018
e21a2ae
move live region experiments
jonahwilliams Jul 11, 2018
d7bc1f6
remove automatic live region update
jonahwilliams Jul 11, 2018
fc98ca0
Merge branch 'master' of github.com:flutter/engine into image_flag
jonahwilliams Jul 11, 2018
4cc928a
clean up comments
jonahwilliams Jul 11, 2018
c83e15a
merge with master
jonahwilliams Jul 11, 2018
b75b257
address some comments
jonahwilliams Jul 11, 2018
8114b03
remove initial live region update, all updates handled by framework
jonahwilliams Jul 11, 2018
9169bf2
WIP
jonahwilliams Jul 11, 2018
2ed58bd
never mind they work for real
jonahwilliams Jul 12, 2018
4dbca6c
add comments
jonahwilliams Jul 12, 2018
fb13c0f
clean up comments
jonahwilliams Jul 12, 2018
1778dde
doc comment clean up
jonahwilliams Jul 12, 2018
99fef79
Update semantics.dart
jonahwilliams Jul 12, 2018
788e239
fix live regions once and for all
jonahwilliams Jul 13, 2018
c0d6d30
clang format
jonahwilliams Jul 14, 2018
f25ae65
Update semantics.dart
jonahwilliams Jul 14, 2018
17e60b3
Update semantics.dart
jonahwilliams Jul 14, 2018
20134b4
Merge branch 'master' of github.com:flutter/engine into image_flag
jonahwilliams Jul 17, 2018
89bfcc1
special case text field
jonahwilliams Jul 17, 2018
9efe1ac
address comments
jonahwilliams Jul 19, 2018
f32c555
remove unused import
jonahwilliams Jul 19, 2018
4249d62
make adjusted changes
jonahwilliams Jul 20, 2018
8f2df6a
Merge branch 'image_flag' of github.com:jonahwilliams/engine into ima…
jonahwilliams Jul 20, 2018
a1e0882
remember that equals and == are different in Java
jonahwilliams Jul 20, 2018
11ea454
Address comments
jonahwilliams Jul 20, 2018
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
83 changes: 80 additions & 3 deletions lib/ui/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SemanticsAction {
static const int _kDidGainAccessibilityFocusIndex = 1 << 15;
static const int _kDidLoseAccessibilityFocusIndex = 1 << 16;
static const int _kCustomAction = 1 << 17;
static const int _kDismissIndex = 1 << 18;

/// The numerical value for this action.
///
Expand Down Expand Up @@ -148,11 +149,20 @@ class SemanticsAction {
static const SemanticsAction didLoseAccessibilityFocus = const SemanticsAction._(_kDidLoseAccessibilityFocusIndex);

/// Indicates that the user has invoked a custom accessibility action.
///
///
/// This handler is added automatically whenever a custom accessibility
/// action is added to a semantics node.
static const SemanticsAction customAction = const SemanticsAction._(_kCustomAction);

/// A request that the node should be dismissed.
///
/// A [Snackbar], for example, may have a dismiss action to indicate to the
/// user that it can be removed after it is no longer relevant. On Android,
/// (with TalkBack) special hint text is spoken when focusing the node and
/// a custom action is availible in the local context menu. On iOS,
/// (with VoiceOver) users can perform a standard gesture to dismiss it.
static const SemanticsAction dismiss = const SemanticsAction._(_kDismissIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does TalkBack expose the dismiss action? Is this not just a custom action of the snackbar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That link is for VoiceOver :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what the ios MDC use for snackbar, for example


/// The possible semantics actions.
///
/// The map's key is the [index] of the action and the value is the action
Expand All @@ -176,6 +186,7 @@ class SemanticsAction {
_kDidGainAccessibilityFocusIndex: didGainAccessibilityFocus,
_kDidLoseAccessibilityFocusIndex: didLoseAccessibilityFocus,
_kCustomAction: customAction,
_kDismissIndex: dismiss,
};

@override
Expand Down Expand Up @@ -217,6 +228,8 @@ class SemanticsAction {
return 'SemanticsAction.didLoseAccessibilityFocus';
case _kCustomAction:
return 'SemanticsAction.customAction';
case _kDismissIndex:
return 'SemanticsAction.dismiss';
}
return null;
}
Expand All @@ -238,6 +251,10 @@ class SemanticsFlag {
static const int _kScopesRouteIndex= 1 << 11;
static const int _kNamesRouteIndex = 1 << 12;
static const int _kIsHiddenIndex = 1 << 13;
static const int _kIsImageIndex = 1 << 14;
static const int _kIsLiveRegionIndex = 1 << 15;
static const int _kHasToggledStateIndex = 1 << 16;
static const int _kIsToggledIndex = 1 << 17;

const SemanticsFlag._(this.index);

Expand All @@ -248,7 +265,13 @@ class SemanticsFlag {

/// The semantics node has the quality of either being "checked" or "unchecked".
///
/// This flag is mutually exclusive with [hasToggledState].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enforce this with an assert on the framework side.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to do this in the same place with handle the scopesRoute assert

///
/// For example, a checkbox or a radio button widget has checked state.
///
/// See also:
///
/// * [SemanticsFlag.isChecked], which controls whether the node is "checked" or "unchecked".
static const SemanticsFlag hasCheckedState = const SemanticsFlag._(_kHasCheckedStateIndex);

/// Whether a semantics node that [hasCheckedState] is checked.
Expand All @@ -257,6 +280,10 @@ class SemanticsFlag {
/// "unchecked".
///
/// For example, if a checkbox has a visible checkmark, [isChecked] is true.
///
/// See also:
///
/// * [SemanticsFlag.hasCheckedState], which enables a checked state.
static const SemanticsFlag isChecked = const SemanticsFlag._(_kIsCheckedIndex);


Expand Down Expand Up @@ -376,6 +403,44 @@ class SemanticsFlag {
/// used to implement accessibility scrolling on iOS.
static const SemanticsFlag isHidden = const SemanticsFlag._(_kIsHiddenIndex);

/// Whether the semantics node represents an image.
///
/// Both TalkBack and VoiceOver will inform the user the the semantics node
/// represents an image.
static const SemanticsFlag isImage = const SemanticsFlag._(_kIsImageIndex);

/// Whether the semantics node is a live region.
///
/// A live region indicates that updates to semantics node are important.
/// Platforms may use this information to make polite announcements to the
/// user to inform them of updates to this node.
///
/// An example of a live region is a [SnackBar] widget. On Android, A live
/// region causes a polite announcement to be generated automatically, even
/// if the user does not have focus of the widget.
static const SemanticsFlag isLiveRegion = const SemanticsFlag._(_kIsLiveRegionIndex);

/// The semantics node has the quality of either being "on" or "off".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc should link to isToggled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

///
/// This flag is mutually exclusive with [hasCheckedState].
///
/// For example, a switch has toggled state.
///
/// See also:
///
/// * [SemanticsFlag.isToggled], which controls whether the node is "on" or "off".
static const SemanticsFlag hasToggledState = const SemanticsFlag._(_kHasToggledStateIndex);

/// If true, the semantics node is "on". If false, the semantics node is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this doc to hasToggledState

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// "off".
///
/// For example, if a switch is in the on position, [isToggled] is true.
///
/// See also:
///
/// * [SemanticsFlag.hasToggledState], which enables a toggled state.
static const SemanticsFlag isToggled = const SemanticsFlag._(_kIsToggledIndex);

/// The possible semantics flags.
///
/// The map's key is the [index] of the flag and the value is the flag itself.
Expand All @@ -394,6 +459,10 @@ class SemanticsFlag {
_kScopesRouteIndex: scopesRoute,
_kNamesRouteIndex: namesRoute,
_kIsHiddenIndex: isHidden,
_kIsImageIndex: isImage,
_kIsLiveRegionIndex: isLiveRegion,
_kHasToggledStateIndex: hasToggledState,
_kIsToggledIndex: isToggled,
};

@override
Expand Down Expand Up @@ -427,6 +496,14 @@ class SemanticsFlag {
return 'SemanticsFlag.namesRoute';
case _kIsHiddenIndex:
return 'SemanticsFlag.isHidden';
case _kIsImageIndex:
return 'SemanticsFlag.isImage';
case _kIsLiveRegionIndex:
return 'SemanticsFlag.isLiveRegion';
case _kHasToggledStateIndex:
return 'SemanticsFlag.hasToggledState';
case _kIsToggledIndex:
return 'SemanticsFlag.isToggled';
}
return null;
}
Expand Down Expand Up @@ -563,8 +640,8 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass2 {
) native 'SemanticsUpdateBuilder_updateNode';

/// Update the custom accessibility action associated with the given `id`.
///
/// The name of the action exposed to the user is the `label`. The text
///
/// The name of the action exposed to the user is the `label`. The text
/// direction of this label is the same as the global window.
void updateCustomAction({int id, String label}) {
assert(id != null);
Expand Down
5 changes: 5 additions & 0 deletions lib/ui/semantics/semantics_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum class SemanticsAction : int32_t {
kDidGainAccessibilityFocus = 1 << 15,
kDidLoseAccessibilityFocus = 1 << 16,
kCustomAction = 1 << 17,
kDismiss = 1 << 18,
};

const int kScrollableSemanticsActions =
Expand All @@ -60,6 +61,10 @@ enum class SemanticsFlags : int32_t {
kScopesRoute = 1 << 11,
kNamesRoute = 1 << 12,
kIsHidden = 1 << 13,
kIsImage = 1 << 14,
kIsLiveRegion = 1 << 15,
kHasToggledState = 1 << 16,
kIsToggled = 1 << 17,
};

struct SemanticsNode {
Expand Down
Loading