Skip to content


Browse files Browse the repository at this point in the history
BREAKING [react_native/css_layout] Update RN shadow nodes to hold CSS…
…Node instead of extending CSSNode

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).

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
  • Loading branch information
astreet authored and Facebook Github Bot committed Nov 14, 2016
1 parent 307871e commit 0df65bb
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 122 deletions.
Expand Up @@ -29,27 +29,32 @@ public void setWidth(float width) {

@ReactProp(name = ViewProps.MIN_WIDTH, defaultFloat = CSSConstants.UNDEFINED)
public void setMinWidth(float minWidth) {
setStyleMinWidth(CSSConstants.isUndefined(minWidth) ? minWidth : PixelUtil.toPixelFromDIP(minWidth));
CSSConstants.isUndefined(minWidth) ? minWidth : PixelUtil.toPixelFromDIP(minWidth));

@ReactProp(name = ViewProps.MAX_WIDTH, defaultFloat = CSSConstants.UNDEFINED)
public void setMaxWidth(float maxWidth) {
setStyleMaxWidth(CSSConstants.isUndefined(maxWidth) ? maxWidth : PixelUtil.toPixelFromDIP(maxWidth));
CSSConstants.isUndefined(maxWidth) ? maxWidth : PixelUtil.toPixelFromDIP(maxWidth));

@ReactProp(name = ViewProps.HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
public void setHeight(float height) {
setStyleHeight(CSSConstants.isUndefined(height) ? height : PixelUtil.toPixelFromDIP(height));
CSSConstants.isUndefined(height) ? height : PixelUtil.toPixelFromDIP(height));

@ReactProp(name = ViewProps.MIN_HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
public void setMinHeight(float minHeight) {
setStyleMinHeight(CSSConstants.isUndefined(minHeight) ? minHeight : PixelUtil.toPixelFromDIP(minHeight));
CSSConstants.isUndefined(minHeight) ? minHeight : PixelUtil.toPixelFromDIP(minHeight));

@ReactProp(name = ViewProps.MAX_HEIGHT, defaultFloat = CSSConstants.UNDEFINED)
public void setMaxHeight(float maxHeight) {
setStyleMaxHeight(CSSConstants.isUndefined(maxHeight) ? maxHeight : PixelUtil.toPixelFromDIP(maxHeight));
CSSConstants.isUndefined(maxHeight) ? maxHeight : PixelUtil.toPixelFromDIP(maxHeight));

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

@ReactProp(name = ViewProps.FLEX_WRAP)
public void setFlexWrap(@Nullable String flexWrap) {
setWrap(flexWrap == null ? CSSWrap.NOWRAP : CSSWrap.valueOf(flexWrap.toUpperCase(Locale.US)));
flexWrap == null ? CSSWrap.NOWRAP : CSSWrap.valueOf(flexWrap.toUpperCase(Locale.US)));

@ReactProp(name = ViewProps.ALIGN_SELF)
Expand Down

0 comments on commit 0df65bb

Please sign in to comment.