Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update public API for intrinsic sizing setters #46939

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ - (void)setUp
auto &props = *sharedProps;
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
auto &yogaStyle = props.yogaStyle;
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(200));
return sharedProps;
})
.children({
Expand All @@ -136,8 +136,8 @@ - (void)setUp
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(0));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(200));
return sharedProps;
})
.children({
Expand Down Expand Up @@ -216,8 +216,8 @@ - (void)setUp
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(30));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(50));
return sharedProps;
})
.children({
Expand Down Expand Up @@ -260,8 +260,8 @@ - (void)setUp
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(50));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(50));
return sharedProps;
})
.children({
Expand Down Expand Up @@ -418,8 +418,8 @@ - (void)testEntireParagraphLink
auto &props = *sharedProps;
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
auto &yogaStyle = props.yogaStyle;
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(200));
return sharedProps;
})
.children({
Expand All @@ -434,8 +434,8 @@ - (void)testEntireParagraphLink
yogaStyle.setPositionType(yoga::PositionType::Absolute);
yogaStyle.setPosition(yoga::Edge::Left, yoga::StyleLength::points(0));
yogaStyle.setPosition(yoga::Edge::Top, yoga::StyleLength::points(90));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleLength::points(20));
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeValue::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeValue::points(20));
return sharedProps;
})
.children({
Expand Down
50 changes: 41 additions & 9 deletions packages/react-native/React/Views/RCTShadowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ + (YGConfigRef)yogaConfig
#define RCT_SET_YGVALUE(ygvalue, setter, ...) \
switch (ygvalue.unit) { \
case YGUnitAuto: \
case YGUnitMaxContent: \
case YGUnitFitContent: \
case YGUnitStretch: \
case YGUnitUndefined: \
setter(__VA_ARGS__, YGUndefined); \
break; \
Expand All @@ -88,6 +91,35 @@ + (YGConfigRef)yogaConfig
case YGUnitPercent: \
setter##Percent(__VA_ARGS__, ygvalue.value); \
break; \
case YGUnitMaxContent: \
case YGUnitFitContent: \
case YGUnitStretch: \
break; \
}

#define RCT_SET_YGVALUE_AUTO_INTRINSIC(ygvalue, setter, ...) \
switch (ygvalue.unit) { \
case YGUnitAuto: \
setter##Auto(__VA_ARGS__); \
break; \
case YGUnitMaxContent: \
setter##MaxContent(__VA_ARGS__); \
break; \
case YGUnitFitContent: \
setter##FitContent(__VA_ARGS__); \
break; \
case YGUnitStretch: \
setter##Stretch(__VA_ARGS__); \
break; \
case YGUnitUndefined: \
setter(__VA_ARGS__, YGUndefined); \
break; \
case YGUnitPoint: \
setter(__VA_ARGS__, ygvalue.value); \
break; \
case YGUnitPercent: \
setter##Percent(__VA_ARGS__, ygvalue.value); \
break; \
}

static void RCTProcessMetaPropsPadding(const YGValue metaProps[META_PROP_COUNT], YGNodeRef node)
Expand Down Expand Up @@ -483,14 +515,14 @@ -(float)border##prop##Width \
RCT_BORDER_PROPERTY(End, END)

// Dimensions
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
-(void)set##setProp : (YGValue)value \
{ \
RCT_SET_YGVALUE_AUTO(value, YGNodeStyleSet##cssProp, _yogaNode); \
} \
-(YGValue)getProp \
{ \
return YGNodeStyleGet##cssProp(_yogaNode); \
#define RCT_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
-(void)set##setProp : (YGValue)value \
{ \
RCT_SET_YGVALUE_AUTO_INTRINSIC(value, YGNodeStyleSet##cssProp, _yogaNode); \
} \
-(YGValue)getProp \
{ \
return YGNodeStyleGet##cssProp(_yogaNode); \
}

#define RCT_MIN_MAX_DIMENSION_PROPERTY(setProp, getProp, cssProp) \
Expand Down Expand Up @@ -634,7 +666,7 @@ - (void)setLocalData:(__unused NSObject *)localData

- (void)setFlexBasis:(YGValue)value
{
RCT_SET_YGVALUE_AUTO(value, YGNodeStyleSetFlexBasis, _yogaNode);
RCT_SET_YGVALUE_AUTO_INTRINSIC(value, YGNodeStyleSetFlexBasis, _yogaNode);
}

- (YGValue)flexBasis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class YogaNative {
static native void jni_YGNodeStyleSetFlexBasisJNI(long nativePointer, float flexBasis);
static native void jni_YGNodeStyleSetFlexBasisPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetFlexBasisAutoJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasisMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasisFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexBasisStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetMarginJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetMarginJNI(long nativePointer, int edge, float margin);
static native void jni_YGNodeStyleSetMarginPercentJNI(long nativePointer, int edge, float percent);
Expand All @@ -91,22 +94,40 @@ public class YogaNative {
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetWidthAutoJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetHeightJNI(long nativePointer, float height);
static native void jni_YGNodeStyleSetHeightPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetHeightAutoJNI(long nativePointer);
static native void jni_YGNodeStyleSetHeightMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetHeightFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetHeightStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetMinWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinWidthJNI(long nativePointer, float minWidth);
static native void jni_YGNodeStyleSetMinWidthPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetMinWidthMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinWidthFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinWidthStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetMinHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinHeightJNI(long nativePointer, float minHeight);
static native void jni_YGNodeStyleSetMinHeightPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetMinHeightMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinHeightFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMinHeightStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetMaxWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidthJNI(long nativePointer, float maxWidth);
static native void jni_YGNodeStyleSetMaxWidthPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetMaxWidthMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidthFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxWidthStretchJNI(long nativePointer);
static native long jni_YGNodeStyleGetMaxHeightJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeightJNI(long nativePointer, float maxheight);
static native void jni_YGNodeStyleSetMaxHeightPercentJNI(long nativePointer, float percent);
static native void jni_YGNodeStyleSetMaxHeightMaxContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeightFitContentJNI(long nativePointer);
static native void jni_YGNodeStyleSetMaxHeightStretchJNI(long nativePointer);
static native float jni_YGNodeStyleGetAspectRatioJNI(long nativePointer);
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public interface Inputs {

public abstract void setFlexBasisAuto();

public abstract void setFlexBasisMaxContent();

public abstract void setFlexBasisFitContent();

public abstract void setFlexBasisStretch();

public abstract YogaValue getMargin(YogaEdge edge);

public abstract void setMargin(YogaEdge edge, float margin);
Expand Down Expand Up @@ -158,6 +164,12 @@ public interface Inputs {

public abstract void setWidthAuto();

public abstract void setWidthMaxContent();

public abstract void setWidthFitContent();

public abstract void setWidthStretch();

public abstract YogaValue getHeight();

public abstract void setHeight(float height);
Expand All @@ -166,30 +178,60 @@ public interface Inputs {

public abstract void setHeightAuto();

public abstract void setHeightMaxContent();

public abstract void setHeightFitContent();

public abstract void setHeightStretch();

public abstract YogaValue getMinWidth();

public abstract void setMinWidth(float minWidth);

public abstract void setMinWidthPercent(float percent);

public abstract void setMinWidthMaxContent();

public abstract void setMinWidthFitContent();

public abstract void setMinWidthStretch();

public abstract YogaValue getMinHeight();

public abstract void setMinHeight(float minHeight);

public abstract void setMinHeightPercent(float percent);

public abstract void setMinHeightMaxContent();

public abstract void setMinHeightFitContent();

public abstract void setMinHeightStretch();

public abstract YogaValue getMaxWidth();

public abstract void setMaxWidth(float maxWidth);

public abstract void setMaxWidthPercent(float percent);

public abstract void setMaxWidthMaxContent();

public abstract void setMaxWidthFitContent();

public abstract void setMaxWidthStretch();

public abstract YogaValue getMaxHeight();

public abstract void setMaxHeight(float maxheight);

public abstract void setMaxHeightPercent(float percent);

public abstract void setMaxHeightMaxContent();

public abstract void setMaxHeightFitContent();

public abstract void setMaxHeightStretch();

public abstract float getAspectRatio();

public abstract void setAspectRatio(float aspectRatio);
Expand Down
Loading
Loading