Unverified Commit 2eb290e7 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Wire up SemanticsFlag.isHidden (#16772)

parent 4f31a3f5
09d05a38912a3c1a906e95099cac9a7e14fae85f 232060828a1d4a9c3ee16b92f3af5f5a15041e32
...@@ -834,6 +834,9 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -834,6 +834,9 @@ class RenderCustomPaint extends RenderProxyBox {
if (properties.obscured != null) { if (properties.obscured != null) {
config.isObscured = properties.obscured; config.isObscured = properties.obscured;
} }
if (properties.hidden != null) {
config.isHidden = properties.hidden;
}
if (properties.header != null) { if (properties.header != null) {
config.isHeader = properties.header; config.isHeader = properties.header;
} }
......
...@@ -3021,6 +3021,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3021,6 +3021,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
bool obscured, bool obscured,
bool scopesRoute, bool scopesRoute,
bool namesRoute, bool namesRoute,
bool hidden,
String label, String label,
String value, String value,
String increasedValue, String increasedValue,
...@@ -3058,6 +3059,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3058,6 +3059,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
_obscured = obscured, _obscured = obscured,
_scopesRoute = scopesRoute, _scopesRoute = scopesRoute,
_namesRoute = namesRoute, _namesRoute = namesRoute,
_hidden = hidden,
_label = label, _label = label,
_value = value, _value = value,
_increasedValue = increasedValue, _increasedValue = increasedValue,
...@@ -3237,6 +3239,17 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3237,6 +3239,17 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
markNeedsSemanticsUpdate(); markNeedsSemanticsUpdate();
} }
/// If non-null, sets the [SemanticsNode.isHidden] semantic to the given
/// value.
bool get hidden => _hidden;
bool _hidden;
set hidden(bool value) {
if (hidden == value)
return;
_hidden = value;
markNeedsSemanticsUpdate();
}
/// If non-null, sets the [SemanticsNode.label] semantic to the given value. /// If non-null, sets the [SemanticsNode.label] semantic to the given value.
/// ///
/// The reading direction is given by [textDirection]. /// The reading direction is given by [textDirection].
...@@ -3678,6 +3691,8 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3678,6 +3691,8 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
config.isInMutuallyExclusiveGroup = inMutuallyExclusiveGroup; config.isInMutuallyExclusiveGroup = inMutuallyExclusiveGroup;
if (obscured != null) if (obscured != null)
config.isObscured = obscured; config.isObscured = obscured;
if (hidden != null)
config.isHidden = hidden;
if (label != null) if (label != null)
config.label = label; config.label = label;
if (value != null) if (value != null)
......
...@@ -319,6 +319,7 @@ class SemanticsProperties extends DiagnosticableTree { ...@@ -319,6 +319,7 @@ class SemanticsProperties extends DiagnosticableTree {
this.textField, this.textField,
this.focused, this.focused,
this.inMutuallyExclusiveGroup, this.inMutuallyExclusiveGroup,
this.hidden,
this.obscured, this.obscured,
this.scopesRoute, this.scopesRoute,
this.namesRoute, this.namesRoute,
...@@ -401,7 +402,25 @@ class SemanticsProperties extends DiagnosticableTree { ...@@ -401,7 +402,25 @@ class SemanticsProperties extends DiagnosticableTree {
/// For example, a radio button is in a mutually exclusive group because only /// For example, a radio button is in a mutually exclusive group because only
/// one radio button in that group can be marked as [checked]. /// one radio button in that group can be marked as [checked].
final bool inMutuallyExclusiveGroup; final bool inMutuallyExclusiveGroup;
/// If non-null, whether the node is considered hidden.
///
/// Hidden elements are currently not visible on screen. They may be covered
/// by other elements or positioned outside of the visible area of a viewport.
///
/// Hidden elements cannot gain accessibility focus though regular touch. The
/// only way they can be focused is by moving the focus to them via linear
/// navigation.
///
/// Platforms are free to completely ignore hidden elements and new platforms
/// are encouraged to do so.
///
/// Instead of marking an element as hidden it should usually be excluded from
/// the semantics tree altogether. Hidden elements are only included in the
/// semantics tree to work around platform limitations and they are mainly
/// used to implement accessibility scrolling on iOS.
final bool hidden;
/// If non-null, whether [value] should be obscured. /// If non-null, whether [value] should be obscured.
/// ///
/// This option is usually set in combination with [textField] to indicate /// This option is usually set in combination with [textField] to indicate
...@@ -1442,6 +1461,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -1442,6 +1461,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
final List<String> flags = SemanticsFlag.values.values.where((SemanticsFlag flag) => _hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList(); final List<String> flags = SemanticsFlag.values.values.where((SemanticsFlag flag) => _hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList();
properties.add(new IterableProperty<String>('flags', flags, ifEmpty: null)); properties.add(new IterableProperty<String>('flags', flags, ifEmpty: null));
properties.add(new FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible')); properties.add(new FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible'));
properties.add(new FlagProperty('isHidden', value: _hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN'));
properties.add(new StringProperty('label', _label, defaultValue: '')); properties.add(new StringProperty('label', _label, defaultValue: ''));
properties.add(new StringProperty('value', _value, defaultValue: '')); properties.add(new StringProperty('value', _value, defaultValue: ''));
properties.add(new StringProperty('increasedValue', _increasedValue, defaultValue: '')); properties.add(new StringProperty('increasedValue', _increasedValue, defaultValue: ''));
...@@ -2450,6 +2470,27 @@ class SemanticsConfiguration { ...@@ -2450,6 +2470,27 @@ class SemanticsConfiguration {
_setFlag(SemanticsFlag.isHeader, value); _setFlag(SemanticsFlag.isHeader, value);
} }
/// Whether the owning [RenderObject] is considered hidden.
///
/// Hidden elements are currently not visible on screen. They may be covered
/// by other elements or positioned outside of the visible area of a viewport.
///
/// Hidden elements cannot gain accessibility focus though regular touch. The
/// only way they can be focused is by moving the focus to them via linear
/// navigation.
///
/// Platforms are free to completely ignore hidden elements and new platforms
/// are encouraged to do so.
///
/// Instead of marking an element as hidden it should usually be excluded from
/// the semantics tree altogether. Hidden elements are only included in the
/// semantics tree to work around platform limitations and they are mainly
/// used to implement accessibility scrolling on iOS.
bool get isHidden => _hasFlag(SemanticsFlag.isHidden);
set isHidden(bool value) {
_setFlag(SemanticsFlag.isHidden, value);
}
/// Whether the owning [RenderObject] is a text field. /// Whether the owning [RenderObject] is a text field.
bool get isTextField => _hasFlag(SemanticsFlag.isTextField); bool get isTextField => _hasFlag(SemanticsFlag.isTextField);
set isTextField(bool value) { set isTextField(bool value) {
......
...@@ -4898,6 +4898,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -4898,6 +4898,7 @@ class Semantics extends SingleChildRenderObjectWidget {
bool obscured, bool obscured,
bool scopesRoute, bool scopesRoute,
bool namesRoute, bool namesRoute,
bool hidden,
String label, String label,
String value, String value,
String increasedValue, String increasedValue,
...@@ -4938,6 +4939,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -4938,6 +4939,7 @@ class Semantics extends SingleChildRenderObjectWidget {
obscured: obscured, obscured: obscured,
scopesRoute: scopesRoute, scopesRoute: scopesRoute,
namesRoute: namesRoute, namesRoute: namesRoute,
hidden: hidden,
label: label, label: label,
value: value, value: value,
increasedValue: increasedValue, increasedValue: increasedValue,
...@@ -5023,6 +5025,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -5023,6 +5025,7 @@ class Semantics extends SingleChildRenderObjectWidget {
obscured: properties.obscured, obscured: properties.obscured,
scopesRoute: properties.scopesRoute, scopesRoute: properties.scopesRoute,
namesRoute: properties.namesRoute, namesRoute: properties.namesRoute,
hidden: properties.hidden,
label: properties.label, label: properties.label,
value: properties.value, value: properties.value,
increasedValue: properties.increasedValue, increasedValue: properties.increasedValue,
...@@ -5065,16 +5068,23 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -5065,16 +5068,23 @@ class Semantics extends SingleChildRenderObjectWidget {
void updateRenderObject(BuildContext context, RenderSemanticsAnnotations renderObject) { void updateRenderObject(BuildContext context, RenderSemanticsAnnotations renderObject) {
renderObject renderObject
..container = container ..container = container
..scopesRoute = properties.scopesRoute
..explicitChildNodes = explicitChildNodes ..explicitChildNodes = explicitChildNodes
..enabled = properties.enabled ..enabled = properties.enabled
..checked = properties.checked ..checked = properties.checked
..selected = properties.selected ..selected = properties.selected
..button = properties.button
..header = properties.header
..textField = properties.textField
..focused = properties.focused
..inMutuallyExclusiveGroup = properties.inMutuallyExclusiveGroup
..obscured = properties.obscured
..hidden = properties.hidden
..label = properties.label ..label = properties.label
..value = properties.value ..value = properties.value
..increasedValue = properties.increasedValue ..increasedValue = properties.increasedValue
..decreasedValue = properties.decreasedValue ..decreasedValue = properties.decreasedValue
..hint = properties.hint ..hint = properties.hint
..scopesRoute = properties.scopesRoute
..namesRoute = properties.namesRoute ..namesRoute = properties.namesRoute
..textDirection = _getTextDirection(context) ..textDirection = _getTextDirection(context)
..sortKey = properties.sortKey ..sortKey = properties.sortKey
......
...@@ -361,6 +361,7 @@ void main() { ...@@ -361,6 +361,7 @@ void main() {
' actions: []\n' ' actions: []\n'
' flags: []\n' ' flags: []\n'
' invisible\n' ' invisible\n'
' isHidden: false\n'
' label: ""\n' ' label: ""\n'
' value: ""\n' ' value: ""\n'
' increasedValue: ""\n' ' increasedValue: ""\n'
......
...@@ -410,6 +410,7 @@ void _defineTests() { ...@@ -410,6 +410,7 @@ void _defineTests() {
enabled: true, enabled: true,
checked: true, checked: true,
selected: true, selected: true,
hidden: true,
button: true, button: true,
textField: true, textField: true,
focused: true, focused: true,
......
...@@ -461,8 +461,10 @@ void main() { ...@@ -461,8 +461,10 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
new Semantics( new Semantics(
container: true, container: true,
explicitChildNodes: true,
// flags // flags
enabled: true, enabled: true,
hidden: true,
checked: true, checked: true,
selected: true, selected: true,
button: true, button: true,
...@@ -473,11 +475,10 @@ void main() { ...@@ -473,11 +475,10 @@ void main() {
obscured: true, obscured: true,
scopesRoute: true, scopesRoute: true,
namesRoute: true, namesRoute: true,
explicitChildNodes: true,
) )
); );
final TestSemantics expectedSemantics = new TestSemantics.root( TestSemantics expectedSemantics = new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
...@@ -487,6 +488,19 @@ void main() { ...@@ -487,6 +488,19 @@ void main() {
); );
expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true));
await tester.pumpWidget(new Semantics(
container: true,
));
expectedSemantics = new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
rect: TestSemantics.fullScreen,
flags: <SemanticsFlag>[],
),
],
);
expect(semantics, hasSemantics(expectedSemantics, ignoreId: true));
semantics.dispose(); semantics.dispose();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment