mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 22:42:05 +08:00
Promote grandchildren of certain views are Views
Summary: As an optimization, for something like a ScrollView which contains a FlatViewGroup containing posts, make sure that each post is explicitly mounted to a View. This may help improve performance, especially when said Views are otherwise inlined as DrawCommands instead of actual Views. Reviewed By: astreet Differential Revision: D3161232
This commit is contained in:
@@ -23,6 +23,7 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
@Nullable private final ReactShadowNode mReactShadowNode;
|
||||
private final boolean mNeedsCustomLayoutForChildren;
|
||||
private boolean mPaddingChanged = false;
|
||||
private boolean mForceMountGrandChildrenToView;
|
||||
|
||||
/* package */ NativeViewWrapper(ViewManager viewManager) {
|
||||
ReactShadowNode reactShadowNode = viewManager.createShadowNodeInstance();
|
||||
@@ -36,11 +37,13 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
if (viewManager instanceof ViewGroupManager) {
|
||||
ViewGroupManager viewGroupManager = (ViewGroupManager) viewManager;
|
||||
mNeedsCustomLayoutForChildren = viewGroupManager.needsCustomLayoutForChildren();
|
||||
mForceMountGrandChildrenToView = viewGroupManager.shouldPromoteGrandchildren();
|
||||
} else {
|
||||
mNeedsCustomLayoutForChildren = false;
|
||||
}
|
||||
|
||||
forceMountToView();
|
||||
forceMountChildrenToView();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,8 +85,8 @@ import com.facebook.react.uimanager.ViewManager;
|
||||
@Override
|
||||
public void addChildAt(CSSNode child, int i) {
|
||||
super.addChildAt(child, i);
|
||||
if (child instanceof FlatShadowNode) {
|
||||
((FlatShadowNode) child).forceMountToView();
|
||||
if (mForceMountGrandChildrenToView && child instanceof FlatShadowNode) {
|
||||
((FlatShadowNode) child).forceMountChildrenToView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user