Unverified Commit c132c0fa authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Revert "Add OrderedFocusTraversalPolicy and FocusTraversalGrou… (#50660)

This reverts commit 8ef5e2f0 because it breaks some semantics tests.
parent 7f819c93
...@@ -435,7 +435,7 @@ class _FocusDemoState extends State<FocusDemo> { ...@@ -435,7 +435,7 @@ class _FocusDemoState extends State<FocusDemo> {
kUndoActionKey: () => kUndoAction, kUndoActionKey: () => kUndoAction,
kRedoActionKey: () => kRedoAction, kRedoActionKey: () => kRedoAction,
}, },
child: FocusTraversalGroup( child: DefaultFocusTraversal(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: Shortcuts( child: Shortcuts(
shortcuts: <LogicalKeySet, Intent>{ shortcuts: <LogicalKeySet, Intent>{
......
...@@ -142,7 +142,7 @@ class _FocusDemoState extends State<FocusDemo> { ...@@ -142,7 +142,7 @@ class _FocusDemoState extends State<FocusDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme; final TextTheme textTheme = Theme.of(context).textTheme;
return FocusTraversalGroup( return DefaultFocusTraversal(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: FocusScope( child: FocusScope(
debugLabel: 'Scope', debugLabel: 'Scope',
......
...@@ -1395,7 +1395,7 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver { ...@@ -1395,7 +1395,7 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
debugLabel: '<Default WidgetsApp Shortcuts>', debugLabel: '<Default WidgetsApp Shortcuts>',
child: Actions( child: Actions(
actions: widget.actions ?? WidgetsApp.defaultActions, actions: widget.actions ?? WidgetsApp.defaultActions,
child: FocusTraversalGroup( child: DefaultFocusTraversal(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: _MediaQueryFromWindow( child: _MediaQueryFromWindow(
child: Localizations( child: Localizations(
......
...@@ -230,12 +230,12 @@ class FocusAttachment { ...@@ -230,12 +230,12 @@ class FocusAttachment {
/// particular direction, is determined by the [FocusTraversalPolicy] in force. /// particular direction, is determined by the [FocusTraversalPolicy] in force.
/// ///
/// The ambient policy is determined by looking up the widget hierarchy for a /// The ambient policy is determined by looking up the widget hierarchy for a
/// [FocusTraversalGroup] widget, and obtaining the focus traversal policy /// [DefaultFocusTraversal] widget, and obtaining the focus traversal policy
/// from it. Different focus nodes can inherit difference policies, so part of /// from it. Different focus nodes can inherit difference policies, so part of
/// the app can go in widget order, and part can go in reading order, depending /// the app can go in widget order, and part can go in reading order, depending
/// upon the use case. /// upon the use case.
/// ///
/// Predefined policies include [WidgetOrderTraversalPolicy], /// Predefined policies include [WidgetOrderFocusTraversalPolicy],
/// [ReadingOrderTraversalPolicy], and [DirectionalFocusTraversalPolicyMixin], /// [ReadingOrderTraversalPolicy], and [DirectionalFocusTraversalPolicyMixin],
/// but custom policies can be built based upon these policies. /// but custom policies can be built based upon these policies.
/// ///
...@@ -361,8 +361,8 @@ class FocusAttachment { ...@@ -361,8 +361,8 @@ class FocusAttachment {
/// events to focused nodes. /// events to focused nodes.
/// * [FocusTraversalPolicy], a class used to determine how to move the focus /// * [FocusTraversalPolicy], a class used to determine how to move the focus
/// to other nodes. /// to other nodes.
/// * [FocusTraversalGroup], a widget used to group together and configure the /// * [DefaultFocusTraversal], a widget used to configure the default focus
/// focus traversal policy for a widget subtree. /// traversal policy for a widget subtree.
class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
/// Creates a focus node. /// Creates a focus node.
/// ///
...@@ -426,8 +426,8 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -426,8 +426,8 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
/// ///
/// See also: /// See also:
/// ///
/// * [FocusTraversalGroup], a widget used to group together and configure the /// * [DefaultFocusTraversal], a widget that sets the traversal policy for
/// focus traversal policy for a widget subtree. /// its descendants.
/// * [FocusTraversalPolicy], a class that can be extended to describe a /// * [FocusTraversalPolicy], a class that can be extended to describe a
/// traversal policy. /// traversal policy.
bool get canRequestFocus { bool get canRequestFocus {
...@@ -518,8 +518,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -518,8 +518,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
return _descendants; return _descendants;
} }
/// Returns all descendants which do not have the [skipTraversal] and do have /// Returns all descendants which do not have the [skipTraversal] flag set.
/// the [canRequestFocus] flag set.
Iterable<FocusNode> get traversalDescendants => descendants.where((FocusNode node) => !node.skipTraversal && node.canRequestFocus); Iterable<FocusNode> get traversalDescendants => descendants.where((FocusNode node) => !node.skipTraversal && node.canRequestFocus);
/// An [Iterable] over the ancestors of this node. /// An [Iterable] over the ancestors of this node.
...@@ -777,7 +776,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -777,7 +776,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
_manager?.primaryFocus?._setAsFocusedChild(); _manager?.primaryFocus?._setAsFocusedChild();
} }
if (oldScope != null && child.context != null && child.enclosingScope != oldScope) { if (oldScope != null && child.context != null && child.enclosingScope != oldScope) {
FocusTraversalGroup.of(child.context, nullOk: true)?.changedScope(node: child, oldScope: oldScope); DefaultFocusTraversal.of(child.context, nullOk: true)?.changedScope(node: child, oldScope: oldScope);
} }
if (child._requestFocusWhenReparented) { if (child._requestFocusWhenReparented) {
child._doRequestFocus(); child._doRequestFocus();
...@@ -916,19 +915,19 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -916,19 +915,19 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
/// [FocusTraversalPolicy.next] method. /// [FocusTraversalPolicy.next] method.
/// ///
/// Returns true if it successfully found a node and requested focus. /// Returns true if it successfully found a node and requested focus.
bool nextFocus() => FocusTraversalGroup.of(context).next(this); bool nextFocus() => DefaultFocusTraversal.of(context).next(this);
/// Request to move the focus to the previous focus node, by calling the /// Request to move the focus to the previous focus node, by calling the
/// [FocusTraversalPolicy.previous] method. /// [FocusTraversalPolicy.previous] method.
/// ///
/// Returns true if it successfully found a node and requested focus. /// Returns true if it successfully found a node and requested focus.
bool previousFocus() => FocusTraversalGroup.of(context).previous(this); bool previousFocus() => DefaultFocusTraversal.of(context).previous(this);
/// Request to move the focus to the nearest focus node in the given /// Request to move the focus to the nearest focus node in the given
/// direction, by calling the [FocusTraversalPolicy.inDirection] method. /// direction, by calling the [FocusTraversalPolicy.inDirection] method.
/// ///
/// Returns true if it successfully found a node and requested focus. /// Returns true if it successfully found a node and requested focus.
bool focusInDirection(TraversalDirection direction) => FocusTraversalGroup.of(context).inDirection(this, direction); bool focusInDirection(TraversalDirection direction) => DefaultFocusTraversal.of(context).inDirection(this, direction);
@override @override
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
......
...@@ -462,10 +462,8 @@ class _FocusState extends State<Focus> { ...@@ -462,10 +462,8 @@ class _FocusState extends State<Focus> {
return _FocusMarker( return _FocusMarker(
node: focusNode, node: focusNode,
child: Semantics( child: Semantics(
// If these values are false, then just don't set them, so they don't focusable: _canRequestFocus,
// eclipse values set by children. focused: _hasPrimaryFocus,
focusable: _canRequestFocus ? true : null,
focused: _hasPrimaryFocus ? true : null,
child: widget.child, child: widget.child,
), ),
); );
......
...@@ -2191,8 +2191,6 @@ abstract class BuildContext { ...@@ -2191,8 +2191,6 @@ abstract class BuildContext {
/// Obtains the element corresponding to the nearest widget of the given type [T], /// Obtains the element corresponding to the nearest widget of the given type [T],
/// which must be the type of a concrete [InheritedWidget] subclass. /// which must be the type of a concrete [InheritedWidget] subclass.
/// ///
/// Returns null if no such element is found.
///
/// Calling this method is O(1) with a small constant factor. /// Calling this method is O(1) with a small constant factor.
/// ///
/// This method does not establish a relationship with the target in the way /// This method does not establish a relationship with the target in the way
......
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byType(Focus)), matchesSemantics( expect(tester.getSemantics(find.byType(Focus).last), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
isEnabled: true, isEnabled: true,
...@@ -83,7 +83,7 @@ void main() { ...@@ -83,7 +83,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byType(Focus)), matchesSemantics( expect(tester.getSemantics(find.byType(Focus).last), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
isChecked: true, isChecked: true,
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_CheckboxRenderObjectWidget')), matchesSemantics( expect(tester.getSemantics(find.byType(Focus).last), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
)); ));
...@@ -111,7 +111,7 @@ void main() { ...@@ -111,7 +111,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_CheckboxRenderObjectWidget')), matchesSemantics( expect(tester.getSemantics(find.byType(Focus).last), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
isChecked: true, isChecked: true,
......
...@@ -116,7 +116,7 @@ void main() { ...@@ -116,7 +116,7 @@ void main() {
' The ancestors of this widget were:\n' ' The ancestors of this widget were:\n'
' Semantics\n' ' Semantics\n'
' Builder\n' ' Builder\n'
' RepaintBoundary-[GlobalKey#00000]\n' ' RepaintBoundary-[GlobalKey#2d465]\n'
' IgnorePointer\n' ' IgnorePointer\n'
' AnimatedBuilder\n' ' AnimatedBuilder\n'
' FadeTransition\n' ' FadeTransition\n'
...@@ -131,19 +131,19 @@ void main() { ...@@ -131,19 +131,19 @@ void main() {
' PageStorage\n' ' PageStorage\n'
' Offstage\n' ' Offstage\n'
' _ModalScopeStatus\n' ' _ModalScopeStatus\n'
' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#00000]\n' ' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#969b7]\n'
' _EffectiveTickerMode\n' ' _EffectiveTickerMode\n'
' TickerMode\n' ' TickerMode\n'
' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000]\n' ' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#545d0]\n'
' _Theatre\n' ' _Theatre\n'
' Overlay-[LabeledGlobalKey<OverlayState>#00000]\n' ' Overlay-[LabeledGlobalKey<OverlayState>#31a52]\n'
' _FocusMarker\n' ' _FocusMarker\n'
' Semantics\n' ' Semantics\n'
' FocusScope\n' ' FocusScope\n'
' AbsorbPointer\n' ' AbsorbPointer\n'
' _PointerListener\n' ' _PointerListener\n'
' Listener\n' ' Listener\n'
' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#00000]\n' ' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#10579]\n'
' IconTheme\n' ' IconTheme\n'
' IconTheme\n' ' IconTheme\n'
' _InheritedCupertinoTheme\n' ' _InheritedCupertinoTheme\n'
...@@ -158,23 +158,19 @@ void main() { ...@@ -158,23 +158,19 @@ void main() {
' CheckedModeBanner\n' ' CheckedModeBanner\n'
' Title\n' ' Title\n'
' Directionality\n' ' Directionality\n'
' _LocalizationsScope-[GlobalKey#00000]\n' ' _LocalizationsScope-[GlobalKey#a51e3]\n'
' Semantics\n' ' Semantics\n'
' Localizations\n' ' Localizations\n'
' MediaQuery\n' ' MediaQuery\n'
' _MediaQueryFromWindow\n' ' _MediaQueryFromWindow\n'
' Semantics\n' ' DefaultFocusTraversal\n'
' _FocusMarker\n'
' Focus\n'
' _FocusTraversalGroupMarker\n'
' FocusTraversalGroup\n'
' Actions\n' ' Actions\n'
' _ShortcutsMarker\n' ' _ShortcutsMarker\n'
' Semantics\n' ' Semantics\n'
' _FocusMarker\n' ' _FocusMarker\n'
' Focus\n' ' Focus\n'
' Shortcuts\n' ' Shortcuts\n'
' WidgetsApp-[GlobalObjectKey _MaterialAppState#00000]\n' ' WidgetsApp-[GlobalObjectKey _MaterialAppState#38e79]\n'
' ScrollConfiguration\n' ' ScrollConfiguration\n'
' MaterialApp\n' ' MaterialApp\n'
' [root]\n' ' [root]\n'
......
...@@ -570,7 +570,7 @@ void main() { ...@@ -570,7 +570,7 @@ void main() {
} }
Widget wrap({ Widget child }) { Widget wrap({ Widget child }) {
return FocusTraversalGroup( return DefaultFocusTraversal(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: Directionality( child: Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -598,7 +598,7 @@ void main() { ...@@ -598,7 +598,7 @@ void main() {
// This checks both FocusScopes that have their own nodes, as well as those // This checks both FocusScopes that have their own nodes, as well as those
// that use external nodes. // that use external nodes.
await tester.pumpWidget( await tester.pumpWidget(
FocusTraversalGroup( DefaultFocusTraversal(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
FocusScope( FocusScope(
...@@ -661,7 +661,7 @@ void main() { ...@@ -661,7 +661,7 @@ void main() {
final FocusScopeNode parentFocusScope2 = FocusScopeNode(debugLabel: 'Parent Scope 2'); final FocusScopeNode parentFocusScope2 = FocusScopeNode(debugLabel: 'Parent Scope 2');
await tester.pumpWidget( await tester.pumpWidget(
FocusTraversalGroup( DefaultFocusTraversal(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
FocusScope( FocusScope(
...@@ -711,7 +711,7 @@ void main() { ...@@ -711,7 +711,7 @@ void main() {
expect(find.text('b'), findsOneWidget); expect(find.text('b'), findsOneWidget);
await tester.pumpWidget( await tester.pumpWidget(
FocusTraversalGroup( DefaultFocusTraversal(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
FocusScope( FocusScope(
...@@ -746,7 +746,7 @@ void main() { ...@@ -746,7 +746,7 @@ void main() {
final FocusScopeNode parentFocusScope2 = FocusScopeNode(debugLabel: 'Parent Scope 2'); final FocusScopeNode parentFocusScope2 = FocusScopeNode(debugLabel: 'Parent Scope 2');
await tester.pumpWidget( await tester.pumpWidget(
FocusTraversalGroup( DefaultFocusTraversal(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
FocusScope( FocusScope(
...@@ -794,7 +794,7 @@ void main() { ...@@ -794,7 +794,7 @@ void main() {
expect(find.text('b'), findsOneWidget); expect(find.text('b'), findsOneWidget);
await tester.pumpWidget( await tester.pumpWidget(
FocusTraversalGroup( DefaultFocusTraversal(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
FocusScope( FocusScope(
......
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