Rename Element -> ARTElement
Summary: Element, Shape, Group, Text are too generic, we are renaming these classes to ARTElement, ARTBGroup, ARTShape... changelog: [Internal] internal changes to support ART in android Reviewed By: JoshuaGross Differential Revision: D21681878 fbshipit-source-id: f6b35443486a3db210f61dcaf91bd32df47fbc66
This commit is contained in:
Родитель
cfd2e7d88d
Коммит
55c36661d9
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTShapeProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -17,16 +17,16 @@ namespace react {
|
|||
class ARTBaseShadowNode {
|
||||
public:
|
||||
int test;
|
||||
virtual Element::Shared getElement() const = 0;
|
||||
virtual ARTElement::Shared getARTElement() const = 0;
|
||||
|
||||
static void buildElements(
|
||||
ShadowNode const &parentNode,
|
||||
Element::ListOfShared &outNodes) {
|
||||
ARTElement::ListOfShared &outNodes) {
|
||||
for (auto const &child : parentNode.getChildren()) {
|
||||
auto baseShadowNode =
|
||||
std::dynamic_pointer_cast<ARTBaseShadowNode const>(child);
|
||||
if (baseShadowNode) {
|
||||
outNodes.push_back(baseShadowNode->getElement());
|
||||
outNodes.push_back(baseShadowNode->getARTElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
#include <Glog/logging.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/components/art/ARTGroup.h>
|
||||
#include <react/components/art/ARTShape.h>
|
||||
#include <react/components/art/ARTSurfaceViewState.h>
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/components/art/Shape.h>
|
||||
#include <react/components/art/Text.h>
|
||||
#include <react/components/art/ARTText.h>
|
||||
#include <react/components/art/primitives.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -18,10 +18,10 @@ namespace react {
|
|||
|
||||
#ifdef ANDROID
|
||||
|
||||
inline folly::dynamic toDynamic(Group const &group);
|
||||
inline folly::dynamic toDynamic(Shape const &shape);
|
||||
inline folly::dynamic toDynamic(Text const &text);
|
||||
inline folly::dynamic toDynamic(Element const &element);
|
||||
inline folly::dynamic toDynamic(ARTGroup const &group);
|
||||
inline folly::dynamic toDynamic(ARTShape const &shape);
|
||||
inline folly::dynamic toDynamic(ARTText const &text);
|
||||
inline folly::dynamic toDynamic(ARTElement const &element);
|
||||
|
||||
inline folly::dynamic toDynamic(std::vector<Float> const &elements) {
|
||||
folly::dynamic result = folly::dynamic::array();
|
||||
|
@ -40,7 +40,7 @@ inline void addOptionalKey(
|
|||
}
|
||||
}
|
||||
|
||||
inline folly::dynamic toDynamic(Element::ListOfShared const &elements) {
|
||||
inline folly::dynamic toDynamic(ARTElement::ListOfShared const &elements) {
|
||||
folly::dynamic children = folly::dynamic::array();
|
||||
for (auto const &element : elements) {
|
||||
children.push_back(element->getDynamic());
|
||||
|
@ -48,7 +48,7 @@ inline folly::dynamic toDynamic(Element::ListOfShared const &elements) {
|
|||
return children;
|
||||
}
|
||||
|
||||
inline folly::dynamic toDynamic(Group const &group) {
|
||||
inline folly::dynamic toDynamic(ARTGroup const &group) {
|
||||
folly::dynamic result = folly::dynamic::object();
|
||||
result["opacity"] = group.opacity;
|
||||
result["type"] = 1;
|
||||
|
@ -60,7 +60,7 @@ inline folly::dynamic toDynamic(Group const &group) {
|
|||
return result;
|
||||
}
|
||||
|
||||
inline folly::dynamic toDynamic(Shape const &shape) {
|
||||
inline folly::dynamic toDynamic(ARTShape const &shape) {
|
||||
folly::dynamic result = folly::dynamic::object();
|
||||
result["type"] = 2;
|
||||
result["opacity"] = shape.opacity;
|
||||
|
@ -109,7 +109,7 @@ inline folly::dynamic toDynamic(ARTTextFrame const &frame) {
|
|||
return result;
|
||||
}
|
||||
|
||||
inline folly::dynamic toDynamic(Text const &text) {
|
||||
inline folly::dynamic toDynamic(ARTText const &text) {
|
||||
folly::dynamic result = folly::dynamic::object();
|
||||
result["type"] = 3;
|
||||
result["opacity"] = text.opacity;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTGroup.h>
|
||||
#include <react/core/Props.h>
|
||||
#include <react/debug/DebugStringConvertible.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
|
||||
#include <react/components/art/ARTGroupShadowNode.h>
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTGroup.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ARTGroupComponentName[] = "ARTGroup";
|
||||
|
||||
Element::Shared ARTGroupShadowNode::getElement() const {
|
||||
auto elements = Element::ListOfShared{};
|
||||
ARTElement::Shared ARTGroupShadowNode::getARTElement() const {
|
||||
auto elements = ARTElement::ListOfShared{};
|
||||
for (auto const &child : getChildren()) {
|
||||
auto node = std::dynamic_pointer_cast<ARTBaseShadowNode const>(child);
|
||||
if (node) {
|
||||
elements.push_back(node->getElement());
|
||||
elements.push_back(node->getARTElement());
|
||||
}
|
||||
}
|
||||
|
||||
auto props = getConcreteProps();
|
||||
return std::make_shared<Group>(
|
||||
return std::make_shared<ARTGroup>(
|
||||
props.opacity, props.transform, elements, props.clipping);
|
||||
}
|
||||
} // namespace react
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTGroup.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 {
|
||||
|
@ -29,7 +29,7 @@ class ARTGroupShadowNode : public ConcreteShadowNode<
|
|||
public:
|
||||
using ConcreteShadowNode::ConcreteShadowNode;
|
||||
|
||||
virtual Element::Shared getElement() const override;
|
||||
virtual ARTElement::Shared getARTElement() const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
|
||||
#include "ARTShapeShadowNode.h"
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Shape.h>
|
||||
#include <react/components/art/ARTShape.h>
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ARTShapeComponentName[] = "ARTShape";
|
||||
|
||||
Element::Shared ARTShapeShadowNode::getElement() const {
|
||||
ARTElement::Shared ARTShapeShadowNode::getARTElement() const {
|
||||
auto props = getConcreteProps();
|
||||
return std::make_shared<Shape>(
|
||||
return std::make_shared<ARTShape>(
|
||||
props.opacity,
|
||||
props.transform,
|
||||
props.d,
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTShapeProps.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
|
||||
namespace facebook {
|
||||
|
@ -28,7 +28,7 @@ class ARTShapeShadowNode : public ConcreteShadowNode<
|
|||
public:
|
||||
using ConcreteShadowNode::ConcreteShadowNode;
|
||||
|
||||
virtual Element::Shared getElement() const override;
|
||||
virtual ARTElement::Shared getARTElement() const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {} // namespace react
|
|
@ -24,17 +24,20 @@ namespace react {
|
|||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of base ART Element
|
||||
*/
|
||||
class Element {
|
||||
class ARTElement {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Element>;
|
||||
using ListOfShared = better::small_vector<Element::Shared, 0>;
|
||||
using Shared = std::shared_ptr<const ARTElement>;
|
||||
using ListOfShared = better::small_vector<ARTElement::Shared, 0>;
|
||||
|
||||
Element() = default;
|
||||
Element(ARTElement elementType, Float opacity, std::vector<Float> transform)
|
||||
ARTElement() = default;
|
||||
ARTElement(
|
||||
ARTElementType elementType,
|
||||
Float opacity,
|
||||
std::vector<Float> transform)
|
||||
: elementType(elementType), opacity(opacity), transform(transform){};
|
||||
virtual ~Element(){};
|
||||
virtual ~ARTElement(){};
|
||||
|
||||
ARTElement elementType;
|
||||
ARTElementType elementType;
|
||||
Float opacity;
|
||||
std::vector<Float> transform;
|
||||
|
|
@ -5,15 +5,15 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <react/components/art/Group.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTGroup.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/conversions.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Group::getDynamic() const {
|
||||
folly::dynamic ARTGroup::getDynamic() const {
|
||||
return toDynamic(*this);
|
||||
}
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/primitives.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <functional>
|
||||
|
@ -19,21 +19,21 @@ namespace react {
|
|||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of ART Group element
|
||||
*/
|
||||
class Group : public Element {
|
||||
class ARTGroup : public ARTElement {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Group>;
|
||||
Group(
|
||||
using Shared = std::shared_ptr<const ARTGroup>;
|
||||
ARTGroup(
|
||||
Float opacity,
|
||||
std::vector<Float> transform,
|
||||
Element::ListOfShared elements,
|
||||
ARTElement::ListOfShared elements,
|
||||
std::vector<Float> clipping)
|
||||
: Element(ARTElement::Group, opacity, transform),
|
||||
: ARTElement(ARTElementType::Group, opacity, transform),
|
||||
elements(elements),
|
||||
clipping(clipping){};
|
||||
Group() = default;
|
||||
virtual ~Group(){};
|
||||
ARTGroup() = default;
|
||||
virtual ~ARTGroup(){};
|
||||
|
||||
Element::ListOfShared elements{};
|
||||
ARTElement::ListOfShared elements{};
|
||||
|
||||
std::vector<Float> clipping{};
|
||||
|
|
@ -5,15 +5,15 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <react/components/art/Text.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTShape.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/conversions.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Text::getDynamic() const {
|
||||
folly::dynamic ARTShape::getDynamic() const {
|
||||
return toDynamic(*this);
|
||||
}
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/primitives.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <functional>
|
||||
|
@ -19,10 +19,10 @@ namespace react {
|
|||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of ART Shape Element
|
||||
*/
|
||||
class Shape : public Element {
|
||||
class ARTShape : public ARTElement {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Shape>;
|
||||
Shape(
|
||||
using Shared = std::shared_ptr<const ARTShape>;
|
||||
ARTShape(
|
||||
Float opacity,
|
||||
std::vector<Float> transform,
|
||||
std::vector<Float> d,
|
||||
|
@ -32,7 +32,7 @@ class Shape : public Element {
|
|||
Float strokeWidth,
|
||||
int strokeCap,
|
||||
int strokeJoin)
|
||||
: Element(ARTElement::Shape, opacity, transform),
|
||||
: ARTElement(ARTElementType::Shape, opacity, transform),
|
||||
d(d),
|
||||
stroke(stroke),
|
||||
strokeDash(strokeDash),
|
||||
|
@ -40,8 +40,8 @@ class Shape : public Element {
|
|||
strokeWidth(strokeWidth),
|
||||
strokeCap(strokeCap),
|
||||
strokeJoin(strokeJoin){};
|
||||
Shape() = default;
|
||||
virtual ~Shape(){};
|
||||
ARTShape() = default;
|
||||
virtual ~ARTShape(){};
|
||||
|
||||
std::vector<Float> d{};
|
||||
std::vector<Float> stroke{};
|
|
@ -5,15 +5,15 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <react/components/art/Shape.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTText.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/conversions.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
#ifdef ANDROID
|
||||
folly::dynamic Shape::getDynamic() const {
|
||||
folly::dynamic ARTText::getDynamic() const {
|
||||
return toDynamic(*this);
|
||||
}
|
||||
#endif
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/Shape.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTShape.h>
|
||||
#include <react/components/art/primitives.h>
|
||||
#include <react/graphics/Geometry.h>
|
||||
#include <functional>
|
||||
|
@ -21,10 +21,10 @@ namespace react {
|
|||
/*
|
||||
* Simple, cross-platfrom, React-specific implementation of ART Text Element
|
||||
*/
|
||||
class Text : public Shape {
|
||||
class ARTText : public ARTShape {
|
||||
public:
|
||||
using Shared = std::shared_ptr<const Text>;
|
||||
Text(
|
||||
using ARTShared = std::shared_ptr<const ARTText>;
|
||||
ARTText(
|
||||
Float opacity,
|
||||
std::vector<Float> transform,
|
||||
std::vector<Float> d,
|
||||
|
@ -36,7 +36,7 @@ class Text : public Shape {
|
|||
int strokeJoin,
|
||||
ARTTextAlignment alignment,
|
||||
ARTTextFrame frame)
|
||||
: Shape(
|
||||
: ARTShape(
|
||||
opacity,
|
||||
transform,
|
||||
d,
|
||||
|
@ -47,9 +47,11 @@ class Text : public Shape {
|
|||
strokeCap,
|
||||
strokeJoin),
|
||||
alignment(alignment),
|
||||
frame(frame){};
|
||||
Text() = default;
|
||||
virtual ~Text(){};
|
||||
frame(frame){
|
||||
// elementType = ARTElementType::Text;
|
||||
};
|
||||
ARTText() = default;
|
||||
virtual ~ARTText(){};
|
||||
|
||||
ARTTextAlignment alignment{ARTTextAlignment::Default};
|
||||
ARTTextFrame frame{};
|
|
@ -15,7 +15,7 @@
|
|||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
enum class ARTElement { Shape, Text, Group };
|
||||
enum class ARTElementType { Shape, Text, Group };
|
||||
|
||||
enum class ARTTextAlignment { Default, Right, Center };
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ Content const &ARTSurfaceViewShadowNode::getContent() const {
|
|||
return content_.value();
|
||||
}
|
||||
ensureUnsealed();
|
||||
auto elements = Element::ListOfShared{};
|
||||
auto elements = ARTElement::ListOfShared{};
|
||||
ARTBaseShadowNode::buildElements(*this, elements);
|
||||
content_ = Content{elements};
|
||||
return content_.value();
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTSurfaceViewProps.h>
|
||||
#include <react/components/art/ARTSurfaceViewState.h>
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/view/ConcreteViewShadowNode.h>
|
||||
#include <react/core/ConcreteShadowNode.h>
|
||||
#include <react/core/LayoutContext.h>
|
||||
|
@ -42,7 +42,7 @@ class ARTSurfaceViewShadowNode : public ConcreteViewShadowNode<
|
|||
|
||||
class Content final {
|
||||
public:
|
||||
Element::ListOfShared elements{};
|
||||
ARTElement::ListOfShared elements{};
|
||||
};
|
||||
|
||||
void layout(LayoutContext layoutContext) override;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <react/components/art/Element.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <folly/dynamic.h>
|
||||
|
@ -21,10 +21,10 @@ namespace react {
|
|||
*/
|
||||
class ARTSurfaceViewState final {
|
||||
public:
|
||||
Element::ListOfShared elements{};
|
||||
ARTElement::ListOfShared elements{};
|
||||
|
||||
#ifdef ANDROID
|
||||
ARTSurfaceViewState(Element::ListOfShared const &elements)
|
||||
ARTSurfaceViewState(ARTElement::ListOfShared const &elements)
|
||||
: elements(elements) {}
|
||||
ARTSurfaceViewState() = default;
|
||||
ARTSurfaceViewState(
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
|
||||
#include "ARTTextShadowNode.h"
|
||||
#include <Glog/logging.h>
|
||||
#include <react/components/art/Text.h>
|
||||
#include <react/components/art/ARTText.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern const char ARTTextComponentName[] = "ARTText";
|
||||
|
||||
Element::Shared ARTTextShadowNode::getElement() const {
|
||||
ARTElement::Shared ARTTextShadowNode::getARTElement() const {
|
||||
auto props = getConcreteProps();
|
||||
return std::make_shared<Text>(
|
||||
return std::make_shared<ARTText>(
|
||||
props.opacity,
|
||||
props.transform,
|
||||
props.d,
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <react/components/art/ARTBaseShadowNode.h>
|
||||
#include <react/components/art/ARTElement.h>
|
||||
#include <react/components/art/ARTText.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 {
|
||||
|
@ -27,7 +27,7 @@ class ARTTextShadowNode
|
|||
public:
|
||||
using ConcreteShadowNode::ConcreteShadowNode;
|
||||
|
||||
virtual Element::Shared getElement() const override;
|
||||
virtual ARTElement::Shared getARTElement() const override;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
Загрузка…
Ссылка в новой задаче