From 1aca811f07a360db427930a67c2ef968a12ef884 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Wed, 27 Nov 2019 09:37:41 -0800 Subject: [PATCH 1/9] adding the default text editing strategy --- .../src/engine/text_editing/text_editing.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart index edba66651a583..e3e23b2c6aba0 100644 --- a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart +++ b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart @@ -222,6 +222,22 @@ class InputConfiguration { typedef _OnChangeCallback = void Function(EditingState editingState); typedef _OnActionCallback = void Function(String inputAction); +/// Interface defining the template for text editing strategies. +/// +/// The starategies defined by this interface are: +/// * position +/// * attach +/// * remove +/// * add listeners +/// +/// The algorithms will be picked in the runtime depending on the concrete +/// class implementing the interface. +/// +/// These algorithms is expected to differ by operating system and/or browser. +abstract class TextEditingStrategy { + +} + /// Wraps the DOM element used to provide text editing capabilities. /// /// The backing DOM element could be one of: From 08ec6ec15f5edf95980467a7fe309a9ce56c8d91 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Wed, 4 Dec 2019 10:06:42 -0800 Subject: [PATCH 2/9] [DRAFT] Refactoring text editing. Strategy pattern is used to handle different browser/operating system and a11y behaviour. Unit tests are missing. Documentation needs updating. --- .../src/engine/text_editing/text_editing.dart | 575 +++++++++++------- 1 file changed, 356 insertions(+), 219 deletions(-) diff --git a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart index e3e23b2c6aba0..d98dfaae3e970 100644 --- a/lib/web_ui/lib/src/engine/text_editing/text_editing.dart +++ b/lib/web_ui/lib/src/engine/text_editing/text_editing.dart @@ -12,16 +12,6 @@ const int _kReturnKeyCode = 13; void _emptyCallback(dynamic _) {} -/// Indicates whether virtual keyboard shifts the location of input element. -/// -/// Value decided using the operating system and the browser engine. -/// -/// In iOS, the virtual keyboard might shifts the screen up to make input -/// visible depending on the location of the focused input element. -bool get _doesKeyboardShiftInput => - browserEngine == BrowserEngine.webkit && - operatingSystem == OperatingSystem.iOs; - /// These style attributes are constant throughout the life time of an input /// element. /// @@ -224,51 +214,42 @@ typedef _OnActionCallback = void Function(String inputAction); /// Interface defining the template for text editing strategies. /// -/// The starategies defined by this interface are: -/// * position -/// * attach -/// * remove -/// * add listeners -/// /// The algorithms will be picked in the runtime depending on the concrete /// class implementing the interface. /// /// These algorithms is expected to differ by operating system and/or browser. abstract class TextEditingStrategy { + void initializeTextEditing( + InputConfiguration inputConfig, { + @required _OnChangeCallback onChange, + @required _OnActionCallback onAction, + }); -} - -/// Wraps the DOM element used to provide text editing capabilities. -/// -/// The backing DOM element could be one of: -/// -/// 1. ``. -/// 2. `