Remove Fabric android implementation

Summary: This diff removes the Fabric Android implementation in favor of Fabric C++, as part of another diff I'm going to move the fabricxx package into fabric package

Reviewed By: shergin

Differential Revision: D9841240

fbshipit-source-id: c7922b7bfb9885f33b1f52237ec7cf00c1df96fb
This commit is contained in:
David Vacca
2018-09-19 08:03:20 -07:00
committed by Facebook Github Bot
parent 5c23f20cee
commit 7e7040b7bd
37 changed files with 28 additions and 2947 deletions
@@ -8,14 +8,11 @@ package com.facebook.react.uimanager;
import static java.lang.System.arraycopy;
import com.facebook.common.logging.FLog;
import com.facebook.debug.holder.PrinterHolder;
import com.facebook.debug.tags.ReactDebugOverlayTags;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
import com.facebook.systrace.Systrace;
import com.facebook.systrace.SystraceMessage;
import com.facebook.yoga.YogaAlign;
import com.facebook.yoga.YogaBaselineFunction;
import com.facebook.yoga.YogaConfig;
@@ -27,7 +24,6 @@ import com.facebook.yoga.YogaFlexDirection;
import com.facebook.yoga.YogaJustify;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaNodeCloneFunction;
import com.facebook.yoga.YogaOverflow;
import com.facebook.yoga.YogaPositionType;
import com.facebook.yoga.YogaValue;
@@ -67,38 +63,9 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
private static final boolean DEBUG = ReactBuildConfig.DEBUG || PrinterHolder.getPrinter().shouldDisplayLogMessage(ReactDebugOverlayTags.FABRIC_UI_MANAGER);
private static final String TAG = ReactShadowNodeImpl.class.getSimpleName();
private static final YogaConfig sYogaConfig;
static {
sYogaConfig = ReactYogaConfigProvider.get();
sYogaConfig.setOnCloneNode(new YogaNodeCloneFunction() {
@Override
public YogaNode cloneNode(YogaNode oldYogaNode,
YogaNode parent,
int childIndex) {
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"FabricReconciler.YogaNodeCloneFunction")
.flush();
try {
ReactShadowNodeImpl parentReactShadowNode = (ReactShadowNodeImpl) parent.getData();
Assertions.assertNotNull(parentReactShadowNode);
ReactShadowNodeImpl oldReactShadowNode = (ReactShadowNodeImpl) oldYogaNode.getData();
Assertions.assertNotNull(oldReactShadowNode);
if (DEBUG) {
FLog.d(
TAG,
"YogaNode started cloning: oldYogaNode: " + oldReactShadowNode + " - parent: "
+ parentReactShadowNode + " index: " + childIndex);
}
ReactShadowNodeImpl newNode = oldReactShadowNode.mutableCopy(oldReactShadowNode.getInstanceHandle());
parentReactShadowNode.replaceChild(newNode, childIndex);
return newNode.mYogaNode;
} finally{
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
});
}
private int mReactTag;
@@ -168,94 +135,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
mIsSealed = false;
}
private void replaceChild(ReactShadowNodeImpl newNode, int childIndex) {
mChildren.remove(childIndex);
mChildren.add(childIndex, newNode);
newNode.mParent = this;
}
/**
* @return a copy of this object (no including copy of its children or the underlying yogaNode).
*/
protected ReactShadowNodeImpl copy() {
return new ReactShadowNodeImpl(this);
}
@Override
public ReactShadowNodeImpl mutableCopy(long instanceHandle) {
ReactShadowNodeImpl copy = copy();
Assertions.assertCondition(
getClass() == copy.getClass(),
"Copied shadow node must use the same class");
copy.mInstanceHandle = instanceHandle;
if (mYogaNode != null) {
copy.mYogaNode = mYogaNode.clone();
copy.mYogaNode.setData(copy);
} else {
// Virtual ReactShadowNode do not have a YogaNode associated
copy.mYogaNode = null;
}
copy.mTotalNativeChildren = mTotalNativeChildren;
copy.mNativeChildren = copyChildren(mNativeChildren);
copy.mChildren = copyChildren(mChildren);
return copy;
}
@Nullable
private ArrayList<ReactShadowNodeImpl> copyChildren(@Nullable List<ReactShadowNodeImpl> list){
ArrayList<ReactShadowNodeImpl> result = list == null ? null : new ArrayList<>(list);
if (result != null) {
for (ReactShadowNodeImpl child : result) {
child.mParent = null;
}
}
return result;
}
@Override
public ReactShadowNodeImpl mutableCopyWithNewChildren(long instanceHandle) {
ReactShadowNodeImpl copy = copy();
copy.mInstanceHandle = instanceHandle;
Assertions.assertCondition(
getClass() == copy.getClass(),
"Copied shadow node must use the same class");
if (mYogaNode != null) {
copy.mYogaNode = mYogaNode.cloneWithNewChildren();
copy.mYogaNode.setData(copy);
} else {
// Virtual ReactShadowNode do not have a YogaNode associated
copy.mYogaNode = null;
}
copy.mNativeChildren = null;
copy.mChildren = null;
copy.mTotalNativeChildren = 0;
return copy;
}
@Override
public ReactShadowNodeImpl mutableCopyWithNewProps(long instanceHandle,
@Nullable ReactStylesDiffMap newProps) {
ReactShadowNodeImpl copy = mutableCopy(instanceHandle);
if (newProps != null) {
copy.updateProperties(newProps);
copy.mNewProps = newProps;
}
return copy;
}
@Override
public ReactShadowNodeImpl mutableCopyWithNewChildrenAndProps(long instanceHandle,
@Nullable ReactStylesDiffMap newProps) {
ReactShadowNodeImpl copy = mutableCopyWithNewChildren(instanceHandle);
if (newProps != null) {
copy.updateProperties(newProps);
copy.mNewProps = newProps;
}
return copy;
}
/**
* Nodes that return {@code true} will be treated as "virtual" nodes. That is, nodes that are not
* mapped into native views (e.g. nested text node). By default this method returns {@code false}.
@@ -299,7 +178,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public final void markUpdateSeen() {
assertNotSealed();
mNodeUpdated = false;
if (hasNewLayout()) {
markLayoutSeen();
@@ -325,7 +203,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void dirty() {
assertNotSealed();
if (!isVirtual()) {
mYogaNode.dirty();
}
@@ -338,7 +215,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void addChildAt(ReactShadowNodeImpl child, int i) {
assertNotSealed();
if (mChildren == null) {
mChildren = new ArrayList<>(4);
}
@@ -370,7 +246,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public ReactShadowNodeImpl removeChildAt(int i) {
assertNotSealed();
if (mChildren == null) {
throw new ArrayIndexOutOfBoundsException(
"Index " + i + " out of bounds: node has no children");
@@ -543,7 +418,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setReactTag(int reactTag) {
assertNotSealed();
mReactTag = reactTag;
}
@@ -555,13 +429,11 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public final void setRootTag(int rootTag) {
assertNotSealed();
mRootTag = rootTag;
}
@Override
public final void setViewClassName(String viewClassName) {
assertNotSealed();
mViewClassName = viewClassName;
}
@@ -603,7 +475,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public final void markLayoutSeen() {
assertNotSealed();
if (mYogaNode != null) {
mYogaNode.markLayoutSeen();
}
@@ -615,7 +486,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
*/
@Override
public final void addNativeChildAt(ReactShadowNodeImpl child, int nativeIndex) {
assertNotSealed();
Assertions.assertCondition(!mIsLayoutOnly);
Assertions.assertCondition(!child.mIsLayoutOnly);
@@ -667,7 +537,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
*/
@Override
public final void setIsLayoutOnly(boolean isLayoutOnly) {
assertNotSealed();
Assertions.assertCondition(getParent() == null, "Must remove from no opt parent first");
Assertions.assertCondition(mNativeParent == null, "Must remove from native parent first");
Assertions.assertCondition(getNativeChildCount() == 0, "Must remove all native children first");
@@ -816,7 +685,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setLayoutDirection(YogaDirection direction) {
assertNotSealed();
mYogaNode.setDirection(direction);
}
@@ -827,43 +695,36 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setStyleWidth(float widthPx) {
assertNotSealed();
mYogaNode.setWidth(widthPx);
}
@Override
public void setStyleWidthPercent(float percent) {
assertNotSealed();
mYogaNode.setWidthPercent(percent);
}
@Override
public void setStyleWidthAuto() {
assertNotSealed();
mYogaNode.setWidthAuto();
}
@Override
public void setStyleMinWidth(float widthPx) {
assertNotSealed();
mYogaNode.setMinWidth(widthPx);
}
@Override
public void setStyleMinWidthPercent(float percent) {
assertNotSealed();
mYogaNode.setMinWidthPercent(percent);
}
@Override
public void setStyleMaxWidth(float widthPx) {
assertNotSealed();
mYogaNode.setMaxWidth(widthPx);
}
@Override
public void setStyleMaxWidthPercent(float percent) {
assertNotSealed();
mYogaNode.setMaxWidthPercent(percent);
}
@@ -874,151 +735,126 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setStyleHeight(float heightPx) {
assertNotSealed();
mYogaNode.setHeight(heightPx);
}
@Override
public void setStyleHeightPercent(float percent) {
assertNotSealed();
mYogaNode.setHeightPercent(percent);
}
@Override
public void setStyleHeightAuto() {
assertNotSealed();
mYogaNode.setHeightAuto();
}
@Override
public void setStyleMinHeight(float widthPx) {
assertNotSealed();
mYogaNode.setMinHeight(widthPx);
}
@Override
public void setStyleMinHeightPercent(float percent) {
assertNotSealed();
mYogaNode.setMinHeightPercent(percent);
}
@Override
public void setStyleMaxHeight(float widthPx) {
assertNotSealed();
mYogaNode.setMaxHeight(widthPx);
}
@Override
public void setStyleMaxHeightPercent(float percent) {
assertNotSealed();
mYogaNode.setMaxHeightPercent(percent);
}
@Override
public void setFlex(float flex) {
assertNotSealed();
mYogaNode.setFlex(flex);
}
@Override
public void setFlexGrow(float flexGrow) {
assertNotSealed();
mYogaNode.setFlexGrow(flexGrow);
}
@Override
public void setFlexShrink(float flexShrink) {
assertNotSealed();
mYogaNode.setFlexShrink(flexShrink);
}
@Override
public void setFlexBasis(float flexBasis) {
assertNotSealed();
mYogaNode.setFlexBasis(flexBasis);
}
@Override
public void setFlexBasisAuto() {
assertNotSealed();
mYogaNode.setFlexBasisAuto();
}
@Override
public void setFlexBasisPercent(float percent) {
assertNotSealed();
mYogaNode.setFlexBasisPercent(percent);
}
@Override
public void setStyleAspectRatio(float aspectRatio) {
assertNotSealed();
mYogaNode.setAspectRatio(aspectRatio);
}
@Override
public void setFlexDirection(YogaFlexDirection flexDirection) {
assertNotSealed();
mYogaNode.setFlexDirection(flexDirection);
}
@Override
public void setFlexWrap(YogaWrap wrap) {
assertNotSealed();
mYogaNode.setWrap(wrap);
}
@Override
public void setAlignSelf(YogaAlign alignSelf) {
assertNotSealed();
mYogaNode.setAlignSelf(alignSelf);
}
@Override
public void setAlignItems(YogaAlign alignItems) {
assertNotSealed();
mYogaNode.setAlignItems(alignItems);
}
@Override
public void setAlignContent(YogaAlign alignContent) {
assertNotSealed();
mYogaNode.setAlignContent(alignContent);
}
@Override
public void setJustifyContent(YogaJustify justifyContent) {
assertNotSealed();
mYogaNode.setJustifyContent(justifyContent);
}
@Override
public void setOverflow(YogaOverflow overflow) {
assertNotSealed();
mYogaNode.setOverflow(overflow);
}
@Override
public void setDisplay(YogaDisplay display) {
assertNotSealed();
mYogaNode.setDisplay(display);
}
@Override
public void setMargin(int spacingType, float margin) {
assertNotSealed();
mYogaNode.setMargin(YogaEdge.fromInt(spacingType), margin);
}
@Override
public void setMarginPercent(int spacingType, float percent) {
assertNotSealed();
mYogaNode.setMarginPercent(YogaEdge.fromInt(spacingType), percent);
}
@Override
public void setMarginAuto(int spacingType) {
assertNotSealed();
mYogaNode.setMarginAuto(YogaEdge.fromInt(spacingType));
}
@@ -1034,14 +870,12 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setDefaultPadding(int spacingType, float padding) {
assertNotSealed();
mDefaultPadding.set(spacingType, padding);
updatePadding();
}
@Override
public void setPadding(int spacingType, float padding) {
assertNotSealed();
mPadding[spacingType] = padding;
mPaddingIsPercent[spacingType] = false;
updatePadding();
@@ -1049,14 +883,12 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setPaddingPercent(int spacingType, float percent) {
assertNotSealed();
mPadding[spacingType] = percent;
mPaddingIsPercent[spacingType] = !YogaConstants.isUndefined(percent);
updatePadding();
}
private void updatePadding() {
assertNotSealed();
for (int spacingType = Spacing.LEFT; spacingType <= Spacing.ALL; spacingType++) {
if (spacingType == Spacing.LEFT
|| spacingType == Spacing.RIGHT
@@ -1092,43 +924,36 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
@Override
public void setBorder(int spacingType, float borderWidth) {
assertNotSealed();
mYogaNode.setBorder(YogaEdge.fromInt(spacingType), borderWidth);
}
@Override
public void setPosition(int spacingType, float position) {
assertNotSealed();
mYogaNode.setPosition(YogaEdge.fromInt(spacingType), position);
}
@Override
public void setPositionPercent(int spacingType, float percent) {
assertNotSealed();
mYogaNode.setPositionPercent(YogaEdge.fromInt(spacingType), percent);
}
@Override
public void setPositionType(YogaPositionType positionType) {
assertNotSealed();
mYogaNode.setPositionType(positionType);
}
@Override
public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) {
assertNotSealed();
mShouldNotifyOnLayout = shouldNotifyOnLayout;
}
@Override
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
assertNotSealed();
mYogaNode.setBaselineFunction(baselineFunction);
}
@Override
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
assertNotSealed();
mYogaNode.setMeasureFunction(measureFunction);
}
@@ -1184,43 +1009,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
return mChildren == null ? null : Collections.<ReactShadowNode>unmodifiableList(mChildren);
}
@Override
public ReactShadowNode getOriginalReactShadowNode() {
return mOriginalReactShadowNode;
}
@Override
public void setOriginalReactShadowNode(ReactShadowNode node) {
mOriginalReactShadowNode = node;
}
@Override
public long getInstanceHandle() {
return mInstanceHandle;
}
@Override
public void setInstanceHandle(long instanceHandle) {
assertNotSealed();
mInstanceHandle = instanceHandle;
}
@Override
public void markAsSealed() {
mIsSealed = true;
}
@Override
public boolean isSealed() {
return mIsSealed;
}
private void assertNotSealed() {
if (mIsSealed) {
throw new IllegalStateException("Can not modify sealed node " + toString());
}
}
@Override
public void updateScreenLayout(ReactShadowNode prevNode) {
mScreenHeight = prevNode.getScreenHeight();