diff --git a/ReactCommon/fabric/components/art/ARTBaseShadowNode.h b/ReactCommon/fabric/components/art/ARTBaseShadowNode.h new file mode 100644 index 00000000000..c105b608c0c --- /dev/null +++ b/ReactCommon/fabric/components/art/ARTBaseShadowNode.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include +#include + +namespace facebook { +namespace react { + +class ARTBaseShadowNode { + public: + int test; + virtual Element::Shared getElement() const = 0; + + static void buildElements( + ShadowNode const &parentNode, + Element::ListOfShared &outNodes) { + for (auto const &child : parentNode.getChildren()) { + auto baseShadowNode = + std::dynamic_pointer_cast(child); + if (baseShadowNode) { + outNodes.push_back(baseShadowNode->getElement()); + } + } + } +}; + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/fabric/components/art/group/ARTGroupProps.cpp b/ReactCommon/fabric/components/art/group/ARTGroupProps.cpp index b1142071114..04e9c602376 100644 --- a/ReactCommon/fabric/components/art/group/ARTGroupProps.cpp +++ b/ReactCommon/fabric/components/art/group/ARTGroupProps.cpp @@ -15,7 +15,6 @@ ARTGroupProps::ARTGroupProps( const ARTGroupProps &sourceProps, const RawProps &rawProps) : Props(sourceProps, rawProps), - opacity(convertRawProp(rawProps, "opacity", sourceProps.opacity, {1.0})), transform( convertRawProp(rawProps, "transform", sourceProps.transform, {})), diff --git a/ReactCommon/fabric/components/art/group/ARTGroupProps.h b/ReactCommon/fabric/components/art/group/ARTGroupProps.h index f931842d34b..bd4190c7db2 100644 --- a/ReactCommon/fabric/components/art/group/ARTGroupProps.h +++ b/ReactCommon/fabric/components/art/group/ARTGroupProps.h @@ -7,11 +7,12 @@ #pragma once -#include -#include - +#include +#include #include #include +#include +#include namespace facebook { namespace react { @@ -30,10 +31,6 @@ class ARTGroupProps : public Props { std::vector clipping{}; #pragma mark - DebugStringConvertible - -#if RN_DEBUG_STRING_CONVERTIBLE - SharedDebugStringConvertibleList getDebugProps() const override; -#endif }; } // namespace react diff --git a/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.cpp b/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.cpp index d01f9ba198b..0972a933e50 100644 --- a/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.cpp +++ b/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.cpp @@ -6,11 +6,27 @@ */ #include +#include +#include +#include namespace facebook { namespace react { extern const char ARTGroupComponentName[] = "ARTGroup"; +Element::Shared ARTGroupShadowNode::getElement() const { + auto elements = Element::ListOfShared{}; + for (auto const &child : getChildren()) { + auto node = std::dynamic_pointer_cast(child); + if (node) { + elements.push_back(node->getElement()); + } + } + + auto props = getConcreteProps(); + return std::make_shared( + props.opacity, props.transform, elements, props.clipping); +} } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.h b/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.h index 28d87bf202c..7e0800ad94c 100644 --- a/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.h +++ b/ReactCommon/fabric/components/art/group/ARTGroupShadowNode.h @@ -7,7 +7,10 @@ #pragma once +#include #include +#include +#include #include namespace facebook { @@ -18,10 +21,16 @@ extern const char ARTGroupComponentName[]; /* * `ShadowNode` for component. */ -using ARTGroupShadowNode = - ConcreteShadowNode; +class ARTGroupShadowNode : public ConcreteShadowNode< + ARTGroupComponentName, + ShadowNode, + ARTGroupProps>, + public ARTBaseShadowNode { + public: + using ConcreteShadowNode::ConcreteShadowNode; -extern const char ARTShapeComponentName[]; + virtual Element::Shared getElement() const override; +}; } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/components/art/shape/ARTShapeProps.cpp b/ReactCommon/fabric/components/art/shape/ARTShapeProps.cpp index 5ce61b603a7..9b1c79c00ae 100644 --- a/ReactCommon/fabric/components/art/shape/ARTShapeProps.cpp +++ b/ReactCommon/fabric/components/art/shape/ARTShapeProps.cpp @@ -6,6 +6,7 @@ */ #include +#include #include namespace facebook { @@ -31,11 +32,10 @@ ARTShapeProps::ARTShapeProps( {1.0})), strokeCap( convertRawProp(rawProps, "strokeCap", sourceProps.strokeCap, {1})), - strokeJoin(convertRawProp( - rawProps, - "strokeJoin", - sourceProps.strokeJoin, - {1})){}; + strokeJoin( + convertRawProp(rawProps, "strokeJoin", sourceProps.strokeJoin, {1})){ + + }; #pragma mark - DebugStringConvertible diff --git a/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.cpp b/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.cpp index 36053eb099f..50e2a40fd9e 100644 --- a/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.cpp +++ b/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.cpp @@ -6,11 +6,26 @@ */ #include "ARTShapeShadowNode.h" - +#include +#include namespace facebook { namespace react { extern const char ARTShapeComponentName[] = "ARTShape"; +Element::Shared ARTShapeShadowNode::getElement() const { + auto props = getConcreteProps(); + return std::make_shared( + props.opacity, + props.transform, + props.d, + props.stroke, + props.strokeDash, + props.fill, + props.strokeWidth, + props.strokeCap, + props.strokeJoin); +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.h b/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.h index 1d4da7f016d..5f75bf01d6f 100644 --- a/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.h +++ b/ReactCommon/fabric/components/art/shape/ARTShapeShadowNode.h @@ -7,7 +7,9 @@ #pragma once +#include #include +#include #include namespace facebook { @@ -18,8 +20,16 @@ extern const char ARTShapeComponentName[]; /* * `ShadowNode` for component. */ -using ARTShapeShadowNode = - ConcreteShadowNode; +class ARTShapeShadowNode : public ConcreteShadowNode< + ARTShapeComponentName, + ShadowNode, + ARTShapeProps>, + public ARTBaseShadowNode { + public: + using ConcreteShadowNode::ConcreteShadowNode; + + virtual Element::Shared getElement() const override; +}; } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/components/art/text/ARTTextShadowNode.cpp b/ReactCommon/fabric/components/art/text/ARTTextShadowNode.cpp index 9f12120672b..49312c2ff2d 100644 --- a/ReactCommon/fabric/components/art/text/ARTTextShadowNode.cpp +++ b/ReactCommon/fabric/components/art/text/ARTTextShadowNode.cpp @@ -5,12 +5,19 @@ * LICENSE file in the root directory of this source tree. */ -#include +#include "ARTTextShadowNode.h" +#include +#include namespace facebook { namespace react { extern const char ARTTextComponentName[] = "ARTText"; +Element::Shared ARTTextShadowNode::getElement() const { + // TODO add support for Text + return std::make_shared(); +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/components/art/text/ARTTextShadowNode.h b/ReactCommon/fabric/components/art/text/ARTTextShadowNode.h index 35ab43d85a1..a1a68da6938 100644 --- a/ReactCommon/fabric/components/art/text/ARTTextShadowNode.h +++ b/ReactCommon/fabric/components/art/text/ARTTextShadowNode.h @@ -7,7 +7,10 @@ #pragma once +#include #include +#include +#include #include namespace facebook { @@ -18,8 +21,14 @@ extern const char ARTTextComponentName[]; /* * `ShadowNode` for component. */ -using ARTTextShadowNode = - ConcreteShadowNode; +class ARTTextShadowNode + : public ConcreteShadowNode, + public ARTBaseShadowNode { + public: + using ConcreteShadowNode::ConcreteShadowNode; + + virtual Element::Shared getElement() const override; +}; } // namespace react } // namespace facebook