Clearly mark java CSSNode as deprecated. It will go away very soon

Summary: Clearly mark java CSSNode as deprecated. It will go away very soon.

Reviewed By: lucasr

Differential Revision: D3992775

fbshipit-source-id: b3ceca277e5c7426eb51f8cbeacf5e2fe451c6ec
This commit is contained in:
Emil Sjolander
2016-10-12 02:49:37 -07:00
committed by Facebook Github Bot
parent 871a7cf310
commit 62dba4c741
9 changed files with 88 additions and 88 deletions

View File

@@ -12,7 +12,7 @@ package com.facebook.csslayout;
import java.util.Arrays; import java.util.Arrays;
/** /**
* Where the output of {@link LayoutEngine#layoutNode(CSSNode, float)} will go in the CSSNode. * Where the output of {@link LayoutEngine#layoutNode(CSSNodeDEPRECATED, float)} will go in the CSSNodeDEPRECATED.
*/ */
public class CSSLayout { public class CSSLayout {
// This value was chosen based on empiracle data. Even the most complicated // This value was chosen based on empiracle data. Even the most complicated

View File

@@ -13,7 +13,7 @@ package com.facebook.csslayout;
* A context for holding values local to a given instance of layout computation. * A context for holding values local to a given instance of layout computation.
* *
* This is necessary for making layout thread-safe. A separate instance should * This is necessary for making layout thread-safe. A separate instance should
* be used when {@link CSSNode#calculateLayout} is called concurrently on * be used when {@link CSSNodeDEPRECATED#calculateLayout} is called concurrently on
* different node hierarchies. * different node hierarchies.
*/ */
public class CSSLayoutContext { public class CSSLayoutContext {

View File

@@ -24,7 +24,7 @@ import static com.facebook.csslayout.CSSLayout.POSITION_TOP;
* A CSS Node. It has a style object you can manipulate at {@link #style}. After calling * A CSS Node. It has a style object you can manipulate at {@link #style}. After calling
* {@link #calculateLayout()}, {@link #layout} will be filled with the results of the layout. * {@link #calculateLayout()}, {@link #layout} will be filled with the results of the layout.
*/ */
public class CSSNode implements CSSNodeAPI<CSSNode> { public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
private enum LayoutState { private enum LayoutState {
/** /**
@@ -52,10 +52,10 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
public int lineIndex = 0; public int lineIndex = 0;
CSSNode nextChild; CSSNodeDEPRECATED nextChild;
private @Nullable ArrayList<CSSNode> mChildren; private @Nullable ArrayList<CSSNodeDEPRECATED> mChildren;
private @Nullable CSSNode mParent; private @Nullable CSSNodeDEPRECATED mParent;
private @Nullable MeasureFunction mMeasureFunction = null; private @Nullable MeasureFunction mMeasureFunction = null;
private LayoutState mLayoutState = LayoutState.DIRTY; private LayoutState mLayoutState = LayoutState.DIRTY;
private boolean mIsTextNode = false; private boolean mIsTextNode = false;
@@ -72,13 +72,13 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
} }
@Override @Override
public CSSNode getChildAt(int i) { public CSSNodeDEPRECATED getChildAt(int i) {
Assertions.assertNotNull(mChildren); Assertions.assertNotNull(mChildren);
return mChildren.get(i); return mChildren.get(i);
} }
@Override @Override
public void addChildAt(CSSNode child, int i) { public void addChildAt(CSSNodeDEPRECATED child, int i) {
if (child.mParent != null) { if (child.mParent != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first."); throw new IllegalStateException("Child already has a parent, it must be removed first.");
} }
@@ -93,16 +93,17 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
} }
@Override @Override
public CSSNode removeChildAt(int i) { public CSSNodeDEPRECATED removeChildAt(int i) {
Assertions.assertNotNull(mChildren); Assertions.assertNotNull(mChildren);
CSSNode removed = mChildren.remove(i); CSSNodeDEPRECATED removed = mChildren.remove(i);
removed.mParent = null; removed.mParent = null;
dirty(); dirty();
return removed; return removed;
} }
@Override @Override
public @Nullable CSSNode getParent() { public @Nullable
CSSNodeDEPRECATED getParent() {
return mParent; return mParent;
} }
@@ -110,7 +111,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
* @return the index of the given child, or -1 if the child doesn't exist in this node. * @return the index of the given child, or -1 if the child doesn't exist in this node.
*/ */
@Override @Override
public int indexOf(CSSNode child) { public int indexOf(CSSNodeDEPRECATED child) {
Assertions.assertNotNull(mChildren); Assertions.assertNotNull(mChildren);
return mChildren.indexOf(child); return mChildren.indexOf(child);
} }
@@ -427,7 +428,6 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
} }
} }
/** /**
* Get this node's margin, as defined by style + default margin. * Get this node's margin, as defined by style + default margin.
*/ */
@@ -637,12 +637,12 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
/** /**
* Resets this instance to its default state. This method is meant to be used when * Resets this instance to its default state. This method is meant to be used when
* recycling {@link CSSNode} instances. * recycling {@link CSSNodeDEPRECATED} instances.
*/ */
@Override @Override
public void reset() { public void reset() {
if (mParent != null || (mChildren != null && mChildren.size() > 0)) { if (mParent != null || (mChildren != null && mChildren.size() > 0)) {
throw new IllegalStateException("You should not reset an attached CSSNode"); throw new IllegalStateException("You should not reset an attached CSSNodeDEPRECATED");
} }
style.reset(); style.reset();

View File

@@ -12,7 +12,7 @@ package com.facebook.csslayout;
import java.util.Arrays; import java.util.Arrays;
/** /**
* The CSS style definition for a {@link CSSNode}. * The CSS style definition for a {@link CSSNodeDEPRECATED}.
*/ */
public class CSSStyle { public class CSSStyle {

View File

@@ -19,7 +19,7 @@ import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT;
import static com.facebook.csslayout.CSSLayout.POSITION_TOP; import static com.facebook.csslayout.CSSLayout.POSITION_TOP;
/** /**
* Calculates layouts based on CSS style. See {@link #layoutNode(CSSNode, float, float)}. * Calculates layouts based on CSS style. See {@link #layoutNode(CSSNodeDEPRECATED, float, float)}.
*/ */
public class LayoutEngine { public class LayoutEngine {
@@ -77,20 +77,20 @@ public class LayoutEngine {
Spacing.END Spacing.END
}; };
private static boolean isFlexBasisAuto(CSSNode node) { private static boolean isFlexBasisAuto(CSSNodeDEPRECATED node) {
return CSSConstants.isUndefined(node.style.flexBasis); return CSSConstants.isUndefined(node.style.flexBasis);
} }
private static float getFlexGrowFactor(CSSNode node) { private static float getFlexGrowFactor(CSSNodeDEPRECATED node) {
return node.style.flexGrow; return node.style.flexGrow;
} }
private static float getFlexShrinkFactor(CSSNode node) { private static float getFlexShrinkFactor(CSSNodeDEPRECATED node) {
return node.style.flexShrink; return node.style.flexShrink;
} }
private static float boundAxisWithinMinAndMax(CSSNode node, int axis, float value) { private static float boundAxisWithinMinAndMax(CSSNodeDEPRECATED node, int axis, float value) {
float min = CSSConstants.UNDEFINED; float min = CSSConstants.UNDEFINED;
float max = CSSConstants.UNDEFINED; float max = CSSConstants.UNDEFINED;
@@ -116,7 +116,7 @@ public class LayoutEngine {
return boundValue; return boundValue;
} }
private static float boundAxis(CSSNode node, int axis, float value) { private static float boundAxis(CSSNodeDEPRECATED node, int axis, float value) {
float paddingAndBorderAxis = float paddingAndBorderAxis =
node.style.padding.getWithFallback(leadingSpacing[axis], leading[axis]) + node.style.padding.getWithFallback(leadingSpacing[axis], leading[axis]) +
node.style.border.getWithFallback(leadingSpacing[axis], leading[axis]) + node.style.border.getWithFallback(leadingSpacing[axis], leading[axis]) +
@@ -125,7 +125,7 @@ public class LayoutEngine {
return Math.max(boundAxisWithinMinAndMax(node, axis, value), paddingAndBorderAxis); return Math.max(boundAxisWithinMinAndMax(node, axis, value), paddingAndBorderAxis);
} }
private static float getRelativePosition(CSSNode node, int axis) { private static float getRelativePosition(CSSNodeDEPRECATED node, int axis) {
float lead = node.style.position.getWithFallback(leadingSpacing[axis], leading[axis]); float lead = node.style.position.getWithFallback(leadingSpacing[axis], leading[axis]);
if (!Float.isNaN(lead)) { if (!Float.isNaN(lead)) {
return lead; return lead;
@@ -135,7 +135,7 @@ public class LayoutEngine {
return Float.isNaN(trailingPos) ? 0 : -trailingPos; return Float.isNaN(trailingPos) ? 0 : -trailingPos;
} }
private static void setPosition(CSSNode node, CSSDirection direction) { private static void setPosition(CSSNodeDEPRECATED node, CSSDirection direction) {
int mainAxis = resolveAxis(getFlexDirection(node), direction); int mainAxis = resolveAxis(getFlexDirection(node), direction);
int crossAxis = getCrossFlexDirection(mainAxis, direction); int crossAxis = getCrossFlexDirection(mainAxis, direction);
@@ -163,7 +163,7 @@ public class LayoutEngine {
return axis; return axis;
} }
private static CSSDirection resolveDirection(CSSNode node, CSSDirection parentDirection) { private static CSSDirection resolveDirection(CSSNodeDEPRECATED node, CSSDirection parentDirection) {
CSSDirection direction = node.style.direction; CSSDirection direction = node.style.direction;
if (direction == CSSDirection.INHERIT) { if (direction == CSSDirection.INHERIT) {
direction = (parentDirection == null ? CSSDirection.LTR : parentDirection); direction = (parentDirection == null ? CSSDirection.LTR : parentDirection);
@@ -172,7 +172,7 @@ public class LayoutEngine {
return direction; return direction;
} }
private static int getFlexDirection(CSSNode node) { private static int getFlexDirection(CSSNodeDEPRECATED node) {
return node.style.flexDirection.ordinal(); return node.style.flexDirection.ordinal();
} }
@@ -187,20 +187,20 @@ public class LayoutEngine {
} }
} }
private static CSSAlign getAlignItem(CSSNode node, CSSNode child) { private static CSSAlign getAlignItem(CSSNodeDEPRECATED node, CSSNodeDEPRECATED child) {
if (child.style.alignSelf != CSSAlign.AUTO) { if (child.style.alignSelf != CSSAlign.AUTO) {
return child.style.alignSelf; return child.style.alignSelf;
} }
return node.style.alignItems; return node.style.alignItems;
} }
private static boolean isMeasureDefined(CSSNode node) { private static boolean isMeasureDefined(CSSNodeDEPRECATED node) {
return node.isMeasureDefined(); return node.isMeasureDefined();
} }
/*package*/ static void layoutNode( /*package*/ static void layoutNode(
CSSLayoutContext layoutContext, CSSLayoutContext layoutContext,
CSSNode node, CSSNodeDEPRECATED node,
float availableWidth, float availableWidth,
float availableHeight, float availableHeight,
CSSDirection parentDirection) { CSSDirection parentDirection) {
@@ -326,7 +326,7 @@ public class LayoutEngine {
// //
private static boolean layoutNodeInternal( private static boolean layoutNodeInternal(
CSSLayoutContext layoutContext, CSSLayoutContext layoutContext,
CSSNode node, CSSNodeDEPRECATED node,
float availableWidth, float availableWidth,
float availableHeight, float availableHeight,
CSSDirection parentDirection, CSSDirection parentDirection,
@@ -522,7 +522,7 @@ public class LayoutEngine {
// //
private static void layoutNodeImpl( private static void layoutNodeImpl(
CSSLayoutContext layoutContext, CSSLayoutContext layoutContext,
CSSNode node, CSSNodeDEPRECATED node,
float availableWidth, float availableWidth,
float availableHeight, float availableHeight,
CSSDirection parentDirection, CSSDirection parentDirection,
@@ -636,8 +636,8 @@ public class LayoutEngine {
CSSJustify justifyContent = node.style.justifyContent; CSSJustify justifyContent = node.style.justifyContent;
boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.WRAP); boolean isNodeFlexWrap = (node.style.flexWrap == CSSWrap.WRAP);
CSSNode firstAbsoluteChild = null; CSSNodeDEPRECATED firstAbsoluteChild = null;
CSSNode currentAbsoluteChild = null; CSSNodeDEPRECATED currentAbsoluteChild = null;
float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis])); float leadingPaddingAndBorderMain = (node.style.padding.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]) + node.style.border.getWithFallback(leadingSpacing[mainAxis], leading[mainAxis]));
float trailingPaddingAndBorderMain = (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis])); float trailingPaddingAndBorderMain = (node.style.padding.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]) + node.style.border.getWithFallback(trailingSpacing[mainAxis], trailing[mainAxis]));
@@ -655,7 +655,7 @@ public class LayoutEngine {
float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth; float availableInnerCrossDim = isMainAxisRow ? availableInnerHeight : availableInnerWidth;
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
CSSNode child; CSSNodeDEPRECATED child;
int i; int i;
float childWidth; float childWidth;
float childHeight; float childHeight;
@@ -791,8 +791,8 @@ public class LayoutEngine {
i = startOfLineIndex; i = startOfLineIndex;
// Maintain a linked list of the child nodes that can shrink and/or grow. // Maintain a linked list of the child nodes that can shrink and/or grow.
CSSNode firstRelativeChild = null; CSSNodeDEPRECATED firstRelativeChild = null;
CSSNode currentRelativeChild = null; CSSNodeDEPRECATED currentRelativeChild = null;
// Add items to the current line until it's full or we run out of items. // Add items to the current line until it's full or we run out of items.
while (i < childCount) { while (i < childCount) {

View File

@@ -17,19 +17,19 @@ public class CSSLayoutFlexBasisTest {
@Test @Test
public void testFlexBasis() { public void testFlexBasis() {
final CSSNode root = new CSSNode(); final CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(300); root.setStyleWidth(300);
root.setStyleHeight(100); root.setStyleHeight(100);
final CSSNode root_child0 = new CSSNode(); final CSSNodeDEPRECATED root_child0 = new CSSNodeDEPRECATED();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1);
root_child0.setFlexBasis(100); root_child0.setFlexBasis(100);
root_child0.setStyleWidth(200); root_child0.setStyleWidth(200);
root_child0.setStyleHeight(100); root_child0.setStyleHeight(100);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNodeDEPRECATED root_child1 = new CSSNodeDEPRECATED();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1);
root_child1.setStyleWidth(100); root_child1.setStyleWidth(100);
root_child1.setStyleHeight(100); root_child1.setStyleHeight(100);

View File

@@ -15,14 +15,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
/** /**
* Tests for {@link CSSNode}. * Tests for {@link CSSNodeDEPRECATED}.
*/ */
public class CSSNodeTest { public class CSSNodeTest {
@Test @Test
public void testAddChildGetParent() { public void testAddChildGetParent() {
CSSNode parent = new CSSNode(); CSSNodeDEPRECATED parent = new CSSNodeDEPRECATED();
CSSNode child = new CSSNode(); CSSNodeDEPRECATED child = new CSSNodeDEPRECATED();
assertNull(child.getParent()); assertNull(child.getParent());
assertEquals(0, parent.getChildCount()); assertEquals(0, parent.getChildCount());
@@ -41,9 +41,9 @@ public class CSSNodeTest {
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void testCannotAddChildToMultipleParents() { public void testCannotAddChildToMultipleParents() {
CSSNode parent1 = new CSSNode(); CSSNodeDEPRECATED parent1 = new CSSNodeDEPRECATED();
CSSNode parent2 = new CSSNode(); CSSNodeDEPRECATED parent2 = new CSSNodeDEPRECATED();
CSSNode child = new CSSNode(); CSSNodeDEPRECATED child = new CSSNodeDEPRECATED();
parent1.addChildAt(child, 0); parent1.addChildAt(child, 0);
parent2.addChildAt(child, 0); parent2.addChildAt(child, 0);

View File

@@ -14,12 +14,12 @@ import org.junit.Test;
import static junit.framework.Assert.*; import static junit.framework.Assert.*;
/** /**
* Tests for {@link LayoutEngine} and {@link CSSNode} to make sure layouts are only generated when * Tests for {@link LayoutEngine} and {@link CSSNodeDEPRECATED} to make sure layouts are only generated when
* needed. * needed.
*/ */
public class LayoutCachingTest { public class LayoutCachingTest {
private void assertTreeHasNewLayout(boolean expectedHasNewLayout, CSSNode root) { private void assertTreeHasNewLayout(boolean expectedHasNewLayout, CSSNodeDEPRECATED root) {
assertEquals(expectedHasNewLayout, root.hasNewLayout()); assertEquals(expectedHasNewLayout, root.hasNewLayout());
for (int i = 0; i < root.getChildCount(); i++) { for (int i = 0; i < root.getChildCount(); i++) {
@@ -27,7 +27,7 @@ public class LayoutCachingTest {
} }
} }
private void markLayoutAppliedForTree(CSSNode root) { private void markLayoutAppliedForTree(CSSNodeDEPRECATED root) {
root.markLayoutSeen(); root.markLayoutSeen();
for (int i = 0; i < root.getChildCount(); i++) { for (int i = 0; i < root.getChildCount(); i++) {
markLayoutAppliedForTree(root.getChildAt(i)); markLayoutAppliedForTree(root.getChildAt(i));
@@ -37,10 +37,10 @@ public class LayoutCachingTest {
@Test @Test
public void testCachesFullTree() { public void testCachesFullTree() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);
@@ -58,12 +58,12 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidatesCacheWhenChildAdded() { public void testInvalidatesCacheWhenChildAdded() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
CSSNode c0c1 = new CSSNode(); CSSNodeDEPRECATED c0c1 = new CSSNodeDEPRECATED();
CSSNode c1c0 = new CSSNode(); CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
c0c1.setStyleWidth(200); c0c1.setStyleWidth(200);
c0c1.setStyleHeight(200); c0c1.setStyleHeight(200);
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
@@ -90,10 +90,10 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidatesCacheWhenEnumPropertyChanges() { public void testInvalidatesCacheWhenEnumPropertyChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);
@@ -114,10 +114,10 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidatesCacheWhenFloatPropertyChanges() { public void testInvalidatesCacheWhenFloatPropertyChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);
@@ -138,11 +138,11 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidatesFullTreeWhenParentWidthChanges() { public void testInvalidatesFullTreeWhenParentWidthChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
CSSNode c1c0 = new CSSNode(); CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);
@@ -165,10 +165,10 @@ public class LayoutCachingTest {
@Test @Test
public void testDoesNotInvalidateCacheWhenPropertyIsTheSame() { public void testDoesNotInvalidateCacheWhenPropertyIsTheSame() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);
@@ -188,10 +188,10 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidateCacheWhenHeightChangesPosition() { public void testInvalidateCacheWhenHeightChangesPosition() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c1c0 = new CSSNode(); CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c1.addChildAt(c1c0, 0); c1.addChildAt(c1c0, 0);
@@ -211,10 +211,10 @@ public class LayoutCachingTest {
@Test @Test
public void testInvalidatesOnNewMeasureFunction() { public void testInvalidatesOnNewMeasureFunction() {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNode root = new CSSNode(); CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNode c0 = new CSSNode(); CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNode c1 = new CSSNode(); CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNode c0c0 = new CSSNode(); CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0); root.addChildAt(c0, 0);
root.addChildAt(c1, 1); root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0); c0.addChildAt(c0c0, 0);

View File

@@ -23,7 +23,7 @@ import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT;
public class LayoutEngineTest { public class LayoutEngineTest {
private static final CSSNodeAPI.MeasureFunction sTestMeasureFunction = private static final CSSNodeAPI.MeasureFunction sTestMeasureFunction =
new CSSNode.MeasureFunction() { new CSSNodeDEPRECATED.MeasureFunction() {
@Override @Override
public void measure(CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput) { public void measure(CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput) {
@@ -72,7 +72,7 @@ public class LayoutEngineTest {
} }
}; };
private static class TestCSSNode extends CSSNode { private static class TestCSSNode extends CSSNodeDEPRECATED {
public String context = null; public String context = null;
@@ -81,7 +81,7 @@ public class LayoutEngineTest {
} }
} }
private static void test(String message, CSSNode style, CSSNode expectedLayout) { private static void test(String message, CSSNodeDEPRECATED style, CSSNodeDEPRECATED expectedLayout) {
CSSLayoutContext layoutContext = new CSSLayoutContext(); CSSLayoutContext layoutContext = new CSSLayoutContext();
style.calculateLayout(layoutContext); style.calculateLayout(layoutContext);
assertLayoutsEqual(message, style, expectedLayout); assertLayoutsEqual(message, style, expectedLayout);
@@ -93,13 +93,13 @@ public class LayoutEngineTest {
} }
} }
private static void assertLayoutsEqual(String message, CSSNode actual, CSSNode expected) { private static void assertLayoutsEqual(String message, CSSNodeDEPRECATED actual, CSSNodeDEPRECATED expected) {
Assert.assertTrue( Assert.assertTrue(
message + "\nActual:\n" + actual.toString() + "\nExpected:\n" + expected.toString(), message + "\nActual:\n" + actual.toString() + "\nExpected:\n" + expected.toString(),
areLayoutsEqual(actual, expected)); areLayoutsEqual(actual, expected));
} }
private static boolean areLayoutsEqual(CSSNode a, CSSNode b) { private static boolean areLayoutsEqual(CSSNodeDEPRECATED a, CSSNodeDEPRECATED b) {
boolean doNodesHaveSameLayout = boolean doNodesHaveSameLayout =
areFloatsEqual(a.layout.position[POSITION_LEFT], b.layout.position[POSITION_LEFT]) && areFloatsEqual(a.layout.position[POSITION_LEFT], b.layout.position[POSITION_LEFT]) &&
areFloatsEqual(a.layout.position[POSITION_TOP], b.layout.position[POSITION_TOP]) && areFloatsEqual(a.layout.position[POSITION_TOP], b.layout.position[POSITION_TOP]) &&