Refactor ReactShadowNode to add emoji support for TextInput and Fabric
Summary: This diff refactors support of emojis in RN classic in order to make it easy to extend support for text input and fabric (as part of this stack) changelog:[internal] Reviewed By: JoshuaGross Differential Revision: D19679394 fbshipit-source-id: 45eff49800b3db281721088f107494005d390fff
This commit is contained in:
Родитель
acaef83a27
Коммит
86d1153586
|
@ -66,6 +66,8 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode {
|
|||
|
||||
public static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
|
||||
|
||||
protected @Nullable ReactTextViewManagerCallback mReactTextViewManagerCallback;
|
||||
|
||||
private static class SetSpanOperation {
|
||||
protected int start, end;
|
||||
protected ReactSpan what;
|
||||
|
@ -313,6 +315,10 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode {
|
|||
textShadowNode.mTextAttributes.setHeightOfTallestInlineViewOrImage(
|
||||
heightOfTallestInlineViewOrImage);
|
||||
|
||||
if (mReactTextViewManagerCallback != null) {
|
||||
mReactTextViewManagerCallback.onPostProcessSpannable(sb);
|
||||
}
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
@ -379,7 +385,13 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode {
|
|||
protected Map<Integer, ReactShadowNode> mInlineViews;
|
||||
|
||||
public ReactBaseTextShadowNode() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public ReactBaseTextShadowNode(
|
||||
@Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) {
|
||||
mTextAttributes = new TextAttributes();
|
||||
mReactTextViewManagerCallback = reactTextViewManagerCallback;
|
||||
}
|
||||
|
||||
// Return text alignment according to LTR or RTL style
|
||||
|
|
|
@ -57,8 +57,6 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
|||
|
||||
private boolean mShouldNotifyOnTextLayout;
|
||||
|
||||
private @Nullable ReactTextViewManagerCallback mReactTextViewManagerCallback = null;
|
||||
|
||||
private final YogaMeasureFunction mTextMeasureFunction =
|
||||
new YogaMeasureFunction() {
|
||||
@Override
|
||||
|
@ -189,6 +187,11 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
|||
};
|
||||
|
||||
public ReactTextShadowNode() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public ReactTextShadowNode(@Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) {
|
||||
super(reactTextViewManagerCallback);
|
||||
initMeasureFunction();
|
||||
}
|
||||
|
||||
|
@ -198,10 +201,6 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
|||
}
|
||||
}
|
||||
|
||||
public void setReactTextViewManagerCallback(ReactTextViewManagerCallback callback) {
|
||||
mReactTextViewManagerCallback = callback;
|
||||
}
|
||||
|
||||
// Return text alignment according to LTR or RTL style
|
||||
private int getTextAlign() {
|
||||
int textAlign = mTextAlign;
|
||||
|
@ -223,9 +222,6 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode {
|
|||
/* text (e.g. from `value` prop): */ null,
|
||||
/* supportsInlineViews: */ true,
|
||||
nativeViewHierarchyOptimizer);
|
||||
if (mReactTextViewManagerCallback != null) {
|
||||
mReactTextViewManagerCallback.onPostProcessSpannable(mPreparedSpannableText);
|
||||
}
|
||||
markUpdated();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ public class ReactTextViewManager
|
|||
|
||||
@VisibleForTesting public static final String REACT_CLASS = "RCTText";
|
||||
|
||||
protected @Nullable ReactTextViewManagerCallback mReactTextViewManagerCallback;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return REACT_CLASS;
|
||||
|
@ -59,6 +61,11 @@ public class ReactTextViewManager
|
|||
return new ReactTextShadowNode();
|
||||
}
|
||||
|
||||
public ReactTextShadowNode createShadowNodeInstance(
|
||||
@Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) {
|
||||
return new ReactTextShadowNode(reactTextViewManagerCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactTextShadowNode> getShadowNodeClass() {
|
||||
return ReactTextShadowNode.class;
|
||||
|
|
Загрузка…
Ссылка в новой задаче