Fabric: Support for setIsJSResponder, all the native changes

Summary:
This is a Fabric-compliant implementation of `JSResponder` feature. To make it work e2e we also need to update FabricRenderer in React repository. But before we can do this, we need to ship the native changes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D24630027

fbshipit-source-id: 70c30e1250b554d83862956b536714704093072f
This commit is contained in:
Valentin Shergin
2021-02-04 13:16:29 -08:00
committed by Facebook GitHub Bot
parent f0ed1e8201
commit fc24bb4af0
20 changed files with 121 additions and 119 deletions
@@ -1106,11 +1106,9 @@ void Binding::schedulerDidSendAccessibilityEvent(
eventTypeStr.get());
}
void Binding::schedulerDidSetJSResponder(
SurfaceId surfaceId,
const ShadowView &shadowView,
const ShadowView &initialShadowView,
bool blockNativeResponder) {
void Binding::schedulerDidSetIsJSResponder(
ShadowView const &shadowView,
bool isJSResponder) {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::schedulerSetJSResponder: JavaUIManager disappeared";
@@ -1121,27 +1119,24 @@ void Binding::schedulerDidSetJSResponder(
jni::findClassStatic(Binding::UIManagerJavaDescriptor)
->getMethod<void(jint, jint, jint, jboolean)>("setJSResponder");
setJSResponder(
localJavaUIManager,
shadowView.surfaceId,
shadowView.tag,
initialShadowView.tag,
(jboolean)blockNativeResponder);
}
void Binding::schedulerDidClearJSResponder() {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR)
<< "Binding::schedulerClearJSResponder: JavaUIManager disappeared";
return;
}
static auto clearJSResponder =
jni::findClassStatic(Binding::UIManagerJavaDescriptor)
->getMethod<void()>("clearJSResponder");
clearJSResponder(localJavaUIManager);
if (isJSResponder) {
setJSResponder(
localJavaUIManager,
shadowView.surfaceId,
shadowView.tag,
// The closest non-flattened ancestor of the same value if the node is
// not flattened. For now, we don't support the case when the node can
// be flattened because the only component that uses this feature -
// ScrollView - cannot be flattened.
shadowView.tag,
(jboolean) true);
} else {
clearJSResponder(localJavaUIManager);
}
}
void Binding::registerNatives() {
@@ -140,13 +140,9 @@ class Binding : public jni::HybridClass<Binding>,
const ShadowView &shadowView,
std::string const &eventType) override;
void schedulerDidSetJSResponder(
SurfaceId surfaceId,
const ShadowView &shadowView,
const ShadowView &initialShadowView,
bool blockNativeResponder) override;
void schedulerDidClearJSResponder() override;
void schedulerDidSetIsJSResponder(
ShadowView const &shadowView,
bool isJSResponder) override;
void setPixelDensity(float pointScaleFactor);