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

Conversation

@nturgut
Copy link
Contributor

@nturgut nturgut commented Dec 4, 2019

Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behavior.

There are 5 different text editing strategies:

  • DefaultTextEditingStrategy
  • AndroidTextEditingStrategy
  • IOSTextEditingStrategy
  • FirefoxTextEditingStrategy
  • AccesibiltyModeTextEditingStrategy

Tested manually for:

  • Chrome on Linux desktop
  • Chrome on Linux desktop a11y on with chromevox
  • Firefox on Linux desktop
  • Chrome on Android
  • Chrome on Android a11y on with talkback
  • Safari on IOS
  • Safari on IOS a11y on with voiceover

Pre-work for: flutter/flutter#43034

@auto-assign auto-assign bot requested a review from jason-simmons December 4, 2019 18:08
@nturgut nturgut requested review from mdebbar and removed request for jason-simmons December 4, 2019 18:08
@nturgut nturgut added platform-web Code specifically for the web engine affects: text input labels Dec 4, 2019
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

This looks really good! Cleaned up a lot of the if-else mess that we used to have.

I have a general comment about the new structure. We now have the following components:

(HybridTextEditing) <-> (TextEditingElement) <-> (TextEditingStrategy)

And it looks like TextEditingElement is an extra layer that isn't doing much other than delegating to TextEditingStrategy. What if we remove that layer, and provide a factory constructor on TextEditingStrategy that knows which class to instantiate based on browserEngine. And then, HybridTextEditing would talk directly with the TextEditingStrategy.

I didn't think deeply about it so maybe it won't work well, but I wanted to share the thought with you anyway. Especially in the case of accessibility, I'm not sure yet how we can do that.

@nturgut
Copy link
Contributor Author

nturgut commented Dec 11, 2019

This looks really good! Cleaned up a lot of the if-else mess that we used to have.

I have a general comment about the new structure. We now have the following components:

(HybridTextEditing) <-> (TextEditingElement) <-> (TextEditingStrategy)

And it looks like TextEditingElement is an extra layer that isn't doing much other than delegating to TextEditingStrategy. What if we remove that layer, and provide a factory constructor on TextEditingStrategy that knows which class to instantiate based on browserEngine. And then, HybridTextEditing would talk directly with the TextEditingStrategy.

I didn't think deeply about it so maybe it won't work well, but I wanted to share the thought with you anyway. Especially in the case of accessibility, I'm not sure yet how we can do that.

I totally agree. Plus you are right accessibility has a special case. Shall I do it in the next PR since this will change semantics as well?

@mdebbar
Copy link
Contributor

mdebbar commented Dec 11, 2019

Shall I do it in the next PR since this will change semantics as well?

That sounds good!

@nturgut
Copy link
Contributor Author

nturgut commented Dec 12, 2019

This looks really good! Cleaned up a lot of the if-else mess that we used to have.
I have a general comment about the new structure. We now have the following components:

(HybridTextEditing) <-> (TextEditingElement) <-> (TextEditingStrategy)

And it looks like TextEditingElement is an extra layer that isn't doing much other than delegating to TextEditingStrategy. What if we remove that layer, and provide a factory constructor on TextEditingStrategy that knows which class to instantiate based on browserEngine. And then, HybridTextEditing would talk directly with the TextEditingStrategy.
I didn't think deeply about it so maybe it won't work well, but I wanted to share the thought with you anyway. Especially in the case of accessibility, I'm not sure yet how we can do that.

I totally agree. Plus you are right accessibility has a special case. Shall I do it in the next PR since this will change semantics as well?

I did the change cause I realize, I had touch semantics code for the unit tests anyway.

Please have another look.

@nturgut nturgut changed the title [DRAFT] Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behavior. Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behavior. Dec 12, 2019
@nturgut nturgut requested a review from mdebbar December 12, 2019 17:21
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for doing this!

I only have a few minor comments about docs and renaming.

LGTM

/// There is no callback to know if the keyboard is up and how much the screen
/// has shifted. Therefore instead of listening to the shift and passing this
/// information to Flutter Framework, we are trying to stop the shift.
/// These event listener will be removed in [disable].
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's important to mention that event listeners need to be added to the _subscriptions list in order to be cleaned up properly.

/// semantic tree. It also requires that the DOM element remains in the tree
/// when the user isn't editing.
class PersistentTextEditingElement extends TextEditingElement {
class PersistentTextEditingElement extends DefaultTextEditingStrategy {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be called PersistentTextEditingStrategy?

///
/// It uses an HTML element to manage editing state when a custom element is
/// not provided via [useCustomEditableElement]
DefaultTextEditingStrategy _defaultEditingElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

s/_defaultEditingElement/_defaultEditingStrategy

/// [_defaultEditableElement] is used instead.
TextEditingElement _customEditingElement;
/// [_defaultEditingElement] is used instead.
DefaultTextEditingStrategy _customEditingElement;
Copy link
Contributor

Choose a reason for hiding this comment

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

several variables/methods should be renamed from editing element to editing strategy.

@nturgut nturgut merged commit f650bca into flutter:master Dec 12, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 13, 2019
…different browser/operating system and a11y behavior. (flutter/engine#14131)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 13, 2019
…different browser/operating system and a11y behavior. (flutter/engine#14131)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 13, 2019
…different browser/operating system and a11y behavior. (flutter/engine#14131)
iskakaushik pushed a commit to flutter/flutter that referenced this pull request Dec 13, 2019
* fb9dfe0 [fuchsia] Move async_get_default_dispatcher include to the header (flutter/engine#14351)

* 3ebb7b4 Roll src/third_party/skia 75799967be60..3517aa7b14ad (3 commits) (flutter/engine#14345)

* 2713225 Remove duplicate and outdated src/third_party/dart/tools/sdks entry from DEPS. (flutter/engine#14340)

* 80d80ff Add ability to control dithering on Paint (flutter/engine#13868)

* 8595361 Conditionally use offscreen root surface only when needed

* 0a40f3d Assert that arc end caps on canvases with root surface transformations are drawn correctly. (flutter/engine#14359)

* d698d96 Fix missing timeline event of flutter engine's startup time (flutter/engine#14319)

* 9dc23b8 Fix missing API stream when record event in systrace (flutter/engine#14323)

* 9e4c6ad Fix CGMutablePathRef memory leaks when the path is invalid. (flutter/engine#14275)

* fc8cafb objcdoc fix for some ambiguity (flutter/engine#14367)

* 9bafb3c [tests] Use distinct begin and end times (flutter/engine#14361)

* 897ce34 Roll src/third_party/skia 3517aa7b14ad..826484f2631f (18 commits) (flutter/engine#14375)

* 1ce85be [flutter_runner] Enable Skia tracing by default on Fuchsia (flutter/engine#13457)

* a7b6ee5 Smart quote/dash configuration support in iOS (flutter/engine#13863)

* 48ba39c Roll fuchsia/sdk/core/mac-amd64 from otkJA... to SlgE8... (flutter/engine#14407)

* 0081e8c Remove unused _TypeNone enum field. (flutter/engine#14440)

* d8edfea Roll src/third_party/dart d9fa37e85d5c..45db29709547 (48 commits) (flutter/engine#14453)

* f650bca Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behavior. (flutter/engine#14131)

* 4275b49 Fix type in build_fuchsia_artifacts (flutter/engine#14452)

* 0c24f3d Roll src/third_party/skia 51b99659ed82..c514e7d9be6e (13 commits) (flutter/engine#14457)

* ffbe2a4 [testing] Move test vsync waiters to their own TUs (flutter/engine#14456)

* 181ad4e Use futures to images used for comparison with fixtures in embedder unit-tests. (flutter/engine#14465)

* e0e0ac0 [testing] Make vsync waiters pluggable in shell_unittests (flutter/engine#14463)
filmil pushed a commit to filmil/engine that referenced this pull request Mar 13, 2020
…t browser/operating system and a11y behavior. (flutter#14131)

* adding the default text editing strategy

* [DRAFT] Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behaviour. Unit tests are missing. Documentation needs updating.

* addressing PR comments

* addressing PR comments. Fixing documentation

* fixing persistenttextediting element which is used in a11y mode

* removing texteditingelement and using texteditingstrategy from hybridtextediting. fixing the unit tests. fixing comments

* fix unit tests

* add todos for firefox tests

* fixing chrome/android a11y issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

affects: text input cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants