Reverts "[web] fix text selection offset in multi-line fields (#166565)" (#166644)

<!-- start_original_pr_link -->
Reverts: flutter/flutter#166565
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: jtmcdole
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Tree is broken
https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20linux_web_engine_tests/1240/overview
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: yjbanov
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {justinmc}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
Fixes https://github.com/flutter/flutter/issues/162698
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
This commit is contained in:
auto-submit[bot]
2025-04-05 17:14:19 +00:00
committed by GitHub
parent 31dfefc79e
commit 778ed9e8b6
5 changed files with 5 additions and 56 deletions

View File

@@ -543,7 +543,6 @@ extension type DomCSSStyleDeclaration._(JSObject _) implements JSObject {
set textAlign(String value) => setProperty('text-align', value);
set font(String value) => setProperty('font', value);
set cursor(String value) => setProperty('cursor', value);
set scrollbarWidth(String value) => setProperty('scrollbar-width', value);
String get width => getPropertyValue('width');
String get height => getPropertyValue('height');
String get position => getPropertyValue('position');
@@ -605,7 +604,6 @@ extension type DomCSSStyleDeclaration._(JSObject _) implements JSObject {
String get textAlign => getPropertyValue('text-align');
String get font => getPropertyValue('font');
String get cursor => getPropertyValue('cursor');
String get scrollbarWidth => getPropertyValue('scrollbar-width');
external String getPropertyValue(String property);

View File

@@ -6,7 +6,6 @@ import 'package:ui/ui.dart' as ui;
import '../dom.dart';
import '../platform_dispatcher.dart';
import '../text_editing/input_type.dart';
import '../text_editing/text_editing.dart';
import 'semantics.dart';
@@ -230,7 +229,7 @@ class SemanticTextField extends SemanticRole {
}
DomHTMLTextAreaElement _createMultiLineField() {
final textArea = createMultilineTextArea();
final textArea = createDomHTMLTextAreaElement();
if (semanticsObject.hasFlag(ui.SemanticsFlag.isObscured)) {
// -webkit-text-security is not standard, but it's the best we can do.

View File

@@ -120,7 +120,7 @@ class MultilineNoTextInputType extends MultilineInputType {
String? get inputmodeAttribute => 'none';
@override
DomHTMLElement createDomElement() => createMultilineTextArea();
DomHTMLElement createDomElement() => createDomHTMLTextAreaElement();
}
/// Single-line text input type.
@@ -184,12 +184,5 @@ class MultilineInputType extends EngineInputType {
String? get inputmodeAttribute => null;
@override
DomHTMLElement createDomElement() => createMultilineTextArea();
}
DomHTMLTextAreaElement createMultilineTextArea() {
final element = createDomHTMLTextAreaElement();
// Scrollbar width affects text layout. This zeroes out the scrollbar width.
element.style.scrollbarWidth = 'none';
return element;
DomHTMLElement createDomElement() => createDomHTMLTextAreaElement();
}

View File

@@ -64,6 +64,7 @@ void _setStaticStyleAttributes(DomHTMLElement domElement) {
// For more details, see: https://developer.mozilla.org/en-US/docs/Web/CSS/forced-color-adjust
..setProperty('forced-color-adjust', 'none')
..whiteSpace = 'pre-wrap'
..alignContent = 'center'
..position = 'absolute'
..top = '0'
..left = '0'
@@ -107,6 +108,7 @@ void _styleAutofillElements(
final DomCSSStyleDeclaration elementStyle = domElement.style;
elementStyle
..whiteSpace = 'pre-wrap'
..alignContent = 'center'
..padding = '0'
..opacity = '1'
..color = 'transparent'

View File

@@ -840,45 +840,6 @@ Future<void> testMain() async {
expect(spy.messages, isEmpty);
});
test('Does not align content in autofill group elements', () {
final setClient = MethodCall('TextInput.setClient', <dynamic>[
123,
createFlutterConfig('text'),
]);
sendFrameworkMessage(codec.encodeMethodCall(setClient));
const setEditingState = MethodCall('TextInput.setEditingState', <String, dynamic>{
'text': 'abcd',
'selectionBase': 2,
'selectionExtent': 3,
});
sendFrameworkMessage(codec.encodeMethodCall(setEditingState));
const show = MethodCall('TextInput.show');
sendFrameworkMessage(codec.encodeMethodCall(show));
// Form elements
{
final formElement = textEditing!.configuration!.autofillGroup!.formElement;
expect(formElement.style.alignContent, isEmpty);
// Should contain one <input type="text"> and one <input type="submit">
expect(formElement.children, hasLength(2));
final inputElement = formElement.children.first;
expect(inputElement.style.alignContent, isEmpty);
final submitElement = formElement.children.last;
expect(submitElement.style.alignContent, isEmpty);
}
// Active element
{
final DomHTMLElement activeElement = textEditing!.strategy.activeDomElement;
expect(activeElement.style.alignContent, isEmpty);
}
});
test('focus and connection with blur', () async {
// In all the desktop browsers we are keeping the connection
// open, keep the text editing element focused if it receives a blur
@@ -3624,10 +3585,6 @@ Future<void> testMain() async {
// though it supports forced-colors. Safari doesn't support forced-colors
// so this isn't a problem there.
}, skip: isFirefox || isSafari);
test('Multi-line text area scrollbars are zero-width', () {
expect(createMultilineTextArea().style.scrollbarWidth, 'none');
});
});
}