Fabric: Stopping creating ShadowView instances for non-View ShadowNodes

Summary:
Apparently, the previous behavior brings more problems than some *possible-in-the-future* features and flexibility.
The new model allows us to easily implement "nested text" feature.

(We temporary hope the old behavious for Android only for compatibility reasons.)

Reviewed By: mdvacca

Differential Revision: D13176277

fbshipit-source-id: 01f7bfb3c2e70cc89d76ecb78add016ee91cbd63
This commit is contained in:
Valentin Shergin 2018-11-25 22:15:00 -08:00 committed by Facebook Github Bot
parent e581977b51
commit cd5f0bd95c
2 changed files with 14 additions and 0 deletions

View File

@ -28,6 +28,10 @@ public:
}
void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, ComponentName componentName, bool isLayoutable, ComponentHandle componentHandle) override {
if (!isLayoutable) {
return;
}
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerOptimisticallyCreateComponentViewWithComponentHandle:componentHandle];
}

View File

@ -20,7 +20,17 @@ static void sliceChildShadowNodeViewPairsRecursively(
const auto layoutableShadowNode =
dynamic_cast<const LayoutableShadowNode *>(childShadowNode.get());
#ifndef ANDROID
// New approach (iOS):
// Non-view components are treated as layout-only views (they aren't
// represented as `ShadowView`s).
if (!layoutableShadowNode || layoutableShadowNode->isLayoutOnly()) {
#else
// Previous approach (Android):
// Non-view components are treated as normal views with an empty layout
// (they are represented as `ShadowView`s).
if (layoutableShadowNode && layoutableShadowNode->isLayoutOnly()) {
#endif
sliceChildShadowNodeViewPairsRecursively(
pairList,
layoutOffset + shadowView.layoutMetrics.frame.origin,