Set measure function after YogaNode has been copied
Reviewed By: mdvacca Differential Revision: D7338948 fbshipit-source-id: e805169e162a47d0c7c775a3decbe9013c27c0e4
This commit is contained in:
parent
96daf677b7
commit
47910f0cad
|
@ -1024,11 +1024,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
|
||||||
if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) && getChildCount() != 0) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Since a node with a measure function does not add any native yoga children, it's "
|
|
||||||
+ "not safe to transition to/from having a measure function unless a node has no children");
|
|
||||||
}
|
|
||||||
mYogaNode.setMeasureFunction(measureFunction);
|
mYogaNode.setMeasureFunction(measureFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.view.Gravity;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.facebook.infer.annotation.Assertions;
|
import com.facebook.infer.annotation.Assertions;
|
||||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||||
|
import com.facebook.react.uimanager.ReactShadowNodeImpl;
|
||||||
import com.facebook.react.uimanager.Spacing;
|
import com.facebook.react.uimanager.Spacing;
|
||||||
import com.facebook.react.uimanager.UIViewOperationQueue;
|
import com.facebook.react.uimanager.UIViewOperationQueue;
|
||||||
import com.facebook.yoga.YogaConstants;
|
import com.facebook.yoga.YogaConstants;
|
||||||
|
@ -144,7 +145,6 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
||||||
private ReactTextShadowNode(ReactTextShadowNode node) {
|
private ReactTextShadowNode(ReactTextShadowNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
this.mPreparedSpannableText = node.mPreparedSpannableText;
|
this.mPreparedSpannableText = node.mPreparedSpannableText;
|
||||||
initMeasureFunction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMeasureFunction() {
|
private void initMeasureFunction() {
|
||||||
|
@ -158,6 +158,20 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
||||||
return new ReactTextShadowNode(this);
|
return new ReactTextShadowNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReactShadowNodeImpl mutableCopy() {
|
||||||
|
ReactTextShadowNode copy = (ReactTextShadowNode) super.mutableCopy();
|
||||||
|
copy.initMeasureFunction();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReactShadowNodeImpl mutableCopyWithNewChildren() {
|
||||||
|
ReactTextShadowNode copy = (ReactTextShadowNode) super.mutableCopyWithNewChildren();
|
||||||
|
copy.initMeasureFunction();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
// Return text alignment according to LTR or RTL style
|
// Return text alignment according to LTR or RTL style
|
||||||
private int getTextAlign() {
|
private int getTextAlign() {
|
||||||
int textAlign = mTextAlign;
|
int textAlign = mTextAlign;
|
||||||
|
|
Loading…
Reference in New Issue