-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix text.rich to merge widget span #113461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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 Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
444a836 to
2bcc637
Compare
|
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.
|
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.
isPlaceholder could be true for an InlineSpan that's not a WidgetSpan right? But only WidgetSpans are tagged in the rich text implementation?
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.
yes, this will ignore any other placeholder subclass, since we don't know what how they would contribute to the semantics...
45d2766 to
6d7ca3e
Compare
9505a01 to
3eeb35b
Compare
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.
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?
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.
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
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.
Makes sense. Thanks for the explanation.
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.
How are _buildChildSemanticsConfigurationsResultAndFillCache and _buildChildSemanticsConfigurationsResultAndFillCache kept in sync to make sure they end up producing the same ChildSemanticsConfigurationsResult?
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.
added assert
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 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.
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.
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?
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.
Yes, sorry if I wasn't clear...
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 one actually surprised me a little bit. I sort of expected there would be three sibling nodes: "before", "inner", and "after".
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 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'),
]
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.
Maybe some tests that combines these cases with recognizers?
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.
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.
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.
Makes sense. Thanks for the explanation.
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 calling _buildChildSemanticsConfigurationsResultFromCache instead?
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 just return result instead of calling _buildChildSemanticsConfigurationsResultAndFillCache again?
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 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.
|
(triage fly by:) Looks like checks are failing on this one. |
2dbbc27 to
8b48479
Compare
goderbauer
left a comment
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.
LGTM
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.
belongs -> belonging
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.
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.
|
internal test failure blocked on #120996 |
8b48479 to
2bcc793
Compare
This reverts commit 660992a.
…lutter#121562)" This reverts commit c8d8016.
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
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.