mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 17:13:46 +08:00
Cleanup native view hierarchy when view is dropped.
Differential Revision: D2659738 fb-gh-sync-id: 1c14b8c3c6fabbd0e580777bb94221df6dd98f71
This commit is contained in:
committed by
facebook-github-bot-7
parent
0f590d1233
commit
bd1885b5d4
@@ -122,16 +122,7 @@ public class ReactShadowNode extends CSSNode {
|
||||
int increase = node.mIsLayoutOnly ? node.mTotalNativeChildren : 1;
|
||||
mTotalNativeChildren += increase;
|
||||
|
||||
if (mIsLayoutOnly) {
|
||||
ReactShadowNode parent = getParent();
|
||||
while (parent != null) {
|
||||
parent.mTotalNativeChildren += increase;
|
||||
if (!parent.mIsLayoutOnly) {
|
||||
break;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
updateNativeChildrenCountInParent(increase);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,17 +132,31 @@ public class ReactShadowNode extends CSSNode {
|
||||
|
||||
int decrease = removed.mIsLayoutOnly ? removed.mTotalNativeChildren : 1;
|
||||
mTotalNativeChildren -= decrease;
|
||||
updateNativeChildrenCountInParent(-decrease);
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void removeAllChildren() {
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
super.removeChildAt(i);
|
||||
}
|
||||
markUpdated();
|
||||
|
||||
updateNativeChildrenCountInParent(-mTotalNativeChildren);
|
||||
mTotalNativeChildren = 0;
|
||||
}
|
||||
|
||||
private void updateNativeChildrenCountInParent(int delta) {
|
||||
if (mIsLayoutOnly) {
|
||||
ReactShadowNode parent = getParent();
|
||||
while (parent != null) {
|
||||
parent.mTotalNativeChildren -= decrease;
|
||||
parent.mTotalNativeChildren -= delta;
|
||||
if (!parent.mIsLayoutOnly) {
|
||||
break;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user