-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Check for index bounds in RTL handling for trailing whitespace runs. #12336
Conversation
@@ -415,7 +415,11 @@ bool ParagraphTxt::ComputeBidiRuns(std::vector<BidiRun>* result) { | |||
// | |||
// This only applies to the final whitespace at the end as other whitespace is | |||
// no longer ambiguous when surrounded by additional text. | |||
|
|||
// TODO(garyq): Handle this in the text editor caret code instead at layout |
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'd still prefer to revert this instead of adding more complex post-processing to the output of the bidi algorithm.
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 don't think it is viable for the RTL users of flutter if we revert this without a complete solution ready to go, as it causes all RTL input to look completely wrong. Reverting would make RTL essentially unusable until the final solution is rolled.
@@ -429,6 +433,9 @@ bool ParagraphTxt::ComputeBidiRuns(std::vector<BidiRun>* result) { | |||
if (u_hasBinaryProperty(last_char, UCHAR_WHITE_SPACE)) { | |||
has_trailing_whitespace = true; | |||
bidi_run_count--; | |||
if (bidi_run_start == 0) { |
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.
IIUC, the goal here is merging the last visual run into the second-to-last run if the last run consists of a single whitespace character.
Would it work to check whether the last run's start index follows the second-to-last run's end index here? If that is the case, then it's safe to reduce the bidi_run_count and increase the final run's length.
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.
Yeah, that should be a more robust check. Implemented.
ubidi_getVisualRun(bidi.get(), bidi_run_count - 2, | ||
&second_last_bidi_run_start, | ||
&second_last_bidi_run_length); | ||
if (bidi_run_start <= second_last_bidi_run_start) { |
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.
There are two cases:
- last_bidi_run_start == second_last_bidi_run_end + 1
- last_bidi_run_start == second_last_bidi_run_start - 1
For #1, it's safe to merge the last run into the second-to-last run.
For #2, the is_leading
flag will merge the last two runs to create a run where the last whitespace occurs at the start of the final run. Is that desirable? Or would we be better off leaving the bidi runs unmodified 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.
Let me try both modifying and not to see which one we want in terms of text input.
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.
Ok, it looks like both produce reasonable results during text input. In this case, I will prefer not modifying it when it is leading.
@jason-simmons Ready for additional review! |
ubidi_getVisualRun(bidi.get(), bidi_run_count - 2, | ||
&second_last_bidi_run_start, | ||
&second_last_bidi_run_length); | ||
if (bidi_run_start >= second_last_bidi_run_start) { |
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.
Check whether bidi_run_start == second_last_bidi_run_start + second_last_bidi_run_length
has_trailing_whitespace
will extend the second-to-last run by one character. This only makes sense if the additional character is the whitespace character comprising the final run
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.
Oops, forgot to push -f, thought I had pushed the changes already!
4ea01db
to
443a61d
Compare
git@github.com:flutter/engine.git/compare/e7fd442410f4...953ac71 git log e7fd442..953ac71 --no-merges --oneline 2019-09-24 bkonyi@google.com Roll src/third_party/dart acac9ab11b..d53d355c6c (12 commits) 2019-09-24 skia-flutter-autoroll@skia.org Roll src/third_party/skia b4b1005d485f..c096654fa7c6 (1 commits) (flutter/engine#12415) 2019-09-24 skia-flutter-autoroll@skia.org Roll src/third_party/skia b3542d95da65..b4b1005d485f (6 commits) (flutter/engine#12414) 2019-09-24 ueman@users.noreply.github.com Write MINIMAL_SDK to exception message (flutter/engine#11345) 2019-09-23 franciscojma86@gmail.com Track "mouse leave" event (flutter/engine#12363) 2019-09-23 bkonyi@google.com Roll src/third_party/dart 77ff89b223..acac9ab11b (6 commits) 2019-09-23 mouad.debbar@gmail.com Don't send pointer events when the framework isn't ready yet (flutter/engine#12403) 2019-09-23 aam@google.com Update test to verify that secondary isolate gets shutdown before root isolate exits. (flutter/engine#12342) 2019-09-23 skia-flutter-autoroll@skia.org Roll src/third_party/skia 57ef68077574..b3542d95da65 (12 commits) (flutter/engine#12409) 2019-09-23 bkonyi@google.com Update --dart-vm-flags whitelist to include --write-service-info and --sample-buffer-duration (flutter/engine#12395) 2019-09-23 47866232+chunhtai@users.noreply.github.com Add system font change listener for windows (flutter/engine#12276) 2019-09-23 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from xPX7p... to kgFwg... (flutter/engine#12405) 2019-09-23 garyq@google.com Check for index bounds in RTL handling for trailing whitespace runs. (flutter/engine#12336) 2019-09-23 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from F-g18... to NY2A5... (flutter/engine#12407) 2019-09-23 bkonyi@google.com Roll src/third_party/dart f546362691..77ff89b223 (6 commits) 2019-09-23 50856934+nturgut@users.noreply.github.com Updating text field location in IOS as a pre-work for spellcheck (flutter/engine#12192) 2019-09-23 chinmaygarde@google.com Roll buildroot and remove toolchain prefix. (flutter/engine#12324) 2019-09-23 bkonyi@google.com Roll src/third_party/dart 94dd49cdb6..f546362691 (1 commits) 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 stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
git@github.com:flutter/engine.git/compare/e7fd442410f4...953ac71 git log e7fd442..953ac71 --no-merges --oneline 2019-09-24 bkonyi@google.com Roll src/third_party/dart acac9ab11b..d53d355c6c (12 commits) 2019-09-24 skia-flutter-autoroll@skia.org Roll src/third_party/skia b4b1005d485f..c096654fa7c6 (1 commits) (flutter/engine#12415) 2019-09-24 skia-flutter-autoroll@skia.org Roll src/third_party/skia b3542d95da65..b4b1005d485f (6 commits) (flutter/engine#12414) 2019-09-24 ueman@users.noreply.github.com Write MINIMAL_SDK to exception message (flutter/engine#11345) 2019-09-23 franciscojma86@gmail.com Track "mouse leave" event (flutter/engine#12363) 2019-09-23 bkonyi@google.com Roll src/third_party/dart 77ff89b223..acac9ab11b (6 commits) 2019-09-23 mouad.debbar@gmail.com Don't send pointer events when the framework isn't ready yet (flutter/engine#12403) 2019-09-23 aam@google.com Update test to verify that secondary isolate gets shutdown before root isolate exits. (flutter/engine#12342) 2019-09-23 skia-flutter-autoroll@skia.org Roll src/third_party/skia 57ef68077574..b3542d95da65 (12 commits) (flutter/engine#12409) 2019-09-23 bkonyi@google.com Update --dart-vm-flags whitelist to include --write-service-info and --sample-buffer-duration (flutter/engine#12395) 2019-09-23 47866232+chunhtai@users.noreply.github.com Add system font change listener for windows (flutter/engine#12276) 2019-09-23 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from xPX7p... to kgFwg... (flutter/engine#12405) 2019-09-23 garyq@google.com Check for index bounds in RTL handling for trailing whitespace runs. (flutter/engine#12336) 2019-09-23 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/linux-amd64 from F-g18... to NY2A5... (flutter/engine#12407) 2019-09-23 bkonyi@google.com Roll src/third_party/dart f546362691..77ff89b223 (6 commits) 2019-09-23 50856934+nturgut@users.noreply.github.com Updating text field location in IOS as a pre-work for spellcheck (flutter/engine#12192) 2019-09-23 chinmaygarde@google.com Roll buildroot and remove toolchain prefix. (flutter/engine#12324) 2019-09-23 bkonyi@google.com Roll src/third_party/dart 94dd49cdb6..f546362691 (1 commits) 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 stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
This prevents crashing when leading whitespace occurs in RTL text. This is a semi-temporary fix to prevent rolling back the change that fixes RTL text input in general.
Fixes flutter/flutter#39553