Skip to content

Move geometric sort for semantics to the framework side. - #14539

Merged
gspencergoog merged 1 commit into
flutter:masterfrom
gspencergoog:geometric
Feb 13, 2018
Merged

gspencergoog merged 1 commit into
flutter:masterfrom
gspencergoog:geometric

Conversation

@gspencergoog

Copy link
Copy Markdown
Contributor

This adds geometric sort ordering back in for semantics nodes that don't have a sort order defined.

With this change, widgets that either have no sort order, or have an equivalent sort order, will be compared geometrically. The comparison is between the two starting corners, so it is TextDirection-aware: parent nodes that are set to have LTR text will compare upper left corners of their children, and upper right when set to RTL.

Also fixed a bug in the Transform widget that didn't mark modified nodes as needing a semantics update.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please assert containerTextDirection is not null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I did need to document this.

Actually, we don't need an assert because I do handle the null case properly. I added a bunch of comments to clarify. A null value is allowed, because in that case we want to fall back to ordering by Y position, and then child insertion order.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

trivial nit: generally we prefer rtl to be first

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I was going alphabetically, and L < R. Is there a rationale for that preference?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if there's no Directionality widget? e.g. with a Stack rather than a Column.

@gspencergoog gspencergoog Feb 8, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, actually...

  1. A Column doesn't need directionality
  2. You can't use a Stack without directionality (it'll assert).
  3. Just adding a label on a Semantics node will assert without a directionality.

I've tried to add a test that will check that widgets that don't have any directionality end up with child order as a result, but really it's hard to do without a horizontal layout widget that ignores directionality, since I do still sort vertically in that case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use a stack without directionality, just set its alignment to something non-directional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oooh! OK, I'll try that!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, see below.

@gspencergoog
gspencergoog force-pushed the geometric branch 2 times, most recently from c46f8bf to b9fe5ed Compare February 9, 2018 23:53
@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

Comment thread appveyor.yml Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did you mean to do this in this PR?

// coordinate is also ignored when doing the comparison in that case, so
// this isn't actually expressing a directionality opinion.
globalStartCorner = _transformPoint(
containerTextDirection == TextDirection.rtl ? node.rect.topRight : node.rect.topLeft,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pass in topRight when direction is null, so we're more likely to catch regressions where someone starts depending on it

@Hixie

Hixie commented Feb 13, 2018

Copy link
Copy Markdown
Contributor

LGTM

@gspencergoog
gspencergoog merged commit 7be0bd1 into flutter:master Feb 13, 2018
@gspencergoog
gspencergoog deleted the geometric branch March 22, 2018 15:16
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
This adds geometric sort ordering back in for semantics nodes that don't have a sort order defined.

With this change, widgets that either have no sort order, or have an equivalent sort order, will be compared geometrically. The comparison is between the two starting corners, so it is TextDirection-aware: parent nodes that are set to have LTR text will compare upper left corners of their children, and upper right when set to RTL.

Also fixed a bug in the Transform widget that didn't mark modified nodes as needing a semantics update.
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants