Compare commits
20 Commits
dependabot
...
NickGerlem
Author | SHA1 | Date | |
---|---|---|---|
|
74face1db4 | ||
|
cb6dd1d01e | ||
|
f3793303f3 | ||
|
9591210a7a | ||
|
91997d6cd3 | ||
|
909e4bea6e | ||
|
13f4adbbcd | ||
|
ae2d06d0f5 | ||
|
5478812db3 | ||
|
050ac8a413 | ||
|
733ba24064 | ||
|
e177477144 | ||
|
76ffdbc25d | ||
|
f99e657acd | ||
|
a9246bc7db | ||
|
be72b8e8aa | ||
|
b876f596d9 | ||
|
be00354b71 | ||
|
0c995496c8 | ||
|
c12e732fab |
2
.github/actions/clang-format/action.yml
vendored
2
.github/actions/clang-format/action.yml
vendored
@@ -6,7 +6,7 @@ inputs:
|
||||
version:
|
||||
description: LLVM version to use # Should be kept roughly in sync with arcanist
|
||||
required: false
|
||||
default: 12
|
||||
default: 18
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
1
.github/actions/setup-cpp/action.yml
vendored
1
.github/actions/setup-cpp/action.yml
vendored
@@ -16,6 +16,7 @@ runs:
|
||||
if: ${{ inputs.toolchain == 'Clang' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install -y libc++-dev libc++abi-dev
|
||||
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
|
||||
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV
|
||||
|
2
.github/workflows/validate-cpp.yml
vendored
2
.github/workflows/validate-cpp.yml
vendored
@@ -107,3 +107,5 @@ jobs:
|
||||
|
||||
- name: clang-format
|
||||
uses: ./.github/actions/clang-format
|
||||
with:
|
||||
directory: yoga
|
||||
|
@@ -225,17 +225,17 @@ static void serializeTreeImpl(
|
||||
appendEdges<&YGNodeStyleGetPosition>(
|
||||
j, "position", node, defaultNode.get());
|
||||
|
||||
appendFloatIfNotDefault(
|
||||
appendYGValueIfNotDefault(
|
||||
j["style"],
|
||||
"gap",
|
||||
YGNodeStyleGetGap(node, YGGutterAll),
|
||||
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
|
||||
appendFloatIfNotDefault(
|
||||
appendYGValueIfNotDefault(
|
||||
j["style"],
|
||||
"column-gap",
|
||||
YGNodeStyleGetGap(node, YGGutterColumn),
|
||||
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
|
||||
appendFloatIfNotDefault(
|
||||
appendYGValueIfNotDefault(
|
||||
j["style"],
|
||||
"row-gap",
|
||||
YGNodeStyleGetGap(node, YGGutterRow),
|
||||
|
@@ -157,6 +157,31 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="contains_inner_text_max_width_max_height_column" style="width:2000px; align-items: flex-start;">
|
||||
<div style="max-width: 50px;">
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
|
||||
volutpat
|
||||
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
|
||||
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
|
||||
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
|
||||
vitae
|
||||
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
|
||||
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
|
||||
tincidunt
|
||||
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
|
||||
vulputate eleifasd lectus vel varius.
|
||||
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
|
||||
in
|
||||
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
|
||||
venenatis
|
||||
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
|
||||
nunc
|
||||
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
|
||||
lobortis.
|
||||
Sed at consectetur ipsum.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="contains_inner_text_max_width" style="width:2000px;height:2000px;align-items: flex-start;">
|
||||
<div style="flex-direction:row;max-width:100px">
|
||||
@@ -229,7 +254,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_width" style="width: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_width" style="width: 90px;">
|
||||
<div style="flex-direction: row; width: fit-content; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -240,7 +265,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_width" style="width: 500px; position: relative;">
|
||||
<div id="stretch_width" style="width: 500px;">
|
||||
<div style="flex-direction: row; width: -webkit-fill-available; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -260,7 +285,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_height" style="height: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_height" style="height: 90px; ">
|
||||
<div style="height: fit-content; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -271,7 +296,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_height" style="height: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_height" style="height: 500px;">
|
||||
<div style="height: -webkit-fill-available; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -291,7 +316,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px;">
|
||||
<div style="flex-basis: fit-content; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -302,7 +327,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_flex_basis_column" style="height: 500px; position: relative;">
|
||||
<div id="stretch_flex_basis_column" style="height: 500px;">
|
||||
<div style="flex-basis: -webkit-fill-available; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -313,7 +338,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="max_content_flex_basis_row" style="flex-direction: row; flex-basis: max-content; flex-wrap: wrap;">
|
||||
<div data-disabled="true" id="max_content_flex_basis_row" style="flex-direction: row; flex-basis: max-content; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
<div style="width: 100px; height: 500px;">
|
||||
@@ -322,7 +347,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px;">
|
||||
<div style="flex-direction: row; flex-basis: fit-content; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -333,7 +358,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px;">
|
||||
<div style="flex-direction: row; flex-basis: -webkit-fill-available; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -344,7 +369,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="max_content_max_width" style="flex-direction: row; max-width:max-content; width: 200px; flex-wrap: wrap;">
|
||||
<div data-disabled="true" id="max_content_max_width"
|
||||
style="flex-direction: row; max-width:max-content; width: 200px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
<div style="width: 100px; height: 50px;">
|
||||
@@ -353,7 +379,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_max_width" style="width: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_max_width" style="width: 90px;">
|
||||
<div style="flex-direction: row; max-width: fit-content; width: 110px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -364,7 +390,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_max_width" style="width: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_max_width" style="width: 500px;">
|
||||
<div style="flex-direction: row; max-width: -webkit-fill-available; width: 600px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -375,7 +401,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="max_content_min_width" style="flex-direction: row; min-width:max-content; width: 100px; flex-wrap: wrap;">
|
||||
<div data-disabled="true" id="max_content_min_width"
|
||||
style="flex-direction: row; min-width:max-content; width: 100px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
<div style="width: 100px; height: 50px;">
|
||||
@@ -384,7 +411,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_min_width" style="width: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_min_width" style="width: 90px;">
|
||||
<div style="flex-direction: row; min-width: fit-content; width: 90px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -395,7 +422,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_min_width" style="width: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_min_width" style="width: 500px;">
|
||||
<div style="flex-direction: row; min-width: -webkit-fill-available; width: 400px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -415,7 +442,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_max_height" style="height: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_max_height" style="height: 90px;">
|
||||
<div style="max-height: fit-content; height: 110px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -426,7 +453,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_max_height" style="height: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_max_height" style="height: 500px;">
|
||||
<div style="max-height: -webkit-fill-available; flex-wrap: wrap; height: 600px;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -446,7 +473,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="fit_content_min_height" style="height: 90px; position: relative;">
|
||||
<div data-disabled="true" id="fit_content_min_height" style="height: 90px;">
|
||||
<div style="min-height: fit-content; height: 90px; flex-wrap: wrap;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -457,7 +484,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="stretch_min_height" style="height: 500px; position: relative;">
|
||||
<div data-disabled="true" id="stretch_min_height" style="height: 500px;">
|
||||
<div style="min-height: -webkit-fill-available; flex-wrap: wrap; height: 400px;">
|
||||
<div style="width: 50px; height: 50px;">
|
||||
</div>
|
||||
@@ -467,3 +494,75 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_max_content_width" style="width: 200px">
|
||||
<div style="width: max-content;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_stretch_width" style="width: 200px">
|
||||
<div style="width: -webkit-fill-available;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_fit_content_width" style="width: 200px">
|
||||
<div style="width: fit-content;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_max_content_min_width" style="width: 200px">
|
||||
<div style="min-width: max-content; width: 200px;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_stretch_min_width" style="width: 200px">
|
||||
<div style="min-width: -webkit-fill-available; width: 100px;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" data-disabled="true" id="text_fit_content_min_width" style="width: 200px">
|
||||
<div style="min-width: fit-content; width: 300px">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_max_content_max_width" style="width: 200px">
|
||||
<div style="max-width: max-content; width: 2000px;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_stretch_max_width" style="width: 200px">
|
||||
<div style="max-width: -webkit-fill-available; width: 300px;">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-disabled="true" id="text_fit_content_max_width" style="width: 200px">
|
||||
<div style="max-width: fit-content; width: 1000px">
|
||||
<div style="flex-direction:row;">
|
||||
Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -502,7 +502,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
},
|
||||
|
||||
YGNodeSetMeasureFunc: {
|
||||
value: function (nodeName, innerText) {
|
||||
value: function (nodeName, innerText, _) {
|
||||
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
|
||||
this.push(
|
||||
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
|
||||
|
@@ -467,7 +467,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
},
|
||||
|
||||
YGNodeSetMeasureFunc: {
|
||||
value: function (nodeName, innerText) {
|
||||
value: function (nodeName, innerText, _) {
|
||||
this.push(`${nodeName}.setData("${innerText}");`);
|
||||
this.push(
|
||||
`${nodeName}.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());`,
|
||||
|
@@ -429,9 +429,11 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
},
|
||||
|
||||
YGNodeSetMeasureFunc: {
|
||||
value: function (nodeName, innerText) {
|
||||
value: function (nodeName, innerText, flexDirection) {
|
||||
this.push(
|
||||
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind("${innerText}"));`,
|
||||
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "${innerText}", flexDirection: ${toValueJavascript(
|
||||
flexDirection,
|
||||
)}}));`,
|
||||
);
|
||||
},
|
||||
},
|
||||
|
@@ -533,7 +533,11 @@ function setupTestTree(
|
||||
}
|
||||
|
||||
if (node.innerText && node.children.length === 0) {
|
||||
e.YGNodeSetMeasureFunc(nodeName, node.innerText);
|
||||
e.YGNodeSetMeasureFunc(
|
||||
nodeName,
|
||||
node.innerText,
|
||||
flexDirectionValue(e, node.style['flex-direction']),
|
||||
);
|
||||
}
|
||||
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
|
@@ -30,6 +30,7 @@ android {
|
||||
consumerProguardFiles("proguard-rules.pro")
|
||||
|
||||
ndk { abiFilters.addAll(setOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a")) }
|
||||
externalNativeBuild { cmake { arguments("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") } }
|
||||
}
|
||||
|
||||
externalNativeBuild { cmake { path("CMakeLists.txt") } }
|
||||
|
@@ -130,7 +130,7 @@ public class YogaNative {
|
||||
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);
|
||||
static native long jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
|
||||
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
|
||||
static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength);
|
||||
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);
|
||||
|
@@ -236,7 +236,7 @@ public abstract class YogaNode implements YogaProps {
|
||||
|
||||
public abstract void setAspectRatio(float aspectRatio);
|
||||
|
||||
public abstract float getGap(YogaGutter gutter);
|
||||
public abstract YogaValue getGap(YogaGutter gutter);
|
||||
|
||||
public abstract void setGap(YogaGutter gutter, float gapLength);
|
||||
|
||||
|
@@ -811,8 +811,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGap(YogaGutter gutter) {
|
||||
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue());
|
||||
public YogaValue getGap(YogaGutter gutter) {
|
||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -725,13 +725,13 @@ jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
|
||||
return reinterpret_cast<jlong>(clonedYogaNode);
|
||||
}
|
||||
|
||||
static jfloat jni_YGNodeStyleGetGapJNI(
|
||||
static jlong jni_YGNodeStyleGetGapJNI(
|
||||
JNIEnv* /*env*/,
|
||||
jobject /*obj*/,
|
||||
jlong nativePointer,
|
||||
jint gutter) {
|
||||
return (jfloat)YGNodeStyleGetGap(
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter));
|
||||
return YogaValue::asJavaLong(YGNodeStyleGetGap(
|
||||
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)));
|
||||
}
|
||||
|
||||
static void jni_YGNodeStyleSetGapJNI(
|
||||
@@ -1057,7 +1057,7 @@ static JNINativeMethod methods[] = {
|
||||
{"jni_YGNodeSetHasMeasureFuncJNI",
|
||||
"(JZ)V",
|
||||
(void*)jni_YGNodeSetHasMeasureFuncJNI},
|
||||
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI},
|
||||
{"jni_YGNodeStyleGetGapJNI", "(JI)J", (void*)jni_YGNodeStyleGetGapJNI},
|
||||
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
|
||||
{"jni_YGNodeStyleSetGapPercentJNI",
|
||||
"(JIF)V",
|
||||
|
@@ -11,6 +11,7 @@ import com.facebook.yoga.YogaMeasureMode;
|
||||
import com.facebook.yoga.YogaMeasureOutput;
|
||||
import com.facebook.yoga.YogaMeasureFunction;
|
||||
import com.facebook.yoga.YogaNode;
|
||||
import com.facebook.yoga.YogaFlexDirection;
|
||||
|
||||
public class TestUtils {
|
||||
|
||||
@@ -43,9 +44,13 @@ public class TestUtils {
|
||||
} else if (heightMode == YogaMeasureMode.AT_MOST) {
|
||||
measuredHeight =
|
||||
Math.min(
|
||||
caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text))), height);
|
||||
caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
|
||||
? measuredWidth
|
||||
: Math.max(measuredWidth, getWidestWordWidth(text))), height);
|
||||
} else {
|
||||
measuredHeight = caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text)));
|
||||
measuredHeight = caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
|
||||
? measuredWidth
|
||||
: Math.max(measuredWidth, getWidestWordWidth(text)));
|
||||
}
|
||||
|
||||
return YogaMeasureOutput.make(measuredWidth, measuredHeight);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -439,8 +439,9 @@ Value Node::getPadding(int edge) const {
|
||||
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
|
||||
}
|
||||
|
||||
float Node::getGap(int gutter) {
|
||||
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
|
||||
Value Node::getGap(int gutter) const {
|
||||
return Value::fromYGValue(
|
||||
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
|
||||
}
|
||||
|
||||
bool Node::isReferenceBaseline() {
|
||||
|
@@ -186,7 +186,7 @@ class Node {
|
||||
|
||||
Value getPadding(int edge) const;
|
||||
|
||||
float getGap(int gutter);
|
||||
Value getGap(int gutter) const;
|
||||
|
||||
int getBoxSizing(void) const;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -5,17 +5,23 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {MeasureMode} from 'yoga-layout';
|
||||
import {FlexDirection, MeasureMode} from 'yoga-layout';
|
||||
|
||||
type MeasureContext = {
|
||||
text: string;
|
||||
flexDirection: FlexDirection;
|
||||
};
|
||||
|
||||
export function instrinsicSizeMeasureFunc(
|
||||
this: string,
|
||||
this: MeasureContext,
|
||||
width: number,
|
||||
widthMode: MeasureMode,
|
||||
height: number,
|
||||
heightMode: MeasureMode,
|
||||
): {width: number; height: number} {
|
||||
const textLength = this.length;
|
||||
const words = this.split(' ');
|
||||
const textLength = this.text.length;
|
||||
const words = this.text.split(' ');
|
||||
const flexDirection = this.flexDirection;
|
||||
const widthPerChar = 10;
|
||||
const heightPerChar = 10;
|
||||
|
||||
@@ -53,7 +59,10 @@ export function instrinsicSizeMeasureFunc(
|
||||
return heightPerChar;
|
||||
}
|
||||
|
||||
const maxLineWidth = Math.max(longestWordWidth(), measuredWidth);
|
||||
const maxLineWidth =
|
||||
flexDirection == FlexDirection.Column
|
||||
? measuredWidth
|
||||
: Math.max(longestWordWidth(), measuredWidth);
|
||||
|
||||
//if fixed width < width of widest word, take width of widest word
|
||||
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yoga/Yoga.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
TEST(YogaTest, rounding_value) {
|
||||
// Test that whole numbers are rounded to whole despite ceil/floor flags
|
||||
ASSERT_FLOAT_EQ(6.0, YGRoundValueToPixelGrid(6.000001, 2.0, false, false));
|
||||
@@ -39,6 +41,44 @@ TEST(YogaTest, rounding_value) {
|
||||
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-5.5, YGRoundValueToPixelGrid(-5.99, 2.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-6.0, YGRoundValueToPixelGrid(-5.99, 2.0, false, true));
|
||||
|
||||
// Rounding up/down halfway values is as expected for both positive and
|
||||
// negative numbers
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5, 1.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.4, 1.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.6, 1.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.499999, 1.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.500001, 1.0, false, false));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5001, 1.0, false, false));
|
||||
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.4, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.6, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.499999, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.500001, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.5001, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.00001, 1.0, true, false));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3, 1.0, true, false));
|
||||
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.4, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.6, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.499999, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.500001, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-4, YGRoundValueToPixelGrid(-3.5001, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3.00001, 1.0, false, true));
|
||||
ASSERT_FLOAT_EQ(-3, YGRoundValueToPixelGrid(-3, 1.0, false, true));
|
||||
|
||||
// NAN is treated as expected:
|
||||
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||
std::numeric_limits<double>::quiet_NaN(), 1.5, false, false)));
|
||||
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||
1.5, std::numeric_limits<double>::quiet_NaN(), false, false)));
|
||||
ASSERT_TRUE(std::isnan(YGRoundValueToPixelGrid(
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
std::numeric_limits<double>::quiet_NaN(),
|
||||
false,
|
||||
false)));
|
||||
}
|
||||
|
||||
static YGSize measureText(
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -90,14 +90,20 @@ YGSize IntrinsicSizeMeasure(
|
||||
measuredHeight = std::min(
|
||||
calculateHeight(
|
||||
innerText,
|
||||
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
|
||||
? measuredWidth
|
||||
: std::max(
|
||||
longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||
widthPerChar,
|
||||
heightPerChar),
|
||||
height);
|
||||
} else {
|
||||
measuredHeight = calculateHeight(
|
||||
innerText,
|
||||
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
|
||||
? measuredWidth
|
||||
: std::max(
|
||||
longestWordWidth(innerText, widthPerChar), measuredWidth),
|
||||
widthPerChar,
|
||||
heightPerChar);
|
||||
}
|
||||
|
83
website/blog/2024-12-02-announcing-yoga-3.2.md
Normal file
83
website/blog/2024-12-02-announcing-yoga-3.2.md
Normal file
@@ -0,0 +1,83 @@
|
||||
---
|
||||
slug: announcing-yoga-3.2
|
||||
title: Announcing Yoga 3.2
|
||||
authors:
|
||||
- NickGerleman
|
||||
---
|
||||
|
||||
import Playground from '@site/src/components/Playground';
|
||||
|
||||
Yoga 3.2 is a new minor version of Yoga, used by React Native 0.77.
|
||||
|
||||
## Highlights
|
||||
|
||||
1. Support for `box-sizing`
|
||||
2. Support for `display: contents`
|
||||
3. Bug fixes and improvements
|
||||
|
||||
## `box-sizing`
|
||||
|
||||
Yoga [now supports](https://github.com/facebook/yoga/commit/671ae61a39d02091d1e73fe773d6a09f2f93cda4) [`box-sizing`](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) on styles, allowing sizing values to influence the content box instead of the border box.
|
||||
|
||||
:::warning
|
||||
|
||||
To preserve compatibility, Yoga nodes default to `box-sizing: border-box`, even if `UseWebDefaults` is set. We recommend manually setting node defaults instead of using the `UseWebDefaults` API.
|
||||
|
||||
:::
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: true}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 100,
|
||||
height: 100,
|
||||
padding: 50,
|
||||
boxSizing: "border-box",
|
||||
}}>
|
||||
</Node>
|
||||
</Layout>`} />
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: true}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 100,
|
||||
height: 100,
|
||||
padding: 50,
|
||||
boxSizing: "content-box",
|
||||
}}>
|
||||
</Node>
|
||||
</Layout>`} />
|
||||
|
||||
|
||||
|
||||
## `display: contents`
|
||||
|
||||
Yoga nodes [may now be set to `display: contents`](https://github.com/facebook/yoga/commit/68bb2343d2b470962065789d09016bba8e785340) to remove them from the layout flow, while preserving and hoisting the node's children. This may be used by the higher level UI framework to allow more easily composing wrapper components (such as those which may need to handle events, without influencing child layout). Thanks [@j-piasecki](https://github.com/j-piasecki) for the contribution!
|
||||
|
||||
<Playground code={`<Layout config={{useWebDefaults: false}}>
|
||||
<Node
|
||||
style={{
|
||||
width: 100,
|
||||
height: 100,
|
||||
gap: 10,
|
||||
}}
|
||||
>
|
||||
<Node style={{display: "contents"}}>
|
||||
<Node style={{flexGrow: 1}} />
|
||||
<Node style={{flexGrow: 1}} />
|
||||
<Node style={{flexGrow: 1}} />
|
||||
</Node>
|
||||
</Node>
|
||||
</Layout>`} />
|
||||
|
||||
|
||||
## Removal of legacy absolute positioning
|
||||
|
||||
Yoga 3.0 introduced a new algorithm used for absolute positioning. This algorithm is more correct than the one previously used, but led to observed compatibility issues with existing code, so we left the option to disable it via the `AbsolutePositioningIncorrect` erratum (enabled by default in frameworks like React Native). Yoga 3.2 removes the legacy absolute positioning path, but ports over the main compatibility quirk under a new erratum `AbsolutePositionWithoutInsetsExcludesPadding` (where the previous incorrect behavior would omit padding when a position was not specified on the absolute node). Errata users should see more correct absolute positioning behavior, while preserving compatibility with existing code.
|
||||
|
||||
## Fixed non-global YogaConfig in Java bindings
|
||||
|
||||
Yoga would previously allow garbage collection of a `YogaConfig` if it was not retained outside of the Yoga tree. This could result in confusing errors caused by use-after free. Yoga nodes [now correctly retain the configs they are using](https://github.com/facebook/yoga/commit/22b018c957e930de950338ad87f4ef8d59e8a169). Thanks [@michaeltroger](https://github.com/michaeltroger) for this fix!
|
||||
|
||||
## Fixed behavior when combining `align-items` with `align-content`
|
||||
|
||||
A regression [was fixed](https://github.com/facebook/yoga/commit/77c99870127e9c2d46a07264fa372025334d8fd0) in how Yoga handles some combinations of `align-content` and `align-items`. Thanks [@phuccvx12](https://github.com/phuccvx12) for this fix!
|
@@ -63,7 +63,7 @@ export type FlexStyle = {
|
||||
bottom?: number | `${number}%`;
|
||||
boxSizing?: 'border-box' | 'content-box';
|
||||
direction?: 'ltr' | 'rtl';
|
||||
display?: 'none' | 'flex';
|
||||
display?: 'none' | 'flex' | 'contents';
|
||||
end?: number | `${number}%`;
|
||||
flex?: number;
|
||||
flexBasis?: number | 'auto' | `${number}%`;
|
||||
@@ -360,12 +360,14 @@ function direction(str?: 'ltr' | 'rtl'): Direction {
|
||||
throw new Error(`"${str}" is not a valid value for direction`);
|
||||
}
|
||||
|
||||
function display(str?: 'none' | 'flex'): Display {
|
||||
function display(str?: 'none' | 'flex' | 'contents'): Display {
|
||||
switch (str) {
|
||||
case 'none':
|
||||
return Display.None;
|
||||
case 'flex':
|
||||
return Display.Flex;
|
||||
case 'contents':
|
||||
return Display.Contents;
|
||||
}
|
||||
throw new Error(`"${str}" is not a valid value for display`);
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ export type LayoutMetrics = {
|
||||
width: number;
|
||||
height: number;
|
||||
overflow?: 'visible' | 'hidden' | 'scroll';
|
||||
display?: 'flex' | 'none' | 'contents';
|
||||
children?: LayoutMetrics[];
|
||||
};
|
||||
|
||||
@@ -49,7 +50,11 @@ export default function LayoutBox({metrics, depth, className}: Props) {
|
||||
position: depth === 0 ? 'relative' : 'absolute',
|
||||
}}>
|
||||
{children?.map((child, i) => (
|
||||
<LayoutBox key={i} metrics={child} depth={depth + 1} />
|
||||
<LayoutBox
|
||||
key={i}
|
||||
metrics={child}
|
||||
depth={style.display === 'contents' ? depth : depth + 1}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
@@ -8,7 +8,12 @@
|
||||
*/
|
||||
|
||||
import {useMemo} from 'react';
|
||||
import Yoga, {Direction, Overflow, Node as YogaNode} from 'yoga-layout';
|
||||
import Yoga, {
|
||||
Direction,
|
||||
Display,
|
||||
Overflow,
|
||||
Node as YogaNode,
|
||||
} from 'yoga-layout';
|
||||
import {FlexStyle, applyStyle} from './FlexStyle';
|
||||
import LayoutBox from './LayoutBox';
|
||||
|
||||
@@ -109,6 +114,16 @@ function metricsFromYogaNode(node: YogaNode): LayoutMetrics {
|
||||
return 'visible';
|
||||
}
|
||||
})(),
|
||||
display: (() => {
|
||||
switch (node.getDisplay()) {
|
||||
case Display.Flex:
|
||||
return 'flex';
|
||||
case Display.None:
|
||||
return 'none';
|
||||
case Display.Contents:
|
||||
return 'contents';
|
||||
}
|
||||
})(),
|
||||
children,
|
||||
};
|
||||
}
|
||||
|
37
yarn.lock
37
yarn.lock
@@ -4049,9 +4049,9 @@ cosmiconfig@^8.1.3, cosmiconfig@^8.2.0:
|
||||
path-type "^4.0.0"
|
||||
|
||||
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
|
||||
version "7.0.6"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.6.tgz#8a58fe78f00dcd70c370451759dfbfaf03e8ee9f"
|
||||
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
||||
dependencies:
|
||||
path-key "^3.1.0"
|
||||
shebang-command "^2.0.0"
|
||||
@@ -10173,16 +10173,7 @@ string-length@^4.0.1:
|
||||
char-regex "^1.0.2"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
@@ -10273,14 +10264,7 @@ stringify-object@^3.3.0:
|
||||
is-obj "^1.0.1"
|
||||
is-regexp "^1.0.0"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
@@ -11180,16 +11164,7 @@ word-wrap@^1.2.3:
|
||||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
|
||||
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
|
||||
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
|
@@ -293,13 +293,8 @@ void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
|
||||
node, scopedEnum(gutter), StyleLength::percent(percent));
|
||||
}
|
||||
|
||||
float YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
||||
auto gapLength = resolveRef(node)->style().gap(scopedEnum(gutter));
|
||||
if (gapLength.isUndefined() || gapLength.isAuto()) {
|
||||
return YGUndefined;
|
||||
}
|
||||
|
||||
return static_cast<YGValue>(gapLength).value;
|
||||
YGValue YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
|
||||
return (YGValue)resolveRef(node)->style().gap(scopedEnum(gutter));
|
||||
}
|
||||
|
||||
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {
|
||||
|
@@ -96,7 +96,7 @@ YG_EXPORT void
|
||||
YGNodeStyleSetGap(YGNodeRef node, YGGutter gutter, float gapLength);
|
||||
YG_EXPORT void
|
||||
YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float gapLength);
|
||||
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
||||
YG_EXPORT YGValue YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
|
||||
|
||||
YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
|
||||
YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);
|
||||
|
@@ -1213,10 +1213,10 @@ static void calculateLayoutImpl(
|
||||
const float ownerWidth,
|
||||
const float ownerHeight,
|
||||
const bool performLayout,
|
||||
const LayoutPassReason reason,
|
||||
LayoutData& layoutMarkerData,
|
||||
const uint32_t depth,
|
||||
const uint32_t generationCount,
|
||||
const LayoutPassReason reason) {
|
||||
const uint32_t generationCount) {
|
||||
yoga::assertFatalWithNode(
|
||||
node,
|
||||
yoga::isUndefined(availableWidth)
|
||||
@@ -1780,7 +1780,7 @@ static void calculateLayoutImpl(
|
||||
crossAxis,
|
||||
direction,
|
||||
unclampedCrossDim,
|
||||
ownerHeight,
|
||||
crossAxisOwnerSize,
|
||||
ownerWidth) -
|
||||
paddingAndBorderAxisCross;
|
||||
|
||||
@@ -2268,10 +2268,10 @@ bool calculateLayoutInternal(
|
||||
ownerWidth,
|
||||
ownerHeight,
|
||||
performLayout,
|
||||
reason,
|
||||
layoutMarkerData,
|
||||
depth,
|
||||
generationCount,
|
||||
reason);
|
||||
generationCount);
|
||||
|
||||
layout->lastOwnerDirection = ownerDirection;
|
||||
layout->configVersion = node->getConfig()->getVersion();
|
||||
|
@@ -17,7 +17,7 @@ FlexLine calculateFlexLine(
|
||||
yoga::Node* const node,
|
||||
const Direction ownerDirection,
|
||||
const float ownerWidth,
|
||||
const float mainAxisownerSize,
|
||||
const float mainAxisOwnerSize,
|
||||
const float availableInnerWidth,
|
||||
const float availableInnerMainDim,
|
||||
Node::LayoutableChildren::Iterator& iterator,
|
||||
@@ -70,7 +70,7 @@ FlexLine calculateFlexLine(
|
||||
direction,
|
||||
mainAxis,
|
||||
child->getLayout().computedFlexBasis,
|
||||
mainAxisownerSize,
|
||||
mainAxisOwnerSize,
|
||||
ownerWidth)
|
||||
.unwrap();
|
||||
|
||||
|
@@ -66,7 +66,7 @@ FlexLine calculateFlexLine(
|
||||
yoga::Node* node,
|
||||
Direction ownerDirection,
|
||||
float ownerWidth,
|
||||
float mainAxisownerSize,
|
||||
float mainAxisOwnerSize,
|
||||
float availableInnerWidth,
|
||||
float availableInnerMainDim,
|
||||
Node::LayoutableChildren::Iterator& iterator,
|
||||
|
@@ -66,7 +66,8 @@ void roundLayoutResultsToPixelGrid(
|
||||
yoga::Node* const node,
|
||||
const double absoluteLeft,
|
||||
const double absoluteTop) {
|
||||
const auto pointScaleFactor = node->getConfig()->getPointScaleFactor();
|
||||
const auto pointScaleFactor =
|
||||
static_cast<double>(node->getConfig()->getPointScaleFactor());
|
||||
|
||||
const double nodeLeft = node->getLayout().position(PhysicalEdge::Left);
|
||||
const double nodeTop = node->getLayout().position(PhysicalEdge::Top);
|
||||
@@ -80,7 +81,7 @@ void roundLayoutResultsToPixelGrid(
|
||||
const double absoluteNodeRight = absoluteNodeLeft + nodeWidth;
|
||||
const double absoluteNodeBottom = absoluteNodeTop + nodeHeight;
|
||||
|
||||
if (pointScaleFactor != 0.0f) {
|
||||
if (pointScaleFactor != 0.0) {
|
||||
// If a node has a custom measure function we never want to round down its
|
||||
// size as this could lead to unwanted text truncation.
|
||||
const bool textRounding = node->getNodeType() == NodeType::Text;
|
||||
@@ -96,12 +97,14 @@ void roundLayoutResultsToPixelGrid(
|
||||
// We multiply dimension by scale factor and if the result is close to the
|
||||
// whole number, we don't have any fraction To verify if the result is close
|
||||
// to whole number we want to check both floor and ceil numbers
|
||||
|
||||
const double scaledNodeWith = nodeWidth * pointScaleFactor;
|
||||
const bool hasFractionalWidth =
|
||||
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 0) &&
|
||||
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 1.0);
|
||||
!yoga::inexactEquals(round(scaledNodeWith), scaledNodeWith);
|
||||
|
||||
const double scaledNodeHeight = nodeHeight * pointScaleFactor;
|
||||
const bool hasFractionalHeight =
|
||||
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 0) &&
|
||||
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 1.0);
|
||||
!yoga::inexactEquals(round(scaledNodeHeight), scaledNodeHeight);
|
||||
|
||||
node->setLayoutDimension(
|
||||
roundValueToPixelGrid(
|
||||
|
@@ -245,8 +245,8 @@ void Node::setLayoutHadOverflow(bool hadOverflow) {
|
||||
layout_.setHadOverflow(hadOverflow);
|
||||
}
|
||||
|
||||
void Node::setLayoutDimension(float LengthValue, Dimension dimension) {
|
||||
layout_.setDimension(dimension, LengthValue);
|
||||
void Node::setLayoutDimension(float lengthValue, Dimension dimension) {
|
||||
layout_.setDimension(dimension, lengthValue);
|
||||
}
|
||||
|
||||
// If both left and right are defined, then use left. Otherwise return +left or
|
||||
|
@@ -259,7 +259,7 @@ class YG_EXPORT Node : public ::YGNode {
|
||||
uint32_t computedFlexBasisGeneration);
|
||||
void setLayoutMeasuredDimension(float measuredDimension, Dimension dimension);
|
||||
void setLayoutHadOverflow(bool hadOverflow);
|
||||
void setLayoutDimension(float LengthValue, Dimension dimension);
|
||||
void setLayoutDimension(float lengthValue, Dimension dimension);
|
||||
void setLayoutDirection(Direction direction);
|
||||
void setLayoutMargin(float margin, PhysicalEdge edge);
|
||||
void setLayoutBorder(float border, PhysicalEdge edge);
|
||||
|
Reference in New Issue
Block a user