[web] Prevent (forced-colors: active) from making the invisible text fields visible (flutter/engine#37089)
This commit is contained in:
@@ -332,6 +332,7 @@ extension DomCSSStyleDeclarationExtension on DomCSSStyleDeclaration {
|
||||
set right(String value) => setProperty('right', value);
|
||||
set bottom(String value) => setProperty('bottom', value);
|
||||
set backgroundColor(String value) => setProperty('background-color', value);
|
||||
set caretColor(String value) => setProperty('caret-color', value);
|
||||
set pointerEvents(String value) => setProperty('pointer-events', value);
|
||||
set filter(String value) => setProperty('filter', value);
|
||||
set zIndex(String value) => setProperty('z-index', value);
|
||||
@@ -400,6 +401,7 @@ extension DomCSSStyleDeclarationExtension on DomCSSStyleDeclaration {
|
||||
String get right => getPropertyValue('right');
|
||||
String get bottom => getPropertyValue('bottom');
|
||||
String get backgroundColor => getPropertyValue('background-color');
|
||||
String get caretColor => getPropertyValue('caret-color');
|
||||
String get pointerEvents => getPropertyValue('pointer-events');
|
||||
String get filter => getPropertyValue('filter');
|
||||
String get zIndex => getPropertyValue('z-index');
|
||||
|
||||
@@ -59,6 +59,9 @@ void _setStaticStyleAttributes(DomHTMLElement domElement) {
|
||||
|
||||
final DomCSSStyleDeclaration elementStyle = domElement.style;
|
||||
elementStyle
|
||||
// Prevent (forced-colors: active) from making our invisible text fields visible.
|
||||
// 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'
|
||||
@@ -69,10 +72,12 @@ void _setStaticStyleAttributes(DomHTMLElement domElement) {
|
||||
..color = 'transparent'
|
||||
..backgroundColor = 'transparent'
|
||||
..background = 'transparent'
|
||||
// This property makes the input's blinking cursor transparent.
|
||||
..caretColor = 'transparent'
|
||||
..outline = 'none'
|
||||
..border = 'none'
|
||||
..resize = 'none'
|
||||
..textShadow = 'transparent'
|
||||
..textShadow = 'none'
|
||||
..overflow = 'hidden'
|
||||
..transformOrigin = '0 0 0';
|
||||
|
||||
@@ -80,9 +85,6 @@ void _setStaticStyleAttributes(DomHTMLElement domElement) {
|
||||
domElement.classList.add(transparentTextEditingClass);
|
||||
}
|
||||
|
||||
// This property makes the input's blinking cursor transparent.
|
||||
elementStyle.setProperty('caret-color', 'transparent');
|
||||
|
||||
if (_debugVisibleTextEditing) {
|
||||
elementStyle
|
||||
..color = 'purple'
|
||||
|
||||
@@ -2528,6 +2528,36 @@ Future<void> testMain() async {
|
||||
expect(textEditingDeltaState.composingExtent, -1);
|
||||
});
|
||||
});
|
||||
|
||||
group('text editing styles', () {
|
||||
test('invisible element', () {
|
||||
editingStrategy!.enable(
|
||||
singlelineConfig,
|
||||
onChange: trackEditingState,
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
|
||||
final DomHTMLElement input = editingStrategy!.activeDomElement;
|
||||
expect(input.style.color, 'transparent');
|
||||
expect(input.style.background, 'transparent');
|
||||
expect(input.style.backgroundColor, 'transparent');
|
||||
expect(input.style.caretColor, 'transparent');
|
||||
expect(input.style.outline, 'none');
|
||||
expect(input.style.border, 'none');
|
||||
expect(input.style.textShadow, 'none');
|
||||
});
|
||||
|
||||
test('prevents effect of (forced-colors: active)', () {
|
||||
editingStrategy!.enable(
|
||||
singlelineConfig,
|
||||
onChange: trackEditingState,
|
||||
onAction: trackInputAction,
|
||||
);
|
||||
|
||||
final DomHTMLElement input = editingStrategy!.activeDomElement;
|
||||
expect(input.style.getPropertyValue('forced-color-adjust'), 'none');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
DomKeyboardEvent dispatchKeyboardEvent(
|
||||
|
||||
Reference in New Issue
Block a user