Fabric: Refinement of `BaseTraits` chain
Summary: Here we refine the `ShadowNode::BaseTraits` static method. Before this change, ConcreteViewShadowNode<> enforces Layoutable and YogaLayoutable traits. This change moves that responsibility to LayoutableShadowNode and YogaLayoutableShadowNode which makes overall logic more coherent. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D20052027 fbshipit-source-id: fd25264204b0232b1dbbff6f9dfefd9fbcb146c4
This commit is contained in:
Родитель
0c50ba5376
Коммит
cdbc21132b
|
@ -58,8 +58,6 @@ class ConcreteViewShadowNode : public ConcreteShadowNode<
|
|||
|
||||
static ShadowNodeTraits BaseTraits() {
|
||||
auto traits = BaseShadowNode::BaseTraits();
|
||||
traits.set(ShadowNodeTraits::Trait::LayoutableKind);
|
||||
traits.set(ShadowNodeTraits::Trait::YogaLayoutableKind);
|
||||
traits.set(ShadowNodeTraits::Trait::ViewKind);
|
||||
return traits;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,12 @@
|
|||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ShadowNodeTraits YogaLayoutableShadowNode::BaseTraits() {
|
||||
auto traits = LayoutableShadowNode::BaseTraits();
|
||||
traits.set(ShadowNodeTraits::Trait::YogaLayoutableKind);
|
||||
return traits;
|
||||
}
|
||||
|
||||
YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
||||
ShadowNodeFragment const &fragment,
|
||||
ShadowNodeFamily::Shared const &family,
|
||||
|
|
|
@ -28,6 +28,8 @@ class YogaLayoutableShadowNode : public LayoutableShadowNode {
|
|||
YogaLayoutableShadowNode *,
|
||||
kShadowNodeChildrenSmallVectorSize>;
|
||||
|
||||
static ShadowNodeTraits BaseTraits();
|
||||
|
||||
#pragma mark - Constructors
|
||||
|
||||
YogaLayoutableShadowNode(
|
||||
|
|
|
@ -81,6 +81,12 @@ LayoutableShadowNode::LayoutableShadowNode(
|
|||
layoutMetrics_(static_cast<LayoutableShadowNode const &>(sourceShadowNode)
|
||||
.layoutMetrics_) {}
|
||||
|
||||
ShadowNodeTraits LayoutableShadowNode::BaseTraits() {
|
||||
auto traits = ShadowNodeTraits{};
|
||||
traits.set(ShadowNodeTraits::Trait::LayoutableKind);
|
||||
return traits;
|
||||
}
|
||||
|
||||
LayoutMetrics LayoutableShadowNode::getLayoutMetrics() const {
|
||||
return layoutMetrics_;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ class LayoutableShadowNode : public ShadowNode {
|
|||
ShadowNode const &sourceShadowNode,
|
||||
ShadowNodeFragment const &fragment);
|
||||
|
||||
static ShadowNodeTraits BaseTraits();
|
||||
|
||||
class LayoutInspectingPolicy final {
|
||||
public:
|
||||
bool includeTransform{true};
|
||||
|
|
|
@ -63,7 +63,7 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
|||
* Reimplement in subclasses to declare class-specific traits.
|
||||
*/
|
||||
static ShadowNodeTraits BaseTraits() {
|
||||
return ShadowNodeTraits{};
|
||||
return BaseShadowNodeT::BaseTraits();
|
||||
}
|
||||
|
||||
static SharedConcreteProps Props(
|
||||
|
|
|
@ -63,6 +63,14 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
|
|||
*/
|
||||
static bool sameFamily(const ShadowNode &first, const ShadowNode &second);
|
||||
|
||||
/*
|
||||
* A set of traits associated with a particular class.
|
||||
* Reimplement in subclasses to declare class-specific traits.
|
||||
*/
|
||||
static ShadowNodeTraits BaseTraits() {
|
||||
return ShadowNodeTraits{};
|
||||
}
|
||||
|
||||
#pragma mark - Constructors
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче