Skip to content

Commit 0df65bb

Browse files
astreetFacebook Github Bot
authored and
Facebook Github Bot
committed
BREAKING [react_native/css_layout] Update RN shadow nodes to hold CSSNode instead of extending CSSNode
Summary: 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 fbshipit-source-id: 2836434dd925d8e4651b9bb94b602c235e1e7665
1 parent 307871e commit 0df65bb

File tree

5 files changed

+305
-122
lines changed

5 files changed

+305
-122
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,32 @@ public void setWidth(float width) {
2929

3030
@ReactProp(name = ViewProps.MIN_WIDTH, defaultFloat = CSSConstants.UNDEFINED)
3131
public void setMinWidth(float minWidth) {
32-
setStyleMinWidth(CSSConstants.isUndefined(minWidth) ? minWidth : PixelUtil.toPixelFromDIP(minWidth));
32+
setStyleMinWidth(
33+
CSSConstants.isUndefined(minWidth) ? minWidth : PixelUtil.toPixelFromDIP(minWidth));
3334
}
3435

3536
@ReactProp(name = ViewProps.MAX_WIDTH, defaultFloat = CSSConstants.UNDEFINED)
3637
public void setMaxWidth(float maxWidth) {
37-
setStyleMaxWidth(CSSConstants.isUndefined(maxWidth) ? maxWidth : PixelUtil.toPixelFromDIP(maxWidth));
38+
setStyleMaxWidth(
39+
CSSConstants.isUndefined(maxWidth) ? maxWidth : PixelUtil.toPixelFromDIP(maxWidth));
3840
}
3941

4042
@ReactProp(name = ViewProps.HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
4143
public void setHeight(float height) {
42-
setStyleHeight(CSSConstants.isUndefined(height) ? height : PixelUtil.toPixelFromDIP(height));
44+
setStyleHeight(
45+
CSSConstants.isUndefined(height) ? height : PixelUtil.toPixelFromDIP(height));
4346
}
4447

4548
@ReactProp(name = ViewProps.MIN_HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
4649
public void setMinHeight(float minHeight) {
47-
setStyleMinHeight(CSSConstants.isUndefined(minHeight) ? minHeight : PixelUtil.toPixelFromDIP(minHeight));
50+
setStyleMinHeight(
51+
CSSConstants.isUndefined(minHeight) ? minHeight : PixelUtil.toPixelFromDIP(minHeight));
4852
}
4953

5054
@ReactProp(name = ViewProps.MAX_HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
5155
public void setMaxHeight(float maxHeight) {
52-
setStyleMaxHeight(CSSConstants.isUndefined(maxHeight) ? maxHeight : PixelUtil.toPixelFromDIP(maxHeight));
56+
setStyleMaxHeight(
57+
CSSConstants.isUndefined(maxHeight) ? maxHeight : PixelUtil.toPixelFromDIP(maxHeight));
5358
}
5459

5560
@ReactProp(name = ViewProps.FLEX, defaultFloat = 0f)
@@ -81,7 +86,8 @@ public void setFlexDirection(@Nullable String flexDirection) {
8186

8287
@ReactProp(name = ViewProps.FLEX_WRAP)
8388
public void setFlexWrap(@Nullable String flexWrap) {
84-
setWrap(flexWrap == null ? CSSWrap.NOWRAP : CSSWrap.valueOf(flexWrap.toUpperCase(Locale.US)));
89+
setFlexWrap(
90+
flexWrap == null ? CSSWrap.NOWRAP : CSSWrap.valueOf(flexWrap.toUpperCase(Locale.US)));
8591
}
8692

8793
@ReactProp(name = ViewProps.ALIGN_SELF)

0 commit comments

Comments
 (0)