Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] Fix default line-height issue for Firefox #13960

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

ferhatb
Copy link
Contributor

@ferhatb ferhatb commented Nov 21, 2019

Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

margin: 0;
}''', sheet.cssRules.length);
if (isFirefox) {
// For firefox set line-height, otherwise textx at same font-size will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "textx"

// measure differently in ruler.
sheet.insertRule(
'flt-ruler-host p, flt-scene p '
'{ margin: 0; line-height: 100%;}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it break things if we add this to other browsers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra CSS matchers slow down browser style recalculation. We should avoid them whenever possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already adding the same CSS matcher to other browser, just without line-height.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. Doesn't matter in this case then.

@@ -220,18 +220,28 @@ class DomRenderer {
_styleElement = html.StyleElement();
html.document.head.append(_styleElement);
final html.CssStyleSheet sheet = _styleElement.sheet;

final bool isWebKit = browserEngine == BrowserEngine.webkit;
final bool isFirefox = browserEngine == BrowserEngine.firefox;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: these could be convenient reusable getters in the browser_detection.dart library.

// measure differently in ruler.
sheet.insertRule(
'flt-ruler-host p, flt-scene p '
'{ margin: 0; line-height: 100%;}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra CSS matchers slow down browser style recalculation. We should avoid them whenever possible.

// For firefox set line-height, otherwise textx at same font-size will
// measure differently in ruler.
sheet.insertRule(
'flt-ruler-host p, flt-scene p '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering now if we are seeing expensive style recalculation because of these descendant matchers. Something we should try at some point is use a custom tag for paragraphs and use a simple tag matcher instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. We could also get away with simply adding a class name to all the p tags we use for text measurement and rendering. I'll file an issue so we don't forget.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, we are doing this here: #32043 🎉

@ferhatb ferhatb merged commit 7e68097 into flutter:master Nov 21, 2019
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 22, 2019
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Nov 22, 2019
[email protected]:flutter/engine.git/compare/96fc607b8a54...7e68097

git log 96fc607..7e68097 --no-merges --oneline
2019-11-21 [email protected] [web] Fix line-height for Firefox (flutter/engine#13960)
2019-11-21 [email protected] [web] Allow users to enable canvas text measurement (flutter/engine#13929)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[web]: icons are rendered with vertical offset on Firefox
4 participants