forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basics of pointer event interception
Summary: Changelog: [Internal] - Add basics of pointer event interception This diff adds the scaffolding for intercepting Pointer Events (without actually doing anything with them yet). Most notably introduces the logic of determining which events are of the PointerEvent type and downcasting to the type so the interceptor can properly work with the typed properties. Originally my plan was to leverage `dynamic_cast` but sandcastle's signals let me know that there exists internal apps (particularly VR ones) which don't have RTTI enabled — so to avoid that usage I introduced an additional abstract method on EventPayload which lets subclasses identify themselves cheaply and then subsequently leverage `static_cast`. Differential Revision: https://internalfb.com/D47443773 fbshipit-source-id: deb804a229db7c57f0d36cd6b34fbf39bd550859
- Loading branch information
1 parent
0cdb9e6
commit c9a714d
Showing
10 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/react-native/ReactCommon/react/renderer/core/EventPayloadType.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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 | ||
|
||
namespace facebook::react { | ||
|
||
enum class EventPayloadType { ValueFactory, PointerEvent }; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/react-native/ReactCommon/react/renderer/uimanager/PointerEventsProcessor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "PointerEventsProcessor.h" | ||
|
||
namespace facebook::react { | ||
|
||
void PointerEventsProcessor::interceptPointerEvent( | ||
jsi::Runtime &runtime, | ||
EventTarget const *eventTarget, | ||
std::string const &type, | ||
ReactEventPriority priority, | ||
PointerEvent const &event, | ||
DispatchEvent const &eventDispatcher) { | ||
// TODO: implement pointer capture redirection | ||
eventDispatcher(runtime, eventTarget, type, priority, event); | ||
} | ||
|
||
} // namespace facebook::react |
36 changes: 36 additions & 0 deletions
36
packages/react-native/ReactCommon/react/renderer/uimanager/PointerEventsProcessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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 <functional> | ||
|
||
#include <jsi/jsi.h> | ||
#include <react/renderer/uimanager/UIManager.h> | ||
#include <react/renderer/uimanager/primitives.h> | ||
|
||
namespace facebook::react { | ||
|
||
using DispatchEvent = std::function<void( | ||
jsi::Runtime &runtime, | ||
const EventTarget *eventTarget, | ||
const std::string &type, | ||
ReactEventPriority priority, | ||
const EventPayload &payload)>; | ||
|
||
class PointerEventsProcessor final { | ||
public: | ||
void interceptPointerEvent( | ||
jsi::Runtime &runtime, | ||
EventTarget const *eventTarget, | ||
std::string const &type, | ||
ReactEventPriority priority, | ||
PointerEvent const &event, | ||
DispatchEvent const &eventDispatcher); | ||
}; | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters