Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
26232c33d7 Bump http-proxy-middleware from 2.0.6 to 2.0.7
Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/chimurai/http-proxy-middleware/releases)
- [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.7/CHANGELOG.md)
- [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: http-proxy-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-21 19:14:09 +00:00
36 changed files with 446 additions and 2415 deletions

View File

@@ -6,7 +6,7 @@ inputs:
version:
description: LLVM version to use # Should be kept roughly in sync with arcanist
required: false
default: 18
default: 12
runs:
using: "composite"

View File

@@ -16,7 +16,6 @@ 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

View File

@@ -107,5 +107,3 @@ jobs:
- name: clang-format
uses: ./.github/actions/clang-format
with:
directory: yoga

View File

@@ -225,17 +225,17 @@ static void serializeTreeImpl(
appendEdges<&YGNodeStyleGetPosition>(
j, "position", node, defaultNode.get());
appendYGValueIfNotDefault(
appendFloatIfNotDefault(
j["style"],
"gap",
YGNodeStyleGetGap(node, YGGutterAll),
YGNodeStyleGetGap(defaultNode.get(), YGGutterAll));
appendYGValueIfNotDefault(
appendFloatIfNotDefault(
j["style"],
"column-gap",
YGNodeStyleGetGap(node, YGGutterColumn),
YGNodeStyleGetGap(defaultNode.get(), YGGutterColumn));
appendYGValueIfNotDefault(
appendFloatIfNotDefault(
j["style"],
"row-gap",
YGNodeStyleGetGap(node, YGGutterRow),

View File

@@ -157,31 +157,6 @@
</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">
@@ -254,7 +229,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_width" style="width: 90px;">
<div data-disabled="true" id="fit_content_width" style="width: 90px; position: relative;">
<div style="flex-direction: row; width: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -265,7 +240,7 @@
</div>
</div>
<div id="stretch_width" style="width: 500px;">
<div data-disabled="true" id="stretch_width" style="width: 500px; position: relative;">
<div style="flex-direction: row; width: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -285,7 +260,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_height" style="height: 90px; ">
<div data-disabled="true" id="fit_content_height" style="height: 90px; position: relative;">
<div style="height: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -296,7 +271,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_height" style="height: 500px;">
<div data-disabled="true" id="stretch_height" style="height: 500px; position: relative;">
<div style="height: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -316,7 +291,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px;">
<div data-disabled="true" id="fit_content_flex_basis_column" style="height: 90px; position: relative;">
<div style="flex-basis: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -327,7 +302,7 @@
</div>
</div>
<div id="stretch_flex_basis_column" style="height: 500px;">
<div data-disabled="true" id="stretch_flex_basis_column" style="height: 500px; position: relative;">
<div style="flex-basis: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -338,7 +313,7 @@
</div>
</div>
<div data-disabled="true" id="max_content_flex_basis_row" style="flex-direction: row; flex-basis: max-content; flex-wrap: wrap;">
<div 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;">
@@ -347,7 +322,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px;">
<div data-disabled="true" id="fit_content_flex_basis_row" style="width: 90px; position: relative;">
<div style="flex-direction: row; flex-basis: fit-content; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -358,7 +333,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px;">
<div data-disabled="true" id="stretch_flex_basis_row" style="width: 500px; position: relative;">
<div style="flex-direction: row; flex-basis: -webkit-fill-available; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -369,8 +344,7 @@
</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;">
@@ -379,7 +353,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_max_width" style="width: 90px;">
<div data-disabled="true" id="fit_content_max_width" style="width: 90px; position: relative;">
<div style="flex-direction: row; max-width: fit-content; width: 110px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -390,7 +364,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_max_width" style="width: 500px;">
<div data-disabled="true" id="stretch_max_width" style="width: 500px; position: relative;">
<div style="flex-direction: row; max-width: -webkit-fill-available; width: 600px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -401,8 +375,7 @@
</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;">
@@ -411,7 +384,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_min_width" style="width: 90px;">
<div data-disabled="true" id="fit_content_min_width" style="width: 90px; position: relative;">
<div style="flex-direction: row; min-width: fit-content; width: 90px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -422,7 +395,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_min_width" style="width: 500px;">
<div data-disabled="true" id="stretch_min_width" style="width: 500px; position: relative;">
<div style="flex-direction: row; min-width: -webkit-fill-available; width: 400px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -442,7 +415,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_max_height" style="height: 90px;">
<div data-disabled="true" id="fit_content_max_height" style="height: 90px; position: relative;">
<div style="max-height: fit-content; height: 110px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -453,7 +426,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_max_height" style="height: 500px;">
<div data-disabled="true" id="stretch_max_height" style="height: 500px; position: relative;">
<div style="max-height: -webkit-fill-available; flex-wrap: wrap; height: 600px;">
<div style="width: 50px; height: 50px;">
</div>
@@ -473,7 +446,7 @@
</div>
</div>
<div data-disabled="true" id="fit_content_min_height" style="height: 90px;">
<div data-disabled="true" id="fit_content_min_height" style="height: 90px; position: relative;">
<div style="min-height: fit-content; height: 90px; flex-wrap: wrap;">
<div style="width: 50px; height: 50px;">
</div>
@@ -484,7 +457,7 @@
</div>
</div>
<div data-disabled="true" id="stretch_min_height" style="height: 500px;">
<div data-disabled="true" id="stretch_min_height" style="height: 500px; position: relative;">
<div style="min-height: -webkit-fill-available; flex-wrap: wrap; height: 400px;">
<div style="width: 50px; height: 50px;">
</div>
@@ -494,75 +467,3 @@
</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>

View File

@@ -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);`,

View File

@@ -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());`,

View File

@@ -429,11 +429,9 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText, flexDirection) {
value: function (nodeName, innerText) {
this.push(
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "${innerText}", flexDirection: ${toValueJavascript(
flexDirection,
)}}));`,
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind("${innerText}"));`,
);
},
},

View File

@@ -533,11 +533,7 @@ function setupTestTree(
}
if (node.innerText && node.children.length === 0) {
e.YGNodeSetMeasureFunc(
nodeName,
node.innerText,
flexDirectionValue(e, node.style['flex-direction']),
);
e.YGNodeSetMeasureFunc(nodeName, node.innerText);
}
for (let i = 0; i < node.children.length; i++) {

View File

@@ -30,7 +30,6 @@ 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") } }

View File

@@ -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 long jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
static native float 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);

View File

@@ -236,7 +236,7 @@ public abstract class YogaNode implements YogaProps {
public abstract void setAspectRatio(float aspectRatio);
public abstract YogaValue getGap(YogaGutter gutter);
public abstract float getGap(YogaGutter gutter);
public abstract void setGap(YogaGutter gutter, float gapLength);

View File

@@ -811,8 +811,8 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
}
@Override
public YogaValue getGap(YogaGutter gutter) {
return valueFromLong(YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue()));
public float getGap(YogaGutter gutter) {
return YogaNative.jni_YGNodeStyleGetGapJNI(mNativePointer, gutter.intValue());
}
@Override

View File

@@ -725,13 +725,13 @@ jni_YGNodeCloneJNI(JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer) {
return reinterpret_cast<jlong>(clonedYogaNode);
}
static jlong jni_YGNodeStyleGetGapJNI(
static jfloat jni_YGNodeStyleGetGapJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jint gutter) {
return YogaValue::asJavaLong(YGNodeStyleGetGap(
_jlong2YGNodeRef(nativePointer), static_cast<YGGutter>(gutter)));
return (jfloat)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)J", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
{"jni_YGNodeStyleSetGapPercentJNI",
"(JIF)V",

View File

@@ -11,7 +11,6 @@ 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 {
@@ -44,13 +43,9 @@ public class TestUtils {
} else if (heightMode == YogaMeasureMode.AT_MOST) {
measuredHeight =
Math.min(
caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
? measuredWidth
: Math.max(measuredWidth, getWidestWordWidth(text))), height);
caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text))), height);
} else {
measuredHeight = caclulateHeight(text, node.getFlexDirection() == YogaFlexDirection.COLUMN
? measuredWidth
: Math.max(measuredWidth, getWidestWordWidth(text)));
measuredHeight = caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text)));
}
return YogaMeasureOutput.make(measuredWidth, measuredHeight);

View File

@@ -439,9 +439,8 @@ Value Node::getPadding(int edge) const {
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
}
Value Node::getGap(int gutter) const {
return Value::fromYGValue(
YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter)));
float Node::getGap(int gutter) {
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
}
bool Node::isReferenceBaseline() {

View File

@@ -186,7 +186,7 @@ class Node {
Value getPadding(int edge) const;
Value getGap(int gutter) const;
float getGap(int gutter);
int getBoxSizing(void) const;

File diff suppressed because it is too large Load Diff

View File

@@ -5,23 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/
import {FlexDirection, MeasureMode} from 'yoga-layout';
type MeasureContext = {
text: string;
flexDirection: FlexDirection;
};
import {MeasureMode} from 'yoga-layout';
export function instrinsicSizeMeasureFunc(
this: MeasureContext,
this: string,
width: number,
widthMode: MeasureMode,
height: number,
heightMode: MeasureMode,
): {width: number; height: number} {
const textLength = this.text.length;
const words = this.text.split(' ');
const flexDirection = this.flexDirection;
const textLength = this.length;
const words = this.split(' ');
const widthPerChar = 10;
const heightPerChar = 10;
@@ -59,10 +53,7 @@ export function instrinsicSizeMeasureFunc(
return heightPerChar;
}
const maxLineWidth =
flexDirection == FlexDirection.Column
? measuredWidth
: Math.max(longestWordWidth(), measuredWidth);
const maxLineWidth = Math.max(longestWordWidth(), measuredWidth);
//if fixed width < width of widest word, take width of widest word

View File

@@ -8,8 +8,6 @@
#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));
@@ -41,44 +39,6 @@ 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

View File

@@ -90,20 +90,14 @@ YGSize IntrinsicSizeMeasure(
measuredHeight = std::min(
calculateHeight(
innerText,
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
? measuredWidth
: std::max(
longestWordWidth(innerText, widthPerChar), measuredWidth),
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
widthPerChar,
heightPerChar),
height);
} else {
measuredHeight = calculateHeight(
innerText,
YGNodeStyleGetFlexDirection(node) == YGFlexDirectionColumn
? measuredWidth
: std::max(
longestWordWidth(innerText, widthPerChar), measuredWidth),
std::max(longestWordWidth(innerText, widthPerChar), measuredWidth),
widthPerChar,
heightPerChar);
}

View File

@@ -1,83 +0,0 @@
---
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!

View File

@@ -63,7 +63,7 @@ export type FlexStyle = {
bottom?: number | `${number}%`;
boxSizing?: 'border-box' | 'content-box';
direction?: 'ltr' | 'rtl';
display?: 'none' | 'flex' | 'contents';
display?: 'none' | 'flex';
end?: number | `${number}%`;
flex?: number;
flexBasis?: number | 'auto' | `${number}%`;
@@ -360,14 +360,12 @@ function direction(str?: 'ltr' | 'rtl'): Direction {
throw new Error(`"${str}" is not a valid value for direction`);
}
function display(str?: 'none' | 'flex' | 'contents'): Display {
function display(str?: 'none' | 'flex'): 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`);
}

View File

@@ -16,7 +16,6 @@ export type LayoutMetrics = {
width: number;
height: number;
overflow?: 'visible' | 'hidden' | 'scroll';
display?: 'flex' | 'none' | 'contents';
children?: LayoutMetrics[];
};
@@ -50,11 +49,7 @@ export default function LayoutBox({metrics, depth, className}: Props) {
position: depth === 0 ? 'relative' : 'absolute',
}}>
{children?.map((child, i) => (
<LayoutBox
key={i}
metrics={child}
depth={style.display === 'contents' ? depth : depth + 1}
/>
<LayoutBox key={i} metrics={child} depth={depth + 1} />
))}
</div>
);

View File

@@ -8,12 +8,7 @@
*/
import {useMemo} from 'react';
import Yoga, {
Direction,
Display,
Overflow,
Node as YogaNode,
} from 'yoga-layout';
import Yoga, {Direction, Overflow, Node as YogaNode} from 'yoga-layout';
import {FlexStyle, applyStyle} from './FlexStyle';
import LayoutBox from './LayoutBox';
@@ -114,16 +109,6 @@ 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,
};
}

View File

@@ -5984,9 +5984,9 @@ http-parser-js@>=0.5.1:
integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==
http-proxy-middleware@^2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f"
integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==
version "2.0.7"
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6"
integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==
dependencies:
"@types/http-proxy" "^1.17.8"
http-proxy "^1.18.1"
@@ -10173,7 +10173,16 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"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:
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==
@@ -10264,7 +10273,14 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"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:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11164,7 +11180,16 @@ 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", wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
"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:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

View File

@@ -293,8 +293,13 @@ void YGNodeStyleSetGapPercent(YGNodeRef node, YGGutter gutter, float percent) {
node, scopedEnum(gutter), StyleLength::percent(percent));
}
YGValue YGNodeStyleGetGap(const YGNodeConstRef node, const YGGutter gutter) {
return (YGValue)resolveRef(node)->style().gap(scopedEnum(gutter));
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;
}
void YGNodeStyleSetAspectRatio(const YGNodeRef node, const float aspectRatio) {

View File

@@ -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 YGValue YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
YG_EXPORT float YGNodeStyleGetGap(YGNodeConstRef node, YGGutter gutter);
YG_EXPORT void YGNodeStyleSetBoxSizing(YGNodeRef node, YGBoxSizing boxSizing);
YG_EXPORT YGBoxSizing YGNodeStyleGetBoxSizing(YGNodeConstRef node);

View File

@@ -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 uint32_t generationCount,
const LayoutPassReason reason) {
yoga::assertFatalWithNode(
node,
yoga::isUndefined(availableWidth)
@@ -1780,7 +1780,7 @@ static void calculateLayoutImpl(
crossAxis,
direction,
unclampedCrossDim,
crossAxisOwnerSize,
ownerHeight,
ownerWidth) -
paddingAndBorderAxisCross;
@@ -2268,10 +2268,10 @@ bool calculateLayoutInternal(
ownerWidth,
ownerHeight,
performLayout,
reason,
layoutMarkerData,
depth,
generationCount);
generationCount,
reason);
layout->lastOwnerDirection = ownerDirection;
layout->configVersion = node->getConfig()->getVersion();

View File

@@ -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();

View File

@@ -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,

View File

@@ -66,8 +66,7 @@ void roundLayoutResultsToPixelGrid(
yoga::Node* const node,
const double absoluteLeft,
const double absoluteTop) {
const auto pointScaleFactor =
static_cast<double>(node->getConfig()->getPointScaleFactor());
const auto pointScaleFactor = node->getConfig()->getPointScaleFactor();
const double nodeLeft = node->getLayout().position(PhysicalEdge::Left);
const double nodeTop = node->getLayout().position(PhysicalEdge::Top);
@@ -81,7 +80,7 @@ void roundLayoutResultsToPixelGrid(
const double absoluteNodeRight = absoluteNodeLeft + nodeWidth;
const double absoluteNodeBottom = absoluteNodeTop + nodeHeight;
if (pointScaleFactor != 0.0) {
if (pointScaleFactor != 0.0f) {
// 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;
@@ -97,14 +96,12 @@ 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(round(scaledNodeWith), scaledNodeWith);
const double scaledNodeHeight = nodeHeight * pointScaleFactor;
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 0) &&
!yoga::inexactEquals(fmod(nodeWidth * pointScaleFactor, 1.0), 1.0);
const bool hasFractionalHeight =
!yoga::inexactEquals(round(scaledNodeHeight), scaledNodeHeight);
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 0) &&
!yoga::inexactEquals(fmod(nodeHeight * pointScaleFactor, 1.0), 1.0);
node->setLayoutDimension(
roundValueToPixelGrid(

View File

@@ -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

View File

@@ -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);