Skip to content

Commit

Permalink
Android: Fix handling of line height with inline images
Browse files Browse the repository at this point in the history
Summary:
This PR was split from a commit originally in facebook#8619. /cc dmmiller

When an inline image was larger than the specified line height,
the image would be clipped. This changes the behavior so
that the line height is changed to make room for the inline
image. This is consistent with the behavior of RN for iOS.

Here's how the change works.

ReactTextView now receives its line height from the layout thread
rather than directly from JavaScript.

The reason is that the layout thread may pick a different line height.
In the case that the tallest inline image is larger than the line
height supplied by JavaScript, we want to use that image's height as
the line height rather than the supplied line height.

Also fixed a bug where the image, which is supposed to be baseline
aligned, would be positioned at the wrong y location. To fix this,
we use `y` (the baseline) in the `draw` method rather than trying
to calculate the baseline from `bottom`. For more information
see https://code.google.com/p/andro
Closes facebook#8907

Differential Revision: D3592781

Pulled By: dmmiller
  • Loading branch information
Adam Comella authored and DanielMSchmidt committed Jan 4, 2017
1 parent 283b376 commit 7c72552
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
super.onCollectExtraUpdates(uiViewOperationQueue);
if (mJsEventCount != UNSET) {
ReactTextUpdate reactTextUpdate =
new ReactTextUpdate(getText(), mJsEventCount, false, getPadding());
new ReactTextUpdate(getText(), mJsEventCount, false, getPadding(), Float.NaN);
// TODO: the Float.NaN should be replaced with the real line height see D3592781
uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate);
}
}
Expand Down

0 comments on commit 7c72552

Please sign in to comment.