Fabric: `ParagraphShadowNode::updateLocalDataIfNeeded()`
Summary: Now we don't update `LocalData` for `ParagraphShadowNode` if the attributed string hasn't changed. Reviewed By: mdvacca Differential Revision: D13160128 fbshipit-source-id: 6ffe76ad187452fa37ba36a132b885cbcedfd1d3
This commit is contained in:
parent
7e57755cea
commit
9c961331dd
|
@ -32,11 +32,17 @@ void ParagraphShadowNode::setTextLayoutManager(
|
||||||
textLayoutManager_ = textLayoutManager;
|
textLayoutManager_ = textLayoutManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParagraphShadowNode::updateLocalData() {
|
void ParagraphShadowNode::updateLocalDataIfNeeded() {
|
||||||
ensureUnsealed();
|
ensureUnsealed();
|
||||||
|
|
||||||
|
auto attributedString = getAttributedString();
|
||||||
|
auto currentLocalData = std::static_pointer_cast<const ParagraphLocalData>(getLocalData());
|
||||||
|
if (currentLocalData && currentLocalData->getAttributedString() == attributedString) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto localData = std::make_shared<ParagraphLocalData>();
|
auto localData = std::make_shared<ParagraphLocalData>();
|
||||||
localData->setAttributedString(getAttributedString());
|
localData->setAttributedString(std::move(attributedString));
|
||||||
localData->setTextLayoutManager(textLayoutManager_);
|
localData->setTextLayoutManager(textLayoutManager_);
|
||||||
setLocalData(localData);
|
setLocalData(localData);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +58,7 @@ Size ParagraphShadowNode::measure(LayoutConstraints layoutConstraints) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParagraphShadowNode::layout(LayoutContext layoutContext) {
|
void ParagraphShadowNode::layout(LayoutContext layoutContext) {
|
||||||
updateLocalData();
|
updateLocalDataIfNeeded();
|
||||||
ConcreteViewShadowNode::layout(layoutContext);
|
ConcreteViewShadowNode::layout(layoutContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ParagraphShadowNode : public ConcreteViewShadowNode<
|
||||||
* Creates a `LocalData` object (with `AttributedText` and
|
* Creates a `LocalData` object (with `AttributedText` and
|
||||||
* `TextLayoutManager`) if needed.
|
* `TextLayoutManager`) if needed.
|
||||||
*/
|
*/
|
||||||
void updateLocalData();
|
void updateLocalDataIfNeeded();
|
||||||
|
|
||||||
SharedTextLayoutManager textLayoutManager_;
|
SharedTextLayoutManager textLayoutManager_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue