Import css-layout measure mode changes from pull request #163

Summary: See https://github.com/facebook/css-layout/pull/163

Reviewed By: lucasr

Differential Revision: D3167760
This commit is contained in:
Emil Sjolander 2016-04-12 07:01:31 -07:00 committed by Ahmed El-Helw
parent cd06228f7a
commit 118cc4b9b7
2 changed files with 17 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import com.facebook.csslayout.CSSMeasureMode;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.Spacing;
@ -67,7 +68,13 @@ import com.facebook.react.uimanager.annotations.ReactProp;
}
@Override
public void measure(CSSNode node, float width, float height, MeasureOutput measureOutput) {
public void measure(
CSSNode node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode,
MeasureOutput measureOutput) {
CharSequence text = getText();
if (TextUtils.isEmpty(text)) {
// to indicate that we don't have anything to display
@ -80,8 +87,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
mText = text;
// technically, width should never be negative, but there is currently a bug in
// LayoutEngine where a negative value can be passed.
boolean unconstrainedWidth = Float.isNaN(width) || width < 0;
boolean unconstrainedWidth = widthMode == CSSMeasureMode.UNDEFINED || width < 0;
BoringLayout.Metrics metrics = BoringLayout.isBoring(text, PAINT, sBoringLayoutMetrics);
if (metrics != null) {

View File

@ -16,6 +16,7 @@ import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.EditText;
import com.facebook.csslayout.CSSMeasureMode;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.Spacing;
@ -70,7 +71,13 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
}
@Override
public void measure(CSSNode node, float width, float height, MeasureOutput measureOutput) {
public void measure(
CSSNode node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode,
MeasureOutput measureOutput) {
// measure() should never be called before setThemedContext()
EditText editText = Assertions.assertNotNull(mEditText);