PointerEvents: Remove '2' suffix

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
This commit is contained in:
Luna Wei
2022-07-05 20:00:42 -07:00
committed by Facebook GitHub Bot
parent 22a067b79e
commit 8be49e8746
19 changed files with 145 additions and 203 deletions
@@ -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;
@@ -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) {
@@ -552,33 +552,32 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onPointerDown", "captured", "onPointerDownCapture")))
.put(
"topPointerEnter2",
"topPointerEnter",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onPointerEnter2",
"onPointerEnter",
"captured",
"onPointerEnter2Capture",
"onPointerEnterCapture",
"skipBubbling",
true)))
.put(
"topPointerLeave2",
"topPointerLeave",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onPointerLeave2",
"onPointerLeave",
"captured",
"onPointerLeave2Capture",
"onPointerLeaveCapture",
"skipBubbling",
true)))
.put(
"topPointerMove2",
"topPointerMove",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled", "onPointerMove2", "captured", "onPointerMove2Capture")))
MapBuilder.of("bubbled", "onPointerMove", "captured", "onPointerMoveCapture")))
.put(
"topPointerUp",
MapBuilder.of(
@@ -632,50 +631,35 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
FLog.w(ReactConstants.TAG, "%s doesn't support property '%s'", getName(), propName);
}
/* Experimental W3C Pointer events start */
@ReactProp(name = "onPointerEnter")
public void setPointerEnter(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_enter, value);
}
@ReactProp(name = "onPointerEnterCapture")
public void setPointerEnterCapture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_enter_capture, value);
}
@ReactProp(name = "onPointerLeave")
public void setPointerLeave(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_leave, value);
}
@ReactProp(name = "onPointerLeaveCapture")
public void setPointerLeaveCapture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_leave_capture, value);
}
@ReactProp(name = "onPointerMove")
public void setPointerMove(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_move, value);
}
/* Experimental W3C Pointer events start */
@ReactProp(name = "onPointerEnter2")
public void setPointerEnter2(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_enter2, value);
}
@ReactProp(name = "onPointerEnter2Capture")
public void setPointerEnter2Capture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_enter2_capture, value);
}
@ReactProp(name = "onPointerLeave2")
public void setPointerLeave2(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_leave2, value);
}
@ReactProp(name = "onPointerLeave2Capture")
public void setPointerLeave2Capture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_leave2_capture, value);
}
@ReactProp(name = "onPointerMove2")
public void setPointerMove2(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_move2, value);
}
@ReactProp(name = "onPointerMove2Capture")
public void setPointerMove2Capture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_move2_capture, value);
@ReactProp(name = "onPointerMoveCapture")
public void setPointerMoveCapture(@NonNull T view, boolean value) {
view.setTag(R.id.pointer_move_capture, value);
}
/* Experimental W3C Pointer events end */
@@ -59,9 +59,6 @@ import java.util.Map;
return MapBuilder.builder()
.put("topContentSizeChange", MapBuilder.of(rn, "onContentSizeChange"))
.put("topLayout", MapBuilder.of(rn, "onLayout"))
.put("topPointerEnter", MapBuilder.of(rn, "onPointerEnter"))
.put("topPointerLeave", MapBuilder.of(rn, "onPointerLeave"))
.put("topPointerMove", MapBuilder.of(rn, "onPointerMove"))
.put("topLoadingError", MapBuilder.of(rn, "onLoadingError"))
.put("topLoadingFinish", MapBuilder.of(rn, "onLoadingFinish"))
.put("topLoadingStart", MapBuilder.of(rn, "onLoadingStart"))
@@ -39,9 +39,9 @@ public class PointerEventHelper {
public static final String POINTER_CANCEL = "topPointerCancel";
public static final String POINTER_DOWN = "topPointerDown";
public static final String POINTER_ENTER = "topPointerEnter2";
public static final String POINTER_LEAVE = "topPointerLeave2";
public static final String POINTER_MOVE = "topPointerMove2";
public static final String POINTER_ENTER = "topPointerEnter";
public static final String POINTER_LEAVE = "topPointerLeave";
public static final String POINTER_MOVE = "topPointerMove";
public static final String POINTER_UP = "topPointerUp";
/** We don't dispatch capture events from native; that's currently handled by JS. */
@@ -95,22 +95,22 @@ public class PointerEventHelper {
case CANCEL_CAPTURE:
return true;
case ENTER:
value = view.getTag(R.id.pointer_enter2);
value = view.getTag(R.id.pointer_enter);
break;
case ENTER_CAPTURE:
value = view.getTag(R.id.pointer_enter2_capture);
value = view.getTag(R.id.pointer_enter_capture);
break;
case LEAVE:
value = view.getTag(R.id.pointer_leave2);
value = view.getTag(R.id.pointer_leave);
break;
case LEAVE_CAPTURE:
value = view.getTag(R.id.pointer_leave2_capture);
value = view.getTag(R.id.pointer_leave_capture);
break;
case MOVE:
value = view.getTag(R.id.pointer_move2);
value = view.getTag(R.id.pointer_move);
break;
case MOVE_CAPTURE:
value = view.getTag(R.id.pointer_move2_capture);
value = view.getTag(R.id.pointer_move_capture);
break;
}
@@ -55,12 +55,9 @@ object ReactMapBufferPropSetter {
private const val VP_TEST_ID = 32
private const val VP_TRANSFORM = 33
private const val VP_ZINDEX = 34
private const val VP_POINTER_ENTER2 = 35
private const val VP_POINTER_LEAVE2 = 36
private const val VP_POINTER_MOVE2 = 37
private const val VP_POINTER_ENTER2_CAPTURE = 38
private const val VP_POINTER_LEAVE2_CAPTURE = 39
private const val VP_POINTER_MOVE2_CAPTURE = 40
private const val VP_POINTER_ENTER_CAPTURE = 38
private const val VP_POINTER_LEAVE_CAPTURE = 39
private const val VP_POINTER_MOVE_CAPTURE = 40
// Yoga values
private const val YG_BORDER_WIDTH = 100
@@ -191,23 +188,14 @@ object ReactMapBufferPropSetter {
VP_POINTER_MOVE -> {
viewManager.setPointerMove(view, entry.booleanValue)
}
VP_POINTER_ENTER2 -> {
viewManager.setPointerEnter2(view, entry.booleanValue)
VP_POINTER_ENTER_CAPTURE -> {
viewManager.setPointerEnterCapture(view, entry.booleanValue)
}
VP_POINTER_LEAVE2 -> {
viewManager.setPointerLeave2(view, entry.booleanValue)
VP_POINTER_LEAVE_CAPTURE -> {
viewManager.setPointerLeaveCapture(view, entry.booleanValue)
}
VP_POINTER_MOVE2 -> {
viewManager.setPointerMove2(view, entry.booleanValue)
}
VP_POINTER_ENTER2_CAPTURE -> {
viewManager.setPointerEnter2Capture(view, entry.booleanValue)
}
VP_POINTER_LEAVE2_CAPTURE -> {
viewManager.setPointerLeave2Capture(view, entry.booleanValue)
}
VP_POINTER_MOVE2_CAPTURE -> {
viewManager.setPointerMove2Capture(view, entry.booleanValue)
VP_POINTER_MOVE_CAPTURE -> {
viewManager.setPointerMoveCapture(view, entry.booleanValue)
}
VP_REMOVE_CLIPPED_SUBVIEW -> {
viewManager.setRemoveClippedSubviews(view, entry.booleanValue)