Unverified Commit c8c20fbc authored by chunhtai's avatar chunhtai Committed by GitHub

add read only semantics flag (#34683)

parent 0d9a1b20
20d3861ac8e1f8f38c8659b16b699d0e63db01b1 54f88ab5da4d0f3cff5337ab263dbf3385ee78df
...@@ -832,6 +832,9 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -832,6 +832,9 @@ class RenderCustomPaint extends RenderProxyBox {
if (properties.textField != null) { if (properties.textField != null) {
config.isTextField = properties.textField; config.isTextField = properties.textField;
} }
if (properties.readOnly != null) {
config.isReadOnly = properties.readOnly;
}
if (properties.focused != null) { if (properties.focused != null) {
config.isFocused = properties.focused; config.isFocused = properties.focused;
} }
......
...@@ -3426,6 +3426,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3426,6 +3426,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
bool button, bool button,
bool header, bool header,
bool textField, bool textField,
bool readOnly,
bool focused, bool focused,
bool inMutuallyExclusiveGroup, bool inMutuallyExclusiveGroup,
bool obscured, bool obscured,
...@@ -3473,6 +3474,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3473,6 +3474,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
_button = button, _button = button,
_header = header, _header = header,
_textField = textField, _textField = textField,
_readOnly = readOnly,
_focused = focused, _focused = focused,
_inMutuallyExclusiveGroup = inMutuallyExclusiveGroup, _inMutuallyExclusiveGroup = inMutuallyExclusiveGroup,
_obscured = obscured, _obscured = obscured,
...@@ -3629,6 +3631,16 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3629,6 +3631,16 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
markNeedsSemanticsUpdate(); markNeedsSemanticsUpdate();
} }
/// If non-null, sets the [SemanticsNode.isReadOnly] semantic to the given value.
bool get readOnly => _readOnly;
bool _readOnly;
set readOnly(bool value) {
if (readOnly == value)
return;
_readOnly = value;
markNeedsSemanticsUpdate();
}
/// If non-null, sets the [SemanticsNode.isFocused] semantic to the given value. /// If non-null, sets the [SemanticsNode.isFocused] semantic to the given value.
bool get focused => _focused; bool get focused => _focused;
bool _focused; bool _focused;
...@@ -4252,6 +4264,8 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -4252,6 +4264,8 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
config.isHeader = header; config.isHeader = header;
if (textField != null) if (textField != null)
config.isTextField = textField; config.isTextField = textField;
if (readOnly != null)
config.isReadOnly = readOnly;
if (focused != null) if (focused != null)
config.isFocused = focused; config.isFocused = focused;
if (inMutuallyExclusiveGroup != null) if (inMutuallyExclusiveGroup != null)
......
...@@ -565,6 +565,7 @@ class SemanticsProperties extends DiagnosticableTree { ...@@ -565,6 +565,7 @@ class SemanticsProperties extends DiagnosticableTree {
this.button, this.button,
this.header, this.header,
this.textField, this.textField,
this.readOnly,
this.focused, this.focused,
this.inMutuallyExclusiveGroup, this.inMutuallyExclusiveGroup,
this.hidden, this.hidden,
...@@ -651,6 +652,13 @@ class SemanticsProperties extends DiagnosticableTree { ...@@ -651,6 +652,13 @@ class SemanticsProperties extends DiagnosticableTree {
/// text field. /// text field.
final bool textField; final bool textField;
/// If non-null, indicates that this subtree is read only.
///
/// Only applicable when [textField] is true
///
/// TalkBack/VoiceOver will treat it as non-editable text field.
final bool readOnly;
/// If non-null, whether the node currently holds input focus. /// If non-null, whether the node currently holds input focus.
/// ///
/// At most one node in the tree should hold input focus at any point in time. /// At most one node in the tree should hold input focus at any point in time.
...@@ -3506,6 +3514,14 @@ class SemanticsConfiguration { ...@@ -3506,6 +3514,14 @@ class SemanticsConfiguration {
_setFlag(SemanticsFlag.isTextField, value); _setFlag(SemanticsFlag.isTextField, value);
} }
/// Whether the owning [RenderObject] is read only.
///
/// Only applicable when [isTextField] is true.
bool get isReadOnly => _hasFlag(SemanticsFlag.isReadOnly);
set isReadOnly(bool value) {
_setFlag(SemanticsFlag.isReadOnly, value);
}
/// Whether the [value] should be obscured. /// Whether the [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
......
...@@ -5919,6 +5919,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -5919,6 +5919,7 @@ class Semantics extends SingleChildRenderObjectWidget {
bool button, bool button,
bool header, bool header,
bool textField, bool textField,
bool readOnly,
bool focused, bool focused,
bool inMutuallyExclusiveGroup, bool inMutuallyExclusiveGroup,
bool obscured, bool obscured,
...@@ -5968,6 +5969,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -5968,6 +5969,7 @@ class Semantics extends SingleChildRenderObjectWidget {
button: button, button: button,
header: header, header: header,
textField: textField, textField: textField,
readOnly: readOnly,
focused: focused, focused: focused,
inMutuallyExclusiveGroup: inMutuallyExclusiveGroup, inMutuallyExclusiveGroup: inMutuallyExclusiveGroup,
obscured: obscured, obscured: obscured,
...@@ -6076,6 +6078,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -6076,6 +6078,7 @@ class Semantics extends SingleChildRenderObjectWidget {
button: properties.button, button: properties.button,
header: properties.header, header: properties.header,
textField: properties.textField, textField: properties.textField,
readOnly: properties.readOnly,
focused: properties.focused, focused: properties.focused,
liveRegion: properties.liveRegion, liveRegion: properties.liveRegion,
inMutuallyExclusiveGroup: properties.inMutuallyExclusiveGroup, inMutuallyExclusiveGroup: properties.inMutuallyExclusiveGroup,
...@@ -6141,6 +6144,7 @@ class Semantics extends SingleChildRenderObjectWidget { ...@@ -6141,6 +6144,7 @@ class Semantics extends SingleChildRenderObjectWidget {
..button = properties.button ..button = properties.button
..header = properties.header ..header = properties.header
..textField = properties.textField ..textField = properties.textField
..readOnly = properties.readOnly
..focused = properties.focused ..focused = properties.focused
..inMutuallyExclusiveGroup = properties.inMutuallyExclusiveGroup ..inMutuallyExclusiveGroup = properties.inMutuallyExclusiveGroup
..obscured = properties.obscured ..obscured = properties.obscured
......
...@@ -412,6 +412,7 @@ void _defineTests() { ...@@ -412,6 +412,7 @@ void _defineTests() {
hidden: true, hidden: true,
button: true, button: true,
textField: true, textField: true,
readOnly: true,
focused: true, focused: true,
inMutuallyExclusiveGroup: true, inMutuallyExclusiveGroup: true,
header: true, header: true,
...@@ -458,6 +459,7 @@ void _defineTests() { ...@@ -458,6 +459,7 @@ void _defineTests() {
hidden: true, hidden: true,
button: true, button: true,
textField: true, textField: true,
readOnly: true,
focused: true, focused: true,
inMutuallyExclusiveGroup: true, inMutuallyExclusiveGroup: true,
header: true, header: true,
......
...@@ -474,6 +474,7 @@ void main() { ...@@ -474,6 +474,7 @@ void main() {
selected: true, selected: true,
button: true, button: true,
textField: true, textField: true,
readOnly: true,
focused: true, focused: true,
inMutuallyExclusiveGroup: true, inMutuallyExclusiveGroup: true,
header: true, header: true,
......
...@@ -413,6 +413,7 @@ Matcher matchesSemantics({ ...@@ -413,6 +413,7 @@ Matcher matchesSemantics({
bool isButton = false, bool isButton = false,
bool isFocused = false, bool isFocused = false,
bool isTextField = false, bool isTextField = false,
bool isReadOnly = false,
bool hasEnabledState = false, bool hasEnabledState = false,
bool isEnabled = false, bool isEnabled = false,
bool isInMutuallyExclusiveGroup = false, bool isInMutuallyExclusiveGroup = false,
...@@ -464,6 +465,8 @@ Matcher matchesSemantics({ ...@@ -464,6 +465,8 @@ Matcher matchesSemantics({
flags.add(SemanticsFlag.isButton); flags.add(SemanticsFlag.isButton);
if (isTextField) if (isTextField)
flags.add(SemanticsFlag.isTextField); flags.add(SemanticsFlag.isTextField);
if (isReadOnly)
flags.add(SemanticsFlag.isReadOnly);
if (isFocused) if (isFocused)
flags.add(SemanticsFlag.isFocused); flags.add(SemanticsFlag.isFocused);
if (hasEnabledState) if (hasEnabledState)
......
...@@ -597,6 +597,7 @@ void main() { ...@@ -597,6 +597,7 @@ void main() {
isSelected: true, isSelected: true,
isButton: true, isButton: true,
isTextField: true, isTextField: true,
isReadOnly: true,
hasEnabledState: true, hasEnabledState: true,
isFocused: true, isFocused: true,
isEnabled: true, isEnabled: true,
......
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