Repository navigation
Commit 0414680
authored
[web] Stop iOS auto-zoom by sizing semantic inputs at 16px (flutter#192328)
Fixes flutter#192327 and flutter#129233.
**Problem**
1. The semantic `<input>` and `<textarea>` never get a font size, so
they fall back to the browser default, 11px on iOS. iOS auto-zooms any
focused editable element under 16px, so tapping a `TextField` zoomed the
page to 1.45x and left it there.
2. The framework's own text style never reached the element either. It
arrives before the element is attached, so it is stored, and
`activate()` replayed it before enabling the strategy, which made
`updateElementStyle` skip writing it.
Font size, family, weight and spacing were all dropped. That is flutter#129233.
**Fix**
Set the size on the element itself, to `max(frameworkFontSize, 16)` on
iOS, at element creation and after every style sync. It cannot live in
the global stylesheet because a later style update writes the framework
font as an inline
`font` shorthand, which outranks any stylesheet rule. It assigns rather
than only raises because on the first-focus path that shorthand is
skipped and nothing else sets a size, so raising alone would leave a
24px field at 16px.
Nothing visible changes: the semantics tree is painted at `filter:
opacity(0%)`. Guarded by `isIosSafari`; Android was device-tested and
does not auto-zoom.
**Demo**
| | |
|---|---|
| Before | https://flutter-demo-50-before.web.app |
| After | https://flutter-demo-50-after.web.app |
**iOS auto-zoom.** On an iPhone with semantics enabled, tap the **12px
field**. A default Material field is already 16px and cannot trigger the
bug. Before, `vvScale` jumps to 1.45 and stays until you pinch out.
After, it stays 1.00.
**flutter#129233.** In desktop Chrome, click into the **24px field**, then run:
```js
[...document.querySelectorAll('flt-semantics-host input, flt-semantics-host textarea')]
.map((e, i) => `${i} inline=${e.style.fontSize || 'NONE'} computed=${getComputedStyle(e).fontSize}`)
.join('\n')
```
Index 3 is the 24px field. Before: `inline=NONE computed=13.3333px`.
After: `inline=24px computed=24px`. Only the focused field carries a
style, so the others correctly report `NONE`.1 parent 6af46e7 commit 0414680
2 files changed
Lines changed: 182 additions & 1 deletion
File tree
- engine/src/flutter/lib/web_ui
- lib/src/engine/semantics
- test/engine/semantics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
14 | 50 | | |
15 | 51 | | |
16 | 52 | | |
| |||
90 | 126 | | |
91 | 127 | | |
92 | 128 | | |
93 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
94 | 132 | | |
| 133 | + | |
95 | 134 | | |
96 | 135 | | |
97 | 136 | | |
| |||
253 | 292 | | |
254 | 293 | | |
255 | 294 | | |
| 295 | + | |
256 | 296 | | |
257 | 297 | | |
258 | 298 | | |
| |||
345 | 385 | | |
346 | 386 | | |
347 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
348 | 394 | | |
349 | 395 | | |
350 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
| 920 | + | |
| 921 | + | |
920 | 922 | | |
921 | 923 | | |
922 | 924 | | |
| |||
995 | 997 | | |
996 | 998 | | |
997 | 999 | | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
998 | 1133 | | |
999 | 1134 | | |
1000 | 1135 | | |
| |||
0 commit comments