From c8ae58880df00bd3408239bf1edae76b1ad63999 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 11 Sep 2019 08:41:53 -0700 Subject: [PATCH] Migrate ARTSurfaceView to fabric Summary: Migrates ARTSurfaceView to Fabric, This diff only migrates the necessary minimum for RCTVideo component to work. Other ART components are ARTNode, ARTGroup, ARTRenderable, ARTShape and ARTText. Reviewed By: mdvacca Differential Revision: D17181298 fbshipit-source-id: c2656bbcaefde25e37a9e05a64d2691bc2343b67 --- .../ART/RCTARTSurfaceShadowNode.cpp | 15 ++++++++++ .../ART/RCTARTSurfaceShadowNode.h | 28 +++++++++++++++++++ .../RCTARTSurfaceViewComponentDescriptor.h | 21 ++++++++++++++ .../ART/RCTARTSurfaceViewComponentView.h | 15 ++++++++++ .../ART/RCTARTSurfaceViewComponentView.mm | 28 +++++++++++++++++++ .../ART/RCTARTSurfaceViewProps.cpp | 16 +++++++++++ .../ART/RCTARTSurfaceViewProps.h | 22 +++++++++++++++ .../Mounting/RCTComponentViewFactory.mm | 2 ++ 8 files changed, 147 insertions(+) create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.cpp create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.h create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentDescriptor.h create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.h create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.mm create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.cpp create mode 100644 React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.h diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.cpp b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.cpp new file mode 100644 index 00000000000..23ab8657c5a --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.cpp @@ -0,0 +1,15 @@ + +/** + * 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. + */ + +namespace facebook { +namespace react { + +extern const char RCTARTSurfaceViewComponentName[] = "ARTSurfaceView"; + +} // namespace react +} // namespace facebook diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.h b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.h new file mode 100644 index 00000000000..9df7b7ba353 --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceShadowNode.h @@ -0,0 +1,28 @@ + +/** + * 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 "RCTARTSurfaceViewProps.h" + +namespace facebook { +namespace react { + +extern const char RCTARTSurfaceViewComponentName[]; + +/* + * `ShadowNode` for component. + */ +using RCTARTSurfaceShadowNode = ConcreteViewShadowNode< + RCTARTSurfaceViewComponentName, + RCTARTSurfaceViewProps, + ViewEventEmitter>; + +} // namespace react +} // namespace facebook diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentDescriptor.h b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentDescriptor.h new file mode 100644 index 00000000000..def60e01db9 --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentDescriptor.h @@ -0,0 +1,21 @@ + +/** + * 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 "RCTARTSurfaceShadowNode.h" + +namespace facebook { +namespace react { + +using RCTARTSurfaceComponentDescriptor = + ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.h b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.h new file mode 100644 index 00000000000..80037b40ce8 --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.h @@ -0,0 +1,15 @@ +/** + * 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. + */ + +#import + +/** + * UIView class for root component. + */ +@interface RCTARTSurfaceViewComponentView : RCTViewComponentView + +@end diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.mm new file mode 100644 index 00000000000..2a3055f928b --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewComponentView.mm @@ -0,0 +1,28 @@ + +#import "RCTARTSurfaceViewComponentView.h" +#import +#import "RCTARTSurfaceViewComponentDescriptor.h" + +using namespace facebook::react; + +@implementation RCTARTSurfaceViewComponentView { +} + +- (instancetype)initWithFrame:(CGRect)frame +{ + if (self = [super initWithFrame:frame]) { + static const auto defaultProps = std::make_shared(); + _props = defaultProps; + } + + return self; +} + +#pragma mark - RCTComponentViewProtocol + ++ (ComponentDescriptorProvider)componentDescriptorProvider +{ + return concreteComponentDescriptorProvider(); +} + +@end diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.cpp b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.cpp new file mode 100644 index 00000000000..0837109bd58 --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.cpp @@ -0,0 +1,16 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +#include "RCTARTSurfaceViewProps.h" + +#include + +namespace facebook { +namespace react { + +RCTARTSurfaceViewProps::RCTARTSurfaceViewProps( + const RCTARTSurfaceViewProps &sourceProps, + const RawProps &rawProps) + : ViewProps(sourceProps, rawProps) {} + +} // namespace react +} // namespace facebook diff --git a/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.h b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.h new file mode 100644 index 00000000000..ebe73d755de --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/ART/RCTARTSurfaceViewProps.h @@ -0,0 +1,22 @@ + +// Copyright 2004-present Facebook. All Rights Reserved. + +#pragma once + +#include + +namespace facebook { +namespace react { + +class RCTARTSurfaceViewProps final : public ViewProps { + public: + RCTARTSurfaceViewProps() = default; + RCTARTSurfaceViewProps( + const RCTARTSurfaceViewProps &sourceProps, + const RawProps &rawProps); + +#pragma mark - Props +}; + +} // namespace react +} // namespace facebook diff --git a/React/Fabric/Mounting/RCTComponentViewFactory.mm b/React/Fabric/Mounting/RCTComponentViewFactory.mm index 4a2d9703d31..902775726bb 100644 --- a/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -14,6 +14,7 @@ #import #import +#import "RCTARTSurfaceViewComponentView.h" #import "RCTActivityIndicatorViewComponentView.h" #import "RCTImageComponentView.h" #import "RCTModalHostViewComponentView.h" @@ -49,6 +50,7 @@ using namespace facebook::react; [componentViewFactory registerComponentViewClass:[RCTSwitchComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTUnimplementedNativeComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTModalHostViewComponentView class]]; + [componentViewFactory registerComponentViewClass:[RCTARTSurfaceViewComponentView class]]; return componentViewFactory; }