Skip to content

Commit

Permalink
PointerEvents: Remove '2' suffix
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal] - We can now remove the '2' suffix as we had an internal implementation that was not truly aligned with W3C pointers but used the same name. We have aligned the internal types to match w3c so we can now remove the suffix that differentiates them.

Reviewed By: vincentriemer

Differential Revision: D37545813

fbshipit-source-id: 6f2336ae9e314066c340161113268c1f28621a71
  • Loading branch information
Luna Wei authored and facebook-github-bot committed Jul 6, 2022
1 parent 22a067b commit 8be49e8
Show file tree
Hide file tree
Showing 19 changed files with 145 additions and 203 deletions.
11 changes: 3 additions & 8 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,17 @@ type MouseEventProps = $ReadOnly<{|
// Experimental/Work in Progress Pointer Event Callbacks (not yet ready for use)
type PointerEventProps = $ReadOnly<{|
onPointerEnter?: ?(event: PointerEvent) => void,
onPointerEnterCapture?: ?(event: PointerEvent) => void,
onPointerLeave?: ?(event: PointerEvent) => void,
onPointerLeaveCapture?: ?(event: PointerEvent) => void,
onPointerMove?: ?(event: PointerEvent) => void,
onPointerMoveCapture?: ?(event: PointerEvent) => void,
onPointerCancel?: ?(e: PointerEvent) => void,
onPointerCancelCapture?: ?(e: PointerEvent) => void,
onPointerDown?: ?(e: PointerEvent) => void,
onPointerDownCapture?: ?(e: PointerEvent) => void,
onPointerUp?: ?(e: PointerEvent) => void,
onPointerUpCapture?: ?(e: PointerEvent) => void,

// FIXME: these events are temporary while we converge pointer event handling
onPointerEnter2?: ?(e: PointerEvent) => void,
onPointerEnter2Capture?: ?(e: PointerEvent) => void,
onPointerLeave2?: ?(e: PointerEvent) => void,
onPointerLeave2Capture?: ?(e: PointerEvent) => void,
onPointerMove2?: ?(e: PointerEvent) => void,
onPointerMove2Capture?: ?(e: PointerEvent) => void,
|}>;

type TouchEventProps = $ReadOnly<{|
Expand Down
27 changes: 9 additions & 18 deletions Libraries/NativeComponent/BaseViewConfig.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ const bubblingEventTypes = {
bubbled: 'onPointerDown',
},
},
topPointerEnter2: {
topPointerEnter: {
phasedRegistrationNames: {
captured: 'onPointerEnter2Capture',
bubbled: 'onPointerEnter2',
captured: 'onPointerEnterCapture',
bubbled: 'onPointerEnter',
skipBubbling: true,
},
},
topPointerLeave2: {
topPointerLeave: {
phasedRegistrationNames: {
captured: 'onPointerLeave2Capture',
bubbled: 'onPointerLeave2',
captured: 'onPointerLeaveCapture',
bubbled: 'onPointerLeave',
skipBubbling: true,
},
},
topPointerMove2: {
topPointerMove: {
phasedRegistrationNames: {
captured: 'onPointerMove2Capture',
bubbled: 'onPointerMove2',
captured: 'onPointerMoveCapture',
bubbled: 'onPointerMove',
},
},
topPointerUp: {
Expand All @@ -96,15 +96,6 @@ const directEventTypes = {
topAccessibilityAction: {
registrationName: 'onAccessibilityAction',
},
topPointerEnter: {
registrationName: 'onPointerEnter',
},
topPointerLeave: {
registrationName: 'onPointerLeave',
},
topPointerMove: {
registrationName: 'onPointerMove',
},
onGestureHandlerEvent: DynamicallyInjectedByGestureHandler({
registrationName: 'onGestureHandlerEvent',
}),
Expand Down
24 changes: 12 additions & 12 deletions Libraries/NativeComponent/BaseViewConfig.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ const bubblingEventTypes = {
bubbled: 'onPointerDown',
},
},
topPointerMove2: {
topPointerMove: {
phasedRegistrationNames: {
captured: 'onPointerMove2Capture',
bubbled: 'onPointerMove2',
captured: 'onPointerMoveCapture',
bubbled: 'onPointerMove',
},
},
topPointerUp: {
Expand All @@ -111,17 +111,17 @@ const bubblingEventTypes = {
bubbled: 'onPointerUp',
},
},
topPointerEnter2: {
topPointerEnter: {
phasedRegistrationNames: {
captured: 'onPointerEnter2Capture',
bubbled: 'onPointerEnter2',
captured: 'onPointerEnterCapture',
bubbled: 'onPointerEnter',
skipBubbling: true,
},
},
topPointerLeave2: {
topPointerLeave: {
phasedRegistrationNames: {
captured: 'onPointerLeave2Capture',
bubbled: 'onPointerLeave2',
captured: 'onPointerLeaveCapture',
bubbled: 'onPointerLeave',
skipBubbling: true,
},
},
Expand Down Expand Up @@ -324,9 +324,9 @@ const validAttributesForEventProps = ConditionallyIgnoredEventHandlers({
onPointerUp: true,
onPointerDown: true,
onPointerCancel: true,
onPointerEnter2: true,
onPointerMove2: true,
onPointerLeave2: true,
onPointerEnter: true,
onPointerMove: true,
onPointerLeave: true,
onPointerOver: true,
onPointerOut: true,
});
Expand Down
12 changes: 6 additions & 6 deletions Libraries/Pressability/Pressability.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ export type EventHandlers = $ReadOnly<{|
onFocus: (event: FocusEvent) => void,
onMouseEnter?: (event: MouseEvent) => void,
onMouseLeave?: (event: MouseEvent) => void,
onPointerEnter2?: (event: PointerEvent) => void,
onPointerLeave2?: (event: PointerEvent) => void,
onPointerEnter?: (event: PointerEvent) => void,
onPointerLeave?: (event: PointerEvent) => void,
onResponderGrant: (event: PressEvent) => void,
onResponderMove: (event: PressEvent) => void,
onResponderRelease: (event: PressEvent) => void,
Expand Down Expand Up @@ -557,12 +557,12 @@ export default class Pressability {
ReactNativeFeatureFlags.shouldPressibilityUseW3CPointerEventsForHover()
) {
const hoverPointerEvents = {
onPointerEnter2: undefined,
onPointerLeave2: undefined,
onPointerEnter: undefined,
onPointerLeave: undefined,
};
const {onHoverIn, onHoverOut} = this._config;
if (onHoverIn != null) {
hoverPointerEvents.onPointerEnter2 = (event: PointerEvent) => {
hoverPointerEvents.onPointerEnter = (event: PointerEvent) => {
this._isHovered = true;
this._cancelHoverOutDelayTimeout();
if (onHoverIn != null) {
Expand All @@ -579,7 +579,7 @@ export default class Pressability {
};
}
if (onHoverOut != null) {
hoverPointerEvents.onPointerLeave2 = (event: PointerEvent) => {
hoverPointerEvents.onPointerLeave = (event: PointerEvent) => {
if (this._isHovered) {
this._isHovered = false;
this._cancelHoverInDelayTimeout();
Expand Down
14 changes: 7 additions & 7 deletions React/Fabric/RCTSurfaceTouchHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ - (void)_dispatchActiveTouches:(std::vector<ActiveTouch>)activeTouches eventType
activeTouch.eventEmitter->onPointerDown(pointerEvent);
break;
case RCTTouchEventTypeTouchMove:
activeTouch.eventEmitter->onPointerMove2(pointerEvent);
activeTouch.eventEmitter->onPointerMove(pointerEvent);
break;
case RCTTouchEventTypeTouchEnd:
activeTouch.eventEmitter->onPointerUp(pointerEvent);
Expand Down Expand Up @@ -674,22 +674,22 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))

for (UIView *componentView in [eventPathViews reverseObjectEnumerator]) {
BOOL shouldEmitEvent =
hasParentEnterListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerEnter2);
hasParentEnterListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerEnter);

if (shouldEmitEvent && ![_currentlyHoveredViews containsObject:componentView]) {
SharedTouchEventEmitter eventEmitter =
GetTouchEmitterFromView(componentView, [recognizer locationInView:componentView]);
if (eventEmitter != nil) {
PointerEvent event = CreatePointerEventFromIncompleteHoverData(componentView, clientLocation, timestamp);
eventEmitter->onPointerEnter2(event);
eventEmitter->onPointerEnter(event);
}
}

if (shouldEmitEvent && !hasParentEnterListener) {
hasParentEnterListener = YES;
}

if (!hasMoveListenerInEventPath && IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerMove2)) {
if (!hasMoveListenerInEventPath && IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerMove)) {
hasMoveListenerInEventPath = YES;
}
}
Expand All @@ -699,7 +699,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
SharedTouchEventEmitter eventEmitter = GetTouchEmitterFromView(targetView, [recognizer locationInView:targetView]);
if (eventEmitter != nil) {
PointerEvent event = CreatePointerEventFromIncompleteHoverData(targetView, clientLocation, timestamp);
eventEmitter->onPointerMove2(event);
eventEmitter->onPointerMove(event);
}
}

Expand All @@ -725,7 +725,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
BOOL hasParentLeaveListener = NO;
for (UIView *componentView in [_currentlyHoveredViews reverseObjectEnumerator]) {
BOOL shouldEmitEvent =
hasParentLeaveListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerLeave2);
hasParentLeaveListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerLeave);

if (shouldEmitEvent && ![eventPathViews containsObject:componentView]) {
[viewsToEmitLeaveEventsTo addObject:componentView];
Expand All @@ -741,7 +741,7 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
GetTouchEmitterFromView(componentView, [recognizer locationInView:componentView]);
if (eventEmitter != nil) {
PointerEvent event = CreatePointerEventFromIncompleteHoverData(componentView, clientLocation, timestamp);
eventEmitter->onPointerLeave2(event);
eventEmitter->onPointerLeave(event);
}
}

Expand Down
6 changes: 3 additions & 3 deletions React/Views/RCTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
*/
@property (nonatomic, assign) RCTBubblingEventBlock onPointerCancel;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerDown;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerMove2;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerMove;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerUp;
@property (nonatomic, assign) RCTCapturingEventBlock onPointerEnter2;
@property (nonatomic, assign) RCTCapturingEventBlock onPointerLeave2;
@property (nonatomic, assign) RCTCapturingEventBlock onPointerEnter;
@property (nonatomic, assign) RCTCapturingEventBlock onPointerLeave;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerOver;
@property (nonatomic, assign) RCTBubblingEventBlock onPointerOut;

Expand Down
6 changes: 3 additions & 3 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ - (RCTShadowView *)shadowView
// Experimental/WIP Pointer Events (not yet ready for use)
RCT_EXPORT_VIEW_PROPERTY(onPointerCancel, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerDown, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerMove2, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerMove, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerUp, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerEnter2, RCTCapturingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerLeave2, RCTCapturingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerEnter, RCTCapturingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerLeave, RCTCapturingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerOver, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPointerOut, RCTBubblingEventBlock)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ constexpr MapBuffer::Key VP_SHADOW_COLOR = 31;
constexpr MapBuffer::Key VP_TEST_ID = 32;
constexpr MapBuffer::Key VP_TRANSFORM = 33;
constexpr MapBuffer::Key VP_ZINDEX = 34;
constexpr MapBuffer::Key VP_POINTER_ENTER2 = 35;
constexpr MapBuffer::Key VP_POINTER_LEAVE2 = 36;
constexpr MapBuffer::Key VP_POINTER_MOVE2 = 37;
constexpr MapBuffer::Key VP_POINTER_ENTER2_CAPTURE = 38;
constexpr MapBuffer::Key VP_POINTER_LEAVE2_CAPTURE = 39;
constexpr MapBuffer::Key VP_POINTER_MOVE2_CAPTURE = 40;
constexpr MapBuffer::Key VP_POINTER_ENTER_CAPTURE = 38;
constexpr MapBuffer::Key VP_POINTER_LEAVE_CAPTURE = 39;
constexpr MapBuffer::Key VP_POINTER_MOVE_CAPTURE = 40;

// Yoga values
constexpr MapBuffer::Key YG_BORDER_WIDTH = 100;
Expand Down Expand Up @@ -470,20 +467,20 @@ static inline MapBuffer viewPropsDiff(
VP_POINTER_MOVE, newProps.events[ViewEvents::Offset::PointerMove]);

builder.putBool(
VP_POINTER_ENTER2, newProps.events[ViewEvents::Offset::PointerEnter2]);
VP_POINTER_ENTER, newProps.events[ViewEvents::Offset::PointerEnter]);
builder.putBool(
VP_POINTER_ENTER2_CAPTURE,
newProps.events[ViewEvents::Offset::PointerEnter2Capture]);
VP_POINTER_ENTER_CAPTURE,
newProps.events[ViewEvents::Offset::PointerEnterCapture]);
builder.putBool(
VP_POINTER_LEAVE2, newProps.events[ViewEvents::Offset::PointerLeave2]);
VP_POINTER_LEAVE, newProps.events[ViewEvents::Offset::PointerLeave]);
builder.putBool(
VP_POINTER_LEAVE2_CAPTURE,
newProps.events[ViewEvents::Offset::PointerLeave2Capture]);
VP_POINTER_LEAVE_CAPTURE,
newProps.events[ViewEvents::Offset::PointerLeaveCapture]);
builder.putBool(
VP_POINTER_MOVE2, newProps.events[ViewEvents::Offset::PointerMove2]);
VP_POINTER_MOVE, newProps.events[ViewEvents::Offset::PointerMove]);
builder.putBool(
VP_POINTER_MOVE2_CAPTURE,
newProps.events[ViewEvents::Offset::PointerMove2Capture]);
VP_POINTER_MOVE_CAPTURE,
newProps.events[ViewEvents::Offset::PointerMoveCapture]);
}

if (oldProps.removeClippedSubviews != newProps.removeClippedSubviews) {
Expand Down
Loading

0 comments on commit 8be49e8

Please sign in to comment.