Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Jul 14, 2023

Always add secondary role managers irrespective of the initial state of the semantic node, and have role manager decide whether it applies to the node or not.

Fixes flutter/flutter#130546

@yjbanov yjbanov marked this pull request as ready for review July 14, 2023 01:00
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Jul 14, 2023
@yjbanov yjbanov requested review from mdebbar and ditman July 14, 2023 01:00
@yjbanov yjbanov changed the title [web] update role manager list [web] teach PrimaryRoleManager to update role manager list Jul 14, 2023
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong opinions on this, but the determination of what secondary role factories are needed is a little bit itchy :/

Comment on lines 551 to 555
// A role manager should only be added once. So remove any factories that
// contributed a role manager.
_secondaryRoleManagers?.forEach((RoleManager roleManager) {
secondaryRoleFactories.remove(roleManager.role);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because this update can be called multiple times? Does every update restore the roleFactories for this role manager? Is the role manager disposable?

Comment on lines 543 to 545
secondaryRoleFactories.forEach((Role role, RoleManagerFactory roleFactory) {
final RoleManager? secondaryRoleManager = roleFactory(semanticsObject);
if (secondaryRoleManager != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for loop looks a little bit weird to me. Wouldn't it be better that this knows what availableSecondaryRoles can be used, and the semanticsObject knows what configuredSecondaryRoles it has?

That way instead of this loop checking on every roleFactory if it can support the semanticsObject, an intersection would narrow down the actually needed Roles (which could have the roleFactory associated to the Role an immutable const Map<Role, RoleManagerFactory>, or whatever?)

Comment on lines 465 to 470
addSecondaryRole(Role.focusable, (SemanticsObject semanticsObject) {
if (semanticsObject.isFocusable) {
return Focusable(semanticsObject);
}
return null;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these factories are always the same and have no dependency on the PrimaryRoleManager instance. Can we put them in a global map:

final Map<Role, RoleManagerFactory> secondaryRoleFactories = <Role, RoleManagerFactory> {
  Role.focusable: (SemanticsObject obj) => obj.isFocusable ? Focusable(obj) : null,
  ...
};

or combine them in a switch expression somewhere (I prefer this to make sure we exhaust all cases for Role):

extension RoleFactoryExtension on Role {
  RoleManager? createManager() {
    return switch (this) {
      Role.focusable => this.isFocusable ? Focusable(this) : null,
      ...
    }
  }
}

And the primary role manager only maintains a List<Role> and uses it during update() to decide what secondary role managers to create.

Comment on lines 541 to 555
final Map<Role, RoleManagerFactory>? secondaryRoleFactories = _secondaryRoleFactories;
if (secondaryRoleFactories != null && secondaryRoleFactories.isNotEmpty) {
secondaryRoleFactories.forEach((Role role, RoleManagerFactory roleFactory) {
final RoleManager? secondaryRoleManager = roleFactory(semanticsObject);
if (secondaryRoleManager != null) {
_secondaryRoleManagers ??= <RoleManager>[];
_secondaryRoleManagers!.add(secondaryRoleManager);
}
});

// A role manager should only be added once. So remove any factories that
// contributed a role manager.
_secondaryRoleManagers?.forEach((RoleManager roleManager) {
secondaryRoleFactories.remove(roleManager.role);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify my suggestion above, here's how I'm imagining this method to look like:

    final List<Role> secondaryRoles = _secondaryRoles;
    for (Role role in secondaryRoles) {
      final RoleManager? secondaryRoleManager = role.createManager();
      if (secondaryRoleManager != null) {
        _secondaryRoleManagers ??= <RoleManager>[];
        _secondaryRoleManagers!.add(secondaryRoleManager);
        _secondaryRoles.remove(role); // Is this allowed inside the for loop?
      }
    }

@yjbanov yjbanov changed the title [web] teach PrimaryRoleManager to update role manager list [web] always add secondary role managers Jul 14, 2023
@yjbanov yjbanov requested review from ditman and mdebbar July 14, 2023 21:28
@yjbanov
Copy link
Contributor Author

yjbanov commented Jul 14, 2023

Updated the design based on comments and discussion. We now always add secondary role managers, and have them figure out in their update() methods whether their functionality is needed or not.

@yjbanov
Copy link
Contributor Author

yjbanov commented Jul 14, 2023

PTAL.

@yjbanov yjbanov force-pushed the a11y-update-role-managers branch from dca11b4 to 0d0ecc6 Compare July 14, 2023 21:57
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I like this better now, with the relevant logic in the subclasses!

Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}
_focusManager.changeFocus(semanticsObject.hasFocus && (!semanticsObject.hasEnabledState || semanticsObject.isEnabled));
} else {
_focusManager.stopManaging();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to changeFocus(false) when the node becomes unfocusable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I also noticed that I unconditionally start managing the node in the constructor. Fixing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 14, 2023
@auto-submit auto-submit bot merged commit 85af5ce into flutter:main Jul 14, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 15, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jul 15, 2023
…130646)

flutter/engine@bf6d4bf...85af5ce

2023-07-14 [email protected] [web] always add secondary role managers (flutter/engine#43663)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 15, 2023
zanderso pushed a commit to flutter/flutter that referenced this pull request Jul 15, 2023
…sions) (#130666)

Manual roll requested by [email protected]

flutter/engine@403866d...6830877

2023-07-15 [email protected] Roll Fuchsia Linux SDK from
DEENqWMCYI1SMYsYH... to rmzZN2ZAgpbjAFi5_... (flutter/engine#43722)
2023-07-15 [email protected] Revert "Reland "add
non-rendering operation culling to DisplayListBuilder" (#41463)"
(flutter/engine#43721)
2023-07-15 [email protected] Roll Clang from 6d667d4b261e
to ebd0b8a0472b (flutter/engine#43673)
2023-07-15 [email protected] Roll Dart SDK from
671bbdf6c542 to 0bd185c282d2 (1 revision) (flutter/engine#43719)
2023-07-15 [email protected] Optimizing
performance by avoiding multiple GC operations caused by multiple
surface destruction notifications (flutter/engine#43587)
2023-07-15 [email protected] Roll Skia from 975eb1250431 to
6fb535aede4e (1 revision) (flutter/engine#43716)
2023-07-15 [email protected] Roll Dart SDK from
d1fcadf22aad to 671bbdf6c542 (2 revisions) (flutter/engine#43715)
2023-07-15 [email protected] Roll Fuchsia Mac SDK from
Z-1lzZAOYHvVrdjQ8... to oeYLDNShuD-FTgGwU... (flutter/engine#43714)
2023-07-15 [email protected] Roll Skia from 271b2b6d5aaa to
975eb1250431 (2 revisions) (flutter/engine#43712)
2023-07-15 [email protected] Move ViewConfiguration ownership to
FlutterView (flutter/engine#43701)
2023-07-14 [email protected] [web] always add secondary role managers
(flutter/engine#43663)
2023-07-14 [email protected] [Impeller] Fix text scaling issues again,
this time with perspective when a save layer is involved
(flutter/engine#43695)
2023-07-14 [email protected] Reland "add non-rendering operation culling
to DisplayListBuilder" (#41463) (flutter/engine#43698)
2023-07-14 [email protected] Roll Skia from 5f6578398870 to
271b2b6d5aaa (2 revisions) (flutter/engine#43706)
2023-07-14 [email protected] [Impeller] Ensure that missing color
attachment 0u does not cause crash in embedder API
(flutter/engine#43705)
2023-07-14 [email protected] Roll Skia from 315c7f08c731 to
5f6578398870 (4 revisions) (flutter/engine#43704)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from DEENqWMCYI1S to rmzZN2ZAgpbj
  fuchsia/sdk/core/mac-amd64 from Z-1lzZAOYHvV to oeYLDNShuD-F

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that
a human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit to harryterkelsen/engine that referenced this pull request Jul 20, 2023
Always add secondary role managers irrespective of the initial state of the semantic node, and have role manager decide whether it applies to the node or not.

Fixes flutter/flutter#130546
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…lutter#130646)

flutter/engine@bf6d4bf...85af5ce

2023-07-14 [email protected] [web] always add secondary role managers (flutter/engine#43663)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…sions) (flutter#130666)

Manual roll requested by [email protected]

flutter/engine@403866d...6830877

2023-07-15 [email protected] Roll Fuchsia Linux SDK from
DEENqWMCYI1SMYsYH... to rmzZN2ZAgpbjAFi5_... (flutter/engine#43722)
2023-07-15 [email protected] Revert "Reland "add
non-rendering operation culling to DisplayListBuilder" (flutter#41463)"
(flutter/engine#43721)
2023-07-15 [email protected] Roll Clang from 6d667d4b261e
to ebd0b8a0472b (flutter/engine#43673)
2023-07-15 [email protected] Roll Dart SDK from
671bbdf6c542 to 0bd185c282d2 (1 revision) (flutter/engine#43719)
2023-07-15 [email protected] Optimizing
performance by avoiding multiple GC operations caused by multiple
surface destruction notifications (flutter/engine#43587)
2023-07-15 [email protected] Roll Skia from 975eb1250431 to
6fb535aede4e (1 revision) (flutter/engine#43716)
2023-07-15 [email protected] Roll Dart SDK from
d1fcadf22aad to 671bbdf6c542 (2 revisions) (flutter/engine#43715)
2023-07-15 [email protected] Roll Fuchsia Mac SDK from
Z-1lzZAOYHvVrdjQ8... to oeYLDNShuD-FTgGwU... (flutter/engine#43714)
2023-07-15 [email protected] Roll Skia from 271b2b6d5aaa to
975eb1250431 (2 revisions) (flutter/engine#43712)
2023-07-15 [email protected] Move ViewConfiguration ownership to
FlutterView (flutter/engine#43701)
2023-07-14 [email protected] [web] always add secondary role managers
(flutter/engine#43663)
2023-07-14 [email protected] [Impeller] Fix text scaling issues again,
this time with perspective when a save layer is involved
(flutter/engine#43695)
2023-07-14 [email protected] Reland "add non-rendering operation culling
to DisplayListBuilder" (flutter#41463) (flutter/engine#43698)
2023-07-14 [email protected] Roll Skia from 5f6578398870 to
271b2b6d5aaa (2 revisions) (flutter/engine#43706)
2023-07-14 [email protected] [Impeller] Ensure that missing color
attachment 0u does not cause crash in embedder API
(flutter/engine#43705)
2023-07-14 [email protected] Roll Skia from 315c7f08c731 to
5f6578398870 (4 revisions) (flutter/engine#43704)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from DEENqWMCYI1S to rmzZN2ZAgpbj
  fuchsia/sdk/core/mac-amd64 from Z-1lzZAOYHvV to oeYLDNShuD-F

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected] on the revert to ensure that
a human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web] semantic node initially missing a label cannot be updated to have one
3 participants