-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] better class names for semantics #54070
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the SemanticObject
is the glue that controls the rest, but there's a lot of magic that is happening in semantic object (checking type, need for updates, etc...) that probably should be delegated to the SemanticRole
that it's wrapping? Isn't the _getSemanticRoleId()
method a little bit weird, or having an updateSelf
that grows potentially unbounded (at least linearly with the types of semantics?)
That's probably a bigger refactor. The renaming LGTM other than what we've discussed!
class Checkable extends PrimaryRoleManager { | ||
class Checkable extends SemanticRole { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed much better. It's a shame that the name of the top-level classes sound like java interfaces (*-able), but the alternative (CheckableSemanticRole
) is probably too verbose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made all concrete role type names use the Semantic*
prefix. Looks much better now.
@@ -39,7 +37,7 @@ class Dialog extends PrimaryRoleManager { | |||
|
|||
void _setDefaultFocus() { | |||
semanticsObject.visitDepthFirstInTraversalOrder((SemanticsObject node) { | |||
final PrimaryRoleManager? roleManager = node.primaryRole; | |||
final SemanticRole? roleManager = node.semanticRole; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider doing a pass renaming these roleManager
names. They don't map very well to what they contain anymore, now that the "Manager" name is going away from this class hierarchy.
: super.blank(PrimaryRole.image, semanticsObject) { | ||
// The following secondary roles can coexist with images. `LabelAndValue` is | ||
// not used because this role manager uses special auxiliary elements to | ||
class ImageSemanticRole extends SemanticRole { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that Image
clashes with other 47 classes in the engine, but... should all the extends SemanticRole
be SomethingSomethingSemanticRole
, just for consistency of everything inside "engine/semantics"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (using the Semantic*
prefix)
|
||
PrimaryRole _getPrimaryRoleIdentifier() { | ||
SemanticRoleId _getSemanticRoleId() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a SemanticRole.kind
that every SemanticRole needs to override?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Made it SemanticRoleKind
.
DomElement get element => primaryRole!.element; | ||
DomElement get element => semanticRole!.element; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class SemanticObject
looks a little bit too complicated, shouldn't each SemanticRole
/Behavior
know how to update and identify itself? Is this class doing too much, does it need love? Is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SemanticRole
can change, but a SemanticObject
is persistent for the entire lifecycle of the node. So for now we need both. However, we can revisit who's responsible for what, since both objects are 1:1 with the node. For now, I'm keeping this PR to non-functional changes only, just renames and deletion of dead code.
} | ||
} | ||
|
||
PrimaryRoleManager _createPrimaryRole(PrimaryRole role) { | ||
SemanticRole _createSemanticRole(SemanticRoleId role) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably only used from within the class, but this probably should be factory
(or at least static
)? (Even though it needs "this" to build itself, ouch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't be static. It uses this
. But we could revisit this. Maybe sealed classes can help clean this up.
…ions) (#152305) Manual roll requested by zra@google.com flutter/engine@eb8fac2...7473782 2024-07-25 yjbanov@google.com [web] better class names for semantics (flutter/engine#54070) 2024-07-25 jonahwilliams@google.com Disable FlutterMetalLayer by default. (flutter/engine#54095) 2024-07-25 skia-flutter-autoroll@skia.org Roll Dart SDK from 0b3c00feefb1 to 693848f200d7 (1 revision) (flutter/engine#54092) 2024-07-25 gspencergoog@users.noreply.github.com Remove incorrect line (flutter/engine#54021) 2024-07-24 zanderso@users.noreply.github.com [et] Better RBE defaults (flutter/engine#54059) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 55ecdde3a5fa to 746d444f3efd (2 revisions) (flutter/engine#54091) 2024-07-24 jonahwilliams@google.com [iOS] Switch to FlutterMetalLayer by default. (flutter/engine#54086) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 54d1434637a1 to 55ecdde3a5fa (3 revisions) (flutter/engine#54089) 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 jonahwilliams@google.com,rmistry@google.com,zra@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ions) (flutter#152305) Manual roll requested by zra@google.com flutter/engine@eb8fac2...7473782 2024-07-25 yjbanov@google.com [web] better class names for semantics (flutter/engine#54070) 2024-07-25 jonahwilliams@google.com Disable FlutterMetalLayer by default. (flutter/engine#54095) 2024-07-25 skia-flutter-autoroll@skia.org Roll Dart SDK from 0b3c00feefb1 to 693848f200d7 (1 revision) (flutter/engine#54092) 2024-07-25 gspencergoog@users.noreply.github.com Remove incorrect line (flutter/engine#54021) 2024-07-24 zanderso@users.noreply.github.com [et] Better RBE defaults (flutter/engine#54059) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 55ecdde3a5fa to 746d444f3efd (2 revisions) (flutter/engine#54091) 2024-07-24 jonahwilliams@google.com [iOS] Switch to FlutterMetalLayer by default. (flutter/engine#54086) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 54d1434637a1 to 55ecdde3a5fa (3 revisions) (flutter/engine#54089) 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 jonahwilliams@google.com,rmistry@google.com,zra@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ions) (flutter#152305) Manual roll requested by zra@google.com flutter/engine@eb8fac2...7473782 2024-07-25 yjbanov@google.com [web] better class names for semantics (flutter/engine#54070) 2024-07-25 jonahwilliams@google.com Disable FlutterMetalLayer by default. (flutter/engine#54095) 2024-07-25 skia-flutter-autoroll@skia.org Roll Dart SDK from 0b3c00feefb1 to 693848f200d7 (1 revision) (flutter/engine#54092) 2024-07-25 gspencergoog@users.noreply.github.com Remove incorrect line (flutter/engine#54021) 2024-07-24 zanderso@users.noreply.github.com [et] Better RBE defaults (flutter/engine#54059) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 55ecdde3a5fa to 746d444f3efd (2 revisions) (flutter/engine#54091) 2024-07-24 jonahwilliams@google.com [iOS] Switch to FlutterMetalLayer by default. (flutter/engine#54086) 2024-07-24 skia-flutter-autoroll@skia.org Roll Skia from 54d1434637a1 to 55ecdde3a5fa (3 revisions) (flutter/engine#54089) 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 jonahwilliams@google.com,rmistry@google.com,zra@google.com 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://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
A few non-functional clean-ups in semantics:
RoleManager
toSemanticBehavior
.PrimaryRoleManager
toSemanticRole
.Role
enum. Move the enum docs into the respective classes.Why?
Previous naming was confusing. It's not clear what the difference is between a "role manager" and a "primary role manager". The word "manager" is a meaningless addition; the
Semantic*
prefix is much more meaningful. TheRole
enum was only used for tests, but tests can just useSemanticRole.runtimeType
.New state of the world
After this PR the semantics system has "objects" (class
SemanticsObject
), "roles" (classSemanticRole
), and "behaviors" (classSemanticBehavior
).SemanticNode
. It lives as long as the semantic node does, and provides basic functionality that's common across all nodes.Button
andCheckable
roles use theTappable
behavior. This is why there's a many-to-many relationship between roles and behaviors.Or in entity relationship terms: