Fabric: Explicit dirtying Yoga nodes for Text component (and co.)

Summary:
With recent changes, simple cloning a component does not mean that underlying Yoga node will be dirtied. Autodirtying is only performed if the child nodes were dirtied and/or if the YGStyles were changed.
That's not the case for Text component which does not have direct layotable children, so we have to call `dirtyLayout` explicitly.

Reviewed By: JoshuaGross

Differential Revision: D14508277

fbshipit-source-id: 2c52d7d40da963a976c7d28a13781cc1755ef591
This commit is contained in:
Valentin Shergin
2019-03-18 19:16:40 -07:00
committed by Facebook Github Bot
parent ab86085caf
commit 9a0047f368
2 changed files with 4 additions and 0 deletions

View File

@@ -71,6 +71,8 @@ class ParagraphComponentDescriptor final
paragraphShadowNode->setMeasureCache(
measureCache_ ? measureCache_.get() : nullptr);
paragraphShadowNode->dirtyLayout();
// All `ParagraphShadowNode`s must have leaf Yoga nodes with properly
// setup measure function.
paragraphShadowNode->enableMeasurement();

View File

@@ -141,6 +141,7 @@ void YogaLayoutableShadowNode::setSize(Size size) const {
style.dimensions[YGDimensionWidth] = yogaStyleValueFromFloat(size.width);
style.dimensions[YGDimensionHeight] = yogaStyleValueFromFloat(size.height);
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}
void YogaLayoutableShadowNode::setPositionType(
@@ -150,6 +151,7 @@ void YogaLayoutableShadowNode::setPositionType(
auto style = yogaNode_.getStyle();
style.positionType = positionType;
yogaNode_.setStyle(style);
yogaNode_.setDirty(true);
}
void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {