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

Allow unsetting TextStyle.height #52940

Merged
merged 11 commits into from
May 24, 2024

Conversation

LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented May 20, 2024

Introduces a sentinel value kTextHeightNone for ui.TextStyle.height which can be used to "unset" the current TextStyle.height (and for consistency, it applies to StructStyle.height and ParagraphStyle.height too). Documentation of TextStyle.height can be found here (the one from painting library not dart:ui).

part of flutter/flutter#58765: currently TextStyle.height uses null as the sentinel value for "no height multiplier specified, use the font height", which has conflicting semantics: it means the height multiplier is not set (so the span height is determined by font metrics) but in reality it also means the height should inherit from its parent span (or in copyWith context, it means do not override the height).

The new sentinel value kTextHeightNone is currently set to 0.0. This is because skparagraph internally uses 0 for "no height multiplier", so using 0 should minimize the behavior change:
https://github.com/google/skia/blob/62f369c759947272dfdd2d8f060afadbcc361e79/modules/skparagraph/src/Run.cpp#L65-L67

This MAY still change the current behavior: for consistency setting StructStyle.height / ParagraphStyle.height to the sentinel value also unsets the height multiplier which may not be the current behavior.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the platform-web Code specifically for the web engine label May 20, 2024
@LongCatIsLooong LongCatIsLooong force-pushed the textStyle.height branch 3 times, most recently from 7adb07a to 092a8be Compare May 21, 2024 00:17
@LongCatIsLooong LongCatIsLooong changed the title wip Allow unsetting TextStyle.height May 22, 2024
@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review May 22, 2024 18:59
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.

cc @eyebrowsoffire for skwasm.

The web bits look good to me.

@mdebbar mdebbar requested a review from eyebrowsoffire May 23, 2024 18:09
@@ -94,6 +94,42 @@ void testMain() {
expect(await matchImage(tabImage, tofuImage), isFalse);
});

test('kTextHeightNone unsets the height multiplier', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move these tests into one of the text tests under flutter/lib/web_ui/test/ui so that it runs on all the renderers instead of just CanvasKit? As-is, these unit tests are not testing skwasm.

Copy link
Contributor

@eyebrowsoffire eyebrowsoffire left a comment

Choose a reason for hiding this comment

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

LGTM

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label May 24, 2024
@auto-submit auto-submit bot merged commit f1505f5 into flutter:main May 24, 2024
33 checks passed
@LongCatIsLooong LongCatIsLooong deleted the textStyle.height branch May 24, 2024 00:18
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 24, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 24, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 24, 2024
…149011)

flutter/engine@768c90e...d78f667

2024-05-24 [email protected] Roll Skia from 2ef772706cda to f2053e772e6f (1 revision) (flutter/engine#53009)
2024-05-24 [email protected] Roll Dart SDK from 7809d6e332ff to 9d7324ea563a (7 revisions) (flutter/engine#53008)
2024-05-24 [email protected] Allow unsetting `TextStyle.height`  (flutter/engine#52940)

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],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 29, 2024
Fixes: #58765

The rationale for the choice of the sentinel value: flutter/engine#52940
The exact value of `kTextHeightNone` should be kept as an implementation detail. It's unfortunate that the current value `0` is dangerously close to `TextStyle.height`'s valid domain. If we ever allow `TextStyle.height == 0` (which totally makes sense) then it shouldn't be difficult to change the const.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request May 31, 2024
…lutter#149011)

flutter/engine@768c90e...d78f667

2024-05-24 [email protected] Roll Skia from 2ef772706cda to f2053e772e6f (1 revision) (flutter/engine#53009)
2024-05-24 [email protected] Roll Dart SDK from 7809d6e332ff to 9d7324ea563a (7 revisions) (flutter/engine#53008)
2024-05-24 [email protected] Allow unsetting `TextStyle.height`  (flutter/engine#52940)

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],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request May 31, 2024
Fixes: flutter#58765

The rationale for the choice of the sentinel value: flutter/engine#52940
The exact value of `kTextHeightNone` should be kept as an implementation detail. It's unfortunate that the current value `0` is dangerously close to `TextStyle.height`'s valid domain. If we ever allow `TextStyle.height == 0` (which totally makes sense) then it shouldn't be difficult to change the const.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants