diff --git a/lib/web_ui/lib/src/engine/browser_detection.dart b/lib/web_ui/lib/src/engine/browser_detection.dart index 054b16e6be83b1a2b2e921b765d8bd0da4f1c28e..3a4c1a4cbc305b2ecef659db0bd08e64fd851453 100644 --- a/lib/web_ui/lib/src/engine/browser_detection.dart +++ b/lib/web_ui/lib/src/engine/browser_detection.dart @@ -29,10 +29,23 @@ enum BrowserEngine { /// Lazily initialized current browser engine. BrowserEngine _browserEngine; +/// Override the value of [browserEngine]. +/// +/// Setting this to `null` lets [browserEngine] detect the browser that the +/// app is running on. +/// +/// This is intended to be used for testing and debugging only. +BrowserEngine debugBrowserEngineOverride; + /// Returns the [BrowserEngine] used by the current browser. /// /// This is used to implement browser-specific behavior. -BrowserEngine get browserEngine => _browserEngine ??= _detectBrowserEngine(); +BrowserEngine get browserEngine { + if (debugBrowserEngineOverride != null) { + return debugBrowserEngineOverride; + } + return _browserEngine ??= _detectBrowserEngine(); +} BrowserEngine _detectBrowserEngine() { final String vendor = html.window.navigator.vendor; diff --git a/lib/web_ui/lib/src/engine/text_editing/input_type.dart b/lib/web_ui/lib/src/engine/text_editing/input_type.dart index 47c0ff7a099274939d8a837394634a94ceeffaca..d7620c2f625842984f730c23fb02acdcfdfdc8e7 100644 --- a/lib/web_ui/lib/src/engine/text_editing/input_type.dart +++ b/lib/web_ui/lib/src/engine/text_editing/input_type.dart @@ -66,7 +66,7 @@ abstract class EngineInputType { html.HtmlElement createDomElement() => html.InputElement(); /// Given a [domElement], set attributes that are specific to this input type. - void configureDomElement(html.HtmlElement domElement) { + void configureInputMode(html.HtmlElement domElement) { if (inputmodeAttribute == null) { return; } 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 edba66651a583ad7a8e3c2bc0db37ceffb9903bc..9c99621b78d36349eb8ae43cfa9f0fe0c154b4ee 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. /// @@ -222,37 +212,78 @@ class InputConfiguration { typedef _OnChangeCallback = void Function(EditingState editingState); typedef _OnActionCallback = void Function(String inputAction); -/// Wraps the DOM element used to provide text editing capabilities. +/// Interface defining the template for text editing strategies. /// -/// The backing DOM element could be one of: +/// The algorithms will be picked in the runtime depending on the concrete +/// class implementing the interface. /// -/// 1. ``. -/// 2. `