Adds all semantics roles (#163075)
<!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> This pr adds all the roles enum in one go without actually wiring up to framework and engine. It serves the following purposes 1. reduce pr conflict when multiple people working on adding new enum in the list 2. help with IDE and google test as these enum will be added in the latest engine binary after it merge. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
14c585b5c2
commit
644e46a3b3
@ -396,6 +396,69 @@ enum SemanticsRole {
|
||||
///
|
||||
/// * [table] ,[cell], [row] for table related roles.
|
||||
columnHeader,
|
||||
|
||||
/// An input field for users to enter search terms.
|
||||
searchBox,
|
||||
|
||||
/// A control used for dragging across content.
|
||||
///
|
||||
/// For example, the drag handle of [ReorderableList].
|
||||
dragHandle,
|
||||
|
||||
/// A control to cycle through content on tap.
|
||||
///
|
||||
/// For example, the next and previous month button of a [CalendarDatePicker].
|
||||
spinButton,
|
||||
|
||||
/// A input field with a dropdown list box attached.
|
||||
///
|
||||
/// For example, a [DropDownMenu]
|
||||
comboBox,
|
||||
|
||||
/// Contains a list of [menu]s.
|
||||
///
|
||||
/// For example, a [MenuBar].
|
||||
menuBar,
|
||||
|
||||
/// A button that opens a dropdown that contains multiple [menuItem]s.
|
||||
///
|
||||
/// For example, a [MenuAnchor] or [DropDownButton].
|
||||
menu,
|
||||
|
||||
/// A item in a dropdown created by [menu] or [comboBox].
|
||||
menuItem,
|
||||
|
||||
/// A container to display multiple [listItem]s in vertical or horizontal
|
||||
/// layout.
|
||||
///
|
||||
/// For example, a [LisView] or [Column].
|
||||
list,
|
||||
|
||||
/// An item in a [list].
|
||||
listItem,
|
||||
|
||||
/// An area that represents a form.
|
||||
form,
|
||||
|
||||
/// A pop up displayed when hovering over a component to provide contextual
|
||||
/// explanation.
|
||||
tooltip,
|
||||
|
||||
/// A graphic object that spins to indicate the application is busy.
|
||||
///
|
||||
/// For example, a [CircularProgressIndicator].
|
||||
loadingSpinner,
|
||||
|
||||
/// A graphic object that shows progress with a numeric number.
|
||||
///
|
||||
/// For example, a [LinearProgressIndicator].
|
||||
progressBar,
|
||||
|
||||
/// A keyboard shortcut field that allows the user to enter a combination or
|
||||
/// sequence of keystrokes.
|
||||
///
|
||||
/// For example, [Shortcuts].
|
||||
hotKey,
|
||||
}
|
||||
|
||||
/// A Boolean value that can be associated with a semantics node.
|
||||
|
@ -72,6 +72,22 @@ enum class SemanticsRole : int32_t {
|
||||
kCell = 5,
|
||||
kRow = 6,
|
||||
kColumnHeader = 7,
|
||||
kDialog = 8,
|
||||
kAlertDialog = 9,
|
||||
kSearchBox = 10,
|
||||
kDragHandle = 11,
|
||||
kSpinButton = 12,
|
||||
kComboBox = 13,
|
||||
kMenuBar = 14,
|
||||
kMenu = 15,
|
||||
kMenuItem = 16,
|
||||
kList = 17,
|
||||
kListItem = 18,
|
||||
kForm = 19,
|
||||
kTooltip = 20,
|
||||
kLoadingSpinner = 21,
|
||||
kProgressBar = 22,
|
||||
kHotKey = 23,
|
||||
};
|
||||
|
||||
/// C/C++ representation of `SemanticsFlags` defined in
|
||||
|
@ -256,7 +256,6 @@ class SemanticsFlag {
|
||||
}
|
||||
|
||||
// Mirrors engine/src/flutter/lib/ui/semantics.dart
|
||||
|
||||
enum SemanticsRole {
|
||||
none,
|
||||
tab,
|
||||
@ -268,6 +267,20 @@ enum SemanticsRole {
|
||||
cell,
|
||||
row,
|
||||
columnHeader,
|
||||
searchBox,
|
||||
dragHandle,
|
||||
spinButton,
|
||||
comboBox,
|
||||
menuBar,
|
||||
menu,
|
||||
menuItem,
|
||||
list,
|
||||
listItem,
|
||||
form,
|
||||
tooltip,
|
||||
loadingSpinner,
|
||||
progressBar,
|
||||
hotKey,
|
||||
}
|
||||
|
||||
// When adding a new StringAttributeType, the classes in these file must be
|
||||
|
@ -1776,6 +1776,22 @@ class SemanticsObject {
|
||||
return EngineSemanticsRole.row;
|
||||
case ui.SemanticsRole.columnHeader:
|
||||
return EngineSemanticsRole.columnHeader;
|
||||
// TODO(chunhtai): implement these roles.
|
||||
// https://github.com/flutter/flutter/issues/159741.
|
||||
case ui.SemanticsRole.searchBox:
|
||||
case ui.SemanticsRole.dragHandle:
|
||||
case ui.SemanticsRole.spinButton:
|
||||
case ui.SemanticsRole.comboBox:
|
||||
case ui.SemanticsRole.menuBar:
|
||||
case ui.SemanticsRole.menu:
|
||||
case ui.SemanticsRole.menuItem:
|
||||
case ui.SemanticsRole.list:
|
||||
case ui.SemanticsRole.listItem:
|
||||
case ui.SemanticsRole.form:
|
||||
case ui.SemanticsRole.tooltip:
|
||||
case ui.SemanticsRole.loadingSpinner:
|
||||
case ui.SemanticsRole.progressBar:
|
||||
case ui.SemanticsRole.hotKey:
|
||||
case ui.SemanticsRole.none:
|
||||
// fallback to checking semantics properties.
|
||||
}
|
||||
|
@ -112,12 +112,29 @@ sealed class _DebugSemanticsRoleChecks {
|
||||
SemanticsRole.tabPanel => _noCheckRequired,
|
||||
SemanticsRole.table => _noCheckRequired,
|
||||
SemanticsRole.cell => _semanticsCell,
|
||||
SemanticsRole.row => _unimplementedError,
|
||||
SemanticsRole.columnHeader => _semanticsColumnHeader,
|
||||
// TODO(chunhtai): add checks when the roles are used in framework.
|
||||
// https://github.com/flutter/flutter/issues/159741.
|
||||
SemanticsRole.row => _unimplemented,
|
||||
SemanticsRole.searchBox => _unimplemented,
|
||||
SemanticsRole.dragHandle => _unimplemented,
|
||||
SemanticsRole.spinButton => _unimplemented,
|
||||
SemanticsRole.comboBox => _unimplemented,
|
||||
SemanticsRole.menuBar => _unimplemented,
|
||||
SemanticsRole.menu => _unimplemented,
|
||||
SemanticsRole.menuItem => _unimplemented,
|
||||
SemanticsRole.list => _unimplemented,
|
||||
SemanticsRole.listItem => _unimplemented,
|
||||
SemanticsRole.form => _unimplemented,
|
||||
SemanticsRole.tooltip => _unimplemented,
|
||||
SemanticsRole.loadingSpinner => _unimplemented,
|
||||
SemanticsRole.progressBar => _unimplemented,
|
||||
SemanticsRole.hotKey => _unimplemented,
|
||||
}(node);
|
||||
|
||||
static FlutterError? _unimplementedError(SemanticsNode node) =>
|
||||
FlutterError('This semantics role is not implemented');
|
||||
static FlutterError? _unimplemented(SemanticsNode node) =>
|
||||
FlutterError('Missing checks for role ${node.getSemanticsData().role}');
|
||||
|
||||
static FlutterError? _noCheckRequired(SemanticsNode node) => null;
|
||||
|
||||
static FlutterError? _semanticsTab(SemanticsNode node) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user