Remove YGNode::setAndPropogateUseLegacyFlag
Summary: `YGNode::setAndPropogateUseLegacyFlag` was only used for debugging purposes. Here, we replace it with a free function in `Yoga.cpp`. Now that we have events, the diffing functionality should go into a separate debugging package and be implemented in terms of an event listener. Let's do that as soon as we can support multiple listeners. Reviewed By: SidharthGuglani Differential Revision: D15316863 fbshipit-source-id: db929eba7c2de8aa1550e362dd2c175929c0070e
This commit is contained in:
committed by
Facebook Github Bot
parent
1938792517
commit
54e863cef2
@@ -254,7 +254,7 @@ public class YogaNodeTest {
|
|||||||
root_child0_child0_child0.setFlexShrink(1);
|
root_child0_child0_child0.setFlexShrink(1);
|
||||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
assertFalse(((YogaNodeJNIBase) root).getDoesLegacyStretchFlagAffectsLayout());
|
assertTrue(((YogaNodeJNIBase) root).getDoesLegacyStretchFlagAffectsLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -539,13 +539,6 @@ bool YGNode::didUseLegacyFlag() {
|
|||||||
return didUseLegacyFlag;
|
return didUseLegacyFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNode::setAndPropogateUseLegacyFlag(bool useLegacyFlag) {
|
|
||||||
config_->useLegacyStretchBehaviour = useLegacyFlag;
|
|
||||||
for_each(children_.begin(), children_.end(), [=](YGNodeRef childNode) {
|
|
||||||
childNode->getConfig()->useLegacyStretchBehaviour = useLegacyFlag;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void YGNode::setLayoutDoesLegacyFlagAffectsLayout(
|
void YGNode::setLayoutDoesLegacyFlagAffectsLayout(
|
||||||
bool doesLegacyFlagAffectsLayout) {
|
bool doesLegacyFlagAffectsLayout) {
|
||||||
layout_.doesLegacyStretchFlagAffectsLayout = doesLegacyFlagAffectsLayout;
|
layout_.doesLegacyStretchFlagAffectsLayout = doesLegacyFlagAffectsLayout;
|
||||||
|
@@ -292,7 +292,6 @@ public:
|
|||||||
const float mainSize,
|
const float mainSize,
|
||||||
const float crossSize,
|
const float crossSize,
|
||||||
const float ownerWidth);
|
const float ownerWidth);
|
||||||
void setAndPropogateUseLegacyFlag(bool useLegacyFlag);
|
|
||||||
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
|
void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
|
||||||
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
|
void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
|
||||||
void markDirtyAndPropogateDownwards();
|
void markDirtyAndPropogateDownwards();
|
||||||
|
@@ -3992,6 +3992,13 @@ static void YGRoundToPixelGrid(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void unsetUseLegacyFlagRecursively(YGNodeRef node) {
|
||||||
|
node->getConfig()->useLegacyStretchBehaviour = false;
|
||||||
|
for (auto child : node->getChildren()) {
|
||||||
|
unsetUseLegacyFlagRecursively(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void YGNodeCalculateLayoutWithContext(
|
void YGNodeCalculateLayoutWithContext(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
@@ -4096,16 +4103,16 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
// run experiments.
|
// run experiments.
|
||||||
if (node->getConfig()->shouldDiffLayoutWithoutLegacyStretchBehaviour &&
|
if (node->getConfig()->shouldDiffLayoutWithoutLegacyStretchBehaviour &&
|
||||||
node->didUseLegacyFlag()) {
|
node->didUseLegacyFlag()) {
|
||||||
const YGNodeRef originalNode = YGNodeDeepClone(node);
|
const YGNodeRef nodeWithoutLegacyFlag = YGNodeDeepClone(node);
|
||||||
originalNode->resolveDimension();
|
nodeWithoutLegacyFlag->resolveDimension();
|
||||||
// Recursively mark nodes as dirty
|
// Recursively mark nodes as dirty
|
||||||
originalNode->markDirtyAndPropogateDownwards();
|
nodeWithoutLegacyFlag->markDirtyAndPropogateDownwards();
|
||||||
gCurrentGenerationCount++;
|
gCurrentGenerationCount++;
|
||||||
// Rerun the layout, and calculate the diff
|
// Rerun the layout, and calculate the diff
|
||||||
originalNode->setAndPropogateUseLegacyFlag(false);
|
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
||||||
YGMarkerLayoutData layoutMarkerData;
|
YGMarkerLayoutData layoutMarkerData;
|
||||||
if (YGLayoutNodeInternal(
|
if (YGLayoutNodeInternal(
|
||||||
originalNode,
|
nodeWithoutLegacyFlag,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
ownerDirection,
|
ownerDirection,
|
||||||
@@ -4115,37 +4122,37 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
ownerHeight,
|
ownerHeight,
|
||||||
true,
|
true,
|
||||||
"initial",
|
"initial",
|
||||||
originalNode->getConfig(),
|
nodeWithoutLegacyFlag->getConfig(),
|
||||||
layoutMarkerData,
|
layoutMarkerData,
|
||||||
layoutContext)) {
|
layoutContext)) {
|
||||||
originalNode->setPosition(
|
nodeWithoutLegacyFlag->setPosition(
|
||||||
originalNode->getLayout().direction,
|
nodeWithoutLegacyFlag->getLayout().direction,
|
||||||
ownerWidth,
|
ownerWidth,
|
||||||
ownerHeight,
|
ownerHeight,
|
||||||
ownerWidth);
|
ownerWidth);
|
||||||
YGRoundToPixelGrid(
|
YGRoundToPixelGrid(
|
||||||
originalNode,
|
nodeWithoutLegacyFlag,
|
||||||
originalNode->getConfig()->pointScaleFactor,
|
nodeWithoutLegacyFlag->getConfig()->pointScaleFactor,
|
||||||
0.0f,
|
0.0f,
|
||||||
0.0f);
|
0.0f);
|
||||||
|
|
||||||
// Set whether the two layouts are different or not.
|
// Set whether the two layouts are different or not.
|
||||||
auto neededLegacyStretchBehaviour =
|
auto neededLegacyStretchBehaviour =
|
||||||
!originalNode->isLayoutTreeEqualToNode(*node);
|
!nodeWithoutLegacyFlag->isLayoutTreeEqualToNode(*node);
|
||||||
node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour);
|
node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (originalNode->getConfig()->printTree) {
|
if (nodeWithoutLegacyFlag->getConfig()->printTree) {
|
||||||
YGNodePrint(
|
YGNodePrint(
|
||||||
originalNode,
|
nodeWithoutLegacyFlag,
|
||||||
(YGPrintOptions)(
|
(YGPrintOptions)(
|
||||||
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
YGPrintOptionsLayout | YGPrintOptionsChildren |
|
||||||
YGPrintOptionsStyle));
|
YGPrintOptionsStyle));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
YGConfigFreeRecursive(originalNode);
|
YGConfigFreeRecursive(nodeWithoutLegacyFlag);
|
||||||
YGNodeFreeRecursive(originalNode);
|
YGNodeFreeRecursive(nodeWithoutLegacyFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user