Skip to content

Conversation

@xster
Copy link
Member

@xster xster commented Jul 24, 2017

Fix a bug introduced when calculating the text line height for the text selection overlay #11224 (comment).
Also fix #11261.

Expose the preferredLineHeight from RenderEditable because the information is needed for the text UI.

@xster xster mentioned this pull request Jul 24, 2017
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the grammar of this comment while you're here...

Copy link
Contributor

Choose a reason for hiding this comment

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

Please document whatever this is.
In particular, the documentation should include the following details:

  • What the value represents.
  • What purpose is served by exposing this value here.
  • What the units of the value are.
  • When the value might change.
  • How to get notified when the value changes.

@Hixie
Copy link
Contributor

Hixie commented Jul 24, 2017

This needs a test for the bugs that are fixed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does it not require the layout to be updated? e.g. if the font size was animated up, wouldn't the toolbar need to animate its position also?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rephrase. Was referring to the callee not needing to be laid out

@xster xster force-pushed the fix-text-selection-line-height branch from 2ef66dc to 18afda1 Compare July 26, 2017 00:38
@xster
Copy link
Member Author

xster commented Jul 26, 2017

Added a test for text_selection widget to check plumbing

/// The height of a typical text line in logical pixels.
///
/// This height is based on properties of the text's style such as
/// font size etc and could change when those properties change.
Copy link
Contributor

Choose a reason for hiding this comment

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

But how would a user of this API know when that happens?

For example, if you change the font-size of a text field that is showing its toolbar, will the toolbar's position be adjusted?

Copy link
Member Author

Choose a reason for hiding this comment

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

Generically, the user wouldn't. It's mostly in line with the other getters in this file or that are downstream from the text painter like text or textAlign.

In the context of its relation with the selection overlay, it seems like all property changes of this renderable are coordinated via the EditableTextState which creates the widgets that populates this renderable in the first place by _updateOrDisposeSelectionOverlayIfNeeded etc when anything changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

text and textAlign are upstream of the painter. You set them. As far as I can tell, this is the first getter that would expose layout-based data.

Generally, this is an anti-pattern. If another object reads the layout, e.g. if the parent render object uses the preferredLineHeight in some way, then this render object changes its configuration, the parent won't update, until randomly the other child is dirtied, then suddenly it will update. We go to extreme lengths to make it possible to read the size, the intrinsic dimensions, etc, in such a way that the right objects get dirtied when the values change to avoid these problems.

I don't see anything in this file which causes the EditableTextState to be updated when the layout changes.

@Hixie
Copy link
Contributor

Hixie commented Aug 8, 2017

We discussed this patch in person and if I'm not mistaken we agreed to go a rather different route, so I'm going to close this PR for now to take it off the review queue. We can open a new PR when we have a new patch to review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text selection toolbar position for multi-line text incorrect

3 participants