From 29754eb95d1ec098a19649d0298247421c77f193 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Wed, 23 Nov 2016 05:12:55 -0800 Subject: [PATCH] BREAKING [react_native] Don't create CSSNodes for virtual shadow nodes Summary: @public Virtual shadow nodes (e.g. text) don't use CSSNodes so we don't need to create them. This shows large savings in CSSNodes allocated, depending on the app. This could be breaking if: - You have virtual nodes that still set and get CSS properties. The setters now no-op for virtual nodes (I unfortunately couldn't remove them completely -- see the comment on LayoutShadowNode), but the getters will NPE. If you see these NPE's, you should almost definitely be using your own datastructure instead of a CSSNode as virtual nodes will not participate in the layout process (and the CSSNode is then behaving just as a POJO for you). I do not anticipate this to be breaking for anyone, but am including breaking in the commit message since this is a change in API contract. Reviewed By: emilsjolander Differential Revision: D4220204 --- .../com/facebook/react/flat/StateBuilder.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java index 43fc609bd..7e2318f9d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java @@ -596,7 +596,6 @@ import com.facebook.react.uimanager.events.EventDispatcher; for (int i = 0, childCount = node.getChildCount(); i != childCount; ++i) { ReactShadowNode child = node.getChildAt(i); if (child.isVirtual()) { - markLayoutSeenRecursively(child); continue; } @@ -617,21 +616,6 @@ import com.facebook.react.uimanager.events.EventDispatcher; return updated; } - /** - * Recursively walks this node and child nodes, marking the layout state as UP_TO_DATE. - * - * @param node The node to recur down from. - */ - private void markLayoutSeenRecursively(ReactShadowNode node) { - if (node.hasNewLayout()) { - node.markLayoutSeen(); - } - - for (int i = 0, childCount = node.getChildCount(); i != childCount; ++i) { - markLayoutSeenRecursively(node.getChildAt(i)); - } - } - /** * Collects state and enqueues View boundary updates for a given node tree. Returns true if * this node or any of its descendants that mount to View generated any updates.