From 9e1bcd8557974054adc9d6349eea1ff41c8cde7d Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Thu, 19 Jan 2023 06:38:45 -0800 Subject: [PATCH] Remove legacy layout diffing Summary: This removes some unused flags which will cause Yoga to layout every tree twice, then diffing the tree, reporting whether the whole tree is different. This is too expensive to run outside of local experimentation, but we have more nuanced ways to implement the `YGNodeLayoutAffectedByQuirk` I am wanting to add. Changelog: [Internal] Reviewed By: lunaleaps Differential Revision: D42406917 fbshipit-source-id: b415ed02768f6b59de3a6fa90c60c750d56fd4b0 --- java/com/facebook/yoga/YogaConfig.java | 8 -- java/com/facebook/yoga/YogaConfigJNIBase.java | 11 -- java/com/facebook/yoga/YogaNative.java | 1 - java/com/facebook/yoga/YogaNodeJNIBase.java | 7 - java/jni/YGJNI.h | 1 - java/jni/YGJNIVanilla.cpp | 15 --- .../tests/com/facebook/yoga/YogaNodeTest.java | 25 ---- tests/YGLayoutDiffingTest.cpp | 93 ------------- yoga/YGLayout.h | 25 +--- yoga/YGNode.cpp | 47 ------- yoga/YGNode.h | 4 - yoga/Yoga.cpp | 123 ------------------ yoga/Yoga.h | 5 - 13 files changed, 1 insertion(+), 364 deletions(-) delete mode 100644 tests/YGLayoutDiffingTest.cpp diff --git a/java/com/facebook/yoga/YogaConfig.java b/java/com/facebook/yoga/YogaConfig.java index a91e5157..ec96a963 100644 --- a/java/com/facebook/yoga/YogaConfig.java +++ b/java/com/facebook/yoga/YogaConfig.java @@ -25,14 +25,6 @@ public abstract class YogaConfig { */ public abstract void setUseLegacyStretchBehaviour(boolean useLegacyStretchBehaviour); - /** - * If this flag is set then yoga would diff the layout without legacy flag and would set a bool in - * YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false - * if not - */ - public abstract void setShouldDiffLayoutWithoutLegacyStretchBehaviour( - boolean shouldDiffLayoutWithoutLegacyStretchBehaviour); - public abstract void setLogger(YogaLogger logger); public abstract YogaLogger getLogger(); diff --git a/java/com/facebook/yoga/YogaConfigJNIBase.java b/java/com/facebook/yoga/YogaConfigJNIBase.java index b5820d85..62a740ef 100644 --- a/java/com/facebook/yoga/YogaConfigJNIBase.java +++ b/java/com/facebook/yoga/YogaConfigJNIBase.java @@ -52,17 +52,6 @@ public abstract class YogaConfigJNIBase extends YogaConfig { YogaNative.jni_YGConfigSetUseLegacyStretchBehaviourJNI(mNativePointer, useLegacyStretchBehaviour); } - /** - * If this flag is set then yoga would diff the layout without legacy flag and would set a bool in - * YogaNode(mDoesLegacyStretchFlagAffectsLayout) with true if the layouts were different and false - * if not - */ - public void setShouldDiffLayoutWithoutLegacyStretchBehaviour( - boolean shouldDiffLayoutWithoutLegacyStretchBehaviour) { - YogaNative.jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI( - mNativePointer, shouldDiffLayoutWithoutLegacyStretchBehaviour); - } - public void setLogger(YogaLogger logger) { mLogger = logger; YogaNative.jni_YGConfigSetLoggerJNI(mNativePointer, logger); diff --git a/java/com/facebook/yoga/YogaNative.java b/java/com/facebook/yoga/YogaNative.java index c0246f60..202e4feb 100644 --- a/java/com/facebook/yoga/YogaNative.java +++ b/java/com/facebook/yoga/YogaNative.java @@ -25,7 +25,6 @@ public class YogaNative { 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_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI(long nativePointer, boolean shouldDiffLayoutWithoutLegacyStretchBehaviour); static native void jni_YGConfigSetLoggerJNI(long nativePointer, YogaLogger logger); // YGNode related diff --git a/java/com/facebook/yoga/YogaNodeJNIBase.java b/java/com/facebook/yoga/YogaNodeJNIBase.java index fd44cc0f..ef432cf1 100644 --- a/java/com/facebook/yoga/YogaNodeJNIBase.java +++ b/java/com/facebook/yoga/YogaNodeJNIBase.java @@ -19,7 +19,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable { private static final byte MARGIN = 1; private static final byte PADDING = 2; private static final byte BORDER = 4; - private static final byte DOES_LEGACY_STRETCH_BEHAVIOUR = 8; private static final byte HAS_NEW_LAYOUT = 16; private static final byte LAYOUT_EDGE_SET_FLAG_INDEX = 0; @@ -606,12 +605,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable { return arr != null ? arr[LAYOUT_HEIGHT_INDEX] : 0; } - public boolean getDoesLegacyStretchFlagAffectsLayout() { - return arr != null - && (((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & DOES_LEGACY_STRETCH_BEHAVIOUR) - == DOES_LEGACY_STRETCH_BEHAVIOUR); - } - @Override public float getLayoutMargin(YogaEdge edge) { if (arr != null && ((int) arr[LAYOUT_EDGE_SET_FLAG_INDEX] & MARGIN) == MARGIN) { diff --git a/java/jni/YGJNI.h b/java/jni/YGJNI.h index 8001681c..69f11392 100644 --- a/java/jni/YGJNI.h +++ b/java/jni/YGJNI.h @@ -17,7 +17,6 @@ const short int LAYOUT_BORDER_START_INDEX = 14; namespace { -const int DOES_LEGACY_STRETCH_BEHAVIOUR = 8; const int HAS_NEW_LAYOUT = 16; union YGNodeContext { diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp index e531681c..88608324 100644 --- a/java/jni/YGJNIVanilla.cpp +++ b/java/jni/YGJNIVanilla.cpp @@ -57,15 +57,6 @@ static void jni_YGConfigSetExperimentalFeatureEnabledJNI( config, static_cast(feature), enabled); } -static void jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI( - JNIEnv* env, - jobject obj, - jlong nativePointer, - jboolean enabled) { - const YGConfigRef config = _jlong2YGConfigRef(nativePointer); - YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(config, enabled); -} - static void jni_YGConfigSetUseWebDefaultsJNI( JNIEnv* env, jobject obj, @@ -294,9 +285,6 @@ static void YGTransferLayoutOutputsRecursive( int fieldFlags = edgesSet.get(); fieldFlags |= HAS_NEW_LAYOUT; - if (YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(root)) { - fieldFlags |= DOES_LEGACY_STRETCH_BEHAVIOUR; - } const int arrSize = 6 + (marginFieldSet ? 4 : 0) + (paddingFieldSet ? 4 : 0) + (borderFieldSet ? 4 : 0); @@ -776,9 +764,6 @@ static JNINativeMethod methods[] = { {"jni_YGConfigSetUseLegacyStretchBehaviourJNI", "(JZ)V", (void*) jni_YGConfigSetUseLegacyStretchBehaviourJNI}, - {"jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI", - "(JZ)V", - (void*) jni_YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviourJNI}, {"jni_YGConfigSetLoggerJNI", "(JLcom/facebook/yoga/YogaLogger;)V", (void*) jni_YGConfigSetLoggerJNI}, diff --git a/java/tests/com/facebook/yoga/YogaNodeTest.java b/java/tests/com/facebook/yoga/YogaNodeTest.java index 12c6390a..3dfdd81e 100644 --- a/java/tests/com/facebook/yoga/YogaNodeTest.java +++ b/java/tests/com/facebook/yoga/YogaNodeTest.java @@ -233,29 +233,6 @@ public class YogaNodeTest { } } - @Test - public void testFlagShouldDiffLayoutWithoutLegacyStretchBehaviour() throws Exception { - YogaConfig config = YogaConfigFactory.create(); - config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true); - config.setUseLegacyStretchBehaviour(true); - YogaNode root = createNode(config); - root.setWidth(500); - root.setHeight(500); - YogaNode root_child0 = createNode(config); - root_child0.setAlignItems(YogaAlign.FLEX_START); - root.addChildAt(root_child0, 0); - YogaNode root_child0_child0 = createNode(config); - root_child0_child0.setFlexGrow(1); - root_child0_child0.setFlexShrink(1); - root_child0.addChildAt(root_child0_child0, 0); - YogaNode root_child0_child0_child0 = createNode(config); - root_child0_child0_child0.setFlexGrow(1); - root_child0_child0_child0.setFlexShrink(1); - root_child0_child0.addChildAt(root_child0_child0_child0, 0); - root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); - assertTrue(((YogaNodeJNIBase) root).getDoesLegacyStretchFlagAffectsLayout()); - } - @Test public void initiallyHasNewLayout() { YogaNode root = createNode(); @@ -315,7 +292,6 @@ public class YogaNodeTest { @Test public void testResetApiShouldResetAllLayoutOutputs() { YogaConfig config = YogaConfigFactory.create(); - config.setShouldDiffLayoutWithoutLegacyStretchBehaviour(true); config.setUseLegacyStretchBehaviour(true); YogaNode node = createNode(config); node.setWidth(100); @@ -371,7 +347,6 @@ public class YogaNodeTest { assertTrue(node.hasNewLayout()); assertFalse(node.isMeasureDefined()); assertFalse(node.isBaselineDefined()); - assertFalse(((YogaNodeJNIBase) node).getDoesLegacyStretchFlagAffectsLayout()); assertEquals(null, node.getData()); } diff --git a/tests/YGLayoutDiffingTest.cpp b/tests/YGLayoutDiffingTest.cpp deleted file mode 100644 index ca76b840..00000000 --- a/tests/YGLayoutDiffingTest.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include - -#include "util/TestUtil.h" - -using facebook::yoga::test::TestUtil; - -TEST(YogaTest, assert_layout_trees_are_same) { - TestUtil::startCountingNodes(); - - YGConfig* config = YGConfigNew(); - YGConfigSetUseLegacyStretchBehaviour(config, true); - const YGNodeRef root1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root1, 500); - YGNodeStyleSetHeight(root1, 500); - - const YGNodeRef root1_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetAlignItems(root1_child0, YGAlignFlexStart); - YGNodeInsertChild(root1, root1_child0, 0); - - const YGNodeRef root1_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root1_child0_child0, 1); - YGNodeStyleSetFlexShrink(root1_child0_child0, 1); - YGNodeInsertChild(root1_child0, root1_child0_child0, 0); - - const YGNodeRef root1_child0_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root1_child0_child0_child0, 1); - YGNodeStyleSetFlexShrink(root1_child0_child0_child0, 1); - YGNodeInsertChild(root1_child0_child0, root1_child0_child0_child0, 0); - - const int32_t cal1_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal1_nodeInstanceCount = TestUtil::nodeCount(); - - YGNodeCalculateLayout(root1, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_EQ(YGConfigGetInstanceCount(), cal1_configInstanceCount); - ASSERT_EQ(TestUtil::nodeCount(), cal1_nodeInstanceCount); - - const YGNodeRef root2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root2, 500); - YGNodeStyleSetHeight(root2, 500); - - const YGNodeRef root2_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetAlignItems(root2_child0, YGAlignFlexStart); - YGNodeInsertChild(root2, root2_child0, 0); - - const YGNodeRef root2_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root2_child0_child0, 1); - YGNodeStyleSetFlexShrink(root2_child0_child0, 1); - YGNodeInsertChild(root2_child0, root2_child0_child0, 0); - - const YGNodeRef root2_child0_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexGrow(root2_child0_child0_child0, 1); - YGNodeStyleSetFlexShrink(root2_child0_child0_child0, 1); - YGNodeInsertChild(root2_child0_child0, root2_child0_child0_child0, 0); - - const int32_t cal2_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal2_nodeInstanceCount = TestUtil::nodeCount(); - - YGNodeCalculateLayout(root2, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_EQ(YGConfigGetInstanceCount(), cal2_configInstanceCount); - ASSERT_EQ(TestUtil::nodeCount(), cal2_nodeInstanceCount); - - ASSERT_TRUE(YGNodeLayoutGetDidUseLegacyFlag(root1)); - ASSERT_TRUE(YGNodeLayoutGetDidUseLegacyFlag(root2)); - ASSERT_TRUE(root1->isLayoutTreeEqualToNode(*root2)); - - YGNodeStyleSetAlignItems(root2, YGAlignFlexEnd); - - const int32_t cal3_configInstanceCount = YGConfigGetInstanceCount(); - const int32_t cal3_nodeInstanceCount = TestUtil::nodeCount(); - - YGNodeCalculateLayout(root2, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_EQ(YGConfigGetInstanceCount(), cal3_configInstanceCount); - ASSERT_EQ(TestUtil::stopCountingNodes(), cal3_nodeInstanceCount); - - ASSERT_FALSE(root1->isLayoutTreeEqualToNode(*root2)); - - YGNodeFreeRecursive(root1); - YGNodeFreeRecursive(root2); - - YGConfigFree(config); -} diff --git a/yoga/YGLayout.h b/yoga/YGLayout.h index ce612040..e95efbcc 100644 --- a/yoga/YGLayout.h +++ b/yoga/YGLayout.h @@ -22,12 +22,8 @@ struct YGLayout { private: static constexpr size_t directionOffset = 0; - static constexpr size_t didUseLegacyFlagOffset = - directionOffset + facebook::yoga::detail::bitWidthFn(); - static constexpr size_t doesLegacyStretchFlagAffectsLayoutOffset = - didUseLegacyFlagOffset + 1; static constexpr size_t hadOverflowOffset = - doesLegacyStretchFlagAffectsLayoutOffset + 1; + directionOffset + facebook::yoga::detail::bitWidthFn(); uint8_t flags = 0; public: @@ -56,25 +52,6 @@ public: flags, directionOffset, direction); } - bool didUseLegacyFlag() const { - return facebook::yoga::detail::getBooleanData( - flags, didUseLegacyFlagOffset); - } - - void setDidUseLegacyFlag(bool val) { - facebook::yoga::detail::setBooleanData(flags, didUseLegacyFlagOffset, val); - } - - bool doesLegacyStretchFlagAffectsLayout() const { - return facebook::yoga::detail::getBooleanData( - flags, doesLegacyStretchFlagAffectsLayoutOffset); - } - - void setDoesLegacyStretchFlagAffectsLayout(bool val) { - facebook::yoga::detail::setBooleanData( - flags, doesLegacyStretchFlagAffectsLayoutOffset, val); - } - bool hadOverflow() const { return facebook::yoga::detail::getBooleanData(flags, hadOverflowOffset); } diff --git a/yoga/YGNode.cpp b/yoga/YGNode.cpp index 5e52b615..24e68b05 100644 --- a/yoga/YGNode.cpp +++ b/yoga/YGNode.cpp @@ -560,53 +560,6 @@ YGFloatOptional YGNode::getTrailingPaddingAndBorder( YGFloatOptional(getTrailingBorder(axis)); } -bool YGNode::didUseLegacyFlag() { - bool didUseLegacyFlag = layout_.didUseLegacyFlag(); - if (didUseLegacyFlag) { - return true; - } - for (const auto& child : children_) { - if (child->layout_.didUseLegacyFlag()) { - didUseLegacyFlag = true; - break; - } - } - return didUseLegacyFlag; -} - -void YGNode::setLayoutDoesLegacyFlagAffectsLayout( - bool doesLegacyFlagAffectsLayout) { - layout_.setDoesLegacyStretchFlagAffectsLayout(doesLegacyFlagAffectsLayout); -} - -void YGNode::setLayoutDidUseLegacyFlag(bool didUseLegacyFlag) { - layout_.setDidUseLegacyFlag(didUseLegacyFlag); -} - -bool YGNode::isLayoutTreeEqualToNode(const YGNode& node) const { - if (children_.size() != node.children_.size()) { - return false; - } - if (layout_ != node.layout_) { - return false; - } - if (children_.size() == 0) { - return true; - } - - bool isLayoutTreeEqual = true; - YGNodeRef otherNodeChildren = nullptr; - for (std::vector::size_type i = 0; i < children_.size(); ++i) { - otherNodeChildren = node.children_[i]; - isLayoutTreeEqual = - children_[i]->isLayoutTreeEqualToNode(*otherNodeChildren); - if (!isLayoutTreeEqual) { - return false; - } - } - return isLayoutTreeEqual; -} - void YGNode::reset() { YGAssertWithNode( this, diff --git a/yoga/YGNode.h b/yoga/YGNode.h index ac20b109..90bc93dd 100644 --- a/yoga/YGNode.h +++ b/yoga/YGNode.h @@ -327,8 +327,6 @@ public: const float mainSize, const float crossSize, const float ownerWidth); - void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout); - void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag); void markDirtyAndPropogateDownwards(); // Other methods @@ -351,8 +349,6 @@ public: float resolveFlexGrow() const; float resolveFlexShrink() const; bool isNodeFlexible(); - bool didUseLegacyFlag(); - bool isLayoutTreeEqualToNode(const YGNode& node) const; void reset(); }; diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index dc04b72f..2c8f45b0 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -180,10 +180,6 @@ YOGA_EXPORT bool YGNodeIsDirty(YGNodeRef node) { return node->isDirty(); } -YOGA_EXPORT bool YGNodeLayoutGetDidUseLegacyFlag(const YGNodeRef node) { - return node->didUseLegacyFlag(); -} - YOGA_EXPORT void YGNodeMarkDirtyAndPropogateToDescendants( const YGNodeRef node) { return node->markDirtyAndPropogateDownwards(); @@ -220,32 +216,6 @@ YOGA_EXPORT YGNodeRef YGNodeClone(YGNodeRef oldNode) { return node; } -static YGConfigRef YGConfigClone(const YGConfig& oldConfig) { - const YGConfigRef config = new YGConfig(oldConfig); - YGAssert(config != nullptr, "Could not allocate memory for config"); - gConfigInstanceCount++; - return config; -} - -static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) { - auto config = YGConfigClone(*oldNode->getConfig()); - auto node = new YGNode{*oldNode, config}; - node->setOwner(nullptr); - Event::publish(node, {node->getConfig()}); - - YGVector vec = YGVector(); - vec.reserve(oldNode->getChildren().size()); - YGNodeRef childNode = nullptr; - for (auto* item : oldNode->getChildren()) { - childNode = YGNodeDeepClone(item); - childNode->setOwner(node); - vec.push_back(childNode); - } - node->setChildren(vec); - - return node; -} - YOGA_EXPORT void YGNodeFree(const YGNodeRef node) { if (YGNodeRef owner = node->getOwner()) { owner->removeChild(node); @@ -263,17 +233,6 @@ YOGA_EXPORT void YGNodeFree(const YGNodeRef node) { delete node; } -static void YGConfigFreeRecursive(const YGNodeRef root) { - if (root->getConfig() != nullptr) { - gConfigInstanceCount--; - delete root->getConfig(); - } - // Delete configs recursively for childrens - for (auto* child : root->getChildren()) { - YGConfigFreeRecursive(child); - } -} - YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( const YGNodeRef root, YGNodeCleanupFunc cleanup) { @@ -993,11 +952,6 @@ YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Margin, margin); YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Border, border); YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(float, Padding, padding); -YOGA_EXPORT bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout( - const YGNodeRef node) { - return node->getLayout().doesLegacyStretchFlagAffectsLayout(); -} - std::atomic gCurrentGenerationCount(0); bool YGLayoutNodeInternal( @@ -3051,9 +3005,6 @@ static void YGNodelayoutImpl( collectedFlexItemsValues.sizeConsumedOnCurrentLine; } - if (node->getConfig()->useLegacyStretchBehaviour) { - node->setLayoutDidUseLegacyFlag(true); - } sizeBasedOnContent = !node->getConfig()->useLegacyStretchBehaviour; } } @@ -4205,13 +4156,6 @@ static void YGRoundToPixelGrid( } } -static void unsetUseLegacyFlagRecursively(YGNodeRef node) { - node->getConfig()->useLegacyStretchBehaviour = false; - for (auto child : node->getChildren()) { - unsetUseLegacyFlagRecursively(child); - } -} - YOGA_EXPORT void YGNodeCalculateLayoutWithContext( const YGNodeRef node, const float ownerWidth, @@ -4297,67 +4241,6 @@ YOGA_EXPORT void YGNodeCalculateLayoutWithContext( } Event::publish(node, {layoutContext, &markerData}); - - // We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we - // aren't sure whether client's of yoga have gotten rid off this flag or not. - // So logging this in YGLayout would help to find out the call sites depending - // on this flag. This check would be removed once we are sure no one is - // dependent on this flag anymore. The flag - // `shouldDiffLayoutWithoutLegacyStretchBehaviour` in YGConfig will help to - // run experiments. - if (node->getConfig()->shouldDiffLayoutWithoutLegacyStretchBehaviour && - node->didUseLegacyFlag()) { - const YGNodeRef nodeWithoutLegacyFlag = YGNodeDeepClone(node); - nodeWithoutLegacyFlag->resolveDimension(); - // Recursively mark nodes as dirty - nodeWithoutLegacyFlag->markDirtyAndPropogateDownwards(); - gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed); - // Rerun the layout, and calculate the diff - unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag); - LayoutData layoutMarkerData = {}; - if (YGLayoutNodeInternal( - nodeWithoutLegacyFlag, - width, - height, - ownerDirection, - widthMeasureMode, - heightMeasureMode, - ownerWidth, - ownerHeight, - true, - LayoutPassReason::kInitial, - nodeWithoutLegacyFlag->getConfig(), - layoutMarkerData, - layoutContext, - 0, // tree root - gCurrentGenerationCount.load(std::memory_order_relaxed))) { - nodeWithoutLegacyFlag->setPosition( - nodeWithoutLegacyFlag->getLayout().direction(), - ownerWidth, - ownerHeight, - ownerWidth); - YGRoundToPixelGrid( - nodeWithoutLegacyFlag, - nodeWithoutLegacyFlag->getConfig()->pointScaleFactor, - 0.0f, - 0.0f); - - // Set whether the two layouts are different or not. - auto neededLegacyStretchBehaviour = - !nodeWithoutLegacyFlag->isLayoutTreeEqualToNode(*node); - node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour); - -#ifdef DEBUG - if (nodeWithoutLegacyFlag->getConfig()->printTree) { - YGNodePrint( - nodeWithoutLegacyFlag, - (YGPrintOptions) (YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle)); - } -#endif - } - YGConfigFreeRecursive(nodeWithoutLegacyFlag); - YGNodeFreeRecursive(nodeWithoutLegacyFlag); - } } YOGA_EXPORT void YGNodeCalculateLayout( @@ -4381,12 +4264,6 @@ YOGA_EXPORT void YGConfigSetLogger(const YGConfigRef config, YGLogger logger) { } } -YOGA_EXPORT void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( - const YGConfigRef config, - const bool shouldDiffLayout) { - config->shouldDiffLayoutWithoutLegacyStretchBehaviour = shouldDiffLayout; -} - void YGAssert(const bool condition, const char* message) { if (!condition) { Log::log(YGNodeRef{nullptr}, YGLogLevelFatal, nullptr, "%s\n", message); diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 07beea4e..7fbf269d 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -147,7 +147,6 @@ WIN_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout); YGNodeType YGNodeGetNodeType(YGNodeRef node); void YGNodeSetNodeType(YGNodeRef node, YGNodeType nodeType); WIN_EXPORT bool YGNodeIsDirty(YGNodeRef node); -bool YGNodeLayoutGetDidUseLegacyFlag(YGNodeRef node); WIN_EXPORT void YGNodeStyleSetDirection(YGNodeRef node, YGDirection direction); WIN_EXPORT YGDirection YGNodeStyleGetDirection(YGNodeConstRef node); @@ -290,7 +289,6 @@ WIN_EXPORT float YGNodeLayoutGetWidth(YGNodeRef node); WIN_EXPORT float YGNodeLayoutGetHeight(YGNodeRef node); WIN_EXPORT YGDirection YGNodeLayoutGetDirection(YGNodeRef node); WIN_EXPORT bool YGNodeLayoutGetHadOverflow(YGNodeRef node); -bool YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(YGNodeRef node); // Get the computed values for these nodes after performing layout. If they were // set using point values then the returned value will be the same as @@ -315,9 +313,6 @@ WIN_EXPORT void YGAssertWithConfig( WIN_EXPORT void YGConfigSetPointScaleFactor( YGConfigRef config, float pixelsInPoint); -void YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour( - YGConfigRef config, - bool shouldDiffLayout); // 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