mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create internal State of ART based on Shadow Nodes
Summary: This diff creates the internal state of ART based on its shadow nodes changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D21657607 fbshipit-source-id: 0a15e90ee7465bf3a2b1001ff9d3198eb22fd708
This commit is contained in:
committed by
Facebook GitHub Bot
parent
192bea1613
commit
493d616521
@@ -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 <react/components/art/ARTShapeProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
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<ARTBaseShadowNode const>(child);
|
||||
if (baseShadowNode) {
|
||||
outNodes.push_back(baseShadowNode->getElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -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, {})),
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <memory>
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/core/Props.h>
|
||||
#include <react/debug/DebugStringConvertible.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -30,10 +31,6 @@ class ARTGroupProps : public Props {
|
||||
std::vector<Float> clipping{};
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
#if RN_DEBUG_STRING_CONVERTIBLE
|
||||
SharedDebugStringConvertibleList getDebugProps() const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -6,11 +6,27 @@
|
||||
*/
|
||||
|
||||
#include <react/components/art/ARTGroupShadowNode.h>
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Group.h>
|
||||
|
||||
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<ARTBaseShadowNode const>(child);
|
||||
if (node) {
|
||||
elements.push_back(node->getElement());
|
||||
}
|
||||
}
|
||||
|
||||
auto props = getConcreteProps();
|
||||
return std::make_shared<Group>(
|
||||
props.opacity, props.transform, elements, props.clipping);
|
||||
}
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTGroupProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
namespace facebook {
|
||||
@@ -18,10 +21,16 @@ extern const char ARTGroupComponentName[];
|
||||
/*
|
||||
* `ShadowNode` for <ARTGroup> component.
|
||||
*/
|
||||
using ARTGroupShadowNode =
|
||||
ConcreteShadowNode<ARTGroupComponentName, ShadowNode, ARTGroupProps>;
|
||||
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
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <react/components/art/ARTShapeProps.h>
|
||||
#include <Glog/logging.h>
|
||||
#include <react/core/propsConversions.h>
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -6,11 +6,26 @@
|
||||
*/
|
||||
|
||||
#include "ARTShapeShadowNode.h"
|
||||
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Shape.h>
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ARTShapeComponentName[] = "ARTShape";
|
||||
|
||||
Element::Shared ARTShapeShadowNode::getElement() const {
|
||||
auto props = getConcreteProps();
|
||||
return std::make_shared<Shape>(
|
||||
props.opacity,
|
||||
props.transform,
|
||||
props.d,
|
||||
props.stroke,
|
||||
props.strokeDash,
|
||||
props.fill,
|
||||
props.strokeWidth,
|
||||
props.strokeCap,
|
||||
props.strokeJoin);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTShapeProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
namespace facebook {
|
||||
@@ -18,8 +20,16 @@ extern const char ARTShapeComponentName[];
|
||||
/*
|
||||
* `ShadowNode` for <ARTShape> component.
|
||||
*/
|
||||
using ARTShapeShadowNode =
|
||||
ConcreteShadowNode<ARTShapeComponentName, ShadowNode, ARTShapeProps>;
|
||||
class ARTShapeShadowNode : public ConcreteShadowNode<
|
||||
ARTShapeComponentName,
|
||||
ShadowNode,
|
||||
ARTShapeProps>,
|
||||
public ARTBaseShadowNode {
|
||||
public:
|
||||
using ConcreteShadowNode::ConcreteShadowNode;
|
||||
|
||||
virtual Element::Shared getElement() const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -5,12 +5,19 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <react/components/art/ARTTextShadowNode.h>
|
||||
#include "ARTTextShadowNode.h"
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Text.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ARTTextComponentName[] = "ARTText";
|
||||
|
||||
Element::Shared ARTTextShadowNode::getElement() const {
|
||||
// TODO add support for Text
|
||||
return std::make_shared<Shape>();
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTTextProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Text.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
namespace facebook {
|
||||
@@ -18,8 +21,14 @@ extern const char ARTTextComponentName[];
|
||||
/*
|
||||
* `ShadowNode` for <ARTText> component.
|
||||
*/
|
||||
using ARTTextShadowNode =
|
||||
ConcreteShadowNode<ARTTextComponentName, ShadowNode, ARTTextProps>;
|
||||
class ARTTextShadowNode
|
||||
: public ConcreteShadowNode<ARTTextComponentName, ShadowNode, ARTTextProps>,
|
||||
public ARTBaseShadowNode {
|
||||
public:
|
||||
using ConcreteShadowNode::ConcreteShadowNode;
|
||||
|
||||
virtual Element::Shared getElement() const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
Reference in New Issue
Block a user