Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Oct 14, 2022

fixes #111931

This pr let text widget to use child semanticsconfigurations delegate API to add synthetic semantics configurations to be merge up.

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.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Oct 14, 2022
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@chunhtai
Copy link
Contributor Author

chunhtai commented Dec 22, 2022

This is ready for another look.

I can't find a good way to completely replace assembleSemanticsNode in RenderParahraph because, there isn't a good way to generate semantics node from synthetic SemanticsConfiguration with two reasons.

  1. Semantics node is cached in RenderObject._semantics. This is important because we want to reuse semantics id as much as possible. This becomes tricky now the semantics node generated from synthetic SemanticsConfiguration need to be have a stable id somehow
  2. Needs to figure out a way to set the semantics node rect and transform. Regular semantics node gets its geometry from renderobject directly. The synthetic SemanticsConfiguration need to process these information somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

isPlaceholder could be true for an InlineSpan that's not a WidgetSpan right? But only WidgetSpans are tagged in the rich text implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this will ignore any other placeholder subclass, since we don't know what how they would contribute to the semantics...

@chunhtai chunhtai force-pushed the issues/111931 branch 2 times, most recently from 9505a01 to 3eeb35b Compare February 7, 2023 23:04
@chunhtai chunhtai requested a review from goderbauer February 7, 2023 23:05
Copy link
Member

Choose a reason for hiding this comment

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

It's not clear to me why we can skip the delegate if there's a recognizer. Don't we still have the same problem with the placeholder nodes in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is gesture recognizer, every continuous strings are separated into its own nodes so there won't be merging issue. and the assemblesemanticsnode is smart enough to insert each semanticsnode of widgetspans in the right places. So there is no need to use the childconfigurationdelegate API. As we discussed offline, if we do want to replace assemblesmeanticsnode with the childconfigurationdelegate API we need a way to set stable id and geometry

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Thanks for the explanation.

Copy link
Member

Choose a reason for hiding this comment

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

How are _buildChildSemanticsConfigurationsResultAndFillCache and _buildChildSemanticsConfigurationsResultAndFillCache kept in sync to make sure they end up producing the same ChildSemanticsConfigurationsResult?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added assert

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't really address the maintainability problem. If we ever have to fix anything in this logic, one would have to do it twice. Plus, the (complicated) assert doesn't really inspire confidence that the two are actually equal. For example, in some cases it just assumes configs are equal when the labels match.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, I tried to combine this two functions in the previous commit, but the code looks like a trainwreck.

so I guess what you meant earlier is to make it more readable than to separate them out cache version and non-cache version?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, sorry if I wasn't clear...

Comment on lines 451 to 452
Copy link
Member

Choose a reason for hiding this comment

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

This one actually surprised me a little bit. I sort of expected there would be three sibling nodes: "before", "inner", and "after".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure how we are going to support that, let's say we solve the unique id and geometry issue that synthetic SemanticsConfiguration can be explicit. How would it know when they should be explicit and not merge together. for example, how do they tell they need to merge in this case

[
              const TextSpan(text: 'before '),
              WidgetSpan(
                alignment: PlaceholderAlignment.baseline,
                baseline: TextBaseline.alphabetic,
                child: Semantics(label: 'inner'),
              ),
              const TextSpan(text: ' after'),
]

but not merge in this case

[
              const TextSpan(text: 'before '),
              WidgetSpan(
                alignment: PlaceholderAlignment.baseline,
                baseline: TextBaseline.alphabetic,
                child: Semantics(label: 'inner', container: true),
              ),
              const TextSpan(text: ' after'),
]

Copy link
Member

Choose a reason for hiding this comment

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

Maybe some tests that combines these cases with recognizers?

Copy link
Contributor Author

@chunhtai chunhtai Feb 9, 2023

Choose a reason for hiding this comment

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

We already have test that does that, e.g testWidget('inline widgets generate semantic nodes'). The issue this pr trying to solve is that when there is only plain textspan and widgetspans that want to merge together.

@chunhtai chunhtai requested a review from goderbauer February 9, 2023 22:18
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. Thanks for the explanation.

Copy link
Member

Choose a reason for hiding this comment

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

Should this be calling _buildChildSemanticsConfigurationsResultFromCache instead?

Copy link
Member

Choose a reason for hiding this comment

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

Should this just return result instead of calling _buildChildSemanticsConfigurationsResultAndFillCache again?

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't really address the maintainability problem. If we ever have to fix anything in this logic, one would have to do it twice. Plus, the (complicated) assert doesn't really inspire confidence that the two are actually equal. For example, in some cases it just assumes configs are equal when the labels match.

@goderbauer
Copy link
Member

(triage fly by:) Looks like checks are failing on this one.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

belongs -> belonging

Copy link
Member

Choose a reason for hiding this comment

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

nit: I think dart should allow you to mark this as final instead of late since every branch of the if below it assigns it exactly once.

@chunhtai
Copy link
Contributor Author

internal test failure blocked on #120996

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
chunhtai added a commit to chunhtai/flutter that referenced this pull request Feb 27, 2023
chunhtai added a commit that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
chunhtai added a commit to chunhtai/flutter that referenced this pull request Mar 1, 2023
chunhtai added a commit that referenced this pull request Mar 1, 2023
* Revert "Revert "Fix text.rich to merge widget span (#113461)" (#121562)"

This reverts commit c8d8016.

* Fixes tag to not pollute cached semantics configuration in rendering object
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text.rich does not compose its semantics label in the correct order for embedded widgets

3 participants