mirror of
https://github.com/status-im/react-native.git
synced 2025-01-21 14:58:55 +00:00
2c28310267
Summary: @public Quite trivial. We had to have this from the day one. We don't need cache invalidation policy because all subtree is immutable. Reviewed By: mdvacca Differential Revision: D8709973 fbshipit-source-id: bd7fcf0ae1dcb23894321cb5d16da18cb1ab788f
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ParagraphShadowNode.h"
|
|
|
|
#include <fabric/debug/DebugStringConvertibleItem.h>
|
|
|
|
#import "ParagraphLocalData.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
ComponentName ParagraphShadowNode::getComponentName() const {
|
|
return ComponentName("Paragraph");
|
|
}
|
|
|
|
AttributedString ParagraphShadowNode::getAttributedString() const {
|
|
if (!cachedAttributedString_.has_value()) {
|
|
cachedAttributedString_ =
|
|
BaseTextShadowNode::getAttributedString(getProps()->textAttributes, getChildren());
|
|
}
|
|
|
|
return cachedAttributedString_.value();
|
|
}
|
|
|
|
void ParagraphShadowNode::setTextLayoutManager(SharedTextLayoutManager textLayoutManager) {
|
|
ensureUnsealed();
|
|
textLayoutManager_ = textLayoutManager;
|
|
}
|
|
|
|
void ParagraphShadowNode::updateLocalData() {
|
|
ensureUnsealed();
|
|
|
|
auto localData = std::make_shared<ParagraphLocalData>();
|
|
localData->setAttributedString(getAttributedString());
|
|
localData->setTextLayoutManager(textLayoutManager_);
|
|
setLocalData(localData);
|
|
}
|
|
|
|
#pragma mark - LayoutableShadowNode
|
|
|
|
Size ParagraphShadowNode::measure(LayoutConstraints layoutConstraints) const {
|
|
return textLayoutManager_->measure(
|
|
getAttributedString(),
|
|
getProps()->paragraphAttributes,
|
|
layoutConstraints
|
|
);
|
|
}
|
|
|
|
void ParagraphShadowNode::layout(LayoutContext layoutContext) {
|
|
updateLocalData();
|
|
ConcreteViewShadowNode<ParagraphProps>::layout(layoutContext);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|