@@ -220,18 +220,28 @@ class DomRenderer {
220
220
_styleElement = html.StyleElement ();
221
221
html.document.head.append (_styleElement);
222
222
final html.CssStyleSheet sheet = _styleElement.sheet;
223
-
223
+ final bool isWebKit = browserEngine == BrowserEngine .webkit;
224
+ final bool isFirefox = browserEngine == BrowserEngine .firefox;
224
225
// TODO(butterfly): use more efficient CSS selectors; descendant selectors
225
226
// are slow. More info:
226
227
//
227
228
// https://csswizardry.com/2011/09/writing-efficient-css-selectors/
228
229
229
230
// This undoes browser's default layout attributes for paragraphs. We
230
231
// compute paragraph layout ourselves.
231
- sheet.insertRule ('''
232
- flt-ruler-host p, flt-scene p {
233
- margin: 0;
234
- }''' , sheet.cssRules.length);
232
+ if (isFirefox) {
233
+ // For firefox set line-height, otherwise textx at same font-size will
234
+ // measure differently in ruler.
235
+ sheet.insertRule (
236
+ 'flt-ruler-host p, flt-scene p '
237
+ '{ margin: 0; line-height: 100%;}' ,
238
+ sheet.cssRules.length);
239
+ } else {
240
+ sheet.insertRule (
241
+ 'flt-ruler-host p, flt-scene p '
242
+ '{ margin: 0; }' ,
243
+ sheet.cssRules.length);
244
+ }
235
245
236
246
// This undoes browser's default painting and layout attributes of range
237
247
// input, which is used in semantics.
@@ -248,15 +258,15 @@ flt-semantics input[type=range] {
248
258
left: 0;
249
259
}''' , sheet.cssRules.length);
250
260
251
- if (browserEngine == BrowserEngine .webkit ) {
261
+ if (isWebKit ) {
252
262
sheet.insertRule (
253
263
'flt-semantics input[type=range]::-webkit-slider-thumb {'
254
264
' -webkit-appearance: none;'
255
265
'}' ,
256
266
sheet.cssRules.length);
257
267
}
258
268
259
- if (browserEngine == BrowserEngine .firefox ) {
269
+ if (isFirefox ) {
260
270
sheet.insertRule (
261
271
'input::-moz-selection {'
262
272
' background-color: transparent;'
@@ -292,7 +302,7 @@ flt-semantics [contentEditable="true"] {
292
302
293
303
// By default on iOS, Safari would highlight the element that's being tapped
294
304
// on using gray background. This CSS rule disables that.
295
- if (browserEngine == BrowserEngine .webkit ) {
305
+ if (isWebKit ) {
296
306
sheet.insertRule ('''
297
307
flt-glass-pane * {
298
308
-webkit-tap-highlight-color: transparent;
@@ -393,8 +403,7 @@ flt-glass-pane * {
393
403
// is 1.0.
394
404
window.debugOverrideDevicePixelRatio (1.0 );
395
405
396
- if (html.window.visualViewport == null &&
397
- browserEngine == BrowserEngine .webkit) {
406
+ if (html.window.visualViewport == null && isWebKit) {
398
407
// Safari sometimes gives us bogus innerWidth/innerHeight values when the
399
408
// page loads. When it changes the values to correct ones it does not
400
409
// notify of the change via `onResize`. As a workaround, we setup a
0 commit comments