Add convenient cast method for MeasureOutput.Make
Summary: Same as Java, it allows to use float and double values in Make arguments. Reviewed By: emilsjolander Differential Revision: D4163347 fbshipit-source-id: f373247b3f37e7940a66044000cca2935068decf
This commit is contained in:
committed by
Facebook Github Bot
parent
f222d22ba8
commit
0dbbfc5910
@@ -11,6 +11,11 @@ namespace Facebook.CSSLayout
|
|||||||
{
|
{
|
||||||
public class MeasureOutput
|
public class MeasureOutput
|
||||||
{
|
{
|
||||||
|
public static long Make(double width, double height)
|
||||||
|
{
|
||||||
|
return Make((int) width, (int) height);
|
||||||
|
}
|
||||||
|
|
||||||
public static long Make(int width, int height)
|
public static long Make(int width, int height)
|
||||||
{
|
{
|
||||||
return (long)(((ulong) width) << 32 | ((ulong) height));
|
return (long)(((ulong) width) << 32 | ((ulong) height));
|
||||||
|
@@ -157,8 +157,20 @@ namespace Facebook.CSSLayout
|
|||||||
return MeasureOutput.Make(100, 150);
|
return MeasureOutput.Make(100, 150);
|
||||||
});
|
});
|
||||||
node.CalculateLayout();
|
node.CalculateLayout();
|
||||||
Assert.AreEqual(100, (int)node.LayoutWidth);
|
Assert.AreEqual(100, node.LayoutWidth);
|
||||||
Assert.AreEqual(150, (int)node.LayoutHeight);
|
Assert.AreEqual(150, node.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMeasureFuncWithFloat()
|
||||||
|
{
|
||||||
|
CSSNode node = new CSSNode();
|
||||||
|
node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
|
||||||
|
return MeasureOutput.Make(123.4f, 81.7f);
|
||||||
|
});
|
||||||
|
node.CalculateLayout();
|
||||||
|
Assert.AreEqual(123, node.LayoutWidth);
|
||||||
|
Assert.AreEqual(81, node.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
Reference in New Issue
Block a user