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

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Feb 12, 2019

Fixes flutter/flutter#26658.

This adds the concept of a "ghost" run representing trailing whitespace where it does not impact the layout of visible glyphs, but does have metrics as if it existed in GetRectsForRange().

Previously, these space metrics were discarded.

This allows trailing spaces to appear at the end of center and right aligned text without changing the alignment.

Will require a manual engine roll as it breaks one test in the framework specifically testing for this (flutter/flutter#27808)

// centering/layout/etc). See above declaration of 'ghost_run_count' for
// more details.
run_index++;
bool is_ghost_run = false;
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to add the is_ghost flag to the BidiRun class?

Copy link
Contributor Author

@GaryQian GaryQian Feb 12, 2019

Choose a reason for hiding this comment

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

So a bidi run can actually be split into multiple parts, where the beginning half is a normal run and the last half is span of trailing whitespaces. Only once we split it into line_runs do we reach the level where a 'ghost' run can be defined.

For example, a line_range can have the range [0, 20, 40) where [20, 40) are whitespace. A corresponding bidi run can then be [0, 40), which should be broken into [0, 20) and [20, 40) where the first run is normal and the second is a 'ghost'.

Thus, we can't blanket a is_ghost var onto a whole BidiRun

Copy link
Member

Choose a reason for hiding this comment

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

line_runs is a list of BidiRun instances. I was thinking that it would be simpler to add a flag to the BidiRun struct to track the ghost runs instead of keeping state about which line_runs indexes are ghost runs.

Or maybe a better option would be to create a LineRun struct that includes all the fields of BidiRun plus the ghost flag.

@GaryQian GaryQian changed the title Add space metrics tracking for trailing whitespace called "Ghost" runs. Add space metrics tracking for trailing whitespace "ghost" runs. Feb 12, 2019
@GaryQian
Copy link
Contributor Author

The existing tests for the old behavior actually tests this new feature quite well. I modified them to assert the new behavior.

@GaryQian
Copy link
Contributor Author

Waiting for buildbots to succeed and flutter/flutter to go green

@GaryQian GaryQian merged commit 033f207 into flutter:master Feb 13, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 15, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 15, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 15, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 15, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 15, 2019
GaryQian added a commit to flutter/flutter that referenced this pull request Feb 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants