Refactor types used during yoga meassure calls

Summary: This diff refactors the types used when Yoga requires to measure the size of a View in C++

Reviewed By: shergin

Differential Revision: D13124086

fbshipit-source-id: 89dfe80bb41b4fb2eaba84af630d52ef2509b1e1
This commit is contained in:
David Vacca
2018-11-25 17:18:10 -08:00
committed by Facebook Github Bot
parent 0357d0de64
commit 10ce6c3e11
5 changed files with 24 additions and 14 deletions

View File

@@ -213,7 +213,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
return null;
}
public float[] measure(
public long measure(
ReactContext context,
T view,
ReadableNativeMap localData,
@@ -222,6 +222,6 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
return null;
return 0;
}
}

View File

@@ -103,7 +103,7 @@ public class ReactTextViewManager
return MapBuilder.of("topTextLayout", MapBuilder.of("registrationName", "onTextLayout"));
}
public float[] measure(
public long measure(
ReactContext context,
ReactTextView view,
ReadableNativeMap localData,

View File

@@ -32,6 +32,7 @@ import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ViewDefaults;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
import java.awt.font.TextAttribute;
import java.util.ArrayList;
import java.util.List;
@@ -189,7 +190,7 @@ public class TextLayoutManager {
return sb;
}
public static float[] measureText(
public static long measureText(
ReactContext context,
ReactTextView view,
ReadableNativeMap attributedString,
@@ -296,7 +297,7 @@ public class TextLayoutManager {
height = layout.getHeight();
}
return new float[] { PixelUtil.toSPFromPixel(width), PixelUtil.toSPFromPixel(height) };
return YogaMeasureOutput.make(PixelUtil.toSPFromPixel(width), PixelUtil.toSPFromPixel(height));
}
private static class SetSpanOperation {