diff --git a/engine/src/flutter/lib/ui/semantics.dart b/engine/src/flutter/lib/ui/semantics.dart index 0628722dd0..9ad35343f7 100644 --- a/engine/src/flutter/lib/ui/semantics.dart +++ b/engine/src/flutter/lib/ui/semantics.dart @@ -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. diff --git a/engine/src/flutter/lib/ui/semantics/semantics_node.h b/engine/src/flutter/lib/ui/semantics/semantics_node.h index 3178b71ab7..4d04d3d94e 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_node.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_node.h @@ -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 diff --git a/engine/src/flutter/lib/web_ui/lib/semantics.dart b/engine/src/flutter/lib/web_ui/lib/semantics.dart index 3dcfce67d4..61a21ae294 100644 --- a/engine/src/flutter/lib/web_ui/lib/semantics.dart +++ b/engine/src/flutter/lib/web_ui/lib/semantics.dart @@ -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 diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart index 842bd949cb..085a09f9ee 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart @@ -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. } diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 157cb420ce..e4d3117968 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -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) {