Skip to content

Commit

Permalink
Pass blockNativeResponder param to setIsJSResponder
Browse files Browse the repository at this point in the history
Summary:
The non-Fabric API has a `blockNativeResponder` param in setJSResponder. Make sure to pass that along in Fabric.

On Android this allows us to respect the flag and do the same thing non-Fabric was doing if `blockNativeResponder` is false. It's not clear yet what the impact is on iOS.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27058806

fbshipit-source-id: aa5074fa46191d78f5292a93d9040ab4bb58ca66
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Mar 16, 2021
1 parent 07f9d21 commit 9c19260
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion React/Fabric/RCTScheduler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void schedulerDidDispatchCommand(
[scheduler.delegate schedulerDidDispatchCommand:shadowView commandName:commandName args:args];
}

void schedulerDidSetIsJSResponder(ShadowView const &shadowView, bool isJSResponder) override
void schedulerDidSetIsJSResponder(ShadowView const &shadowView, bool isJSResponder, bool blockNativeResponder)
override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidSetIsJSResponder:isJSResponder forShadowView:shadowView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,8 @@ void Binding::schedulerDidSendAccessibilityEvent(

void Binding::schedulerDidSetIsJSResponder(
ShadowView const &shadowView,
bool isJSResponder) {
bool isJSResponder,
bool blockNativeResponder) {
jni::global_ref<jobject> localJavaUIManager = getJavaUIManager();
if (!localJavaUIManager) {
LOG(ERROR) << "Binding::schedulerSetJSResponder: JavaUIManager disappeared";
Expand All @@ -1214,7 +1215,7 @@ void Binding::schedulerDidSetIsJSResponder(
// be flattened because the only component that uses this feature -
// ScrollView - cannot be flattened.
shadowView.tag,
(jboolean) true);
(jboolean)blockNativeResponder);
} else {
clearJSResponder(localJavaUIManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class Binding : public jni::HybridClass<Binding>,

void schedulerDidSetIsJSResponder(
ShadowView const &shadowView,
bool isJSResponder) override;
bool isJSResponder,
bool blockNativeResponder) override;

void setPixelDensity(float pointScaleFactor);

Expand Down
5 changes: 3 additions & 2 deletions ReactCommon/react/renderer/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,11 @@ void Scheduler::uiManagerDidSendAccessibilityEvent(
*/
void Scheduler::uiManagerDidSetIsJSResponder(
ShadowNode::Shared const &shadowNode,
bool isJSResponder) {
bool isJSResponder,
bool blockNativeResponder) {
if (delegate_) {
delegate_->schedulerDidSetIsJSResponder(
ShadowView(*shadowNode), isJSResponder);
ShadowView(*shadowNode), isJSResponder, blockNativeResponder);
}
}

Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/scheduler/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class Scheduler final : public UIManagerDelegate {
std::string const &eventType) override;
void uiManagerDidSetIsJSResponder(
ShadowNode::Shared const &shadowView,
bool isJSResponder) override;
bool isJSResponder,
bool blockNativeResponder) override;

private:
friend class SurfaceHandler;
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/scheduler/SchedulerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class SchedulerDelegate {
*/
virtual void schedulerDidSetIsJSResponder(
ShadowView const &shadowView,
bool isJSResponder) = 0;
bool isJSResponder,
bool blockNativeResponder) = 0;

virtual ~SchedulerDelegate() noexcept = default;
};
Expand Down
6 changes: 4 additions & 2 deletions ReactCommon/react/renderer/uimanager/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,11 @@ void UIManager::completeSurface(

void UIManager::setIsJSResponder(
ShadowNode::Shared const &shadowNode,
bool isJSResponder) const {
bool isJSResponder,
bool blockNativeResponder) const {
if (delegate_) {
delegate_->uiManagerDidSetIsJSResponder(shadowNode, isJSResponder);
delegate_->uiManagerDidSetIsJSResponder(
shadowNode, isJSResponder, blockNativeResponder);
}
}

Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/uimanager/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class UIManager final : public ShadowTreeDelegate {

void setIsJSResponder(
ShadowNode::Shared const &shadowNode,
bool isJSResponder) const;
bool isJSResponder,
bool blockNativeResponder) const;

ShadowNode::Shared findNodeAtPoint(
ShadowNode::Shared const &shadowNode,
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ jsi::Value UIManagerBinding::get(
size_t count) noexcept -> jsi::Value {
uiManager->setIsJSResponder(
shadowNodeFromValue(runtime, arguments[0]),
arguments[1].getBool());
arguments[1].getBool(),
arguments[2].getBool());

return jsi::Value::undefined();
});
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/react/renderer/uimanager/UIManagerDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class UIManagerDelegate {
*/
virtual void uiManagerDidSetIsJSResponder(
ShadowNode::Shared const &shadowNode,
bool isJSResponder) = 0;
bool isJSResponder,
bool blockNativeResponder) = 0;

virtual ~UIManagerDelegate() noexcept = default;
};
Expand Down

0 comments on commit 9c19260

Please sign in to comment.