From e85f2e25478b7bdd76fccf2e78c9502854a70ed6 Mon Sep 17 00:00:00 2001 From: Vincent Riemer Date: Thu, 7 Apr 2022 14:07:58 -0700 Subject: [PATCH] Add ObjC feature flag for dispatching w3c pointer events Summary: Changelog: [Internal] Set up iOS feature flag for w3c pointer event dispatch Reviewed By: lunaleaps Differential Revision: D35233280 fbshipit-source-id: de439d9bbad4d5d2010a8ca3b99dd46c9a33946c --- React/Base/RCTConstants.h | 6 ++++++ React/Base/RCTConstants.m | 15 +++++++++++++++ React/Fabric/RCTSurfacePresenter.mm | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/React/Base/RCTConstants.h b/React/Base/RCTConstants.h index 14a5263f83a..cc51b2e780f 100644 --- a/React/Base/RCTConstants.h +++ b/React/Base/RCTConstants.h @@ -15,3 +15,9 @@ RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollec */ RCT_EXTERN BOOL RCTExperimentGetPreemptiveViewAllocationDisabled(void); RCT_EXTERN void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value); + +/* + * W3C Pointer Events + */ +RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void); +RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value); diff --git a/React/Base/RCTConstants.m b/React/Base/RCTConstants.m index 8d1e308acd9..75b76d708f7 100644 --- a/React/Base/RCTConstants.m +++ b/React/Base/RCTConstants.m @@ -24,3 +24,18 @@ void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value) { RCTExperimentPreemptiveViewAllocationDisabled = value; } + +/* + * W3C Pointer Events + */ +static BOOL RCTDispatchW3CPointerEvents = NO; + +BOOL RCTGetDispatchW3CPointerEvents() +{ + return RCTDispatchW3CPointerEvents; +} + +void RCTSetDispatchW3CPointerEvents(BOOL value) +{ + RCTDispatchW3CPointerEvents = value; +} diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 59937990722..8ccc496c3de 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -269,6 +269,10 @@ static BackgroundExecutor RCTGetBackgroundExecutor() RCTExperimentSetPreemptiveViewAllocationDisabled(YES); } + if (reactNativeConfig && reactNativeConfig->getBool("rn_convergence:dispatch_pointer_events")) { + RCTSetDispatchW3CPointerEvents(YES); + } + auto componentRegistryFactory = [factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)]( EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) {