From 33bf310920be776bf3f281c2a4be6056b7ede7b9 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 26 Feb 2020 22:03:14 -0800 Subject: [PATCH] Fabric: YogaStylableProps now inherits Props Summary: How we can finally make `ViewProps` inherit `YogaStylableProps` and remove `dynamic_cast`. This overall change is aligned with D19963353. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D20052026 fbshipit-source-id: 1066f9a259b50d4672111c9c03a71c2590d59aca --- ReactCommon/fabric/components/view/ViewProps.cpp | 3 +-- ReactCommon/fabric/components/view/ViewProps.h | 4 +--- .../fabric/components/view/yoga/YogaLayoutableShadowNode.cpp | 2 +- ReactCommon/fabric/components/view/yoga/YogaStylableProps.cpp | 3 ++- ReactCommon/fabric/components/view/yoga/YogaStylableProps.h | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ReactCommon/fabric/components/view/ViewProps.cpp b/ReactCommon/fabric/components/view/ViewProps.cpp index 13b8f995b21..be9e8db543a 100644 --- a/ReactCommon/fabric/components/view/ViewProps.cpp +++ b/ReactCommon/fabric/components/view/ViewProps.cpp @@ -19,8 +19,7 @@ namespace facebook { namespace react { ViewProps::ViewProps(ViewProps const &sourceProps, RawProps const &rawProps) - : Props(sourceProps, rawProps), - YogaStylableProps(sourceProps, rawProps), + : YogaStylableProps(sourceProps, rawProps), AccessibilityProps(sourceProps, rawProps), opacity( convertRawProp(rawProps, "opacity", sourceProps.opacity, (Float)1.0)), diff --git a/ReactCommon/fabric/components/view/ViewProps.h b/ReactCommon/fabric/components/view/ViewProps.h index 6319f556138..a14a3610ae0 100644 --- a/ReactCommon/fabric/components/view/ViewProps.h +++ b/ReactCommon/fabric/components/view/ViewProps.h @@ -23,9 +23,7 @@ class ViewProps; using SharedViewProps = std::shared_ptr; -class ViewProps : public Props, - public YogaStylableProps, - public AccessibilityProps { +class ViewProps : public YogaStylableProps, public AccessibilityProps { public: ViewProps() = default; ViewProps(ViewProps const &sourceProps, RawProps const &rawProps); diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index c64caf9ff1d..47f1d942259 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -36,7 +36,7 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaNode_(&initializeYogaConfig(yogaConfig_)) { yogaNode_.setContext(this); - setProps(dynamic_cast(*fragment.props)); + setProps(static_cast(*fragment.props)); setChildren(YogaLayoutableShadowNode::getYogaLayoutableChildren()); } diff --git a/ReactCommon/fabric/components/view/yoga/YogaStylableProps.cpp b/ReactCommon/fabric/components/view/yoga/YogaStylableProps.cpp index 859b4057f1e..08da2474757 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaStylableProps.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaStylableProps.cpp @@ -22,7 +22,8 @@ namespace react { YogaStylableProps::YogaStylableProps( YogaStylableProps const &sourceProps, RawProps const &rawProps) - : yogaStyle(convertRawProp(rawProps, sourceProps.yogaStyle)){}; + : Props(sourceProps, rawProps), + yogaStyle(convertRawProp(rawProps, sourceProps.yogaStyle)){}; #pragma mark - DebugStringConvertible diff --git a/ReactCommon/fabric/components/view/yoga/YogaStylableProps.h b/ReactCommon/fabric/components/view/yoga/YogaStylableProps.h index e93d1381895..d45b23713aa 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaStylableProps.h +++ b/ReactCommon/fabric/components/view/yoga/YogaStylableProps.h @@ -15,7 +15,7 @@ namespace facebook { namespace react { -class YogaStylableProps { +class YogaStylableProps : public Props { public: YogaStylableProps() = default; YogaStylableProps(