Permalink
Browse files

BREAKING: Add interface for ReactShadowNode

Reviewed By: AaaChiuuu

Differential Revision: D5943137

fbshipit-source-id: 00950190e0256303d423ae86c6c18facf173ad6a
  • Loading branch information...
mdvacca authored and facebook-github-bot committed Oct 2, 2017
1 parent 9c4ec30 commit a5d1d25f5616352eaf737f177de700bc1a5ac4b5
@@ -15,10 +15,9 @@
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.yoga.YogaValue;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaValue;
/**
* FlatReactModalShadowNode
@@ -43,11 +42,11 @@
/**
* We need to set the styleWidth and styleHeight of the one child (represented by the <View/>
* within the <RCTModalHostView/> in Modal.js. This needs to fill the entire window.
* within the <RCTModalHostView/> in Modal.js. This needs to fill the entire window.
*/
@Override
@TargetApi(16)
public void addChildAt(ReactShadowNode child, int i) {
public void addChildAt(ReactShadowNodeImpl child, int i) {
super.addChildAt(child, i);
Context context = getThemedContext();
@@ -9,18 +9,17 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import android.graphics.Rect;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.OnLayoutEvent;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import javax.annotation.Nullable;
/**
* FlatShadowNode is a base class for all shadow node used in FlatUIImplementation. It extends
@@ -213,7 +212,7 @@ public final int getScreenHeight() {
}
@Override
public void addChildAt(ReactShadowNode child, int i) {
public void addChildAt(ReactShadowNodeImpl child, int i) {
super.addChildAt(child, i);
if (mForceMountChildrenToView && child instanceof FlatShadowNode) {
((FlatShadowNode) child).forceMountToView();
@@ -9,11 +9,11 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import javax.annotation.Nullable;
/**
* Helper class that sorts moveFrom/moveTo arrays in lockstep.
@@ -23,7 +23,7 @@
private @Nullable ReadableArray mMoveTo;
private int mSize;
private int[] mMapping = new int[8];
private ReactShadowNode[] mChildren = new ReactShadowNode[4];
private ReactShadowNode[] mChildren = new ReactShadowNodeImpl[4];
/**
* Retuns size of underlying moveTo/moveFrom arrays
@@ -10,6 +10,7 @@
package com.facebook.react.flat;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIViewOperationQueue;
@@ -18,7 +19,6 @@
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaValue;
import javax.annotation.Nullable;
/* package */ final class NativeViewWrapper extends FlatShadowNode implements AndroidView {
@@ -95,7 +95,7 @@ public void setThemedContext(ThemedReactContext themedContext) {
}
@Override
public void addChildAt(ReactShadowNode child, int i) {
public void addChildAt(ReactShadowNodeImpl child, int i) {
super.addChildAt(child, i);
if (mForceMountGrandChildrenToView && child instanceof FlatShadowNode) {
((FlatShadowNode) child).forceMountChildrenToView();
@@ -9,18 +9,16 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import javax.annotation.Nullable;
/**
* RCTVirtualText is a {@link FlatTextShadowNode} that can contain font styling information.
@@ -40,7 +38,7 @@
private ShadowStyleSpan mShadowStyleSpan = ShadowStyleSpan.INSTANCE;
@Override
public void addChildAt(ReactShadowNode child, int i) {
public void addChildAt(ReactShadowNodeImpl child, int i) {
super.addChildAt(child, i);
notifyChanged(true);
}
@@ -2,6 +2,36 @@
package com.facebook.react.processing;
import static javax.lang.model.element.Modifier.ABSTRACT;
import static javax.lang.model.element.Modifier.PRIVATE;
import static javax.lang.model.element.Modifier.PUBLIC;
import static javax.tools.Diagnostic.Kind.ERROR;
import static javax.tools.Diagnostic.Kind.WARNING;
import com.facebook.infer.annotation.SuppressFieldNotInitialized;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.TypeVariableName;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
@@ -20,37 +50,6 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.facebook.infer.annotation.SuppressFieldNotInitialized;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.TypeVariableName;
import static javax.lang.model.element.Modifier.*;
import static javax.tools.Diagnostic.Kind.ERROR;
import static javax.tools.Diagnostic.Kind.WARNING;
/**
* This annotation processor crawls subclasses of ReactShadowNode and ViewManager and finds their
* exported properties with the @ReactProp or @ReactGroupProp annotation. It generates a class
@@ -73,8 +72,8 @@
private static final TypeName VIEW_MANAGER_TYPE =
ClassName.get("com.facebook.react.uimanager", "ViewManager");
private static final TypeName SHADOW_NODE_TYPE =
ClassName.get("com.facebook.react.uimanager", "ReactShadowNode");
private static final TypeName SHADOW_NODE_IMPL_TYPE =
ClassName.get("com.facebook.react.uimanager", "ReactShadowNodeImpl");
private static final ClassName VIEW_MANAGER_SETTER_TYPE =
ClassName.get(
@@ -185,9 +184,13 @@ public int compare(PropertyInfo a, PropertyInfo b) {
return true;
}
private boolean isShadowNodeType(TypeName typeName) {
return typeName.equals(SHADOW_NODE_IMPL_TYPE);
}
private ClassInfo parseClass(ClassName className, TypeElement typeElement) {
TypeName targetType = getTargetType(typeElement.asType());
TypeName viewType = targetType.equals(SHADOW_NODE_TYPE) ? null : targetType;
TypeName viewType = isShadowNodeType(targetType) ? null : targetType;
ClassInfo classInfo = new ClassInfo(className, typeElement, viewType);
findProperties(classInfo, typeElement);
@@ -233,10 +236,10 @@ private TypeName getTargetType(TypeMirror mirror) {
if (parameterizedTypeName.rawType.equals(VIEW_MANAGER_TYPE)) {
return parameterizedTypeName.typeArguments.get(0);
}
} else if (typeName.equals(SHADOW_NODE_TYPE)) {
return SHADOW_NODE_TYPE;
} else if (isShadowNodeType(typeName)) {
return SHADOW_NODE_IMPL_TYPE;
} else if (typeName.equals(TypeName.OBJECT)) {
throw new IllegalArgumentException("Could not find target type");
throw new IllegalArgumentException("Could not find target type " + typeName);
}
List<? extends TypeMirror> types = mTypes.directSupertypes(mirror);
@@ -2,13 +2,11 @@
package com.facebook.react.uimanager;
import javax.annotation.Nullable;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.facebook.yoga.YogaAlign;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaDisplay;
@@ -18,19 +16,18 @@
import com.facebook.yoga.YogaPositionType;
import com.facebook.yoga.YogaUnit;
import com.facebook.yoga.YogaWrap;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import javax.annotation.Nullable;
/**
* Supply setters for base view layout properties such as width, height, flex properties,
* borders, etc.
* Supply setters for base view layout properties such as width, height, flex properties, borders,
* etc.
*
* Checking for isVirtual everywhere is a hack to get around the fact that some virtual nodes still
* have layout properties set on them in JS: for example, a component that returns a <Text> may
* or may not be embedded in a parent text. There are better solutions that should probably be
* <p>Checking for isVirtual everywhere is a hack to get around the fact that some virtual nodes
* still have layout properties set on them in JS: for example, a component that returns a <Text>
* may or may not be embedded in a parent text. There are better solutions that should probably be
* explored, namely using the VirtualText class in JS and setting the correct set of validAttributes
*/
public class LayoutShadowNode extends ReactShadowNode {
public class LayoutShadowNode extends ReactShadowNodeImpl {
/**
* A Mutable version of com.facebook.yoga.YogaValue
Oops, something went wrong.

0 comments on commit a5d1d25

Please sign in to comment.