From 737f1cc67c4b5a53eca5020ff2ed3ef504e00032 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Thu, 9 Feb 2017 03:16:51 -0800 Subject: [PATCH 1/2] Remove now not needed definition of allow_unsafe_import Summary: not needed any more Reviewed By: bolinfest Differential Revision: D4532533 fbshipit-source-id: 43b4db9a21ae774f7d41187e4e4598e171b7a59c --- YOGA_DEFS | 6 ------ 1 file changed, 6 deletions(-) diff --git a/YOGA_DEFS b/YOGA_DEFS index 288b13be..8d17d58f 100644 --- a/YOGA_DEFS +++ b/YOGA_DEFS @@ -27,9 +27,3 @@ BASE_COMPILER_FLAGS = [ def yoga_dep(dep): return '//' + dep - -class allow_unsafe_import: - def __enter__(self): - pass - def __exit__(self, type, value, traceback): - pass -- 2.50.1.windows.1 From 9f192b0372653b0325257209108d54a46faa657b Mon Sep 17 00:00:00 2001 From: David Hart Date: Fri, 3 Feb 2017 20:46:12 +0100 Subject: [PATCH 2/2] Rename pixels to points --- YogaKit/Source/YGLayout.m | 14 +-- YogaKit/Tests/YogaKitTests.m | 84 ++++++------- csharp/Facebook.Yoga/YogaUnit.cs | 2 +- csharp/Facebook.Yoga/YogaValue.cs | 8 +- csharp/Facebook.Yoga/YogaValueExtensions.cs | 8 +- csharp/Facebook.YogaKit/YogaLayout.cs | 4 +- csharp/iOS/Facebook.YogaKit.iOS/YogaLayout.cs | 2 +- enums.py | 2 +- gentest/gentest.js | 64 +++++----- .../facebook/yoga/YogaBaselineFunction.java | 2 +- java/com/facebook/yoga/YogaUnit.java | 4 +- java/com/facebook/yoga/YogaValue.java | 2 +- javascript/sources/YGEnums.js | 2 +- javascript/sources/entry-common.js | 6 +- yoga/YGEnums.h | 111 +++++++++++------- yoga/Yoga.c | 34 +++--- yoga/Yoga.h | 2 +- 17 files changed, 186 insertions(+), 165 deletions(-) diff --git a/YogaKit/Source/YGLayout.m b/YogaKit/Source/YGLayout.m index 9c44cc83..99259aad 100644 --- a/YogaKit/Source/YGLayout.m +++ b/YogaKit/Source/YGLayout.m @@ -25,7 +25,7 @@ - (CGFloat)lowercased_name \ { \ YGValue value = YGNodeStyleGet##capitalized_name(self.node); \ - if (value.unit == YGUnitPixel) { \ + if (value.unit == YGUnitPoint) { \ return value.value; \ } else { \ return YGUndefined; \ @@ -67,7 +67,7 @@ YG_EDGE_PROPERTY_SETTER(lowercased_name, capitalized_name, property, edge) - (CGFloat)objc_lowercased_name \ { \ YGValue value = YGNodeStyleGet##c_name(self.node, edge); \ - if (value.unit == YGUnitPixel) { \ + if (value.unit == YGUnitPoint) { \ return value.value; \ } else { \ return YGUndefined; \ @@ -353,7 +353,7 @@ static void YGRemoveAllChildren(const YGNodeRef node) } } -static CGFloat YGRoundPixelValue(CGFloat value) +static CGFloat YGRoundPointValue(CGFloat value) { static CGFloat scale; static dispatch_once_t onceToken; @@ -387,12 +387,12 @@ static void YGApplyLayoutToViewHierarchy(UIView *view) view.frame = (CGRect) { .origin = { - .x = YGRoundPixelValue(topLeft.x), - .y = YGRoundPixelValue(topLeft.y), + .x = YGRoundPointValue(topLeft.x), + .y = YGRoundPointValue(topLeft.y), }, .size = { - .width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x), - .height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y), + .width = YGRoundPointValue(bottomRight.x) - YGRoundPointValue(topLeft.x), + .height = YGRoundPointValue(bottomRight.y) - YGRoundPointValue(topLeft.y), }, }; diff --git a/YogaKit/Tests/YogaKitTests.m b/YogaKit/Tests/YogaKitTests.m index c9b6c018..e040b8da 100644 --- a/YogaKit/Tests/YogaKitTests.m +++ b/YogaKit/Tests/YogaKitTests.m @@ -417,32 +417,32 @@ view.yoga.left = 1; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).value, 1); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.left, 1); view.yoga.right = 2; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).value, 2); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.right, 2); view.yoga.top = 3; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).value, 3); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.top, 3); view.yoga.bottom = 4; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).value, 4); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertEqual(view.yoga.bottom, 4); view.yoga.start = 5; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).value, 5); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.start, 5); view.yoga.end = 6; XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).value, 6); - XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPosition(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertEqual(view.yoga.end, 6); } @@ -452,67 +452,67 @@ view.yoga.margin = 1; XCTAssertEqual(view.yoga.marginLeft, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginRight, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginStart, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginEnd, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginTop, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginBottom, 1); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.marginHorizontal)); XCTAssertTrue(isnan(view.yoga.marginVertical)); XCTAssertTrue(isnan(view.yoga.margin)); view.yoga.marginHorizontal = 2; XCTAssertEqual(view.yoga.marginLeft, 2); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginRight, 2); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginStart, 2); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginEnd, 2); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.marginHorizontal)); view.yoga.marginVertical = 3; XCTAssertEqual(view.yoga.marginTop, 3); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginBottom, 3); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.marginVertical)); view.yoga.marginLeft = 4; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).value, 4); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginLeft, 4); view.yoga.marginRight = 5; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).value, 5); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginRight, 5); view.yoga.marginTop = 6; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).value, 6); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginTop, 6); view.yoga.marginBottom = 7; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).value, 7); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginBottom, 7); view.yoga.marginStart = 8; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).value, 8); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginStart, 8); view.yoga.marginEnd = 9; XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).value, 9); - XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetMargin(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertEqual(view.yoga.marginEnd, 9); } @@ -522,67 +522,67 @@ view.yoga.padding = 1; XCTAssertEqual(view.yoga.paddingLeft, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingRight, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingStart, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingEnd, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingTop, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingBottom, 1); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.paddingHorizontal)); XCTAssertTrue(isnan(view.yoga.paddingVertical)); XCTAssertTrue(isnan(view.yoga.padding)); view.yoga.paddingHorizontal = 2; XCTAssertEqual(view.yoga.paddingLeft, 2); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingRight, 2); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingStart, 2); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingEnd, 2); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.paddingHorizontal)); view.yoga.paddingVertical = 3; XCTAssertEqual(view.yoga.paddingTop, 3); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingBottom, 3); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertTrue(isnan(view.yoga.paddingVertical)); view.yoga.paddingLeft = 4; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).value, 4); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeLeft).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingLeft, 4); view.yoga.paddingRight = 5; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).value, 5); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeRight).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingRight, 5); view.yoga.paddingTop = 6; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).value, 6); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeTop).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingTop, 6); view.yoga.paddingBottom = 7; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).value, 7); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeBottom).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingBottom, 7); view.yoga.paddingStart = 8; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).value, 8); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeStart).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingStart, 8); view.yoga.paddingEnd = 9; XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).value, 9); - XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPixel); + XCTAssertEqual(YGNodeStyleGetPadding(view.yoga.node, YGEdgeEnd).unit, YGUnitPoint); XCTAssertEqual(view.yoga.paddingEnd, 9); } diff --git a/csharp/Facebook.Yoga/YogaUnit.cs b/csharp/Facebook.Yoga/YogaUnit.cs index 396c45da..5a234702 100644 --- a/csharp/Facebook.Yoga/YogaUnit.cs +++ b/csharp/Facebook.Yoga/YogaUnit.cs @@ -12,7 +12,7 @@ namespace Facebook.Yoga public enum YogaUnit { Undefined, - Pixel, + Point, Percent, } } diff --git a/csharp/Facebook.Yoga/YogaValue.cs b/csharp/Facebook.Yoga/YogaValue.cs index e86e16d3..8457a505 100644 --- a/csharp/Facebook.Yoga/YogaValue.cs +++ b/csharp/Facebook.Yoga/YogaValue.cs @@ -33,12 +33,12 @@ namespace Facebook.Yoga } } - public static YogaValue Pixel(float value) + public static YogaValue Point(float value) { return new YogaValue { value = value, - unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Pixel + unit = YogaConstants.IsUndefined(value) ? YogaUnit.Undefined : YogaUnit.Point }; } @@ -79,9 +79,9 @@ namespace Facebook.Yoga }; } - public static implicit operator YogaValue(float pixelValue) + public static implicit operator YogaValue(float pointValue) { - return Pixel(pixelValue); + return Point(pointValue); } } } diff --git a/csharp/Facebook.Yoga/YogaValueExtensions.cs b/csharp/Facebook.Yoga/YogaValueExtensions.cs index 9ccee62a..73b98057 100644 --- a/csharp/Facebook.Yoga/YogaValueExtensions.cs +++ b/csharp/Facebook.Yoga/YogaValueExtensions.cs @@ -16,9 +16,9 @@ namespace Facebook.Yoga return YogaValue.Percent(value); } - public static YogaValue Px(this float value) + public static YogaValue Pt(this float value) { - return YogaValue.Pixel(value); + return YogaValue.Point(value); } public static YogaValue Percent(this int value) @@ -26,9 +26,9 @@ namespace Facebook.Yoga return YogaValue.Percent(value); } - public static YogaValue Px(this int value) + public static YogaValue Pt(this int value) { - return YogaValue.Pixel(value); + return YogaValue.Point(value); } } } \ No newline at end of file diff --git a/csharp/Facebook.YogaKit/YogaLayout.cs b/csharp/Facebook.YogaKit/YogaLayout.cs index f4cd4635..d59c1b17 100644 --- a/csharp/Facebook.YogaKit/YogaLayout.cs +++ b/csharp/Facebook.YogaKit/YogaLayout.cs @@ -854,9 +854,9 @@ namespace Facebook.YogaKit } } - static double RoundPixelValue(float value) + static double RoundPointValue(float value) { - float scale = NativePixelScale; + float scale = NativePointScale; return Math.Round(value * scale) / scale; } diff --git a/csharp/iOS/Facebook.YogaKit.iOS/YogaLayout.cs b/csharp/iOS/Facebook.YogaKit.iOS/YogaLayout.cs index 6aa052bf..aacd3377 100644 --- a/csharp/iOS/Facebook.YogaKit.iOS/YogaLayout.cs +++ b/csharp/iOS/Facebook.YogaKit.iOS/YogaLayout.cs @@ -30,7 +30,7 @@ namespace Facebook.YogaKit { var topLeft = new CGPoint(node.LayoutX, node.LayoutY); var bottomRight = new CGPoint(topLeft.X + node.LayoutWidth, topLeft.Y + node.LayoutHeight); - view.Frame = new CGRect(RoundPixelValue((float)topLeft.X), RoundPixelValue((float)topLeft.Y), RoundPixelValue((float)bottomRight.X) - RoundPixelValue((float)topLeft.X), RoundPixelValue((float)bottomRight.Y) - RoundPixelValue((float)topLeft.Y)); + view.Frame = new CGRect(RoundPointValue((float)topLeft.X), RoundPointValue((float)topLeft.Y), RoundPointValue((float)bottomRight.X) - RoundPointValue((float)topLeft.X), RoundPointValue((float)bottomRight.Y) - RoundPointValue((float)topLeft.Y)); } bool _disposed; diff --git a/enums.py b/enums.py index 47ff69ca..8c154f93 100644 --- a/enums.py +++ b/enums.py @@ -19,7 +19,7 @@ ENUMS = { ], 'Unit': [ 'Undefined', - 'Pixel', + 'Point', 'Percent', ], 'FlexDirection': [ diff --git a/gentest/gentest.js b/gentest/gentest.js index 98559988..c1cabd49 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -201,105 +201,105 @@ function setupTestTree(e, parent, node, genericNode, nodeName, parentName, index e.YGNodeStyleSetFlexShrink(nodeName, node.style[style]); break; case 'flex-basis': - e.YGNodeStyleSetFlexBasis(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetFlexBasis(nodeName, pointValue(e, node.style[style])); break; case 'left': if (genericNode.rawStyle.indexOf('start:') >= 0) { - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeStart, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style])); } break; case 'top': - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeTop, pointValue(e, node.style[style])); break; case 'right': if (genericNode.rawStyle.indexOf('end:') >= 0) { - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeRight, pointValue(e, node.style[style])); } break; case 'bottom': - e.YGNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPosition(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style])); break; case 'margin-left': if (genericNode.rawStyle.indexOf('margin-start:') >= 0) { - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeStart, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style])); } break; case 'margin-top': - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeTop, pointValue(e, node.style[style])); break; case 'margin-right': if (genericNode.rawStyle.indexOf('margin-end:') >= 0) { - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeRight, pointValue(e, node.style[style])); } break; case 'margin-bottom': - e.YGNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMargin(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style])); break; case 'padding-left': if (genericNode.rawStyle.indexOf('padding-start:') >= 0) { - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeStart, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style])); } break; case 'padding-top': - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeTop, pointValue(e, node.style[style])); break; case 'padding-right': if (genericNode.rawStyle.indexOf('padding-end:') >= 0) { - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeRight, pointValue(e, node.style[style])); } break; case 'padding-bottom': - e.YGNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetPadding(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style])); break; case 'border-left-width': if (genericNode.rawStyle.indexOf('border-start-width:') >= 0) { - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeStart, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeStart, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeLeft, pointValue(e, node.style[style])); } break; case 'border-top-width': - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeTop, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeTop, pointValue(e, node.style[style])); break; case 'border-right-width': if (genericNode.rawStyle.indexOf('border-end-width:') >= 0) { - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeEnd, pointValue(e, node.style[style])); } else { - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeRight, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeRight, pointValue(e, node.style[style])); } break; case 'border-bottom-width': - e.YGNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pixelValue(e, node.style[style])); + e.YGNodeStyleSetBorder(nodeName, e.YGEdgeBottom, pointValue(e, node.style[style])); break; case 'width': - e.YGNodeStyleSetWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetWidth(nodeName, pointValue(e, node.style[style])); break; case 'min-width': - e.YGNodeStyleSetMinWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMinWidth(nodeName, pointValue(e, node.style[style])); break; case 'max-width': - e.YGNodeStyleSetMaxWidth(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMaxWidth(nodeName, pointValue(e, node.style[style])); break; case 'height': - e.YGNodeStyleSetHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetHeight(nodeName, pointValue(e, node.style[style])); break; case 'min-height': - e.YGNodeStyleSetMinHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMinHeight(nodeName, pointValue(e, node.style[style])); break; case 'max-height': - e.YGNodeStyleSetMaxHeight(nodeName, pixelValue(e, node.style[style])); + e.YGNodeStyleSetMaxHeight(nodeName, pointValue(e, node.style[style])); break; case 'display': e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style])) @@ -385,7 +385,7 @@ function alignValue(e, value) { } } -function pixelValue(e, value) { +function pointValue(e, value) { switch (value) { case 'auto': return e.YGUndefined; case 'undefined': return e.YGUndefined; diff --git a/java/com/facebook/yoga/YogaBaselineFunction.java b/java/com/facebook/yoga/YogaBaselineFunction.java index 1bfb52a7..60de81c5 100644 --- a/java/com/facebook/yoga/YogaBaselineFunction.java +++ b/java/com/facebook/yoga/YogaBaselineFunction.java @@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip public interface YogaBaselineFunction { /** - * Return the baseline of the node in pixels. When no baseline function is set the baseline + * Return the baseline of the node in points. When no baseline function is set the baseline * default to the computed height of the node. */ @DoNotStrip diff --git a/java/com/facebook/yoga/YogaUnit.java b/java/com/facebook/yoga/YogaUnit.java index f14e5216..39b44cf8 100644 --- a/java/com/facebook/yoga/YogaUnit.java +++ b/java/com/facebook/yoga/YogaUnit.java @@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip public enum YogaUnit { UNDEFINED(0), - PIXEL(1), + POINT(1), PERCENT(2); private int mIntValue; @@ -30,7 +30,7 @@ public enum YogaUnit { public static YogaUnit fromInt(int value) { switch (value) { case 0: return UNDEFINED; - case 1: return PIXEL; + case 1: return POINT; case 2: return PERCENT; default: throw new IllegalArgumentException("Unknown enum value: " + value); } diff --git a/java/com/facebook/yoga/YogaValue.java b/java/com/facebook/yoga/YogaValue.java index 1110eded..300b04d9 100644 --- a/java/com/facebook/yoga/YogaValue.java +++ b/java/com/facebook/yoga/YogaValue.java @@ -14,7 +14,7 @@ import com.facebook.proguard.annotations.DoNotStrip; @DoNotStrip public class YogaValue { static final YogaValue UNDEFINED = new YogaValue(YogaConstants.UNDEFINED, YogaUnit.UNDEFINED); - static final YogaValue ZERO = new YogaValue(0, YogaUnit.PIXEL); + static final YogaValue ZERO = new YogaValue(0, YogaUnit.POINT); public final float value; public final YogaUnit unit; diff --git a/javascript/sources/YGEnums.js b/javascript/sources/YGEnums.js index b48c7b7a..fb4b90db 100644 --- a/javascript/sources/YGEnums.js +++ b/javascript/sources/YGEnums.js @@ -86,7 +86,7 @@ module.exports = { UNIT_COUNT: 3, UNIT_UNDEFINED: 0, - UNIT_PIXEL: 1, + UNIT_POINT: 1, UNIT_PERCENT: 2, WRAP_COUNT: 2, diff --git a/javascript/sources/entry-common.js b/javascript/sources/entry-common.js index c4161663..1fa3522a 100644 --- a/javascript/sources/entry-common.js +++ b/javascript/sources/entry-common.js @@ -102,7 +102,7 @@ module.exports = function (bind, lib) { switch (this.unit) { - case constants.UNIT_PIXEL: + case constants.UNIT_POINT: return `${this.value}`; case constants.UNIT_PERCENT: @@ -126,7 +126,7 @@ module.exports = function (bind, lib) { for (let fnName of [ `setPosition`, `setMargin`, `setFlexBasis`, `setWidth`, `setHeight`, `setMinWidth`, `setMinHeight`, `setMaxWidth`, `setMaxHeight`, `setPadding` ]) { - let methods = { [constants.UNIT_PIXEL]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] }; + let methods = { [constants.UNIT_POINT]: lib.Node.prototype[fnName], [constants.UNIT_PERCENT]: lib.Node.prototype[`${fnName}Percent`] }; if (Object.keys(methods).some(method => methods[method] == null)) throw new Error(`Assertion failed; some unit derivates of ${fnName} seem missing`); @@ -146,7 +146,7 @@ module.exports = function (bind, lib) { } else { - unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_PIXEL; + unit = typeof value === `string` && value.endsWith(`%`) ? constants.UNIT_PERCENT : constants.UNIT_POINT; asNumber = parseFloat(value); } diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index b4efc9cc..b981cdc7 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -15,21 +15,26 @@ YG_EXTERN_C_BEGIN #define YGAlignCount 6 typedef YG_ENUM_BEGIN(YGAlign) { - YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, YGAlignBaseline, -} -YG_ENUM_END(YGAlign); + YGAlignAuto, + YGAlignFlexStart, + YGAlignCenter, + YGAlignFlexEnd, + YGAlignStretch, + YGAlignBaseline, +} YG_ENUM_END(YGAlign); #define YGDimensionCount 2 typedef YG_ENUM_BEGIN(YGDimension) { - YGDimensionWidth, YGDimensionHeight, -} -YG_ENUM_END(YGDimension); + YGDimensionWidth, + YGDimensionHeight, +} YG_ENUM_END(YGDimension); #define YGDirectionCount 3 typedef YG_ENUM_BEGIN(YGDirection) { - YGDirectionInherit, YGDirectionLTR, YGDirectionRTL, -} -YG_ENUM_END(YGDirection); + YGDirectionInherit, + YGDirectionLTR, + YGDirectionRTL, +} YG_ENUM_END(YGDirection); #define YGDisplayCount 2 typedef YG_ENUM_BEGIN(YGDisplay) { @@ -39,71 +44,87 @@ typedef YG_ENUM_BEGIN(YGDisplay) { #define YGEdgeCount 9 typedef YG_ENUM_BEGIN(YGEdge) { - YGEdgeLeft, YGEdgeTop, YGEdgeRight, YGEdgeBottom, YGEdgeStart, YGEdgeEnd, YGEdgeHorizontal, - YGEdgeVertical, YGEdgeAll, -} -YG_ENUM_END(YGEdge); + YGEdgeLeft, + YGEdgeTop, + YGEdgeRight, + YGEdgeBottom, + YGEdgeStart, + YGEdgeEnd, + YGEdgeHorizontal, + YGEdgeVertical, + YGEdgeAll, +} YG_ENUM_END(YGEdge); #define YGExperimentalFeatureCount 2 typedef YG_ENUM_BEGIN(YGExperimentalFeature) { - YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis, -} -YG_ENUM_END(YGExperimentalFeature); + YGExperimentalFeatureRounding, + YGExperimentalFeatureWebFlexBasis, +} YG_ENUM_END(YGExperimentalFeature); #define YGFlexDirectionCount 4 typedef YG_ENUM_BEGIN(YGFlexDirection) { - YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow, - YGFlexDirectionRowReverse, -} -YG_ENUM_END(YGFlexDirection); + YGFlexDirectionColumn, + YGFlexDirectionColumnReverse, + YGFlexDirectionRow, + YGFlexDirectionRowReverse, +} YG_ENUM_END(YGFlexDirection); #define YGJustifyCount 5 typedef YG_ENUM_BEGIN(YGJustify) { - YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween, - YGJustifySpaceAround, -} -YG_ENUM_END(YGJustify); + YGJustifyFlexStart, + YGJustifyCenter, + YGJustifyFlexEnd, + YGJustifySpaceBetween, + YGJustifySpaceAround, +} YG_ENUM_END(YGJustify); #define YGLogLevelCount 5 typedef YG_ENUM_BEGIN(YGLogLevel) { - YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose, -} -YG_ENUM_END(YGLogLevel); + YGLogLevelError, + YGLogLevelWarn, + YGLogLevelInfo, + YGLogLevelDebug, + YGLogLevelVerbose, +} YG_ENUM_END(YGLogLevel); #define YGMeasureModeCount 3 typedef YG_ENUM_BEGIN(YGMeasureMode) { - YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost, -} -YG_ENUM_END(YGMeasureMode); + YGMeasureModeUndefined, + YGMeasureModeExactly, + YGMeasureModeAtMost, +} YG_ENUM_END(YGMeasureMode); #define YGOverflowCount 3 typedef YG_ENUM_BEGIN(YGOverflow) { - YGOverflowVisible, YGOverflowHidden, YGOverflowScroll, -} -YG_ENUM_END(YGOverflow); + YGOverflowVisible, + YGOverflowHidden, + YGOverflowScroll, +} YG_ENUM_END(YGOverflow); #define YGPositionTypeCount 2 typedef YG_ENUM_BEGIN(YGPositionType) { - YGPositionTypeRelative, YGPositionTypeAbsolute, -} -YG_ENUM_END(YGPositionType); + YGPositionTypeRelative, + YGPositionTypeAbsolute, +} YG_ENUM_END(YGPositionType); #define YGPrintOptionsCount 3 typedef YG_ENUM_BEGIN(YGPrintOptions) { - YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4, -} -YG_ENUM_END(YGPrintOptions); + YGPrintOptionsLayout = 1, + YGPrintOptionsStyle = 2, + YGPrintOptionsChildren = 4, +} YG_ENUM_END(YGPrintOptions); #define YGUnitCount 3 typedef YG_ENUM_BEGIN(YGUnit) { - YGUnitUndefined, YGUnitPixel, YGUnitPercent, -} -YG_ENUM_END(YGUnit); + YGUnitUndefined, + YGUnitPoint, + YGUnitPercent, +} YG_ENUM_END(YGUnit); #define YGWrapCount 2 typedef YG_ENUM_BEGIN(YGWrap) { - YGWrapNoWrap, YGWrapWrap, -} -YG_ENUM_END(YGWrap); + YGWrapNoWrap, + YGWrapWrap, +} YG_ENUM_END(YGWrap); YG_EXTERN_C_END diff --git a/yoga/Yoga.c b/yoga/Yoga.c index 3bd71471..ed0b566e 100644 --- a/yoga/Yoga.c +++ b/yoga/Yoga.c @@ -188,7 +188,7 @@ YGCalloc gYGCalloc = &calloc; YGRealloc gYGRealloc = &realloc; YGFree gYGFree = &free; -static YGValue YGValueZero = {.value = 0, .unit = YGUnitPixel}; +static YGValue YGValueZero = {.value = 0, .unit = YGUnitPoint}; #ifdef ANDROID #include @@ -265,7 +265,7 @@ static inline float YGValueResolve(const YGValue *const value, const float paren switch (value->unit) { case YGUnitUndefined: return YGUndefined; - case YGUnitPixel: + case YGUnitPoint: return value->value; case YGUnitPercent: return value->value * parentSize / 100.0f; @@ -462,10 +462,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_PROPERTY_SETTER_UNIT_IMPL(type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ if (node->style.instanceName.value != paramName || \ - node->style.instanceName.unit != YGUnitPixel) { \ + node->style.instanceName.unit != YGUnitPoint) { \ node->style.instanceName.value = paramName; \ node->style.instanceName.unit = \ - YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -497,10 +497,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_IMPL(type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || \ - node->style.instanceName[edge].unit != YGUnitPixel) { \ + node->style.instanceName[edge].unit != YGUnitPoint) { \ node->style.instanceName[edge].value = paramName; \ node->style.instanceName[edge].unit = \ - YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -524,10 +524,10 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) { #define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const YGEdge edge, const float paramName) { \ if (node->style.instanceName[edge].value != paramName || \ - node->style.instanceName[edge].unit != YGUnitPixel) { \ + node->style.instanceName[edge].unit != YGUnitPoint) { \ node->style.instanceName[edge].value = paramName; \ node->style.instanceName[edge].unit = \ - YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPixel; \ + YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \ YGNodeMarkDirtyInternal(node); \ } \ } \ @@ -671,7 +671,7 @@ static void YGPrintNumberIfNotZero(const char *str, const YGValue *const number) "%s: %g%s, ", str, number->value, - number->unit == YGUnitPixel ? "px" : "%"); + number->unit == YGUnitPoint ? "pt" : "%"); } } @@ -687,7 +687,7 @@ static void YGPrintNumberIfNotUndefined(const char *str, const YGValue *const nu "%s: %g%s, ", str, number->value, - number->unit == YGUnitPixel ? "px" : "%"); + number->unit == YGUnitPoint ? "pt" : "%"); } } @@ -1098,7 +1098,7 @@ static inline bool YGNodeIsStyleDimDefined(const YGNodeRef node, const YGFlexDirection axis, const float parentSize) { return !(node->resolvedDimensions[dim[axis]].unit == YGUnitUndefined || - (node->resolvedDimensions[dim[axis]].unit == YGUnitPixel && + (node->resolvedDimensions[dim[axis]].unit == YGUnitPoint && node->resolvedDimensions[dim[axis]].value < 0.0f) || (node->resolvedDimensions[dim[axis]].unit == YGUnitPercent && YGFloatIsUndefined(parentSize))); @@ -1723,11 +1723,11 @@ static void YGZeroOutLayoutRecursivly(const YGNodeRef node) { // the width/height attributes. // flex: -1 (or any negative value) is equivalent to flex: 0 1 auto // * Margins cannot be specified as 'auto'. They must be specified in terms of -// pixel +// points // values, and the default value is 0. // * Values of width, maxWidth, minWidth, height, maxHeight and minHeight must // be -// specified as pixel values, not as percentages. +// specified as point values, not as percentages. // * There is no support for calculation of dimensions based on intrinsic // aspect ratios // (e.g. images). @@ -2122,7 +2122,7 @@ static void YGNodelayoutImpl(const YGNodeRef node, // based on its // content. // sizeConsumedOnCurrentLine is negative which means the node will - // allocate 0 pixels for + // allocate 0 points for // its content. Consequently, remainingFreeSpace is 0 - // sizeConsumedOnCurrentLine. remainingFreeSpace = -sizeConsumedOnCurrentLine; @@ -3144,7 +3144,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, return (needToVisitNode || cachedResults == NULL); } -static void roundToPixelGrid(const YGNodeRef node) { +static void roundToPointGrid(const YGNodeRef node) { const float fractialLeft = node->layout.position[YGEdgeLeft] - floorf(node->layout.position[YGEdgeLeft]); const float fractialTop = @@ -3159,7 +3159,7 @@ static void roundToPixelGrid(const YGNodeRef node) { const uint32_t childCount = YGNodeListCount(node->children); for (uint32_t i = 0; i < childCount; i++) { - roundToPixelGrid(YGNodeGetChild(node, i)); + roundToPointGrid(YGNodeGetChild(node, i)); } } @@ -3219,7 +3219,7 @@ void YGNodeCalculateLayout(const YGNodeRef node, YGNodeSetPosition(node, node->layout.direction, availableWidth, availableHeight, availableWidth); if (YGIsExperimentalFeatureEnabled(YGExperimentalFeatureRounding)) { - roundToPixelGrid(node); + roundToPointGrid(node); } if (gPrintTree) { diff --git a/yoga/Yoga.h b/yoga/Yoga.h index bf9bd3e8..4b0dd9b2 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -200,7 +200,7 @@ YG_NODE_LAYOUT_PROPERTY(float, Height); YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction); // Get the computed values for these nodes after performing layout. If they were set using -// pixel values then the returned value will be the same as YGNodeStyleGetXXX. However if +// point values then the returned value will be the same as YGNodeStyleGetXXX. However if // they were set using a percentage value then the returned value is the computed value used // during layout. YG_NODE_LAYOUT_EDGE_PROPERTY(float, Margin); -- 2.50.1.windows.1