From 747d1f70295cbc3bc81331997070421aff8d47cd Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sun, 3 Mar 2019 15:47:07 -0800 Subject: [PATCH] Cleanup SchedulerDelegate interface Summary: This diff removes the "isLayoutable" parameter from SchedulerDelegate.schedulerDidRequestPreliminaryViewAllocation. This now can be infered from the shadowView parameter Reviewed By: shergin Differential Revision: D14296481 fbshipit-source-id: b200504f9c2bef41f0a70257f1f5a274fbe97cbb --- React/Fabric/RCTScheduler.mm | 8 +++----- .../java/com/facebook/react/fabric/jsi/jni/Binding.cpp | 5 +++-- .../main/java/com/facebook/react/fabric/jsi/jni/Binding.h | 1 - ReactCommon/fabric/uimanager/Scheduler.cpp | 6 +----- ReactCommon/fabric/uimanager/SchedulerDelegate.h | 1 - 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/React/Fabric/RCTScheduler.mm b/React/Fabric/RCTScheduler.mm index e47ba28df..d749e5b5d 100644 --- a/React/Fabric/RCTScheduler.mm +++ b/React/Fabric/RCTScheduler.mm @@ -33,12 +33,10 @@ class SchedulerDelegateProxy : public SchedulerDelegate { [scheduler.delegate schedulerDidFinishTransaction:mutations rootTag:rootTag]; } - void schedulerDidRequestPreliminaryViewAllocation( - SurfaceId surfaceId, - bool isLayoutable, - const ShadowView &shadowView) override + void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, const ShadowView &shadowView) override { - if (!isLayoutable) { + bool isLayoutableShadowNode = shadowView.layoutMetrics != EmptyLayoutMetrics; + if (!isLayoutableShadowNode) { return; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.cpp index 2d6143a3d..d7ecdc20a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.cpp @@ -467,10 +467,11 @@ void Binding::setPixelDensity(float pointScaleFactor) { void Binding::schedulerDidRequestPreliminaryViewAllocation( const SurfaceId surfaceId, - bool isLayoutable, const ShadowView &shadowView) { - if (isLayoutable) { + bool isLayoutableShadowNode = shadowView.layoutMetrics != EmptyLayoutMetrics; + + if (isLayoutableShadowNode) { static auto preallocateView = jni::findClassStatic(UIManagerJavaDescriptor) ->getMethod("preallocateView"); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.h index 3e3d80fb6..b17e3f352 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jsi/jni/Binding.h @@ -64,7 +64,6 @@ class Binding : public jni::HybridClass, public SchedulerDelegate { void schedulerDidRequestPreliminaryViewAllocation( const SurfaceId surfaceId, - bool isLayoutable, const ShadowView &shadowView); void setPixelDensity(float pointScaleFactor); diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index 56f7939a2..c3e7cabba 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -258,13 +258,9 @@ void Scheduler::uiManagerDidCreateShadowNode( SystraceSection s("Scheduler::uiManagerDidCreateShadowNode"); if (delegate_) { - auto layoutableShadowNode = - dynamic_cast(shadowNode.get()); - auto isLayoutable = layoutableShadowNode != nullptr; - auto shadowView = ShadowView(*shadowNode); delegate_->schedulerDidRequestPreliminaryViewAllocation( - shadowNode->getRootTag(), isLayoutable, shadowView); + shadowNode->getRootTag(), shadowView); } } diff --git a/ReactCommon/fabric/uimanager/SchedulerDelegate.h b/ReactCommon/fabric/uimanager/SchedulerDelegate.h index 7976005c6..c2d81cdbd 100644 --- a/ReactCommon/fabric/uimanager/SchedulerDelegate.h +++ b/ReactCommon/fabric/uimanager/SchedulerDelegate.h @@ -35,7 +35,6 @@ class SchedulerDelegate { */ virtual void schedulerDidRequestPreliminaryViewAllocation( SurfaceId surfaceId, - bool isLayoutable, const ShadowView &shadowView) = 0; virtual ~SchedulerDelegate() noexcept = default;