mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Moving logic from ConcreteViewShadowNode constructors to YogaLayoutableShadowNode constructors
Summary: Now we can move custom to `YogaLayoutableShadowNode` code from `ConcreteViewShadowNode<>` template to `YogaLayoutableShadowNode` itself reducing the amount of templated code and reduce overall complexity. Note, here we have to do `dynamic_cast` for now, we will address that in coming diffs. Changelog: [Internal] Fabric-specific internal change. Reviewed By: mdvacca Differential Revision: D20052021 fbshipit-source-id: dac5969a97b75e54c7728a1ca8161922bd2245ca
This commit is contained in:
committed by
Facebook Github Bot
parent
6f08c37633
commit
0c50ba5376
@@ -54,31 +54,7 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
|
||||
Ts...>;
|
||||
using ConcreteViewProps = ViewPropsT;
|
||||
|
||||
ConcreteViewShadowNode(
|
||||
ShadowNodeFragment const &fragment,
|
||||
ShadowNodeFamily::Shared const &family,
|
||||
ShadowNodeTraits traits)
|
||||
: BaseShadowNode(fragment, family, traits) {
|
||||
YogaLayoutableShadowNode::setProps(
|
||||
*std::static_pointer_cast<const ConcreteViewProps>(fragment.props));
|
||||
YogaLayoutableShadowNode::setChildren(
|
||||
YogaLayoutableShadowNode::getYogaLayoutableChildren());
|
||||
}
|
||||
|
||||
ConcreteViewShadowNode(
|
||||
ShadowNode const &sourceShadowNode,
|
||||
ShadowNodeFragment const &fragment)
|
||||
: BaseShadowNode(sourceShadowNode, fragment) {
|
||||
if (fragment.props) {
|
||||
YogaLayoutableShadowNode::setProps(
|
||||
*std::static_pointer_cast<const ConcreteViewProps>(fragment.props));
|
||||
}
|
||||
|
||||
if (fragment.children) {
|
||||
YogaLayoutableShadowNode::setChildren(
|
||||
YogaLayoutableShadowNode::getYogaLayoutableChildren());
|
||||
}
|
||||
}
|
||||
using BaseShadowNode::BaseShadowNode;
|
||||
|
||||
static ShadowNodeTraits BaseTraits() {
|
||||
auto traits = BaseShadowNode::BaseTraits();
|
||||
|
||||
@@ -29,6 +29,9 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
||||
yogaConfig_(nullptr),
|
||||
yogaNode_(&initializeYogaConfig(yogaConfig_)) {
|
||||
yogaNode_.setContext(this);
|
||||
|
||||
setProps(dynamic_cast<YogaStylableProps const &>(*fragment.props));
|
||||
setChildren(YogaLayoutableShadowNode::getYogaLayoutableChildren());
|
||||
}
|
||||
|
||||
YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
||||
@@ -47,6 +50,14 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
||||
assert(
|
||||
static_cast<YogaLayoutableShadowNode const &>(sourceShadowNode)
|
||||
.yogaNode_.isDirty() == yogaNode_.isDirty());
|
||||
|
||||
if (fragment.props) {
|
||||
setProps(dynamic_cast<YogaStylableProps const &>(*fragment.props));
|
||||
}
|
||||
|
||||
if (fragment.children) {
|
||||
setChildren(YogaLayoutableShadowNode::getYogaLayoutableChildren());
|
||||
}
|
||||
}
|
||||
|
||||
void YogaLayoutableShadowNode::cleanLayout() {
|
||||
@@ -165,7 +176,7 @@ void YogaLayoutableShadowNode::setChildren(
|
||||
yogaNode_.setDirty(!isClean);
|
||||
}
|
||||
|
||||
void YogaLayoutableShadowNode::setProps(const YogaStylableProps &props) {
|
||||
void YogaLayoutableShadowNode::setProps(YogaStylableProps const &props) {
|
||||
ensureUnsealed();
|
||||
|
||||
// Resetting `dirty` flag only if `yogaStyle` portion of `Props` was changed.
|
||||
|
||||
Reference in New Issue
Block a user