mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 09:29:07 +08:00
BREAKING [react_native/css_layout] Update RN shadow nodes to hold CSSNode instead of extending CSSNode
Summary: @public This diff makes it so ReactShadowNode holds a CSSNode instead of extending one. This will enable us to pool and re-use CSSNodes and will allow us to keep from breaking the CSSNode api assumption that nodes that have measure functions don't have children (right now, text nodes have measure functions, but they also have raw text children). BREAKING This diff makes ReactShadowNode no longer extend CSSNodeDEPRECATED. If you have code that depended on that, e.g. via instanceof checks, that will no longer work as expected. Subclasses that override getChildAt/addChildAt/etc will need to update your method signatures. There should be no runtime behavior changes. Reviewed By: emilsjolander Differential Revision: D4153818
This commit is contained in:
committed by
Ahmed El-Helw
parent
947e885487
commit
1d555bff22
@@ -16,7 +16,7 @@ import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.facebook.csslayout.CSSNodeDEPRECATED;
|
||||
import com.facebook.react.uimanager.ReactShadowNode;
|
||||
|
||||
/**
|
||||
* FlatReactModalShadowNode
|
||||
@@ -45,7 +45,7 @@ class FlatReactModalShadowNode extends FlatShadowNode implements AndroidView {
|
||||
*/
|
||||
@Override
|
||||
@TargetApi(16)
|
||||
public void addChildAt(CSSNodeDEPRECATED child, int i) {
|
||||
public void addChildAt(ReactShadowNode child, int i) {
|
||||
super.addChildAt(child, i);
|
||||
|
||||
Context context = getThemedContext();
|
||||
|
||||
@@ -18,13 +18,4 @@ package com.facebook.react.flat;
|
||||
forceMountToView();
|
||||
signalBackingViewIsCreated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when this CSSNodeDEPRECATED tree needs to be re-laid out. If true, FlatUIImplementation
|
||||
* will request LayoutEngine to perform a layout pass to update node boundaries. This is used
|
||||
* to avoid unnecessary node updates.
|
||||
*/
|
||||
/* package */ boolean needsLayout() {
|
||||
return isDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildAt(CSSNodeDEPRECATED child, int i) {
|
||||
public void addChildAt(ReactShadowNode child, int i) {
|
||||
super.addChildAt(child, i);
|
||||
if (mForceMountChildrenToView && child instanceof FlatShadowNode) {
|
||||
((FlatShadowNode) child).forceMountToView();
|
||||
|
||||
@@ -115,7 +115,7 @@ public class FlatUIImplementation extends UIImplementation {
|
||||
ReactShadowNode node = new FlatRootShadowNode();
|
||||
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
|
||||
if (sharedI18nUtilInstance.isRTL(mReactContext)) {
|
||||
node.setDirection(CSSDirection.RTL);
|
||||
node.setLayoutDirection(CSSDirection.RTL);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ package com.facebook.react.flat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.facebook.csslayout.CSSNodeDEPRECATED;
|
||||
import com.facebook.csslayout.CSSNodeAPI;
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.react.uimanager.ReactShadowNode;
|
||||
@@ -93,7 +92,7 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildAt(CSSNodeDEPRECATED child, int i) {
|
||||
public void addChildAt(ReactShadowNode child, int i) {
|
||||
super.addChildAt(child, i);
|
||||
if (mForceMountGrandChildrenToView && child instanceof FlatShadowNode) {
|
||||
((FlatShadowNode) child).forceMountChildrenToView();
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.text.TextUtils;
|
||||
import com.facebook.csslayout.CSSNodeDEPRECATED;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ReactShadowNode;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
|
||||
@@ -40,7 +41,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
private ShadowStyleSpan mShadowStyleSpan = ShadowStyleSpan.INSTANCE;
|
||||
|
||||
@Override
|
||||
public void addChildAt(CSSNodeDEPRECATED child, int i) {
|
||||
public void addChildAt(ReactShadowNode child, int i) {
|
||||
super.addChildAt(child, i);
|
||||
notifyChanged(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user