未验证 提交 5fe35fd4 编写于 作者: M Mouad Debbar 提交者: GitHub

[web] Canoncalize font family on input fields (#22215)

上级 59b01e0e
...@@ -1363,7 +1363,8 @@ class TextEditingChannel { ...@@ -1363,7 +1363,8 @@ class TextEditingChannel {
throw StateError( throw StateError(
'Unsupported method call on the flutter/textinput channel: ${call.method}'); 'Unsupported method call on the flutter/textinput channel: ${call.method}');
} }
EnginePlatformDispatcher.instance._replyToPlatformMessage(callback, codec.encodeSuccessEnvelope(true)); EnginePlatformDispatcher.instance
._replyToPlatformMessage(callback, codec.encodeSuccessEnvelope(true));
} }
/// Used for submitting the forms attached on the DOM. /// Used for submitting the forms attached on the DOM.
...@@ -1664,7 +1665,8 @@ class EditableTextStyle { ...@@ -1664,7 +1665,8 @@ class EditableTextStyle {
String? get align => textAlignToCssValue(textAlign, textDirection); String? get align => textAlignToCssValue(textAlign, textDirection);
String get cssFont => '${fontWeight} ${fontSize}px ${fontFamily}'; String get cssFont =>
'${fontWeight} ${fontSize}px ${canonicalizeFontFamily(fontFamily)}';
void applyToDomElement(html.HtmlElement domElement) { void applyToDomElement(html.HtmlElement domElement) {
domElement.style domElement.style
......
...@@ -1405,6 +1405,28 @@ void testMain() { ...@@ -1405,6 +1405,28 @@ void testMain() {
// TODO(nurhan): https://github.com/flutter/flutter/issues/50590 // TODO(nurhan): https://github.com/flutter/flutter/issues/50590
skip: browserEngine == BrowserEngine.webkit); skip: browserEngine == BrowserEngine.webkit);
test('Canonicalizes font family', () {
showKeyboard();
final HtmlElement input = textEditing.editingElement.domElement;
MethodCall setStyle;
setStyle = configureSetStyleMethodCall(12, 'sans-serif', 4, 4, 1);
sendFrameworkMessage(codec.encodeMethodCall(setStyle));
expect(input.style.fontFamily, canonicalizeFontFamily('sans-serif'));
setStyle = configureSetStyleMethodCall(12, '.SF Pro Text', 4, 4, 1);
sendFrameworkMessage(codec.encodeMethodCall(setStyle));
expect(input.style.fontFamily, canonicalizeFontFamily('.SF Pro Text'));
setStyle = configureSetStyleMethodCall(12, 'foo bar baz', 4, 4, 1);
sendFrameworkMessage(codec.encodeMethodCall(setStyle));
expect(input.style.fontFamily, canonicalizeFontFamily('foo bar baz'));
hideKeyboard();
});
test( test(
'negative base offset and selection extent values in editing state is handled', 'negative base offset and selection extent values in editing state is handled',
() { () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册