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

Breaking: Remove "UseLegacyStretchBehaviour" functions #1368

Closed
wants to merge 5 commits into from
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
2 changes: 1 addition & 1 deletion benchmark/YGBenchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void __printBenchmarkResult(
}

static YGSize _measure(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand Down
12 changes: 0 additions & 12 deletions java/com/facebook/yoga/YogaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ public abstract class YogaConfig {
public abstract void setPrintTreeFlag(boolean enable);

public abstract void setPointScaleFactor(float pixelsInPoint);
/**
* Yoga previously had an error where containers would take the maximum space possible instead of the minimum
* like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch;
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
*
* @deprecated "setUseLegacyStretchBehaviour" will be removed in the next release. Usage should be replaced with
* "setErrata(YogaErrata.ALL)" to opt out of all future breaking conformance fixes, or
* "setErrata(YogaErrata.STRETCH_FLEX_BASIS)" to opt out of the specific conformance fix previously disabled by
* "UseLegacyStretchBehaviour".
*/
@Deprecated
public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour);

public abstract void setErrata(YogaErrata errata);

Expand Down
9 changes: 0 additions & 9 deletions java/com/facebook/yoga/YogaConfigJNIBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ public void setPointScaleFactor(float pixelsInPoint) {
YogaNative.jni_YGConfigSetPointScaleFactorJNI(mNativePointer, pixelsInPoint);
}

/**
* Yoga previously had an error where containers would take the maximum space possible instead of the minimum
* like they are supposed to. In practice this resulted in implicit behaviour similar to align-self: stretch;
* Because this was such a long-standing bug we must allow legacy users to switch back to this behaviour.
*/
public void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour) {
YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour);
}

public void setErrata(YogaErrata errata) {
YogaNative.jni_YGConfigSetErrataJNI(mNativePointer, errata.intValue());
}
Expand Down
1 change: 0 additions & 1 deletion java/com/facebook/yoga/YogaNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class YogaNative {
static native void jni_YGConfigSetUseWebDefaultsJNI(long nativePointer, boolean useWebDefaults);
static native void jni_YGConfigSetPrintTreeFlagJNI(long nativePointer, boolean enable);
static native void jni_YGConfigSetPointScaleFactorJNI(long nativePointer, float pixelsInPoint);
static native void jni_YGConfigSetUseLegacyStretchBehaviourJNI(long nativePointer, boolean useLegacyStretchBehaviour);
static native void jni_YGConfigSetErrataJNI(long nativePointer, int errata);
static native int jni_YGConfigGetErrataJNI(long nativePointer);
static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger);
Expand Down
29 changes: 7 additions & 22 deletions java/jni/YGJNIVanilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace facebook::yoga;
using namespace facebook::yoga::vanillajni;

static inline ScopedLocalRef<jobject> YGNodeJobject(
YGNodeRef node,
YGNodeConstRef node,
void* layoutContext) {
return reinterpret_cast<PtrJNodeMapVanilla*>(layoutContext)->ref(node);
}
Expand Down Expand Up @@ -93,18 +93,6 @@ static void jni_YGConfigSetPointScaleFactorJNI(
YGConfigSetPointScaleFactor(config, pixelsInPoint);
}

static void jni_YGConfigSetUseLegacyStretchBehaviourJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jboolean useLegacyStretchBehaviour) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
#pragma clang diagnostic pop
}

static void jni_YGConfigSetErrataJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
Expand Down Expand Up @@ -138,8 +126,8 @@ static jlong jni_YGNodeNewWithConfigJNI(
}

static int YGJNILogFunc(
const YGConfigRef config,
const YGNodeRef /*node*/,
const YGConfigConstRef config,
const YGNodeConstRef /*node*/,
YGLogLevel level,
void* /*layoutContext*/,
const char* format,
Expand Down Expand Up @@ -362,7 +350,7 @@ static void YGTransferLayoutOutputsRecursive(

YGNodeSetHasNewLayout(root, false);

for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
for (size_t i = 0; i < YGNodeGetChildCount(root); i++) {
YGTransferLayoutOutputsRecursive(
env, thiz, YGNodeGetChild(root, i), layoutContext);
}
Expand Down Expand Up @@ -639,7 +627,7 @@ static void jni_YGNodeStyleSetBorderJNI(
yogaNodeRef, static_cast<YGEdge>(edge), static_cast<float>(border));
}

static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) {
static void YGTransferLayoutDirection(YGNodeConstRef node, jobject javaNode) {
// Don't change this field name without changing the name of the field in
// Database.java
JNIEnv* env = getCurrentEnv();
Expand All @@ -655,7 +643,7 @@ static void YGTransferLayoutDirection(YGNodeRef node, jobject javaNode) {
}

static YGSize YGJNIMeasureFunc(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand Down Expand Up @@ -700,7 +688,7 @@ static void jni_YGNodeSetHasMeasureFuncJNI(
}

static float YGJNIBaselineFunc(
YGNodeRef node,
YGNodeConstRef node,
float width,
float height,
void* layoutContext) {
Expand Down Expand Up @@ -790,9 +778,6 @@ static JNINativeMethod methods[] = {
{"jni_YGConfigSetPointScaleFactorJNI",
"(JF)V",
(void*) jni_YGConfigSetPointScaleFactorJNI},
{"jni_YGConfigSetUseLegacyStretchBehaviourJNI",
"(JZ)V",
(void*) jni_YGConfigSetUseLegacyStretchBehaviourJNI},
{"jni_YGConfigSetErrataJNI", "(JI)V", (void*) jni_YGConfigSetErrataJNI},
{"jni_YGConfigGetErrataJNI", "(J)I", (void*) jni_YGConfigGetErrataJNI},
{"jni_YGConfigSetLoggerJNI",
Expand Down
2 changes: 1 addition & 1 deletion java/tests/com/facebook/yoga/YogaNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void directionIsPassedThrough() {
@Test
public void testResetApiShouldResetAllLayoutOutputs() {
YogaConfig config = YogaConfigFactory.create();
config.setUseLegacyStretchBehaviour(true);
config.setErrata(YogaErrata.STRETCH_FLEX_BASIS);
YogaNode node = createNode(config);
node.setWidth(100);
node.setHeight(100);
Expand Down
14 changes: 0 additions & 14 deletions javascript/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ void Config::setPointScaleFactor(float pixelsInPoint) {
YGConfigSetPointScaleFactor(m_config, pixelsInPoint);
}

void Config::setUseLegacyStretchBehaviour(bool useLegacyStretchBehaviour) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
YGConfigSetUseLegacyStretchBehaviour(m_config, useLegacyStretchBehaviour);
#pragma clang diagnostic pop
}

void Config::setErrata(int errata) {
YGConfigSetErrata(m_config, static_cast<YGErrata>(errata));
}
Expand All @@ -52,13 +45,6 @@ bool Config::isExperimentalFeatureEnabled(int feature) const {
m_config, static_cast<YGExperimentalFeature>(feature));
}

bool Config::useLegacyStretchBehaviour() const {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
return YGConfigGetUseLegacyStretchBehaviour(m_config);
#pragma clang diagnostic pop
}

int Config::getErrata() const {
return static_cast<int>(YGConfigGetErrata(m_config));
}
Expand Down
2 changes: 0 additions & 2 deletions javascript/src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ class Config {
public: // Setters
void setExperimentalFeatureEnabled(int feature, bool enabled);
void setPointScaleFactor(float pixelsInPoint);
void setUseLegacyStretchBehaviour(bool useLegacyStretchBehaviour);
void setErrata(int errata);
void setUseWebDefaults(bool useWebDefaults);

public: // Getters
bool isExperimentalFeatureEnabled(int feature) const;
bool useLegacyStretchBehaviour() const;
int getErrata() const;
bool useWebDefaults() const;

Expand Down
4 changes: 2 additions & 2 deletions javascript/src/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "./Config.h"

static YGSize globalMeasureFunc(
YGNodeRef nodeRef,
YGNodeConstRef nodeRef,
float width,
YGMeasureMode widthMode,
float height,
Expand All @@ -29,7 +29,7 @@ static YGSize globalMeasureFunc(
return ygSize;
}

static void globalDirtiedFunc(YGNodeRef nodeRef) {
static void globalDirtiedFunc(YGNodeConstRef nodeRef) {
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));

node.callDirtiedFunc();
Expand Down
3 changes: 0 additions & 3 deletions javascript/src/embind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
"setExperimentalFeatureEnabled",
&Config::setExperimentalFeatureEnabled)
.function("setPointScaleFactor", &Config::setPointScaleFactor)
.function(
"setUseLegacyStretchBehaviour", &Config::setUseLegacyStretchBehaviour)
.function("setErrata", &Config::setErrata)
.function("setUseWebDefaults", &Config::setUseWebDefaults)
.function(
"isExperimentalFeatureEnabled", &Config::isExperimentalFeatureEnabled)
.function("useLegacyStretchBehaviour", &Config::useLegacyStretchBehaviour)
.function("getErrata", &Config::getErrata)
.function("useWebDefaults", &Config::useWebDefaults);

Expand Down
12 changes: 0 additions & 12 deletions javascript/src/wrapAssembly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ export type Config = {
enabled: boolean,
): void;
setPointScaleFactor(factor: number): void;
/**
* @deprecated Please use "getErrata()"
*/
useLegacyStretchBehaviour(): boolean;
/**
* @deprecated "setUseLegacyStretchBehaviour" will be removed in the next
* release. Usage should be replaced with "setErrata(ERRATA_ALL)" to opt out
* of all future breaking conformance fixes, or
* "setErrata(ERRATA_STRETCH_FLEX_BASIS)" to opt out of the specific
* conformance fix previously disabled by "UseLegacyStretchBehaviour".
*/
setUseLegacyStretchBehaviour(useLegacyStretchBehaviour: boolean): void;
getErrata(): Errata;
setErrata(errata: Errata): void;
useWebDefaults(): boolean;
Expand Down
5 changes: 3 additions & 2 deletions tests/EventsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
TEST_F(EventTest, measure_functions_get_wrapped) {
auto root = YGNodeNew();
YGNodeSetMeasureFunc(
root, [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) {
root, [](YGNodeConstRef, float, YGMeasureMode, float, YGMeasureMode) {
return YGSize{};
});

Expand All @@ -267,7 +267,8 @@ TEST_F(EventTest, baseline_functions_get_wrapped) {
auto child = YGNodeNew();
YGNodeInsertChild(root, child, 0);

YGNodeSetBaselineFunc(child, [](YGNodeRef, float, float) { return 0.0f; });
YGNodeSetBaselineFunc(
child, [](YGNodeConstRef, float, float) { return 0.0f; });
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignBaseline);

Expand Down
6 changes: 3 additions & 3 deletions tests/YGAlignBaselineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
#include <yoga/Yoga.h>

static float _baselineFunc(
YGNodeRef /*node*/,
YGNodeConstRef /*node*/,
const float /*width*/,
const float height) {
return height / 2;
}

static YGSize _measure1(
YGNodeRef /*node*/,
YGNodeConstRef /*node*/,
float /*width*/,
YGMeasureMode /*widthMode*/,
float /*height*/,
Expand All @@ -25,7 +25,7 @@ static YGSize _measure1(
}

static YGSize _measure2(
YGNodeRef /*node*/,
YGNodeConstRef /*node*/,
float /*width*/,
YGMeasureMode /*widthMode*/,
float /*height*/,
Expand Down
2 changes: 1 addition & 1 deletion tests/YGAspectRatioTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <yoga/Yoga.h>

static YGSize _measure(
YGNodeRef /*node*/,
YGNodeConstRef /*node*/,
float width,
YGMeasureMode widthMode,
float height,
Expand Down
2 changes: 1 addition & 1 deletion tests/YGBaselineFuncTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <yoga/Yoga.h>

static float _baseline(
YGNodeRef node,
YGNodeConstRef node,
const float /*width*/,
const float /*height*/) {
float* baseline = (float*) YGNodeGetContext(node);
Expand Down
17 changes: 10 additions & 7 deletions tests/generated/YGConfigTest.cpp → tests/YGConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html

#include <gtest/gtest.h>
#include <yoga/Yoga.h>
#include <yoga/config/Config.h>
Expand All @@ -23,8 +21,12 @@ struct ConfigCloningTest : public ::testing::Test {
void TearDown() override;

static yoga::Node clonedNode;
static YGNodeRef cloneNode(YGNodeRef, YGNodeRef, int) { return &clonedNode; }
static YGNodeRef doNotClone(YGNodeRef, YGNodeRef, int) { return nullptr; }
static YGNodeRef cloneNode(YGNodeConstRef, YGNodeConstRef, size_t) {
return &clonedNode;
}
static YGNodeRef doNotClone(YGNodeConstRef, YGNodeConstRef, size_t) {
return nullptr;
}
};

TEST_F(ConfigCloningTest, uses_values_provided_by_cloning_callback) {
Expand All @@ -49,9 +51,10 @@ TEST_F(
}

TEST_F(ConfigCloningTest, can_clone_with_context) {
config->setCloneNodeCallback([](YGNodeRef, YGNodeRef, int, void* context) {
return (YGNodeRef) context;
});
config->setCloneNodeCallback(
[](YGNodeConstRef, YGNodeConstRef, size_t, void* context) {
return (YGNodeRef) context;
});

yoga::Node node{}, owner{}, clone{};
ASSERT_EQ(config->cloneNode(&node, &owner, 0, &clone), &clone);
Expand Down
2 changes: 1 addition & 1 deletion tests/YGDirtiedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

using namespace facebook;

static void _dirtied(YGNodeRef node) {
static void _dirtied(YGNodeConstRef node) {
int* dirtiedCount = (int*) YGNodeGetContext(node);
(*dirtiedCount)++;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/YGDirtyMarkingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ TEST(YogaTest, dirty_propagation_changing_benign_config) {
YGConfigRef newConfig = YGConfigNew();
YGConfigSetLogger(
newConfig,
[](const YGConfigRef, const YGNodeRef, YGLogLevel, const char*, va_list) {
[](YGConfigConstRef, YGNodeConstRef, YGLogLevel, const char*, va_list) {
return 0;
});
YGNodeSetConfig(root_child0, newConfig);
Expand Down
4 changes: 2 additions & 2 deletions tests/YGLoggerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
namespace {
char writeBuffer[4096];
int _unmanagedLogger(
const YGConfigRef /*config*/,
const YGNodeRef /*node*/,
const YGConfigConstRef /*config*/,
const YGNodeConstRef /*node*/,
YGLogLevel /*level*/,
const char* format,
va_list args) {
Expand Down
6 changes: 3 additions & 3 deletions tests/YGMeasureCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <yoga/Yoga.h>

static YGSize _measureMax(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand All @@ -24,7 +24,7 @@ static YGSize _measureMax(
}

static YGSize _measureMin(
YGNodeRef node,
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
Expand All @@ -44,7 +44,7 @@ static YGSize _measureMin(
}

static YGSize _measure_84_49(
YGNodeRef node,
YGNodeConstRef node,
float /*width*/,
YGMeasureMode /*widthMode*/,
float /*height*/,
Expand Down
Loading
Loading