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

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Apr 9, 2021

Remove {StrutStyle, TextStyle}.has_leading_distribution_override from libTxt, and make {StrutStyle, TextStyle}.half_leading final (so they'll never default to ParagraphStyle.text_height_behavior during layout, instead they are resolved earlier than that: when the paragraph is being built).

SkParagraph relies on TextStyle.== to break TextStyles into Runs. If TextStyle.leadingDistribution may depend on ParagraphStyle then we won't be able to provide a reasonable TextStyle.== implementation. Plus it makes more sense to me to do the defaulting in dart:ui.

Related Issue: flutter/flutter#72521

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 Hixie said 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.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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

@google-cla google-cla bot added the cla: yes label Apr 9, 2021
@LongCatIsLooong LongCatIsLooong force-pushed the remove-paragraph-level-halfleading-attribute branch from d433931 to a73d75e Compare April 9, 2021 05:34
@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Apr 9, 2021
@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review April 9, 2021 06:42
lib/ui/text.dart Outdated
///
/// See [encode] for the creation of the encoded form.
TextHeightBehavior.fromEncoded(int encoded)
const TextHeightBehavior.fromEncoded(int encoded, this.leadingDistribution)
Copy link
Member

Choose a reason for hiding this comment

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

Should leadingDistribution be taken out of the TextHeightBehavior object?

leadingDistribution is an attribute that can be applied to individual runs of text. But the other members of TextHeightBehavior can only apply to the whole paragraph.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the framework TextStyle.leadingnDistribution can be null in which case it defers to ParagraphStyle.textHeightBehavior.leadingDistribution. You mean we should add it as a separate field to ParagraphStyle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does make more sense for fromEncoded and encode. But that would break some tests in the framework. Would it be possible to make these 2 methods private?

Copy link
Member

Choose a reason for hiding this comment

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

Yes - I think it would be more consistent to make leadingDistribution a field in ParagraphStyle that can optionally be overridden in the TextStyle

AFAIK there isn't any need for TextHeightBehavior.encode and TextHeightBehavior.fromEncoded to be public.

Most other encode/decode methods for these objects are private (like _encodeParagraphStyle and _encodeTextStyle)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the framework ParagraphStyle code, moving leadingDistribution to ParagraphStyle is going to break it. Is there a process for making such changes? Or I can hide the ugliness by making these methods private at the cost of testability.

@LongCatIsLooong LongCatIsLooong force-pushed the remove-paragraph-level-halfleading-attribute branch from 25b0d33 to f59045f Compare April 9, 2021 22:53
@LongCatIsLooong LongCatIsLooong force-pushed the remove-paragraph-level-halfleading-attribute branch from f59045f to 3c97fe9 Compare April 9, 2021 23:12
@LongCatIsLooong
Copy link
Contributor Author

@jason-simmons #25627 includes the skparagraph half leading commit. Updated the TxtToSkia method.

@LongCatIsLooong LongCatIsLooong added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Apr 19, 2021
@fluttergithubbot fluttergithubbot merged commit 2a3b399 into flutter:master Apr 19, 2021
@LongCatIsLooong LongCatIsLooong deleted the remove-paragraph-level-halfleading-attribute branch April 19, 2021 21:02
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 20, 2021
GuoXi pushed a commit to GuoXi/engine that referenced this pull request Apr 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants