mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-01 06:22:39 +08:00
Import css-layout measure mode changes from pull request #163
Reviewed By: lucasr Differential Revision: D3167760 fb-gh-sync-id: f4f13bcb09a2d8b2db2764bd31fa8cbd8edb484b fbshipit-source-id: f4f13bcb09a2d8b2db2764bd31fa8cbd8edb484b
This commit is contained in:
committed by
Facebook Github Bot 4
parent
2039be9d32
commit
303428ea28
@@ -11,6 +11,7 @@ package com.facebook.react.views.art;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.react.uimanager.BaseViewManager;
|
||||
@@ -27,7 +28,13 @@ public class ARTSurfaceViewManager extends
|
||||
|
||||
private static final CSSNode.MeasureFunction MEASURE_FUNCTION = new CSSNode.MeasureFunction() {
|
||||
@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) {
|
||||
throw new IllegalStateException("SurfaceView should have explicit width and height set");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
@@ -51,7 +52,13 @@ public class ProgressBarShadowNode extends LayoutShadowNode implements CSSNode.M
|
||||
}
|
||||
|
||||
@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) {
|
||||
final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
|
||||
if (!mMeasured.contains(style)) {
|
||||
ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
@@ -50,7 +51,13 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!mMeasured) {
|
||||
SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
|
||||
final int spec = View.MeasureSpec.makeMeasureSpec(
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
@@ -44,7 +45,13 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (!mMeasured) {
|
||||
// Create a switch with the default config and measure it; since we don't (currently)
|
||||
// support setting custom switch text, this is fine, as all switches will measure the same
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.text.style.UnderlineSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.csslayout.CSSConstants;
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
@@ -201,7 +202,13 @@ public class ReactTextShadowNode extends LayoutShadowNode {
|
||||
private static final CSSNode.MeasureFunction TEXT_MEASURE_FUNCTION =
|
||||
new CSSNode.MeasureFunction() {
|
||||
@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) {
|
||||
// TODO(5578671): Handle text direction (see View#getTextDirectionHeuristic)
|
||||
ReactTextShadowNode reactCSSNode = (ReactTextShadowNode) node;
|
||||
TextPaint textPaint = sTextPaintInstance;
|
||||
@@ -214,8 +221,7 @@ public class ReactTextShadowNode extends LayoutShadowNode {
|
||||
Layout.getDesiredWidth(text, textPaint) : Float.NaN;
|
||||
|
||||
// technically, width should never be negative, but there is currently a bug in
|
||||
// LayoutEngine where a negative value can be passed.
|
||||
boolean unconstrainedWidth = CSSConstants.isUndefined(width) || width < 0;
|
||||
boolean unconstrainedWidth = widthMode == CSSMeasureMode.UNDEFINED || width < 0;
|
||||
|
||||
if (boring == null &&
|
||||
(unconstrainedWidth ||
|
||||
|
||||
@@ -16,6 +16,8 @@ import android.util.TypedValue;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.facebook.csslayout.CSSConstants;
|
||||
import com.facebook.csslayout.CSSMeasureMode;
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.csslayout.MeasureOutput;
|
||||
import com.facebook.csslayout.Spacing;
|
||||
@@ -63,11 +65,17 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
measureOutput.width = width;
|
||||
measureOutput.width = widthMode == CSSMeasureMode.UNDEFINED ? CSSConstants.UNDEFINED : width;
|
||||
editText.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
mFontSize == UNSET ?
|
||||
|
||||
Reference in New Issue
Block a user