77 * of patent rights can be found in the PATENTS file in the same directory.
88 */
99
10- #include <assert.h>
11- #include <math.h>
12- #include <stdio.h>
13- #include <stdlib.h>
1410#include <string.h>
1511
1612#include "CSSLayout-internal.h"
@@ -102,7 +98,7 @@ void _CSSNodeMarkDirty(CSSNodeRef node) {
10298 }
10399}
104100
105- void CSSNodeInsertChild (CSSNodeRef node , CSSNodeRef child , unsigned int index ) {
101+ void CSSNodeInsertChild (CSSNodeRef node , CSSNodeRef child , uint32_t index ) {
106102 CSSNodeListInsert (node -> children , child , index );
107103 child -> parent = node ;
108104 _CSSNodeMarkDirty (node );
@@ -114,11 +110,11 @@ void CSSNodeRemoveChild(CSSNodeRef node, CSSNodeRef child) {
114110 _CSSNodeMarkDirty (node );
115111}
116112
117- CSSNodeRef CSSNodeGetChild (CSSNodeRef node , unsigned int index ) {
113+ CSSNodeRef CSSNodeGetChild (CSSNodeRef node , uint32_t index ) {
118114 return CSSNodeListGet (node -> children , index );
119115}
120116
121- unsigned int CSSNodeChildCount (CSSNodeRef node ) {
117+ uint32_t CSSNodeChildCount (CSSNodeRef node ) {
122118 return CSSNodeListCount (node -> children );
123119}
124120
@@ -214,7 +210,7 @@ CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Width, dimensions[CSSDimensionWidth]);
214210CSS_NODE_LAYOUT_PROPERTY_IMPL (float , Height , dimensions [CSSDimensionHeight ]);
215211CSS_NODE_LAYOUT_PROPERTY_IMPL (CSSDirection , Direction , direction );
216212
217- int gCurrentGenerationCount = 0 ;
213+ uint32_t gCurrentGenerationCount = 0 ;
218214
219215bool layoutNodeInternal (CSSNode * node , float availableWidth , float availableHeight , CSSDirection parentDirection ,
220216 CSSMeasureMode widthMeasureMode , CSSMeasureMode heightMeasureMode , bool performLayout , char * reason );
@@ -230,8 +226,8 @@ static bool eq(float a, float b) {
230226 return fabs (a - b ) < 0.0001 ;
231227}
232228
233- static void indent (int n ) {
234- for (int i = 0 ; i < n ; ++ i ) {
229+ static void indent (uint32_t n ) {
230+ for (uint32_t i = 0 ; i < n ; ++ i ) {
235231 printf (" " );
236232 }
237233}
@@ -259,7 +255,7 @@ static bool four_equal(float four[4]) {
259255static void print_css_node_rec (
260256 CSSNode * node ,
261257 CSSPrintOptions options ,
262- int level
258+ uint32_t level
263259) {
264260 indent (level );
265261 printf ("{" );
@@ -382,10 +378,10 @@ static void print_css_node_rec(
382378 print_number_nan ("bottom" , node -> style .position [CSSPositionBottom ]);
383379 }
384380
385- unsigned int childCount = CSSNodeListCount (node -> children );
381+ uint32_t childCount = CSSNodeListCount (node -> children );
386382 if (options & CSSPrintOptionsChildren && childCount > 0 ) {
387383 printf ("children: [\n" );
388- for (unsigned int i = 0 ; i < childCount ; ++ i ) {
384+ for (uint32_t i = 0 ; i < childCount ; ++ i ) {
389385 print_css_node_rec (CSSNodeGetChild (node , i ), options , level + 1 );
390386 }
391387 indent (level );
@@ -852,7 +848,7 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
852848
853849 // For nodes with no children, use the available values if they were provided, or
854850 // the minimum size as indicated by the padding and border sizes.
855- unsigned int childCount = CSSNodeListCount (node -> children );
851+ uint32_t childCount = CSSNodeListCount (node -> children );
856852 if (childCount == 0 ) {
857853 node -> layout .measuredDimensions [CSSDimensionWidth ] = boundAxis (node , CSSFlexDirectionRow ,
858854 (widthMeasureMode == CSSMeasureModeUndefined || widthMeasureMode == CSSMeasureModeAtMost ) ?
@@ -924,7 +920,7 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
924920
925921 // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
926922 CSSNode * child ;
927- unsigned int i ;
923+ uint32_t i ;
928924 float childWidth ;
929925 float childHeight ;
930926 CSSMeasureMode childWidthMeasureMode ;
@@ -1031,11 +1027,11 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
10311027 // STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
10321028
10331029 // Indexes of children that represent the first and last items in the line.
1034- int startOfLineIndex = 0 ;
1035- int endOfLineIndex = 0 ;
1030+ uint32_t startOfLineIndex = 0 ;
1031+ uint32_t endOfLineIndex = 0 ;
10361032
10371033 // Number of lines.
1038- int lineCount = 0 ;
1034+ uint32_t lineCount = 0 ;
10391035
10401036 // Accumulated cross dimensions of all lines so far.
10411037 float totalLineCrossDim = 0 ;
@@ -1047,7 +1043,7 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
10471043
10481044 // Number of items on the currently line. May be different than the difference
10491045 // between start and end indicates because we skip over absolute-positioned items.
1050- int itemsOnLine = 0 ;
1046+ uint32_t itemsOnLine = 0 ;
10511047
10521048 // sizeConsumedOnCurrentLine is accumulation of the dimensions and margin
10531049 // of all the children on the current line. This will be used in order to
@@ -1460,10 +1456,10 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
14601456 }
14611457 }
14621458
1463- int endIndex = 0 ;
1459+ uint32_t endIndex = 0 ;
14641460 for (i = 0 ; i < lineCount ; ++ i ) {
1465- int startIndex = endIndex ;
1466- int j ;
1461+ uint32_t startIndex = endIndex ;
1462+ uint32_t j ;
14671463
14681464 // compute the line's height and find the endIndex
14691465 float lineHeight = 0 ;
@@ -1654,7 +1650,7 @@ static void layoutNodeImpl(CSSNode* node, float availableWidth, float availableH
16541650 }
16551651}
16561652
1657- int gDepth = 0 ;
1653+ uint32_t gDepth = 0 ;
16581654bool gPrintTree = false;
16591655bool gPrintChanges = false;
16601656bool gPrintSkips = false;
@@ -1808,7 +1804,7 @@ bool layoutNodeInternal(CSSNode* node, float availableWidth, float availableHeig
18081804 cachedResults = & layout -> cached_layout ;
18091805 } else {
18101806 // Try to use the measurement cache.
1811- for (int i = 0 ; i < layout -> nextCachedMeasurementsIndex ; i ++ ) {
1807+ for (uint32_t i = 0 ; i < layout -> nextCachedMeasurementsIndex ; i ++ ) {
18121808 if (canUseCachedMeasurement (node -> isTextNode , availableWidth , availableHeight , marginAxisRow , marginAxisColumn ,
18131809 widthMeasureMode , heightMeasureMode , layout -> cachedMeasurements [i ])) {
18141810 cachedResults = & layout -> cachedMeasurements [i ];
@@ -1825,7 +1821,7 @@ bool layoutNodeInternal(CSSNode* node, float availableWidth, float availableHeig
18251821 cachedResults = & layout -> cached_layout ;
18261822 }
18271823 } else {
1828- for (int i = 0 ; i < layout -> nextCachedMeasurementsIndex ; i ++ ) {
1824+ for (uint32_t i = 0 ; i < layout -> nextCachedMeasurementsIndex ; i ++ ) {
18291825 if (eq (layout -> cachedMeasurements [i ].availableWidth , availableWidth ) &&
18301826 eq (layout -> cachedMeasurements [i ].availableHeight , availableHeight ) &&
18311827 layout -> cachedMeasurements [i ].widthMeasureMode == widthMeasureMode &&
0 commit comments