From d49ebbcf6278ef54739be0f99b43c743d898a582 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sat, 9 Jun 2018 13:02:55 -0700 Subject: [PATCH] Fabric: All *EventHandlers were renamed to *EventEmitter Summary: Using `EventHandlers` name was a bad idea, and I cannot tolerate it anymore. The worst part of it is that when you have a collection of `EventHandlers` objects you cannot use plural word to describe it because `EventHandlers` is an already plural word. And, this object is actually an event emitter, the thing on which we call events. Reviewed By: fkgozali Differential Revision: D8247723 fbshipit-source-id: b3303a4b9529bd6d32bb8ca0378287ebefaedda8 --- .../ScrollView/RCTScrollViewComponentView.mm | 20 ++++++------- .../View/RCTViewComponentView.h | 6 ++-- .../View/RCTViewComponentView.mm | 18 +++++------ ...tem.h => RCTUpdateEventEmitterMountItem.h} | 6 ++-- ...m.mm => RCTUpdateEventEmitterMountItem.mm} | 12 ++++---- .../Mounting/RCTComponentViewProtocol.h | 6 ++-- React/Fabric/Mounting/RCTMountingManager.mm | 18 +++++------ .../Mounting/UIView+ComponentViewProtocol.h | 2 +- .../Mounting/UIView+ComponentViewProtocol.mm | 2 +- React/Fabric/RCTSurfaceTouchHandler.mm | 30 +++++++++---------- .../componentdescriptor/ComponentDescriptor.h | 8 ++--- .../ConcreteComponentDescriptor.h | 22 +++++++------- .../fabric/core/events/EventDispatcher.h | 2 +- .../{EventHandlers.cpp => EventEmitter.cpp} | 12 ++++---- .../{EventHandlers.h => EventEmitter.h} | 10 +++---- .../core/shadownode/ConcreteShadowNode.h | 14 ++++----- .../fabric/core/shadownode/ShadowNode.cpp | 16 +++++----- .../fabric/core/shadownode/ShadowNode.h | 12 ++++---- .../fabric/core/tests/ShadowNodeTest.cpp | 6 ++-- ...andlers.cpp => ScrollViewEventEmitter.cpp} | 14 ++++----- ...entHandlers.h => ScrollViewEventEmitter.h} | 14 ++++----- .../fabric/scrollview/ScrollViewShadowNode.h | 4 +-- .../fabric/uimanager/FabricUIManager.cpp | 10 +++---- ReactCommon/fabric/uimanager/ShadowTree.cpp | 14 ++++----- .../fabric/view/ConcreteViewShadowNode.h | 22 +++++++------- ...EventHandlers.cpp => ViewEventEmitter.cpp} | 18 +++++------ ...ViewEventHandlers.h => ViewEventEmitter.h} | 12 ++++---- ReactCommon/fabric/view/ViewShadowNode.h | 2 +- 28 files changed, 166 insertions(+), 166 deletions(-) rename React/Fabric/Mounting/MountItems/{RCTUpdateEventHandlersMountItem.h => RCTUpdateEventEmitterMountItem.h} (68%) rename React/Fabric/Mounting/MountItems/{RCTUpdateEventHandlersMountItem.mm => RCTUpdateEventEmitterMountItem.mm} (65%) rename ReactCommon/fabric/core/events/{EventHandlers.cpp => EventEmitter.cpp} (80%) rename ReactCommon/fabric/core/events/{EventHandlers.h => EventEmitter.h} (83%) rename ReactCommon/fabric/scrollview/{ScrollViewEventHandlers.cpp => ScrollViewEventEmitter.cpp} (69%) rename ReactCommon/fabric/scrollview/{ScrollViewEventHandlers.h => ScrollViewEventEmitter.h} (77%) rename ReactCommon/fabric/view/{ViewEventHandlers.cpp => ViewEventEmitter.cpp} (79%) rename ReactCommon/fabric/view/{ViewEventHandlers.h => ViewEventEmitter.h} (92%) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index e3b157a57..90e47e77f 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -11,7 +11,7 @@ #import #import #import -#import +#import #import "RCTConversions.h" #import "RCTEnhancedScrollView.h" @@ -135,47 +135,47 @@ using namespace facebook::react; - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onScroll([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScroll([self _scrollViewMetrics]); } - (void)scrollViewDidZoom:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onScroll([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScroll([self _scrollViewMetrics]); } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onScrollBeginDrag([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]); } - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset { - std::static_pointer_cast(_eventHandlers)->onScrollEndDrag([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]); } - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onMomentumScrollBegin([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onMomentumScrollBegin([self _scrollViewMetrics]); } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onMomentumScrollEnd([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]); } - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { - std::static_pointer_cast(_eventHandlers)->onMomentumScrollEnd([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onMomentumScrollEnd([self _scrollViewMetrics]); } - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view { - std::static_pointer_cast(_eventHandlers)->onScrollBeginDrag([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScrollBeginDrag([self _scrollViewMetrics]); } - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale { - std::static_pointer_cast(_eventHandlers)->onScrollEndDrag([self _scrollViewMetrics]); + std::static_pointer_cast(_eventEmitter)->onScrollEndDrag([self _scrollViewMetrics]); } @end diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h index f0d482347..73c3302a6 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h @@ -9,10 +9,10 @@ #import #import -#import +#import #import #import -#import +#import NS_ASSUME_NONNULL_BEGIN @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @protected facebook::react::LayoutMetrics _layoutMetrics; facebook::react::SharedProps _props; - facebook::react::SharedViewEventHandlers _eventHandlers; + facebook::react::SharedViewEventEmitter _eventEmitter; } @end diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index fb688d031..f6e74eda4 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -8,7 +8,7 @@ #import "RCTViewComponentView.h" #import -#import +#import using namespace facebook::react; @@ -33,10 +33,10 @@ using namespace facebook::react; // TODO: Implement all sutable non-layout props. } -- (void)updateEventHandlers:(SharedEventHandlers)eventHandlers +- (void)updateEventEmitter:(SharedEventEmitter)eventEmitter { - assert(std::dynamic_pointer_cast(eventHandlers)); - _eventHandlers = std::static_pointer_cast(eventHandlers); + assert(std::dynamic_pointer_cast(eventEmitter)); + _eventEmitter = std::static_pointer_cast(eventEmitter); } - (void)updateLayoutMetrics:(LayoutMetrics)layoutMetrics @@ -51,25 +51,25 @@ using namespace facebook::react; - (BOOL)accessibilityActivate { - _eventHandlers->onAccessibilityTap(); + _eventEmitter->onAccessibilityTap(); return YES; } - (BOOL)accessibilityPerformMagicTap { - _eventHandlers->onAccessibilityMagicTap(); + _eventEmitter->onAccessibilityMagicTap(); return YES; } - (BOOL)didActivateAccessibilityCustomAction:(UIAccessibilityCustomAction *)action { - _eventHandlers->onAccessibilityAction([action.name cStringUsingEncoding:NSASCIIStringEncoding]); + _eventEmitter->onAccessibilityAction([action.name cStringUsingEncoding:NSASCIIStringEncoding]); return YES; } -- (SharedEventHandlers)touchEventHandlers +- (SharedEventEmitter)touchEventEmitter { - return _eventHandlers; + return _eventEmitter; } @end diff --git a/React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.h b/React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.h similarity index 68% rename from React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.h rename to React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.h index dd11971b8..7db403b1d 100644 --- a/React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.h +++ b/React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.h @@ -9,17 +9,17 @@ #import #import -#import +#import NS_ASSUME_NONNULL_BEGIN /** * Updates event handlers of a component view. */ -@interface RCTUpdateEventHandlersMountItem : NSObject +@interface RCTUpdateEventEmitterMountItem : NSObject - (instancetype)initWithTag:(ReactTag)tag - eventHandlers:(facebook::react::SharedEventHandlers)eventHandlers; + eventEmitter:(facebook::react::SharedEventEmitter)eventEmitter; @end diff --git a/React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.mm b/React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.mm similarity index 65% rename from React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.mm rename to React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.mm index cc3066b05..18de9cc3a 100644 --- a/React/Fabric/Mounting/MountItems/RCTUpdateEventHandlersMountItem.mm +++ b/React/Fabric/Mounting/MountItems/RCTUpdateEventEmitterMountItem.mm @@ -5,23 +5,23 @@ * LICENSE file in the root directory of this source tree. */ -#import "RCTUpdateEventHandlersMountItem.h" +#import "RCTUpdateEventEmitterMountItem.h" #import "RCTComponentViewRegistry.h" using namespace facebook::react; -@implementation RCTUpdateEventHandlersMountItem { +@implementation RCTUpdateEventEmitterMountItem { ReactTag _tag; - SharedEventHandlers _eventHandlers; + SharedEventEmitter _eventEmitter; } - (instancetype)initWithTag:(ReactTag)tag - eventHandlers:(SharedEventHandlers)eventHandlers + eventEmitter:(SharedEventEmitter)eventEmitter { if (self = [super init]) { _tag = tag; - _eventHandlers = eventHandlers; + _eventEmitter = eventEmitter; } return self; @@ -31,7 +31,7 @@ using namespace facebook::react; { UIView *componentView = [registry componentViewByTag:_tag]; - [componentView updateEventHandlers:_eventHandlers]; + [componentView updateEventEmitter:_eventEmitter]; } @end diff --git a/React/Fabric/Mounting/RCTComponentViewProtocol.h b/React/Fabric/Mounting/RCTComponentViewProtocol.h index 47048efa1..a426bfd08 100644 --- a/React/Fabric/Mounting/RCTComponentViewProtocol.h +++ b/React/Fabric/Mounting/RCTComponentViewProtocol.h @@ -7,7 +7,7 @@ #import -#import +#import #import #import #import @@ -55,10 +55,10 @@ NS_ASSUME_NONNULL_BEGIN /* * Called for updating component's event handlers set. - * Receiver must cache `eventHandlers` object inside and use it for emitting + * Receiver must cache `eventEmitter` object inside and use it for emitting * events when needed. */ -- (void)updateEventHandlers:(facebook::react::SharedEventHandlers)eventHandlers; +- (void)updateEventEmitter:(facebook::react::SharedEventEmitter)eventEmitter; /* * Called for updating component's layout metrics. diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 93e8f0ea8..8df452c0c 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -20,7 +20,7 @@ #import "RCTInsertMountItem.h" #import "RCTRemoveMountItem.h" #import "RCTUpdatePropsMountItem.h" -#import "RCTUpdateEventHandlersMountItem.h" +#import "RCTUpdateEventEmitterMountItem.h" #import "RCTUpdateLocalDataMountItem.h" #import "RCTUpdateLayoutMetricsMountItem.h" @@ -71,9 +71,9 @@ using namespace facebook::react; oldProps:nullptr newProps:instruction.getNewChildNode()->getProps()]]; - // EventHandlers - [mountItems addObject:[[RCTUpdateEventHandlersMountItem alloc] initWithTag:instruction.getNewChildNode()->getTag() - eventHandlers:instruction.getNewChildNode()->getEventHandlers()]]; + // EventEmitter + [mountItems addObject:[[RCTUpdateEventEmitterMountItem alloc] initWithTag:instruction.getNewChildNode()->getTag() + eventEmitter:instruction.getNewChildNode()->getEventEmitter()]]; // LocalData if (instruction.getNewChildNode()->getLocalData()) { @@ -124,11 +124,11 @@ using namespace facebook::react; [mountItems addObject:mountItem]; } - // EventHandlers - if (oldShadowNode->getEventHandlers() != newShadowNode->getEventHandlers()) { - RCTUpdateEventHandlersMountItem *mountItem = - [[RCTUpdateEventHandlersMountItem alloc] initWithTag:instruction.getOldChildNode()->getTag() - eventHandlers:instruction.getOldChildNode()->getEventHandlers()]; + // EventEmitter + if (oldShadowNode->getEventEmitter() != newShadowNode->getEventEmitter()) { + RCTUpdateEventEmitterMountItem *mountItem = + [[RCTUpdateEventEmitterMountItem alloc] initWithTag:instruction.getOldChildNode()->getTag() + eventEmitter:instruction.getOldChildNode()->getEventEmitter()]; [mountItems addObject:mountItem]; } diff --git a/React/Fabric/Mounting/UIView+ComponentViewProtocol.h b/React/Fabric/Mounting/UIView+ComponentViewProtocol.h index 75524cef7..61c981b59 100644 --- a/React/Fabric/Mounting/UIView+ComponentViewProtocol.h +++ b/React/Fabric/Mounting/UIView+ComponentViewProtocol.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateProps:(facebook::react::SharedProps)props oldProps:(facebook::react::SharedProps)oldProps; -- (void)updateEventHandlers:(facebook::react::SharedEventHandlers)eventHandlers; +- (void)updateEventEmitter:(facebook::react::SharedEventEmitter)eventEmitter; - (void)updateLocalData:(facebook::react::SharedLocalData)localData oldLocalData:(facebook::react::SharedLocalData)oldLocalData; diff --git a/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm b/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm index 223bb7c9b..eeb645811 100644 --- a/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm +++ b/React/Fabric/Mounting/UIView+ComponentViewProtocol.mm @@ -31,7 +31,7 @@ // Default implementation does nothing. } -- (void)updateEventHandlers:(facebook::react::SharedEventHandlers)eventHandlers +- (void)updateEventEmitter:(facebook::react::SharedEventEmitter)eventEmitter { // Default implementation does nothing. } diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index 09f586646..b668da0d8 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -8,7 +8,7 @@ #import "RCTSurfaceTouchHandler.h" #import -#import +#import #import #import @@ -47,7 +47,7 @@ private: }; @protocol RCTTouchableComponentViewProtocol - - (SharedViewEventHandlers)touchEventHandlers; + - (SharedViewEventEmitter)touchEventEmitter; @end typedef NS_ENUM(NSInteger, RCTTouchEventType) { @@ -59,7 +59,7 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) { struct ActiveTouch { Touch touch; - SharedViewEventHandlers eventHandlers; + SharedViewEventEmitter eventEmitter; struct Hasher { size_t operator()(const ActiveTouch &activeTouch) const { @@ -95,8 +95,8 @@ static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, UIView *rootComponen ActiveTouch activeTouch = {}; - if ([componentView respondsToSelector:@selector(touchEventHandlers)]) { - activeTouch.eventHandlers = [(id)componentView touchEventHandlers]; + if ([componentView respondsToSelector:@selector(touchEventEmitter)]) { + activeTouch.eventEmitter = [(id)componentView touchEventEmitter]; activeTouch.touch.target = (Tag)componentView.tag; } @@ -217,23 +217,23 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action { TouchEvent event = {}; std::unordered_set changedActiveTouches = {}; - std::unordered_set uniqueEventHandlers = {}; + std::unordered_set uniqueEventEmitter = {}; BOOL isEndishEventType = eventType == RCTTouchEventTypeTouchEnd || eventType == RCTTouchEventTypeTouchCancel; for (UITouch *touch in touches) { auto &&activeTouch = _activeTouches[touch]; - if (!activeTouch.eventHandlers) { + if (!activeTouch.eventEmitter) { continue; } changedActiveTouches.insert(activeTouch); event.changedTouches.insert(activeTouch.touch); - uniqueEventHandlers.insert(activeTouch.eventHandlers); + uniqueEventEmitter.insert(activeTouch.eventEmitter); } for (auto &&pair : _activeTouches) { - if (!pair.second.eventHandlers) { + if (!pair.second.eventEmitter) { continue; } @@ -247,27 +247,27 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action event.touches.insert(pair.second.touch); } - for (auto &&eventHandlers : uniqueEventHandlers) { + for (auto &&eventEmitter : uniqueEventEmitter) { event.targetTouches.clear(); for (auto &&pair : _activeTouches) { - if (pair.second.eventHandlers == eventHandlers) { + if (pair.second.eventEmitter == eventEmitter) { event.targetTouches.insert(pair.second.touch); } } switch (eventType) { case RCTTouchEventTypeTouchStart: - eventHandlers->onTouchStart(event); + eventEmitter->onTouchStart(event); break; case RCTTouchEventTypeTouchMove: - eventHandlers->onTouchMove(event); + eventEmitter->onTouchMove(event); break; case RCTTouchEventTypeTouchEnd: - eventHandlers->onTouchEnd(event); + eventEmitter->onTouchEnd(event); break; case RCTTouchEventTypeTouchCancel: - eventHandlers->onTouchCancel(event); + eventEmitter->onTouchCancel(event); break; } } diff --git a/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h index 669f8475f..1718860b4 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h @@ -47,7 +47,7 @@ public: virtual SharedShadowNode createShadowNode( const Tag &tag, const Tag &rootTag, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedProps &props ) const = 0; @@ -57,7 +57,7 @@ public: virtual SharedShadowNode cloneShadowNode( const SharedShadowNode &shadowNode, const SharedProps &props = nullptr, - const SharedEventHandlers &eventHandlers = nullptr, + const SharedEventEmitter &eventEmitter = nullptr, const SharedShadowNodeSharedList &children = nullptr ) const = 0; @@ -81,10 +81,10 @@ public: ) const = 0; /* - * Creates a new `EventHandlers` object compatible with particular type of + * Creates a new `EventEmitter` object compatible with particular type of * shadow nodes. */ - virtual SharedEventHandlers createEventHandlers( + virtual SharedEventEmitter createEventEmitter( const InstanceHandle &instanceHandle, const Tag &tag ) const = 0; diff --git a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h index 8b5ab2ce7..4af3582c1 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h @@ -29,8 +29,8 @@ class ConcreteComponentDescriptor: public ComponentDescriptor { using SharedShadowNodeT = std::shared_ptr; using ConcreteProps = typename ShadowNodeT::ConcreteProps; using SharedConcreteProps = typename ShadowNodeT::SharedConcreteProps; - using ConcreteEventHandlers = typename ShadowNodeT::ConcreteEventHandlers; - using SharedConcreteEventHandlers = typename ShadowNodeT::SharedConcreteEventHandlers; + using ConcreteEventEmitter = typename ShadowNodeT::ConcreteEventEmitter; + using SharedConcreteEventEmitter = typename ShadowNodeT::SharedConcreteEventEmitter; public: ConcreteComponentDescriptor(SharedEventDispatcher eventDispatcher): @@ -58,17 +58,17 @@ public: SharedShadowNode createShadowNode( const Tag &tag, const Tag &rootTag, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedProps &props ) const override { assert(std::dynamic_pointer_cast(props)); - assert(std::dynamic_pointer_cast(eventHandlers)); + assert(std::dynamic_pointer_cast(eventEmitter)); auto &&shadowNode = std::make_shared( tag, rootTag, std::static_pointer_cast(props), - std::static_pointer_cast(eventHandlers), + std::static_pointer_cast(eventEmitter), ShadowNode::emptySharedShadowNodeSharedList(), getCloneFunction() ); @@ -80,7 +80,7 @@ public: SharedShadowNode cloneShadowNode( const SharedShadowNode &sourceShadowNode, const SharedProps &props = nullptr, - const SharedEventHandlers &eventHandlers = nullptr, + const SharedEventEmitter &eventEmitter = nullptr, const SharedShadowNodeSharedList &children = nullptr ) const override { assert(std::dynamic_pointer_cast(sourceShadowNode)); @@ -88,7 +88,7 @@ public: auto &&shadowNode = std::make_shared( std::static_pointer_cast(sourceShadowNode), std::static_pointer_cast(props), - std::static_pointer_cast(eventHandlers), + std::static_pointer_cast(eventEmitter), children ); @@ -112,11 +112,11 @@ public: return ShadowNodeT::Props(rawProps, props); }; - virtual SharedEventHandlers createEventHandlers( + virtual SharedEventEmitter createEventEmitter( const InstanceHandle &instanceHandle, const Tag &tag ) const override { - return std::make_shared(instanceHandle, tag, eventDispatcher_); + return std::make_shared(instanceHandle, tag, eventDispatcher_); } protected: @@ -133,9 +133,9 @@ private: ShadowNodeCloneFunction getCloneFunction() const { if (!cloneFunction_) { - cloneFunction_ = [this](const SharedShadowNode &shadowNode, const SharedProps &props, const SharedEventHandlers &eventHandlers, const SharedShadowNodeSharedList &children) { + cloneFunction_ = [this](const SharedShadowNode &shadowNode, const SharedProps &props, const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children) { assert(std::dynamic_pointer_cast(shadowNode)); - return this->cloneShadowNode(shadowNode, props, eventHandlers, children); + return this->cloneShadowNode(shadowNode, props, eventEmitter, children); }; } diff --git a/ReactCommon/fabric/core/events/EventDispatcher.h b/ReactCommon/fabric/core/events/EventDispatcher.h index 40e5184a2..930a547f4 100644 --- a/ReactCommon/fabric/core/events/EventDispatcher.h +++ b/ReactCommon/fabric/core/events/EventDispatcher.h @@ -21,7 +21,7 @@ using SharedEventDispatcher = std::shared_ptr; /* * Abstract class that represent event-delivery infrastructure. - * Particular `EventHandlers` clases use an object of this class to invoke + * Particular `EventEmitter` clases use an object of this class to invoke * events. */ class EventDispatcher { diff --git a/ReactCommon/fabric/core/events/EventHandlers.cpp b/ReactCommon/fabric/core/events/EventEmitter.cpp similarity index 80% rename from ReactCommon/fabric/core/events/EventHandlers.cpp rename to ReactCommon/fabric/core/events/EventEmitter.cpp index 3d4ecc804..b4b3b8db3 100644 --- a/ReactCommon/fabric/core/events/EventHandlers.cpp +++ b/ReactCommon/fabric/core/events/EventEmitter.cpp @@ -5,23 +5,23 @@ * LICENSE file in the root directory of this source tree. */ -#include "EventHandlers.h" +#include "EventEmitter.h" #include namespace facebook { namespace react { -EventHandlers::EventHandlers(const InstanceHandle &instanceHandle, const Tag &tag, const SharedEventDispatcher &eventDispatcher): +EventEmitter::EventEmitter(const InstanceHandle &instanceHandle, const Tag &tag, const SharedEventDispatcher &eventDispatcher): instanceHandle_(instanceHandle), tag_(tag), eventDispatcher_(eventDispatcher) {} -EventHandlers::~EventHandlers() { +EventEmitter::~EventEmitter() { releaseEventTargetIfNeeded(); } -void EventHandlers::dispatchEvent( +void EventEmitter::dispatchEvent( const std::string &type, const folly::dynamic &payload, const EventPriority &priority @@ -42,7 +42,7 @@ void EventHandlers::dispatchEvent( eventDispatcher->dispatchEvent(eventTarget_, type, extendedPayload, priority); } -void EventHandlers::createEventTargetIfNeeded() const { +void EventEmitter::createEventTargetIfNeeded() const { std::lock_guard lock(mutex_); if (eventTarget_) { @@ -54,7 +54,7 @@ void EventHandlers::createEventTargetIfNeeded() const { eventTarget_ = eventDispatcher->createEventTarget(instanceHandle_); } -void EventHandlers::releaseEventTargetIfNeeded() const { +void EventEmitter::releaseEventTargetIfNeeded() const { std::lock_guard lock(mutex_); if (!eventTarget_) { diff --git a/ReactCommon/fabric/core/events/EventHandlers.h b/ReactCommon/fabric/core/events/EventEmitter.h similarity index 83% rename from ReactCommon/fabric/core/events/EventHandlers.h rename to ReactCommon/fabric/core/events/EventEmitter.h index b55db7dc7..eb05bd1c6 100644 --- a/ReactCommon/fabric/core/events/EventHandlers.h +++ b/ReactCommon/fabric/core/events/EventEmitter.h @@ -17,9 +17,9 @@ namespace facebook { namespace react { -class EventHandlers; +class EventEmitter; -using SharedEventHandlers = std::shared_ptr; +using SharedEventEmitter = std::shared_ptr; /* * Base class for all particular typed event handlers. @@ -28,11 +28,11 @@ using SharedEventHandlers = std::shared_ptr; * * TODO: Reconsider naming of all event-related things. */ -class EventHandlers { +class EventEmitter { public: - EventHandlers(const InstanceHandle &instanceHandle, const Tag &tag, const SharedEventDispatcher &eventDispatcher); - virtual ~EventHandlers(); + EventEmitter(const InstanceHandle &instanceHandle, const Tag &tag, const SharedEventDispatcher &eventDispatcher); + virtual ~EventEmitter(); protected: diff --git a/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h b/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h index 86c0976b8..c4f08a45a 100644 --- a/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h +++ b/ReactCommon/fabric/core/shadownode/ConcreteShadowNode.h @@ -19,15 +19,15 @@ namespace react { * `ConcreteShadowNode` is a default implementation of `ShadowNode` interface * with many handy features. */ -template +template class ConcreteShadowNode: public ShadowNode { static_assert(std::is_base_of::value, "PropsT must be a descendant of Props"); public: using ConcreteProps = PropsT; using SharedConcreteProps = std::shared_ptr; - using ConcreteEventHandlers = EventHandlersT; - using SharedConcreteEventHandlers = std::shared_ptr; + using ConcreteEventEmitter = EventEmitterT; + using SharedConcreteEventEmitter = std::shared_ptr; using SharedConcreteShadowNode = std::shared_ptr; static SharedConcreteProps Props(const RawProps &rawProps, const SharedProps &baseProps = nullptr) { @@ -43,7 +43,7 @@ public: const Tag &tag, const Tag &rootTag, const SharedConcreteProps &props, - const SharedConcreteEventHandlers &eventHandlers, + const SharedConcreteEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children, const ShadowNodeCloneFunction &cloneFunction ): @@ -51,7 +51,7 @@ public: tag, rootTag, (SharedProps)props, - eventHandlers, + eventEmitter, children, cloneFunction ) {}; @@ -59,13 +59,13 @@ public: ConcreteShadowNode( const SharedConcreteShadowNode &shadowNode, const SharedProps &props, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children ): ShadowNode( shadowNode, (SharedProps)props, - eventHandlers, + eventEmitter, children ) {} diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index e18ae2e38..54e1465eb 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -24,14 +24,14 @@ ShadowNode::ShadowNode( const Tag &tag, const Tag &rootTag, const SharedProps &props, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children, const ShadowNodeCloneFunction &cloneFunction ): tag_(tag), rootTag_(rootTag), props_(props), - eventHandlers_(eventHandlers), + eventEmitter_(eventEmitter), children_(std::make_shared(*children)), cloneFunction_(cloneFunction), revision_(1) {} @@ -39,13 +39,13 @@ ShadowNode::ShadowNode( ShadowNode::ShadowNode( const SharedShadowNode &shadowNode, const SharedProps &props, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children ): tag_(shadowNode->tag_), rootTag_(shadowNode->rootTag_), props_(props ? props : shadowNode->props_), - eventHandlers_(eventHandlers ? eventHandlers : shadowNode->eventHandlers_), + eventEmitter_(eventEmitter ? eventEmitter : shadowNode->eventEmitter_), children_(std::make_shared(*(children ? children : shadowNode->children_))), sourceNode_(shadowNode), localData_(shadowNode->localData_), @@ -57,7 +57,7 @@ SharedShadowNode ShadowNode::clone( const SharedShadowNodeSharedList &children ) const { assert(cloneFunction_); - return cloneFunction_(shared_from_this(), props_, eventHandlers_, children_); + return cloneFunction_(shared_from_this(), props_, eventEmitter_, children_); } #pragma mark - Getters @@ -70,8 +70,8 @@ SharedProps ShadowNode::getProps() const { return props_; } -SharedEventHandlers ShadowNode::getEventHandlers() const { - return eventHandlers_; +SharedEventEmitter ShadowNode::getEventEmitter() const { + return eventEmitter_; } Tag ShadowNode::getTag() const { @@ -147,7 +147,7 @@ bool ShadowNode::operator==(const ShadowNode& rhs) const { tag_ == rhs.tag_ && rootTag_ == rhs.rootTag_ && props_ == rhs.props_ && - eventHandlers_ == rhs.eventHandlers_ && + eventEmitter_ == rhs.eventEmitter_ && localData_ == rhs.localData_; } diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.h b/ReactCommon/fabric/core/shadownode/ShadowNode.h index 9fa1b9341..a526fd698 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ using WeakShadowNode = std::weak_ptr; using ShadowNodeCloneFunction = std::function; @@ -50,7 +50,7 @@ public: const Tag &tag, const Tag &rootTag, const SharedProps &props, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children, const ShadowNodeCloneFunction &cloneFunction ); @@ -58,7 +58,7 @@ public: ShadowNode( const SharedShadowNode &shadowNode, const SharedProps &props, - const SharedEventHandlers &eventHandlers, + const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children ); @@ -77,7 +77,7 @@ public: SharedShadowNodeSharedList getChildren() const; SharedProps getProps() const; - SharedEventHandlers getEventHandlers() const; + SharedEventEmitter getEventEmitter() const; Tag getTag() const; Tag getRootTag() const; @@ -143,7 +143,7 @@ protected: Tag tag_; Tag rootTag_; SharedProps props_; - SharedEventHandlers eventHandlers_; + SharedEventEmitter eventEmitter_; SharedShadowNodeSharedList children_; WeakShadowNode sourceNode_; SharedLocalData localData_; diff --git a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp index 7afbafbb5..a1f7d16b6 100644 --- a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp +++ b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp @@ -34,7 +34,7 @@ TEST(ShadowNodeTest, handleShadowNodeCreation) { ASSERT_STREQ(node->getComponentName().c_str(), "Test"); ASSERT_EQ(node->getTag(), 9); ASSERT_EQ(node->getRootTag(), 1); - ASSERT_EQ(node->getEventHandlers(), nullptr); + ASSERT_EQ(node->getEventEmitter(), nullptr); TestShadowNode *nodePtr = node.get(); ASSERT_EQ(node->getComponentHandle(), typeid(*nodePtr).hash_code()); ASSERT_EQ(node->getSourceNode(), nullptr); @@ -54,7 +54,7 @@ TEST(ShadowNodeTest, handleShadowNodeSimpleCloning) { ASSERT_STREQ(node->getComponentName().c_str(), "Test"); ASSERT_EQ(node->getTag(), 9); ASSERT_EQ(node->getRootTag(), 1); - ASSERT_EQ(node->getEventHandlers(), nullptr); + ASSERT_EQ(node->getEventEmitter(), nullptr); ASSERT_EQ(node2->getSourceNode(), node); } @@ -128,7 +128,7 @@ TEST(ShadowNodeTest, handleCloneFunction) { std::make_shared(), nullptr, ShadowNode::emptySharedShadowNodeSharedList(), - [](const SharedShadowNode &shadowNode, const SharedProps &props, const SharedEventHandlers &eventHandlers, const SharedShadowNodeSharedList &children) { + [](const SharedShadowNode &shadowNode, const SharedProps &props, const SharedEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children) { return std::make_shared( std::static_pointer_cast(shadowNode), props, diff --git a/ReactCommon/fabric/scrollview/ScrollViewEventHandlers.cpp b/ReactCommon/fabric/scrollview/ScrollViewEventEmitter.cpp similarity index 69% rename from ReactCommon/fabric/scrollview/ScrollViewEventHandlers.cpp rename to ReactCommon/fabric/scrollview/ScrollViewEventEmitter.cpp index c331f6b03..c416b98b4 100644 --- a/ReactCommon/fabric/scrollview/ScrollViewEventHandlers.cpp +++ b/ReactCommon/fabric/scrollview/ScrollViewEventEmitter.cpp @@ -5,32 +5,32 @@ * LICENSE file in the root directory of this source tree. */ -#include "ScrollViewEventHandlers.h" +#include "ScrollViewEventEmitter.h" namespace facebook { namespace react { -void ScrollViewEventHandlers::onScroll(const ScrollViewMetrics &scrollViewMetrics) const { +void ScrollViewEventEmitter::onScroll(const ScrollViewMetrics &scrollViewMetrics) const { dispatchScrollViewEvent("scroll", scrollViewMetrics); } -void ScrollViewEventHandlers::onScrollBeginDrag(const ScrollViewMetrics &scrollViewMetrics) const { +void ScrollViewEventEmitter::onScrollBeginDrag(const ScrollViewMetrics &scrollViewMetrics) const { dispatchScrollViewEvent("scrollBeginDrag", scrollViewMetrics); } -void ScrollViewEventHandlers::onScrollEndDrag(const ScrollViewMetrics &scrollViewMetrics) const { +void ScrollViewEventEmitter::onScrollEndDrag(const ScrollViewMetrics &scrollViewMetrics) const { dispatchScrollViewEvent("scrollEndDrag", scrollViewMetrics); } -void ScrollViewEventHandlers::onMomentumScrollBegin(const ScrollViewMetrics &scrollViewMetrics) const { +void ScrollViewEventEmitter::onMomentumScrollBegin(const ScrollViewMetrics &scrollViewMetrics) const { dispatchScrollViewEvent("momentumScrollBegin", scrollViewMetrics); } -void ScrollViewEventHandlers::onMomentumScrollEnd(const ScrollViewMetrics &scrollViewMetrics) const { +void ScrollViewEventEmitter::onMomentumScrollEnd(const ScrollViewMetrics &scrollViewMetrics) const { dispatchScrollViewEvent("momentumScrollEnd", scrollViewMetrics); } -void ScrollViewEventHandlers::dispatchScrollViewEvent(const std::string &name, const ScrollViewMetrics &scrollViewMetrics, const folly::dynamic &payload) const { +void ScrollViewEventEmitter::dispatchScrollViewEvent(const std::string &name, const ScrollViewMetrics &scrollViewMetrics, const folly::dynamic &payload) const { folly::dynamic compoundPayload = folly::dynamic::object(); compoundPayload["contentOffset"] = folly::dynamic::object diff --git a/ReactCommon/fabric/scrollview/ScrollViewEventHandlers.h b/ReactCommon/fabric/scrollview/ScrollViewEventEmitter.h similarity index 77% rename from ReactCommon/fabric/scrollview/ScrollViewEventHandlers.h rename to ReactCommon/fabric/scrollview/ScrollViewEventEmitter.h index 8f6a93e72..c9bd52543 100644 --- a/ReactCommon/fabric/scrollview/ScrollViewEventHandlers.h +++ b/ReactCommon/fabric/scrollview/ScrollViewEventEmitter.h @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include @@ -26,16 +26,16 @@ public: Float zoomScale; }; -class ScrollViewEventHandlers; +class ScrollViewEventEmitter; -using SharedScrollViewEventHandlers = std::shared_ptr; +using SharedScrollViewEventEmitter = std::shared_ptr; -class ScrollViewEventHandlers: - public ViewEventHandlers { +class ScrollViewEventEmitter: + public ViewEventEmitter { public: - using ViewEventHandlers::ViewEventHandlers; + using ViewEventEmitter::ViewEventEmitter; void onScroll(const ScrollViewMetrics &scrollViewMetrics) const; void onScrollBeginDrag(const ScrollViewMetrics &scrollViewMetrics) const; diff --git a/ReactCommon/fabric/scrollview/ScrollViewShadowNode.h b/ReactCommon/fabric/scrollview/ScrollViewShadowNode.h index 5a74f0c32..c2db4ed66 100644 --- a/ReactCommon/fabric/scrollview/ScrollViewShadowNode.h +++ b/ReactCommon/fabric/scrollview/ScrollViewShadowNode.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -25,7 +25,7 @@ using SharedScrollViewShadowNode = std::shared_ptr; * `ShadowNode` for component. */ class ScrollViewShadowNode final: - public ConcreteViewShadowNode { + public ConcreteViewShadowNode { public: diff --git a/ReactCommon/fabric/uimanager/FabricUIManager.cpp b/ReactCommon/fabric/uimanager/FabricUIManager.cpp index 41115a191..30df1137c 100644 --- a/ReactCommon/fabric/uimanager/FabricUIManager.cpp +++ b/ReactCommon/fabric/uimanager/FabricUIManager.cpp @@ -134,7 +134,7 @@ SharedShadowNode FabricUIManager::createNode(int tag, std::string viewName, int componentDescriptor->createShadowNode( tag, rootTag, - componentDescriptor->createEventHandlers(instanceHandle, tag), + componentDescriptor->createEventEmitter(instanceHandle, tag), componentDescriptor->cloneProps(nullptr, rawProps) ); @@ -155,7 +155,7 @@ SharedShadowNode FabricUIManager::cloneNode(const SharedShadowNode &shadowNode, componentDescriptor->cloneShadowNode( shadowNode, nullptr, - componentDescriptor->createEventHandlers(instanceHandle, shadowNode->getTag()), + componentDescriptor->createEventEmitter(instanceHandle, shadowNode->getTag()), nullptr ); @@ -172,7 +172,7 @@ SharedShadowNode FabricUIManager::cloneNodeWithNewChildren(const SharedShadowNod componentDescriptor->cloneShadowNode( shadowNode, nullptr, - componentDescriptor->createEventHandlers(instanceHandle, shadowNode->getTag()), + componentDescriptor->createEventEmitter(instanceHandle, shadowNode->getTag()), ShadowNode::emptySharedShadowNodeSharedList() ); @@ -190,7 +190,7 @@ SharedShadowNode FabricUIManager::cloneNodeWithNewProps(const SharedShadowNode & componentDescriptor->cloneShadowNode( shadowNode, componentDescriptor->cloneProps(shadowNode->getProps(), rawProps), - componentDescriptor->createEventHandlers(instanceHandle, shadowNode->getTag()), + componentDescriptor->createEventEmitter(instanceHandle, shadowNode->getTag()), nullptr ); @@ -208,7 +208,7 @@ SharedShadowNode FabricUIManager::cloneNodeWithNewChildrenAndProps(const SharedS componentDescriptor->cloneShadowNode( shadowNode, componentDescriptor->cloneProps(shadowNode->getProps(), rawProps), - componentDescriptor->createEventHandlers(instanceHandle, shadowNode->getTag()), + componentDescriptor->createEventEmitter(instanceHandle, shadowNode->getTag()), ShadowNode::emptySharedShadowNodeSharedList() ); diff --git a/ReactCommon/fabric/uimanager/ShadowTree.cpp b/ReactCommon/fabric/uimanager/ShadowTree.cpp index 140ff8071..bc19c1b32 100644 --- a/ReactCommon/fabric/uimanager/ShadowTree.cpp +++ b/ReactCommon/fabric/uimanager/ShadowTree.cpp @@ -18,12 +18,12 @@ namespace react { ShadowTree::ShadowTree(Tag rootTag): rootTag_(rootTag) { - auto &&noopEventHandlers = std::make_shared(nullptr, rootTag, nullptr); + auto &&noopEventEmitter = std::make_shared(nullptr, rootTag, nullptr); rootShadowNode_ = std::make_shared( rootTag, rootTag, RootShadowNode::defaultSharedProps(), - noopEventHandlers, + noopEventEmitter, ShadowNode::emptySharedShadowNodeSharedList(), nullptr ); @@ -108,11 +108,11 @@ void ShadowTree::emitLayoutEvents(const TreeMutationInstructionList &instruction type == TreeMutationInstruction::Replacement ) { auto &&newShadowNode = instruction.getNewChildNode(); - auto &&eventHandlers = newShadowNode->getEventHandlers(); - auto &&viewEventHandlers = std::dynamic_pointer_cast(eventHandlers); + auto &&eventEmitter = newShadowNode->getEventEmitter(); + auto &&viewEventEmitter = std::dynamic_pointer_cast(eventEmitter); - // Checking if particular shadow node supports `onLayout` event (part of `ViewEventHandlers`). - if (viewEventHandlers) { + // Checking if particular shadow node supports `onLayout` event (part of `ViewEventEmitter`). + if (viewEventEmitter) { // Now we know that both (old and new) shadow nodes must be `LayoutableShadowNode` subclasses. assert(std::dynamic_pointer_cast(newShadowNode)); // TODO(T29661055): Consider using `std::reinterpret_pointer_cast`. @@ -132,7 +132,7 @@ void ShadowTree::emitLayoutEvents(const TreeMutationInstructionList &instruction } } - viewEventHandlers->onLayout(newLayoutableShadowNode->getLayoutMetrics()); + viewEventEmitter->onLayout(newLayoutableShadowNode->getLayoutMetrics()); } } } diff --git a/ReactCommon/fabric/view/ConcreteViewShadowNode.h b/ReactCommon/fabric/view/ConcreteViewShadowNode.h index df1707ea5..dc898dcdd 100644 --- a/ReactCommon/fabric/view/ConcreteViewShadowNode.h +++ b/ReactCommon/fabric/view/ConcreteViewShadowNode.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include @@ -24,9 +24,9 @@ namespace react { * as and similar basic behaviour). * For example: , , but not , . */ -template +template class ConcreteViewShadowNode: - public ConcreteShadowNode, + public ConcreteShadowNode, public AccessibleShadowNode, public YogaLayoutableShadowNode { @@ -38,23 +38,23 @@ public: using ConcreteViewProps = ViewPropsT; using SharedConcreteViewProps = std::shared_ptr; - using ConcreteViewEventHandlers = ViewEventHandlersT; - using SharedConcreteViewEventHandlers = std::shared_ptr; + using ConcreteViewEventEmitter = ViewEventEmitterT; + using SharedConcreteViewEventEmitter = std::shared_ptr; using SharedConcreteViewShadowNode = std::shared_ptr; ConcreteViewShadowNode( const Tag &tag, const Tag &rootTag, const SharedConcreteViewProps &props, - const SharedConcreteViewEventHandlers &eventHandlers, + const SharedConcreteViewEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children, const ShadowNodeCloneFunction &cloneFunction ): - ConcreteShadowNode( + ConcreteShadowNode( tag, rootTag, props, - eventHandlers, + eventEmitter, children, cloneFunction ), @@ -69,13 +69,13 @@ public: ConcreteViewShadowNode( const SharedConcreteViewShadowNode &shadowNode, const SharedConcreteViewProps &props, - const SharedConcreteViewEventHandlers &eventHandlers, + const SharedConcreteViewEventEmitter &eventEmitter, const SharedShadowNodeSharedList &children ): - ConcreteShadowNode( + ConcreteShadowNode( shadowNode, props, - eventHandlers, + eventEmitter, children ), AccessibleShadowNode( diff --git a/ReactCommon/fabric/view/ViewEventHandlers.cpp b/ReactCommon/fabric/view/ViewEventEmitter.cpp similarity index 79% rename from ReactCommon/fabric/view/ViewEventHandlers.cpp rename to ReactCommon/fabric/view/ViewEventEmitter.cpp index 3cdadd352..fe1b246db 100644 --- a/ReactCommon/fabric/view/ViewEventHandlers.cpp +++ b/ReactCommon/fabric/view/ViewEventEmitter.cpp @@ -5,28 +5,28 @@ * LICENSE file in the root directory of this source tree. */ -#include "ViewEventHandlers.h" +#include "ViewEventEmitter.h" namespace facebook { namespace react { #pragma mark - Accessibility -void ViewEventHandlers::onAccessibilityAction(const std::string &name) const { +void ViewEventEmitter::onAccessibilityAction(const std::string &name) const { dispatchEvent("accessibilityAction", folly::dynamic::object("action", name)); } -void ViewEventHandlers::onAccessibilityTap() const { +void ViewEventEmitter::onAccessibilityTap() const { dispatchEvent("accessibilityTap"); } -void ViewEventHandlers::onAccessibilityMagicTap() const { +void ViewEventEmitter::onAccessibilityMagicTap() const { dispatchEvent("magicTap"); } #pragma mark - Layout -void ViewEventHandlers::onLayout(const LayoutMetrics &layoutMetrics) const { +void ViewEventEmitter::onLayout(const LayoutMetrics &layoutMetrics) const { folly::dynamic payload = folly::dynamic::object(); auto &&frame = layoutMetrics.frame; payload["layout"] = folly::dynamic::object @@ -71,19 +71,19 @@ static folly::dynamic touchEventPayload(const TouchEvent &event) { return object; } -void ViewEventHandlers::onTouchStart(const TouchEvent &event) const { +void ViewEventEmitter::onTouchStart(const TouchEvent &event) const { dispatchEvent("touchStart", touchEventPayload(event)); } -void ViewEventHandlers::onTouchMove(const TouchEvent &event) const { +void ViewEventEmitter::onTouchMove(const TouchEvent &event) const { dispatchEvent("touchMove", touchEventPayload(event)); } -void ViewEventHandlers::onTouchEnd(const TouchEvent &event) const { +void ViewEventEmitter::onTouchEnd(const TouchEvent &event) const { dispatchEvent("touchEnd", touchEventPayload(event)); } -void ViewEventHandlers::onTouchCancel(const TouchEvent &event) const { +void ViewEventEmitter::onTouchCancel(const TouchEvent &event) const { dispatchEvent("touchCancel", touchEventPayload(event)); } diff --git a/ReactCommon/fabric/view/ViewEventHandlers.h b/ReactCommon/fabric/view/ViewEventEmitter.h similarity index 92% rename from ReactCommon/fabric/view/ViewEventHandlers.h rename to ReactCommon/fabric/view/ViewEventEmitter.h index 654649ed3..04af2fee6 100644 --- a/ReactCommon/fabric/view/ViewEventHandlers.h +++ b/ReactCommon/fabric/view/ViewEventEmitter.h @@ -8,7 +8,7 @@ #include -#include +#include #include #include @@ -97,16 +97,16 @@ struct TouchEvent { Touches targetTouches; }; -class ViewEventHandlers; +class ViewEventEmitter; -using SharedViewEventHandlers = std::shared_ptr; +using SharedViewEventEmitter = std::shared_ptr; -class ViewEventHandlers: - public EventHandlers { +class ViewEventEmitter: + public EventEmitter { public: - using EventHandlers::EventHandlers; + using EventEmitter::EventEmitter; #pragma mark - Accessibility diff --git a/ReactCommon/fabric/view/ViewShadowNode.h b/ReactCommon/fabric/view/ViewShadowNode.h index 4ad05c83f..a406f34de 100644 --- a/ReactCommon/fabric/view/ViewShadowNode.h +++ b/ReactCommon/fabric/view/ViewShadowNode.h @@ -20,7 +20,7 @@ class ViewShadowNode; using SharedViewShadowNode = std::shared_ptr; class ViewShadowNode final: - public ConcreteViewShadowNode { + public ConcreteViewShadowNode { public: