@VisibleForTesting static void remeasureTree(InternalNode layout, int widthSpec, int heightSpec) { if (layout == NULL_LAYOUT) { // If NULL LAYOUT return immediately. return; } layout.resetResolvedLayoutProperties(); // Reset all resolved props to force-remeasure. measureTree(layout, widthSpec, heightSpec, layout.getDiffNode()); }
private static void assertCachedMeasurementsDefined(InternalNode node) { float diffHeight = node.getDiffNode() == null ? -1 : node.getDiffNode().getLastMeasuredHeight(); float diffWidth = node.getDiffNode() == null ? -1 : node.getDiffNode().getLastMeasuredWidth(); assertThat(diffHeight != -1).isTrue(); assertThat(diffWidth != -1).isTrue(); assertThat(node.areCachedMeasuresValid()).isTrue(); }
@Before public void setUp() { mDiffNode = mock(DiffNode.class); mNode = mock(InternalNode.class); final YogaNode cssNode = new YogaNode(); cssNode.setData(mNode); mNode.mYogaNode = cssNode; mockStatic(ComponentsPools.class); when(mNode.getLastWidthSpec()).thenReturn(-1); when(mNode.getDiffNode()).thenReturn(mDiffNode); when(mDiffNode.getLastMeasuredWidth()).thenReturn(-1f); when(mDiffNode.getLastMeasuredHeight()).thenReturn(-1f); when(ComponentsPools.acquireInternalNode(any(ComponentContext.class))).thenReturn(mNode); when(ComponentsPools.acquireComponentTreeBuilder( any(ComponentContext.class), any(Component.class))) .thenCallRealMethod(); mockStatic(LayoutState.class); StateHandler stateHandler = mock(StateHandler.class); mContext = spy(new ComponentContext(RuntimeEnvironment.application, stateHandler)); mNestedTreeWidthSpec = SizeSpec.makeSizeSpec(400, SizeSpec.EXACTLY); mNestedTreeHeightSpec = SizeSpec.makeSizeSpec(200, SizeSpec.EXACTLY); }
YogaMeasureMode heightMode) { final InternalNode node = (InternalNode) cssNode.getData(); final DiffNode diffNode = node.areCachedMeasuresValid() ? node.getDiffNode() : null; final Component component = node.getRootComponent(); final int widthSpec; outputHeight = size.height; if (node.getDiffNode() != null) { node.getDiffNode().setLastWidthSpec(widthSpec); node.getDiffNode().setLastHeightSpec(heightSpec); node.getDiffNode().setLastMeasuredWidth(outputWidth); node.getDiffNode().setLastMeasuredHeight(outputHeight);
diffTreeRoot = nestedTreeHolder.getDiffNode(); } else if (root.getStyleDirection() == com.facebook.yoga.YogaDirection.INHERIT && LayoutState.isLayoutDirectionRTL(c.getAndroidContext())) {
final DiffNode currentDiffNode = node.getDiffNode(); final boolean shouldUseCachedOutputs = isMountSpec(component) && currentDiffNode != null;
widthSpec, heightSpec, holder.getDiffNode()); // Was set while traversing the holder's tree.