-
Notifications
You must be signed in to change notification settings - Fork 6k
Update CompositionAwareMixin to correctly compute composingBase in Web engine #44139
Update CompositionAwareMixin to correctly compute composingBase in Web engine #44139
Conversation
1963f94 to
edc289f
Compare
Renzo-Olivares
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.
| } | ||
|
|
||
| final int composingBase = editingState.baseOffset! - composingText!.length; | ||
| final int composingBase = editingState.extentOffset! - composingText!.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.
This looks reasonable to me. Using baseOffset fails when composition changes the selection to be non-collapsed, composingBase turns out being negative so (-1,-1) is reported to the framework. This doesn't fail for non-delta input because for non-delta input we always replace the old editing state with the new one, while with delta input we require the correct ranges to correctly infer the difference.
|
|
||
| group('determine composition state', () { | ||
| test('should return new composition state if valid new composition', () { | ||
| test('should return new composition state - compositing middle of text', () { |
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 is probably outside of the scope of this PR, but I noticed this test has the selection of the EditingState set to (100, 100), while the text it contains is only testing. The selection should always be in the bounds of the text.
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.
htoor3
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.
Thank you for submitting this change! It looks mostly good, I left a few minor comments
| composingExtentOffset: expectedComposingBase + composingText.length)); | ||
| }); | ||
|
|
||
| test('should return new composition state - compositing from beginning of text', () { |
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 looks great! There are some untested code paths in determineCompositionState that we should probably add tests for - mainly the null checks and if composingBase < 0 (will this still occur with this change?)
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 can't think of any scenario that this can happen but it's still possible. Do you think I can address adding tests along with #44139 (comment) in another PR? @htoor3
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.
That works for me @Amir-P
edc289f to
169cb2f
Compare
…132522) flutter/engine@56a0e27...785b249 2023-08-14 amirpanahandeh@yahoo.com Update CompositionAwareMixin to correctly compute composingBase in Web engine (flutter/engine#44139) 2023-08-14 stuartmorgan@google.com Add application:openURLs: forwarding on macOS (flutter/engine#44689) 2023-08-14 skia-flutter-autoroll@skia.org Roll Skia from a4377099b25a to 69ea58157190 (1 revision) (flutter/engine#44692) 2023-08-14 chillers@google.com Update embedder_semantics_update.h imports to include flutter namespace (flutter/engine#44670) 2023-08-14 skia-flutter-autoroll@skia.org Roll Dart SDK from 3295a353980a to d445f5a18876 (1 revision) (flutter/engine#44691) 2023-08-14 dnfield@google.com Revert "Make run_tests.py assert that the ios test dylib is at least as new as libFlutter.dylib" (flutter/engine#44690) 2023-08-14 skia-flutter-autoroll@skia.org Roll Skia from 1cf6f71c8120 to a4377099b25a (1 revision) (flutter/engine#44688) 2023-08-14 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JKTVoxVrHjZjBaxG4... to uIGMbDkXoIcpqWjgR... (flutter/engine#44687) 2023-08-14 jonahwilliams@google.com [Impeller] Conditionally set command debug info. (flutter/engine#44274) 2023-08-14 kjlubick@users.noreply.github.com Migrate more GL calls of GrBackend* (flutter/engine#44682) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JKTVoxVrHjZj to uIGMbDkXoIcp 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 chinmaygarde@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose 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/+doc/main/autoroll/README.md
Adds missing tests for `CompositionAwareMixin`. Check #44139 (comment) and #44139 (comment) [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…b engine (flutter#44139) It fixes an issue in `CompositionAwareMixin` causing wrong deltas being computed and reported to input clients resulting in wrong state when compositing text in rich text editors like [Fleather](https://github.com/fleather-editor/fleather) and possibly others. Reported deltas on Mac: ```console TextEditingDeltaInsertion: start: 0, end: 0, data: k TextEditingDeltaInsertion: start: 1, end: 0, data: y TextEditingDeltaReplacement: start: 0, end: 2, data: ã��ã�� TextEditingDeltaInsertion: start: 2, end: 0, data: ã�� TextEditingDeltaInsertion: start: 3, end: 0, data: h TextEditingDeltaReplacement: start: 0, end: 4, data: ã��ã��ã��ã�¯ TextEditingDeltaReplacement: start: 0, end: 4, data: ä»�æ�¥ã�¯ ``` Reported deltas on Web (Before): ```console TextEditingDeltaInsertion: start: 0, end: 0, data: k TextEditingDeltaInsertion: start: 1, end: 0, data: y TextEditingDeltaReplacement: start: 0, end: 2, data: ã��ã�� TextEditingDeltaInsertion: start: 2, end: 0, data: ã�� TextEditingDeltaInsertion: start: 3, end: 0, data: h TextEditingDeltaReplacement: start: 0, end: 4, data: ã��ã��ã��ã�¯ TextEditingDeltaInsertion: start: 4, end: 0, data: ä»�æ�¥ã�¯ ``` Reported deltas on Web (After): ```console TextEditingDeltaInsertion: start: 0, end: 0, data: k TextEditingDeltaInsertion: start: 1, end: 0, data: y TextEditingDeltaReplacement: start: 0, end: 2, data: ã��ã�� TextEditingDeltaInsertion: start: 2, end: 0, data: ã�� TextEditingDeltaInsertion: start: 3, end: 0, data: h TextEditingDeltaReplacement: start: 0, end: 4, data: ã��ã��ã��ã�¯ TextEditingDeltaReplacement: start: 0, end: 4, data: ä»�æ�¥ã�¯ ``` * Fixes flutter/flutter#131335 * Fixes fleather-editor/fleather#150 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Adds missing tests for `CompositionAwareMixin`. Check flutter#44139 (comment) and flutter#44139 (comment) [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
It fixes an issue in
CompositionAwareMixincausing wrong deltas being computed and reported to input clients resulting in wrong state when compositing text in rich text editors like Fleather and possibly others.Reported deltas on Mac:
Reported deltas on Web (Before):
Reported deltas on Web (After):
Pre-launch Checklist
///).