Skip to content
Closed
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 @@ -11,7 +11,8 @@ package com.facebook.yoga

public enum class YogaExperimentalFeature(public val intValue: Int) {
WEB_FLEX_BASIS(0),
FIX_FLEX_BASIS_FIT_CONTENT(1);
FIX_FLEX_BASIS_FIT_CONTENT(1),
MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH(2);

public fun intValue(): Int = intValue

Expand All @@ -21,6 +22,7 @@ public enum class YogaExperimentalFeature(public val intValue: Int) {
when (value) {
0 -> WEB_FLEX_BASIS
1 -> FIX_FLEX_BASIS_FIT_CONTENT
2 -> MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH
else -> throw IllegalArgumentException("Unknown enum value: $value")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ package com.facebook.yoga
public enum class YogaOverflow(public val intValue: Int) {
VISIBLE(0),
HIDDEN(1),
SCROLL(2);
SCROLL(2),
CLIP(3);

public fun intValue(): Int = intValue

Expand All @@ -23,6 +24,7 @@ public enum class YogaOverflow(public val intValue: Int) {
0 -> VISIBLE
1 -> HIDDEN
2 -> SCROLL
3 -> CLIP
else -> throw IllegalArgumentException("Unknown enum value: $value")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ void YogaLayoutableShadowNode::updateYogaProps() {
break;
case YGOverflowHidden:
case YGOverflowScroll:
case YGOverflowClip:
ShadowNode::traits_.set(ShadowNodeTraits::Trait::FormsContentClip);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ class LayoutTest : public ::testing::Test {
}
};

TEST_F(LayoutTest, overflowClipFormsContentClip) {
std::shared_ptr<ViewShadowNode> viewShadowNode;
auto element = Element<ViewShadowNode>().reference(viewShadowNode).props([] {
auto props = std::make_shared<ViewProps>();
props->yogaStyle.setOverflow(yoga::Overflow::Clip);
return props;
});

builder_.build(element);

EXPECT_TRUE(viewShadowNode->getTraits().check(
ShadowNodeTraits::Trait::FormsContentClip));
}

// Test the layout as described above with no extra changes
TEST_F(LayoutTest, overflowInsetTest) {
initialize(AS_IS);
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ const char* YGExperimentalFeatureToString(const YGExperimentalFeature value) {
return "web-flex-basis";
case YGExperimentalFeatureFixFlexBasisFitContent:
return "fix-flex-basis-fit-content";
case YGExperimentalFeatureMinContentHeightAtGivenWidth:
return "min-content-height-at-given-width";
}
return "unknown";
}
Expand Down Expand Up @@ -255,6 +257,8 @@ const char* YGOverflowToString(const YGOverflow value) {
return "hidden";
case YGOverflowScroll:
return "scroll";
case YGOverflowClip:
return "clip";
}
return "unknown";
}
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/YGEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata)
YG_ENUM_DECL(
YGExperimentalFeature,
YGExperimentalFeatureWebFlexBasis,
YGExperimentalFeatureFixFlexBasisFitContent)
YGExperimentalFeatureFixFlexBasisFitContent,
YGExperimentalFeatureMinContentHeightAtGivenWidth)

YG_ENUM_DECL(
YGFlexDirection,
Expand Down Expand Up @@ -136,7 +137,8 @@ YG_ENUM_DECL(
YGOverflow,
YGOverflowVisible,
YGOverflowHidden,
YGOverflowScroll)
YGOverflowScroll,
YGOverflowClip)

YG_ENUM_DECL(
YGPositionType,
Expand Down
17 changes: 10 additions & 7 deletions packages/react-native/ReactCommon/yoga/yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,20 @@ YG_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node);
* size along the main axis.
*
* The signature mirrors `YGMeasureFunc`. The algorithm calls this with
* `AtMost 0` along the probed axis and `Undefined` on the other. A
* `AtMost 0` along the probed axis and `Undefined` on the other. With
* `YGExperimentalFeatureMinContentHeightAtGivenWidth`, it probes a height
* with the node's width as an `AtMost` width and an `Undefined` height. A
* min-content-aware Primitive can return its true minimum (e.g., `Image`
* and `Collection` along the scroll axis can return 0; text returns its
* longest-word width; etc.) without doing a full measure pass.
*
* When unset, the algorithm falls back to the regular `YGMeasureFunc`
* invoked with the same `AtMost 0` constraint — preserving today's
* behavior. Setting this is a perf opt-in for Primitives whose min-content
* size is cheap to compute or differs from what the regular measure would
* return. Its results are kept, as a measure function's are, until the node is
* marked dirty.
* When unset, the algorithm falls back to the regular `YGMeasureFunc` with
* the same arguments. Setting this is a perf opt-in for Primitives whose
* min-content size is cheap to compute or differs from what the regular
* measure would return. Its results are kept, as a measure function's are,
* until the node is marked dirty. With
* `YGExperimentalFeatureMinContentHeightAtGivenWidth`, a height result is also
* measured again when the width it was measured at changes.
*/
typedef YGSize (*YGMinContentMeasureFunc)(
YGNodeConstRef node,
Expand Down
Loading
Loading