Fix TextInput contentSize

Summary:
This fixes some inaccuracies in our reporting of textinput's contentsize.
First, we were not using the correct padding info. Then, we are converting the
contentSize width and height to ints right before sending
them over to JS. This adds some inaccuracy with the textinput behaviour,
especially in the case of auto expending text inputs, since those same sizes are
then sent right back.

Reviewed By: astreet

Differential Revision: D3806008

fbshipit-source-id: 7e32f91fde50099fd8a122833fd0042683e68df1
This commit is contained in:
Andrei Coman authored and Facebook Github Bot 9 committed 2016-09-06 03:13:43 -07:00
1 parent 0d9490fa67
commit 7c268b31c2
3 files changed
+13 -13

No files matched your search

@@ -21,13 +21,13 @@ public class ReactContentSizeChangedEvent extends Event<ReactTextChangedEvent> {
public static final String EVENT_NAME = "topContentSizeChange";
private int mContentWidth;
private int mContentHeight;
private float mContentWidth;
private float mContentHeight;
public ReactContentSizeChangedEvent(
int viewId,
int contentSizeWidth,
int contentSizeHeight) {
float contentSizeWidth,
float contentSizeHeight) {
super(viewId);
mContentWidth = contentSizeWidth;
mContentHeight = contentSizeHeight;
@@ -23,15 +23,15 @@ public class ReactTextChangedEvent extends Event<ReactTextChangedEvent> {
public static final String EVENT_NAME = "topChange";
private String mText;
private int mContentWidth;
private int mContentHeight;
private float mContentWidth;
private float mContentHeight;
private int mEventCount;
public ReactTextChangedEvent(
int viewId,
String text,
int contentSizeWidth,
int contentSizeHeight,
float contentSizeWidth,
float contentSizeHeight,
int eventCount) {
super(viewId);
mText = text;
@@ -590,8 +590,8 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
new ReactTextChangedEvent(
mEditText.getId(),
s.toString(),
(int) PixelUtil.toDIPFromPixel(contentWidth),
(int) PixelUtil.toDIPFromPixel(contentHeight),
PixelUtil.toDIPFromPixel(contentWidth),
PixelUtil.toDIPFromPixel(contentHeight),
mEditText.incrementAndGetEventCounter()));
mEventDispatcher.dispatchEvent(
@@ -683,7 +683,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
contentWidth = mEditText.getCompoundPaddingLeft() + mEditText.getLayout().getWidth() +
mEditText.getCompoundPaddingRight();
contentHeight = mEditText.getCompoundPaddingTop() + mEditText.getLayout().getHeight() +
mEditText.getCompoundPaddingTop();
mEditText.getCompoundPaddingBottom();
}
if (contentWidth != mPreviousContentWidth || contentHeight != mPreviousContentHeight) {
@@ -693,8 +693,8 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
mEventDispatcher.dispatchEvent(
new ReactContentSizeChangedEvent(
mEditText.getId(),
(int) PixelUtil.toDIPFromPixel(contentWidth),
(int) PixelUtil.toDIPFromPixel(contentHeight)));
PixelUtil.toDIPFromPixel(contentWidth),
PixelUtil.toDIPFromPixel(contentHeight)));
}
}
}