diff --git a/React/CSSLayout/CSSLayout.c b/React/CSSLayout/CSSLayout.c index ebde96c0b..2e2b99601 100644 --- a/React/CSSLayout/CSSLayout.c +++ b/React/CSSLayout/CSSLayout.c @@ -89,7 +89,6 @@ typedef struct CSSNode { CSSLayout layout; uint32_t lineIndex; bool hasNewLayout; - bool isTextNode; CSSNodeRef parent; CSSNodeListRef children; bool isDirty; @@ -382,7 +381,6 @@ void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex) { CSS_NODE_PROPERTY_IMPL(void *, Context, context, context); CSS_NODE_PROPERTY_IMPL(CSSPrintFunc, PrintFunc, printFunc, print); -CSS_NODE_PROPERTY_IMPL(bool, IsTextnode, isTextNode, isTextNode); CSS_NODE_PROPERTY_IMPL(bool, HasNewLayout, hasNewLayout, hasNewLayout); CSS_NODE_STYLE_PROPERTY_IMPL(CSSDirection, Direction, direction, direction); @@ -2104,8 +2102,7 @@ static inline bool newMeasureSizeIsStricterAndStillValid(CSSMeasureMode sizeMode lastSize > size && lastComputedSize <= size; } -bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, - const CSSMeasureMode widthMode, +bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, const float width, const CSSMeasureMode heightMode, const float height, @@ -2134,7 +2131,7 @@ bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, newMeasureSizeIsStricterAndStillValid( widthMode, width - marginRow, lastWidthMode, lastWidth, lastComputedWidth); - const bool heightIsCompatible = isTextNode || hasSameHeightSpec || + const bool heightIsCompatible = hasSameHeightSpec || newSizeIsExactAndMatchesOldMeasuredSize(heightMode, height - marginColumn, lastComputedHeight) || @@ -2203,8 +2200,7 @@ bool layoutNodeInternal(const CSSNodeRef node, const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn); // First, try to use the layout cache. - if (CSSNodeCanUseCachedMeasurement(node->isTextNode, - widthMeasureMode, + if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, availableWidth, heightMeasureMode, availableHeight, @@ -2220,8 +2216,7 @@ bool layoutNodeInternal(const CSSNodeRef node, } else { // Try to use the measurement cache. for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) { - if (CSSNodeCanUseCachedMeasurement(node->isTextNode, - widthMeasureMode, + if (CSSNodeCanUseCachedMeasurement(widthMeasureMode, availableWidth, heightMeasureMode, availableHeight, diff --git a/React/CSSLayout/CSSLayout.h b/React/CSSLayout/CSSLayout.h index 881d8f3b1..88272ad7d 100644 --- a/React/CSSLayout/CSSLayout.h +++ b/React/CSSLayout/CSSLayout.h @@ -161,8 +161,7 @@ WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const CSSPrintOptions option WIN_EXPORT bool CSSValueIsUndefined(const float value); -WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, - const CSSMeasureMode widthMode, +WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode, const float width, const CSSMeasureMode heightMode, const float height, @@ -195,7 +194,6 @@ WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const bool isTextNode, CSS_NODE_PROPERTY(void *, Context, context); CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc); CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc); -CSS_NODE_PROPERTY(bool, IsTextnode, isTextNode); CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout); CSS_NODE_STYLE_PROPERTY(CSSDirection, Direction, direction); diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java index 6d5d61b3e..612be2463 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNode.java @@ -140,18 +140,6 @@ public class CSSNode implements CSSNodeAPI { return mChildren == null ? -1 : mChildren.indexOf(child); } - private native void jni_CSSNodeSetIsTextNode(long nativePointer, boolean isTextNode); - @Override - public void setIsTextNode(boolean isTextNode) { - jni_CSSNodeSetIsTextNode(mNativePointer, isTextNode); - } - - private native boolean jni_CSSNodeGetIsTextNode(long nativePointer); - @Override - public boolean isTextNode() { - return jni_CSSNodeGetIsTextNode(mNativePointer); - } - private native void jni_CSSNodeCalculateLayout(long nativePointer); @Override public void calculateLayout(CSSLayoutContext layoutContext) { diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeAPI.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeAPI.java index 5a5de3825..dd18a54b9 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeAPI.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeAPI.java @@ -31,8 +31,6 @@ public interface CSSNodeAPI { int indexOf(CSSNodeType child); void setMeasureFunction(MeasureFunction measureFunction); boolean isMeasureDefined(); - void setIsTextNode(boolean isTextNode); - boolean isTextNode(); void calculateLayout(CSSLayoutContext layoutContext); boolean isDirty(); boolean hasNewLayout(); diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeDEPRECATED.java b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeDEPRECATED.java index 05632cf81..dc31cc041 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeDEPRECATED.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/CSSNodeDEPRECATED.java @@ -58,7 +58,6 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { private @Nullable CSSNodeDEPRECATED mParent; private @Nullable MeasureFunction mMeasureFunction = null; private LayoutState mLayoutState = LayoutState.DIRTY; - private boolean mIsTextNode = false; private Object mData; @Override @@ -124,16 +123,6 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI { return mMeasureFunction != null; } - @Override - public void setIsTextNode(boolean isTextNode) { - mIsTextNode = isTextNode; - } - - @Override - public boolean isTextNode() { - return mIsTextNode; - } - long measure(float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { if (!isMeasureDefined()) { throw new RuntimeException("Measure function isn't defined!"); diff --git a/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java b/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java index 79d33bce8..c6fa42c2a 100644 --- a/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java +++ b/ReactAndroid/src/main/java/com/facebook/csslayout/LayoutEngine.java @@ -240,7 +240,6 @@ public class LayoutEngine { } /*package*/ static boolean canUseCachedMeasurement( - boolean isTextNode, float availableWidth, float availableHeight, float marginRow, @@ -281,38 +280,6 @@ public class LayoutEngine { return true; } - // We know this to be text so we can apply some more specialized heuristics. - if (isTextNode) { - if (isWidthSame) { - if (heightMeasureMode == CSSMeasureMode.UNDEFINED) { - // Width is the same and height is not restricted. Re-use cahced value. - return true; - } - - if (heightMeasureMode == CSSMeasureMode.AT_MOST && - cachedLayout.computedHeight < (availableHeight - marginColumn)) { - // Width is the same and height restriction is greater than the cached height. Re-use cached value. - return true; - } - - // Width is the same but height restriction imposes smaller height than previously measured. - // Update the cached value to respect the new height restriction. - cachedLayout.computedHeight = availableHeight - marginColumn; - return true; - } - - if (cachedLayout.widthMeasureMode == CSSMeasureMode.UNDEFINED) { - if (widthMeasureMode == CSSMeasureMode.UNDEFINED || - (widthMeasureMode == CSSMeasureMode.AT_MOST && - cachedLayout.computedWidth <= (availableWidth - marginRow))) { - // Previsouly this text was measured with no width restriction, if width is now restricted - // but to a larger value than the previsouly measured width we can re-use the measurement - // as we know it will fit. - return true; - } - } - } - return false; } @@ -364,13 +331,13 @@ public class LayoutEngine { node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]); // First, try to use the layout cache. - if (canUseCachedMeasurement(node.isTextNode(), availableWidth, availableHeight, marginAxisRow, marginAxisColumn, + if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, widthMeasureMode, heightMeasureMode, layout.cachedLayout)) { cachedResults = layout.cachedLayout; } else { // Try to use the measurement cache. for (int i = 0; i < layout.nextCachedMeasurementsIndex; i++) { - if (canUseCachedMeasurement(node.isTextNode(), availableWidth, availableHeight, marginAxisRow, marginAxisColumn, + if (canUseCachedMeasurement(availableWidth, availableHeight, marginAxisRow, marginAxisColumn, widthMeasureMode, heightMeasureMode, layout.cachedMeasurements[i])) { cachedResults = layout.cachedMeasurements[i]; break;