diff --git a/README.md b/README.md index 3f68f28d..05a1b33d 100644 --- a/README.md +++ b/README.md @@ -11,22 +11,68 @@ The JavaScript version has been implemented in a way that can be easily transpil Usage ----- -A single function `computeLayout` is exposed and +A single function `computeLayout` is exposed that - takes a tree of nodes: `{ style: { ... }, children: [ nodes ] }` - - returns a tree of rectangles: `{ width: ..., height: ..., top: ..., left: ..., children: [ rects ] }` + - computes the layout and writes it back to the node tree. For example, ```javascript -computeLayout( - {style: {padding: 50}, children: [ - {style: {padding: 10, alignSelf: 'stretch'}} - ]} -); -// => -{width: 120, height: 120, top: 0, left: 0, children: [ - {width: 20, height: 20, top: 50, left: 50} -]} +// create an initial tree of nodes +var nodeTree = { + "style": { + "padding": 50 + }, + "children": [ + { + "style": { + "padding": 10, + "alignSelf": "stretch" + } + } + ] + }; + +// compute the layout +computeLayout(tree); + +// the layout information is written back to the node tree, with +// each node now having a layout property: + +// JSON.stringify(tree, null, 2); +{ + "style": { + "padding": 50 + }, + "children": [ + { + "style": { + "padding": 10, + "alignSelf": "stretch" + }, + "layout": { + "width": 20, + "height": 20, + "top": 50, + "left": 50, + "right": 50, + "bottom": 50, + "direction": "ltr" + }, + "children": [], + "lineIndex": 0 + } + ], + "layout": { + "width": 120, + "height": 120, + "top": 0, + "left": 0, + "right": 0, + "bottom": 0, + "direction": "ltr" + } +} ``` Supported Attributes diff --git a/dist/css-layout.jar b/dist/css-layout.jar index b28dea04..a6e88d0b 100644 Binary files a/dist/css-layout.jar and b/dist/css-layout.jar differ diff --git a/dist/css-layout.js b/dist/css-layout.js index af198231..3db6a3ac 100644 --- a/dist/css-layout.js +++ b/dist/css-layout.js @@ -99,42 +99,33 @@ var computeLayout = (function() { return 0; } + + // When transpiled to Java / C the node type has layout, children and style + // properties. For the JavaScript version this function adds these properties + // if they don't already exist. function fillNodes(node) { - node.layout = { - width: undefined, - height: undefined, - top: 0, - left: 0, - right: 0, - bottom: 0 - }; + if (!node.layout) { + node.layout = { + width: undefined, + height: undefined, + top: 0, + left: 0, + right: 0, + bottom: 0 + }; + } + if (!node.style) { node.style = {}; } - if (!node.children || node.style.measure) { + if (!node.children) { node.children = []; } node.children.forEach(fillNodes); return node; } - function extractNodes(node) { - var layout = node.layout; - delete node.layout; - if (node.children && node.children.length > 0) { - layout.children = node.children.map(extractNodes); - } else { - delete node.children; - } - - delete layout.right; - delete layout.bottom; - delete layout.direction; - - return layout; - } - function getPositiveSpacing(node, type, suffix, locations) { for (var i = 0; i < locations.length; ++i) { var location = locations[i]; @@ -1000,19 +991,19 @@ var computeLayout = (function() { return { computeLayout: layoutNode, - fillNodes: fillNodes, - extractNodes: extractNodes + fillNodes: fillNodes }; })(); +// This module export is only used for the purposes of unit testing this file. When +// the library is packaged this file is included within css-layout.js which forms +// the public API. if (typeof exports === 'object') { module.exports = computeLayout; } return function(node) { - node = computeLayout.fillNodes(node); + computeLayout.fillNodes(node); computeLayout.computeLayout(node); - node = computeLayout.extractNodes(node); - return node; }; })); diff --git a/dist/css-layout.min.js b/dist/css-layout.min.js index efe7fd66..d8907372 100644 --- a/dist/css-layout.min.js +++ b/dist/css-layout.min.js @@ -1,2 +1,2 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.computeLayout=b()}(this,function(){var a=function(){function a(a){return a.charAt(0).toUpperCase()+a.slice(1)}function b(b,c,d,e){for(var f=0;f0?b.children=a.children.map(d):delete a.children,delete b.right,delete b.bottom,delete b.direction,b}function e(b,c,d,e){for(var f=0;f=0)return b.style[h];if(h=c+d,h in b.style&&b.style[h]>=0)return b.style[h]}return 0}function f(a){return void 0===a}function g(a){return a===Y||a===Z}function h(a){return a===$||a===_}function i(a){var b=[ka[a]];return g(a)&&b.unshift("start"),b}function j(a){var b=[la[a]];return g(a)&&b.unshift("end"),b}function k(a,c){return b(a,"margin","",c)}function l(a,b){return k(a,i(b))}function m(a,b){return k(a,j(b))}function n(a,b){return e(a,"padding","",b)}function o(a,b){return n(a,i(b))}function p(a,b){return n(a,j(b))}function q(a,b){return e(a,"border","Width",b)}function r(a,b){return q(a,i(b))}function s(a,b){return q(a,j(b))}function t(a,b){return o(a,b)+r(a,b)}function u(a,b){return p(a,b)+s(a,b)}function v(a,b){return r(a,b)+s(a,b)}function w(a,b){return l(a,b)+m(a,b)}function x(a,b){return t(a,b)+u(a,b)}function y(a){return"justifyContent"in a.style?a.style.justifyContent:"flex-start"}function z(a){return"alignContent"in a.style?a.style.alignContent:"flex-start"}function A(a,b){return"alignSelf"in b.style?b.style.alignSelf:"alignItems"in a.style?a.style.alignItems:"stretch"}function B(a,b){if(b===X){if(a===Y)return Z;if(a===Z)return Y}return a}function C(a,b){var c;return c="direction"in a.style?a.style.direction:V,c===V&&(c=void 0===b?W:b),c}function D(a){return"flexDirection"in a.style?a.style.flexDirection:$}function E(a,b){return h(a)?B(Y,b):$}function F(a){return"position"in a.style?a.style.position:"relative"}function G(a){return a.style.flex}function H(a){return F(a)===ia&&G(a)>0}function I(a){return"wrap"===a.style.flexWrap}function J(a,b){return a.layout[na[b]]+w(a,b)}function K(a,b){return!f(a.style[na[b]])&&a.style[na[b]]>=0}function L(a,b){return!f(a.style[b])}function M(a){return"measure"in a.style}function N(a,b){return b in a.style?a.style[b]:0}function O(a,b,c){var d={row:a.style.minWidth,"row-reverse":a.style.minWidth,column:a.style.minHeight,"column-reverse":a.style.minHeight}[b],e={row:a.style.maxWidth,"row-reverse":a.style.maxWidth,column:a.style.maxHeight,"column-reverse":a.style.maxHeight}[b],g=c;return!f(e)&&e>=0&&g>e&&(g=e),!f(d)&&d>=0&&d>g&&(g=d),g}function P(a,b){return a>b?a:b}function Q(a,b){f(a.layout[na[b]])&&K(a,b)&&(a.layout[na[b]]=P(O(a,b,a.style[na[b]]),x(a,b)))}function R(a,b,c){b.layout[la[c]]=a.layout[na[c]]-b.layout[na[c]]-b.layout[ma[c]]}function S(a,b){return ka[b]in a.style?N(a,ka[b]):-N(a,la[b])}function T(a,b,c){var d=C(a,c),e=B(D(a),d),h=E(e,d),i=B(Y,d);if(Q(a,e),Q(a,h),a.layout.direction=d,a.layout[ka[e]]+=l(a,e)+S(a,e),a.layout[la[e]]+=m(a,e)+S(a,e),a.layout[ka[h]]+=l(a,h)+S(a,h),a.layout[la[h]]+=m(a,h)+S(a,h),M(a)){var j=U;j=K(a,i)?a.style.width:f(a.layout[na[i]])?b-w(a,i):a.layout[na[i]],j-=x(a,i);var k=!K(a,i)&&f(a.layout[na[i]]),n=!K(a,$)&&f(a.layout[na[$]]);if(k||n){var o=a.style.measure(j);k&&(a.layout.width=o.width+x(a,i)),n&&(a.layout.height=o.height+x(a,$))}if(0===a.children.length)return}var p,q,s,V;for(p=0;pq;q++)V=0!==q?Y:$,!f(a.layout[na[V]])&&!K(s,V)&&L(s,ka[V])&&L(s,la[V])&&(s.layout[na[V]]=P(O(s,V,a.layout[na[V]]-x(a,V)-w(s,V)-N(s,ka[V])-N(s,la[V])),x(s,V)))}else s.layout[na[h]]=P(O(s,h,a.layout[na[h]]-x(a,h)-w(s,h)),x(s,h));var W=U;f(a.layout[na[e]])||(W=a.layout[na[e]]-x(a,e));for(var X=0,Z=0,_=0,oa=0,pa=0,qa=0;ZW&&p!==X){va--,_=1;break}_=0,sa+=wa,Z=p+1}var xa=0,ya=0,za=0;if(za=f(a.layout[na[e]])?P(sa,0)-sa:W-sa,0!==ta){var Aa,Ba,Ca=za/ua;for(p=X;Z>p;++p)s=a.children[p],H(s)&&(Aa=Ca*G(s)+x(s,e),Ba=O(s,e,Aa),Aa!==Ba&&(za-=Ba,ua-=G(s)));for(Ca=za/ua,0>Ca&&(Ca=0),p=X;Z>p;++p)s=a.children[p],H(s)&&(s.layout[na[e]]=O(s,e,Ca*G(s)+x(s,e)),ra=U,K(a,i)?ra=a.layout[na[i]]-x(a,i):g(e)||(ra=b-w(a,i)-x(a,i)),T(s,ra,d))}else{var Da=y(a);Da===aa?xa=za/2:Da===ba?xa=za:Da===ca?(za=P(za,0),ya=ta+va-1!==0?za/(ta+va-1):0):Da===da&&(ya=za/(ta+va),xa=ya/2)}var Ea=0,Fa=xa+t(a,e);for(p=X;Z>p;++p)s=a.children[p],s.lineIndex=qa,F(s)===ja&&L(s,ka[e])?s.layout[ma[e]]=N(s,ka[e])+r(a,e)+l(s,e):(s.layout[ma[e]]+=Fa,f(a.layout[na[e]])||R(a,s,e)),F(s)===ia&&(Fa+=ya+J(s,e),Ea=P(Ea,O(s,h,J(s,h))));var Ga=a.layout[na[h]];for(f(a.layout[na[h]])&&(Ga=P(O(a,h,Ea+x(a,h)),x(a,h))),p=X;Z>p;++p)if(s=a.children[p],F(s)===ja&&L(s,ka[h]))s.layout[ma[h]]=N(s,ka[h])+r(a,h)+l(s,h);else{var Ha=t(a,h);if(F(s)===ia){var Ia=A(a,s);if(Ia===ha)K(s,h)||(s.layout[na[h]]=P(O(s,h,Ga-x(a,h)-w(s,h)),x(s,h)));else if(Ia!==ea){var Ja=Ga-x(a,h)-J(s,h);Ha+=Ia===fa?Ja/2:Ja}}s.layout[ma[h]]+=oa+Ha,f(a.layout[na[h]])||R(a,s,h)}oa+=Ea,pa=P(pa,Fa),qa+=1,X=Z}if(qa>1&&!f(a.layout[na[h]])){var Ka=a.layout[na[h]]-x(a,h),La=Ka-oa,Ma=0,Na=t(a,h),Oa=z(a);Oa===ga?Na+=La:Oa===fa?Na+=La/2:Oa===ha&&Ka>oa&&(Ma=La/qa);var Pa=0;for(p=0;qa>p;++p){var Qa=Pa,Ra=0;for(q=Qa;qq;++q)if(s=a.children[q],F(s)===ia){var Sa=A(a,s);if(Sa===ea)s.layout[ma[h]]=Na+l(s,h);else if(Sa===ga)s.layout[ma[h]]=Na+Ra-m(s,h)-s.layout[na[h]];else if(Sa===fa){var Ta=s.layout[na[h]];s.layout[ma[h]]=Na+(Ra-Ta)/2}else Sa===ha&&(s.layout[ma[h]]=Na+l(s,h))}Na+=Ra}}var Ua=!1,Va=!1;if(f(a.layout[na[e]])&&(a.layout[na[e]]=P(O(a,e,pa+u(a,e)),x(a,e)),Ua=!0),f(a.layout[na[h]])&&(a.layout[na[h]]=P(O(a,h,oa+x(a,h)),x(a,h)),Va=!0),Ua||Va)for(p=0;pq;q++)V=0!==q?Y:$,!f(a.layout[na[V]])&&!K(s,V)&&L(s,ka[V])&&L(s,la[V])&&(s.layout[na[V]]=P(O(s,V,a.layout[na[V]]-v(a,V)-w(s,V)-N(s,ka[V])-N(s,la[V])),x(s,V)));for(q=0;2>q;q++)V=0!==q?Y:$,L(s,la[V])&&!L(s,ka[V])&&(s.layout[ka[V]]=a.layout[na[V]]-s.layout[na[V]]-N(s,la[V]))}}var U,V="inherit",W="ltr",X="rtl",Y="row",Z="row-reverse",$="column",_="column-reverse",aa="center",ba="flex-end",ca="space-between",da="space-around",ea="flex-start",fa="center",ga="flex-end",ha="stretch",ia="relative",ja="absolute",ka={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},la={row:"right","row-reverse":"left",column:"bottom","column-reverse":"top"},ma={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},na={row:"width","row-reverse":"width",column:"height","column-reverse":"height"};return{computeLayout:T,fillNodes:c,extractNodes:d}}();return"object"==typeof exports&&(module.exports=a),function(b){return b=a.fillNodes(b),a.computeLayout(b),b=a.extractNodes(b)}}); +!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.computeLayout=b()}(this,function(){var a=function(){function a(a){return a.charAt(0).toUpperCase()+a.slice(1)}function b(b,c,d,e){for(var f=0;f=0)return b.style[h];if(h=c+d,h in b.style&&b.style[h]>=0)return b.style[h]}return 0}function e(a){return void 0===a}function f(a){return a===X||a===Y}function g(a){return a===Z||a===$}function h(a){var b=[ja[a]];return f(a)&&b.unshift("start"),b}function i(a){var b=[ka[a]];return f(a)&&b.unshift("end"),b}function j(a,c){return b(a,"margin","",c)}function k(a,b){return j(a,h(b))}function l(a,b){return j(a,i(b))}function m(a,b){return d(a,"padding","",b)}function n(a,b){return m(a,h(b))}function o(a,b){return m(a,i(b))}function p(a,b){return d(a,"border","Width",b)}function q(a,b){return p(a,h(b))}function r(a,b){return p(a,i(b))}function s(a,b){return n(a,b)+q(a,b)}function t(a,b){return o(a,b)+r(a,b)}function u(a,b){return q(a,b)+r(a,b)}function v(a,b){return k(a,b)+l(a,b)}function w(a,b){return s(a,b)+t(a,b)}function x(a){return"justifyContent"in a.style?a.style.justifyContent:"flex-start"}function y(a){return"alignContent"in a.style?a.style.alignContent:"flex-start"}function z(a,b){return"alignSelf"in b.style?b.style.alignSelf:"alignItems"in a.style?a.style.alignItems:"stretch"}function A(a,b){if(b===W){if(a===X)return Y;if(a===Y)return X}return a}function B(a,b){var c;return c="direction"in a.style?a.style.direction:U,c===U&&(c=void 0===b?V:b),c}function C(a){return"flexDirection"in a.style?a.style.flexDirection:Z}function D(a,b){return g(a)?A(X,b):Z}function E(a){return"position"in a.style?a.style.position:"relative"}function F(a){return a.style.flex}function G(a){return E(a)===ha&&F(a)>0}function H(a){return"wrap"===a.style.flexWrap}function I(a,b){return a.layout[ma[b]]+v(a,b)}function J(a,b){return!e(a.style[ma[b]])&&a.style[ma[b]]>=0}function K(a,b){return!e(a.style[b])}function L(a){return"measure"in a.style}function M(a,b){return b in a.style?a.style[b]:0}function N(a,b,c){var d={row:a.style.minWidth,"row-reverse":a.style.minWidth,column:a.style.minHeight,"column-reverse":a.style.minHeight}[b],f={row:a.style.maxWidth,"row-reverse":a.style.maxWidth,column:a.style.maxHeight,"column-reverse":a.style.maxHeight}[b],g=c;return!e(f)&&f>=0&&g>f&&(g=f),!e(d)&&d>=0&&d>g&&(g=d),g}function O(a,b){return a>b?a:b}function P(a,b){e(a.layout[ma[b]])&&J(a,b)&&(a.layout[ma[b]]=O(N(a,b,a.style[ma[b]]),w(a,b)))}function Q(a,b,c){b.layout[ka[c]]=a.layout[ma[c]]-b.layout[ma[c]]-b.layout[la[c]]}function R(a,b){return ja[b]in a.style?M(a,ja[b]):-M(a,ka[b])}function S(a,b,c){var d=B(a,c),g=A(C(a),d),h=D(g,d),i=A(X,d);if(P(a,g),P(a,h),a.layout.direction=d,a.layout[ja[g]]+=k(a,g)+R(a,g),a.layout[ka[g]]+=l(a,g)+R(a,g),a.layout[ja[h]]+=k(a,h)+R(a,h),a.layout[ka[h]]+=l(a,h)+R(a,h),L(a)){var j=T;j=J(a,i)?a.style.width:e(a.layout[ma[i]])?b-v(a,i):a.layout[ma[i]],j-=w(a,i);var m=!J(a,i)&&e(a.layout[ma[i]]),n=!J(a,Z)&&e(a.layout[ma[Z]]);if(m||n){var o=a.style.measure(j);m&&(a.layout.width=o.width+w(a,i)),n&&(a.layout.height=o.height+w(a,Z))}if(0===a.children.length)return}var p,r,U,V;for(p=0;pr;r++)V=0!==r?X:Z,!e(a.layout[ma[V]])&&!J(U,V)&&K(U,ja[V])&&K(U,ka[V])&&(U.layout[ma[V]]=O(N(U,V,a.layout[ma[V]]-w(a,V)-v(U,V)-M(U,ja[V])-M(U,ka[V])),w(U,V)))}else U.layout[ma[h]]=O(N(U,h,a.layout[ma[h]]-w(a,h)-v(U,h)),w(U,h));var W=T;e(a.layout[ma[g]])||(W=a.layout[ma[g]]-w(a,g));for(var Y=0,$=0,na=0,oa=0,pa=0,qa=0;$W&&p!==Y){va--,na=1;break}na=0,sa+=wa,$=p+1}var xa=0,ya=0,za=0;if(za=e(a.layout[ma[g]])?O(sa,0)-sa:W-sa,0!==ta){var Aa,Ba,Ca=za/ua;for(p=Y;$>p;++p)U=a.children[p],G(U)&&(Aa=Ca*F(U)+w(U,g),Ba=N(U,g,Aa),Aa!==Ba&&(za-=Ba,ua-=F(U)));for(Ca=za/ua,0>Ca&&(Ca=0),p=Y;$>p;++p)U=a.children[p],G(U)&&(U.layout[ma[g]]=N(U,g,Ca*F(U)+w(U,g)),ra=T,J(a,i)?ra=a.layout[ma[i]]-w(a,i):f(g)||(ra=b-v(a,i)-w(a,i)),S(U,ra,d))}else{var Da=x(a);Da===_?xa=za/2:Da===aa?xa=za:Da===ba?(za=O(za,0),ya=ta+va-1!==0?za/(ta+va-1):0):Da===ca&&(ya=za/(ta+va),xa=ya/2)}var Ea=0,Fa=xa+s(a,g);for(p=Y;$>p;++p)U=a.children[p],U.lineIndex=qa,E(U)===ia&&K(U,ja[g])?U.layout[la[g]]=M(U,ja[g])+q(a,g)+k(U,g):(U.layout[la[g]]+=Fa,e(a.layout[ma[g]])||Q(a,U,g)),E(U)===ha&&(Fa+=ya+I(U,g),Ea=O(Ea,N(U,h,I(U,h))));var Ga=a.layout[ma[h]];for(e(a.layout[ma[h]])&&(Ga=O(N(a,h,Ea+w(a,h)),w(a,h))),p=Y;$>p;++p)if(U=a.children[p],E(U)===ia&&K(U,ja[h]))U.layout[la[h]]=M(U,ja[h])+q(a,h)+k(U,h);else{var Ha=s(a,h);if(E(U)===ha){var Ia=z(a,U);if(Ia===ga)J(U,h)||(U.layout[ma[h]]=O(N(U,h,Ga-w(a,h)-v(U,h)),w(U,h)));else if(Ia!==da){var Ja=Ga-w(a,h)-I(U,h);Ha+=Ia===ea?Ja/2:Ja}}U.layout[la[h]]+=oa+Ha,e(a.layout[ma[h]])||Q(a,U,h)}oa+=Ea,pa=O(pa,Fa),qa+=1,Y=$}if(qa>1&&!e(a.layout[ma[h]])){var Ka=a.layout[ma[h]]-w(a,h),La=Ka-oa,Ma=0,Na=s(a,h),Oa=y(a);Oa===fa?Na+=La:Oa===ea?Na+=La/2:Oa===ga&&Ka>oa&&(Ma=La/qa);var Pa=0;for(p=0;qa>p;++p){var Qa=Pa,Ra=0;for(r=Qa;rr;++r)if(U=a.children[r],E(U)===ha){var Sa=z(a,U);if(Sa===da)U.layout[la[h]]=Na+k(U,h);else if(Sa===fa)U.layout[la[h]]=Na+Ra-l(U,h)-U.layout[ma[h]];else if(Sa===ea){var Ta=U.layout[ma[h]];U.layout[la[h]]=Na+(Ra-Ta)/2}else Sa===ga&&(U.layout[la[h]]=Na+k(U,h))}Na+=Ra}}var Ua=!1,Va=!1;if(e(a.layout[ma[g]])&&(a.layout[ma[g]]=O(N(a,g,pa+t(a,g)),w(a,g)),Ua=!0),e(a.layout[ma[h]])&&(a.layout[ma[h]]=O(N(a,h,oa+w(a,h)),w(a,h)),Va=!0),Ua||Va)for(p=0;pr;r++)V=0!==r?X:Z,!e(a.layout[ma[V]])&&!J(U,V)&&K(U,ja[V])&&K(U,ka[V])&&(U.layout[ma[V]]=O(N(U,V,a.layout[ma[V]]-u(a,V)-v(U,V)-M(U,ja[V])-M(U,ka[V])),w(U,V)));for(r=0;2>r;r++)V=0!==r?X:Z,K(U,ka[V])&&!K(U,ja[V])&&(U.layout[ja[V]]=a.layout[ma[V]]-U.layout[ma[V]]-M(U,ka[V]))}}var T,U="inherit",V="ltr",W="rtl",X="row",Y="row-reverse",Z="column",$="column-reverse",_="center",aa="flex-end",ba="space-between",ca="space-around",da="flex-start",ea="center",fa="flex-end",ga="stretch",ha="relative",ia="absolute",ja={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},ka={row:"right","row-reverse":"left",column:"bottom","column-reverse":"top"},la={row:"left","row-reverse":"right",column:"top","column-reverse":"bottom"},ma={row:"width","row-reverse":"width",column:"height","column-reverse":"height"};return{computeLayout:S,fillNodes:c}}();return"object"==typeof exports&&(module.exports=a),function(b){a.fillNodes(b),a.computeLayout(b)}}); //# sourceMappingURL=css-layout.min.js.map \ No newline at end of file diff --git a/dist/css-layout.min.js.map b/dist/css-layout.min.js.map index b4cdec24..4eeaca1d 100644 --- a/dist/css-layout.min.js.map +++ b/dist/css-layout.min.js.map @@ -1 +1 @@ -{"version":3,"file":"css-layout.min.js","sources":["css-layout.js"],"names":["root","factory","define","amd","exports","module","computeLayout","this","capitalizeFirst","str","charAt","toUpperCase","slice","getSpacing","node","type","suffix","locations","i","length","location","key","style","fillNodes","layout","width","undefined","height","top","left","right","bottom","children","measure","forEach","extractNodes","map","direction","getPositiveSpacing","isUndefined","value","isRowDirection","flexDirection","CSS_FLEX_DIRECTION_ROW","CSS_FLEX_DIRECTION_ROW_REVERSE","isColumnDirection","CSS_FLEX_DIRECTION_COLUMN","CSS_FLEX_DIRECTION_COLUMN_REVERSE","getLeadingLocations","axis","leading","unshift","getTrailingLocations","trailing","getMargin","getLeadingMargin","getTrailingMargin","getPadding","getLeadingPadding","getTrailingPadding","getBorder","getLeadingBorder","getTrailingBorder","getLeadingPaddingAndBorder","getTrailingPaddingAndBorder","getBorderAxis","getMarginAxis","getPaddingAndBorderAxis","getJustifyContent","justifyContent","getAlignContent","alignContent","getAlignItem","child","alignSelf","alignItems","resolveAxis","CSS_DIRECTION_RTL","resolveDirection","parentDirection","CSS_DIRECTION_INHERIT","CSS_DIRECTION_LTR","getFlexDirection","getCrossFlexDirection","getPositionType","position","getFlex","flex","isFlex","CSS_POSITION_RELATIVE","isFlexWrap","flexWrap","getDimWithMargin","dim","isDimDefined","isPosDefined","pos","isMeasureDefined","getPosition","boundAxis","min","row","minWidth","row-reverse","column","minHeight","column-reverse","max","maxWidth","maxHeight","boundValue","fmaxf","a","b","setDimensionFromStyle","setTrailingPosition","getRelativePosition","layoutNode","parentMaxWidth","mainAxis","crossAxis","resolvedRowAxis","CSS_UNDEFINED","isRowUndefined","isColumnUndefined","measureDim","ii","CSS_ALIGN_STRETCH","CSS_POSITION_ABSOLUTE","definedMainDim","startLine","endLine","alreadyComputedNextLayout","linesCrossDim","linesMainDim","linesCount","mainContentDim","flexibleChildrenCount","totalFlexible","nonFlexibleChildrenCount","nextContentDim","leadingMainDim","betweenMainDim","remainingMainDim","baseMainDim","boundMainDim","flexibleMainDim","CSS_JUSTIFY_CENTER","CSS_JUSTIFY_FLEX_END","CSS_JUSTIFY_SPACE_BETWEEN","CSS_JUSTIFY_SPACE_AROUND","crossDim","mainDim","lineIndex","containerCrossAxis","leadingCrossDim","alignItem","CSS_ALIGN_FLEX_START","remainingCrossDim","CSS_ALIGN_CENTER","nodeCrossAxisInnerSize","remainingAlignContentDim","crossDimLead","currentLead","CSS_ALIGN_FLEX_END","endIndex","startIndex","lineHeight","alignContentAlign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C,EAAoB,MACpBJ,EAAoB,MAEpBlC,EAAyB,MACzBC,EAAiC,cACjCE,EAA4B,SAC5BC,EAAoC,iBAGpCoG,GAAqB,SACrBC,GAAuB,WACvBC,GAA4B,gBAC5BC,GAA2B,eAE3BO,GAAuB,aACvBE,GAAmB,SACnBK,GAAqB,WACrBrC,GAAoB,UAEpBtC,GAAwB,WACxBuC,GAAwB,WAExB9E,IACFmD,IAAO,OACPE,cAAe,QACfC,OAAU,MACVE,iBAAkB,UAEhBrD,IACFgD,IAAO,QACPE,cAAe,OACfC,OAAU,SACVE,iBAAkB,OAEhBV,IACFK,IAAO,OACPE,cAAe,QACfC,OAAU,MACVE,iBAAkB,UAEhBb,IACFQ,IAAO,QACPE,cAAe,QACfC,OAAU,SACVE,iBAAkB,SA25BpB,QACEpG,cAAe+G,EACf9F,UAAWA,EACXY,aAAcA,KAQd,OAJmB,gBAAZ/B,WACTC,OAAOD,QAAUE,GAGR,SAASQ,GAId,MAHAA,GAAOR,EAAciB,UAAUT,GAC/BR,EAAcA,cAAcQ,GAC5BA,EAAOR,EAAc6B,aAAarB","sourcesContent":["// UMD (Universal Module Definition)\n// See https://github.com/umdjs/umd for reference\n//\n// This file uses the following specific UMD implementation:\n// https://github.com/umdjs/umd/blob/master/returnExports.js\n(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define([], factory);\n } else if (typeof exports === 'object') {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory();\n } else {\n // Browser globals (root is window)\n root.computeLayout = factory();\n }\n}(this, function () {\n /**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\nvar computeLayout = (function() {\n\n var CSS_UNDEFINED;\n\n var CSS_DIRECTION_INHERIT = 'inherit';\n var CSS_DIRECTION_LTR = 'ltr';\n var CSS_DIRECTION_RTL = 'rtl';\n\n var CSS_FLEX_DIRECTION_ROW = 'row';\n var CSS_FLEX_DIRECTION_ROW_REVERSE = 'row-reverse';\n var CSS_FLEX_DIRECTION_COLUMN = 'column';\n var CSS_FLEX_DIRECTION_COLUMN_REVERSE = 'column-reverse';\n\n // var CSS_JUSTIFY_FLEX_START = 'flex-start';\n var CSS_JUSTIFY_CENTER = 'center';\n var CSS_JUSTIFY_FLEX_END = 'flex-end';\n var CSS_JUSTIFY_SPACE_BETWEEN = 'space-between';\n var CSS_JUSTIFY_SPACE_AROUND = 'space-around';\n\n var CSS_ALIGN_FLEX_START = 'flex-start';\n var CSS_ALIGN_CENTER = 'center';\n var CSS_ALIGN_FLEX_END = 'flex-end';\n var CSS_ALIGN_STRETCH = 'stretch';\n\n var CSS_POSITION_RELATIVE = 'relative';\n var CSS_POSITION_ABSOLUTE = 'absolute';\n\n var leading = {\n 'row': 'left',\n 'row-reverse': 'right',\n 'column': 'top',\n 'column-reverse': 'bottom'\n };\n var trailing = {\n 'row': 'right',\n 'row-reverse': 'left',\n 'column': 'bottom',\n 'column-reverse': 'top'\n };\n var pos = {\n 'row': 'left',\n 'row-reverse': 'right',\n 'column': 'top',\n 'column-reverse': 'bottom'\n };\n var dim = {\n 'row': 'width',\n 'row-reverse': 'width',\n 'column': 'height',\n 'column-reverse': 'height'\n };\n\n function capitalizeFirst(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n function getSpacing(node, type, suffix, locations) {\n for (var i = 0; i < locations.length; ++i) {\n var location = locations[i];\n\n var key = type + capitalizeFirst(location) + suffix;\n if (key in node.style) {\n return node.style[key];\n }\n\n key = type + suffix;\n if (key in node.style) {\n return node.style[key];\n }\n }\n\n return 0;\n }\n function fillNodes(node) {\n node.layout = {\n width: undefined,\n height: undefined,\n top: 0,\n left: 0,\n right: 0,\n bottom: 0\n };\n if (!node.style) {\n node.style = {};\n }\n\n if (!node.children || node.style.measure) {\n node.children = [];\n }\n node.children.forEach(fillNodes);\n return node;\n }\n\n function extractNodes(node) {\n var layout = node.layout;\n delete node.layout;\n if (node.children && node.children.length > 0) {\n layout.children = node.children.map(extractNodes);\n } else {\n delete node.children;\n }\n\n delete layout.right;\n delete layout.bottom;\n delete layout.direction;\n\n return layout;\n }\n\n function getPositiveSpacing(node, type, suffix, locations) {\n for (var i = 0; i < locations.length; ++i) {\n var location = locations[i];\n\n var key = type + capitalizeFirst(location) + suffix;\n if (key in node.style && node.style[key] >= 0) {\n return node.style[key];\n }\n\n key = type + suffix;\n if (key in node.style && node.style[key] >= 0) {\n return node.style[key];\n }\n }\n\n return 0;\n }\n\n function isUndefined(value) {\n return value === undefined;\n }\n\n function isRowDirection(flexDirection) {\n return flexDirection === CSS_FLEX_DIRECTION_ROW ||\n flexDirection === CSS_FLEX_DIRECTION_ROW_REVERSE;\n }\n\n function isColumnDirection(flexDirection) {\n return flexDirection === CSS_FLEX_DIRECTION_COLUMN ||\n flexDirection === CSS_FLEX_DIRECTION_COLUMN_REVERSE;\n }\n\n function getLeadingLocations(axis) {\n var locations = [leading[axis]];\n if (isRowDirection(axis)) {\n locations.unshift('start');\n }\n\n return locations;\n }\n\n function getTrailingLocations(axis) {\n var locations = [trailing[axis]];\n if (isRowDirection(axis)) {\n locations.unshift('end');\n }\n\n return locations;\n }\n\n function getMargin(node, locations) {\n return getSpacing(node, 'margin', '', locations);\n }\n\n function getLeadingMargin(node, axis) {\n return getMargin(node, getLeadingLocations(axis));\n }\n\n function getTrailingMargin(node, axis) {\n return getMargin(node, getTrailingLocations(axis));\n }\n\n function getPadding(node, locations) {\n return getPositiveSpacing(node, 'padding', '', locations);\n }\n\n function getLeadingPadding(node, axis) {\n return getPadding(node, getLeadingLocations(axis));\n }\n\n function getTrailingPadding(node, axis) {\n return getPadding(node, getTrailingLocations(axis));\n }\n\n function getBorder(node, locations) {\n return getPositiveSpacing(node, 'border', 'Width', locations);\n }\n\n function getLeadingBorder(node, axis) {\n return getBorder(node, getLeadingLocations(axis));\n }\n\n function getTrailingBorder(node, axis) {\n return getBorder(node, getTrailingLocations(axis));\n }\n\n function getLeadingPaddingAndBorder(node, axis) {\n return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);\n }\n\n function getTrailingPaddingAndBorder(node, axis) {\n return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);\n }\n\n function getBorderAxis(node, axis) {\n return getLeadingBorder(node, axis) + getTrailingBorder(node, axis);\n }\n\n function getMarginAxis(node, axis) {\n return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);\n }\n\n function getPaddingAndBorderAxis(node, axis) {\n return getLeadingPaddingAndBorder(node, axis) +\n getTrailingPaddingAndBorder(node, axis);\n }\n\n function getJustifyContent(node) {\n if ('justifyContent' in node.style) {\n return node.style.justifyContent;\n }\n return 'flex-start';\n }\n\n function getAlignContent(node) {\n if ('alignContent' in node.style) {\n return node.style.alignContent;\n }\n return 'flex-start';\n }\n\n function getAlignItem(node, child) {\n if ('alignSelf' in child.style) {\n return child.style.alignSelf;\n }\n if ('alignItems' in node.style) {\n return node.style.alignItems;\n }\n return 'stretch';\n }\n\n function resolveAxis(axis, direction) {\n if (direction === CSS_DIRECTION_RTL) {\n if (axis === CSS_FLEX_DIRECTION_ROW) {\n return CSS_FLEX_DIRECTION_ROW_REVERSE;\n } else if (axis === CSS_FLEX_DIRECTION_ROW_REVERSE) {\n return CSS_FLEX_DIRECTION_ROW;\n }\n }\n\n return axis;\n }\n\n function resolveDirection(node, parentDirection) {\n var direction;\n if ('direction' in node.style) {\n direction = node.style.direction;\n } else {\n direction = CSS_DIRECTION_INHERIT;\n }\n\n if (direction === CSS_DIRECTION_INHERIT) {\n direction = (parentDirection === undefined ? CSS_DIRECTION_LTR : parentDirection);\n }\n\n return direction;\n }\n\n function getFlexDirection(node) {\n if ('flexDirection' in node.style) {\n return node.style.flexDirection;\n }\n return CSS_FLEX_DIRECTION_COLUMN;\n }\n\n function getCrossFlexDirection(flexDirection, direction) {\n if (isColumnDirection(flexDirection)) {\n return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);\n } else {\n return CSS_FLEX_DIRECTION_COLUMN;\n }\n }\n\n function getPositionType(node) {\n if ('position' in node.style) {\n return node.style.position;\n }\n return 'relative';\n }\n\n function getFlex(node) {\n return node.style.flex;\n }\n\n function isFlex(node) {\n return (\n getPositionType(node) === CSS_POSITION_RELATIVE &&\n getFlex(node) > 0\n );\n }\n\n function isFlexWrap(node) {\n return node.style.flexWrap === 'wrap';\n }\n\n function getDimWithMargin(node, axis) {\n return node.layout[dim[axis]] + getMarginAxis(node, axis);\n }\n\n function isDimDefined(node, axis) {\n return !isUndefined(node.style[dim[axis]]) && node.style[dim[axis]] >= 0;\n }\n\n function isPosDefined(node, pos) {\n return !isUndefined(node.style[pos]);\n }\n\n function isMeasureDefined(node) {\n return 'measure' in node.style;\n }\n\n function getPosition(node, pos) {\n if (pos in node.style) {\n return node.style[pos];\n }\n return 0;\n }\n\n function boundAxis(node, axis, value) {\n var min = {\n 'row': node.style.minWidth,\n 'row-reverse': node.style.minWidth,\n 'column': node.style.minHeight,\n 'column-reverse': node.style.minHeight\n }[axis];\n\n var max = {\n 'row': node.style.maxWidth,\n 'row-reverse': node.style.maxWidth,\n 'column': node.style.maxHeight,\n 'column-reverse': node.style.maxHeight\n }[axis];\n\n var boundValue = value;\n if (!isUndefined(max) && max >= 0 && boundValue > max) {\n boundValue = max;\n }\n if (!isUndefined(min) && min >= 0 && boundValue < min) {\n boundValue = min;\n }\n return boundValue;\n }\n\n function fmaxf(a, b) {\n if (a > b) {\n return a;\n }\n return b;\n }\n\n // When the user specifically sets a value for width or height\n function setDimensionFromStyle(node, axis) {\n // The parent already computed us a width or height. We just skip it\n if (!isUndefined(node.layout[dim[axis]])) {\n return;\n }\n // We only run if there's a width or height defined\n if (!isDimDefined(node, axis)) {\n return;\n }\n\n // The dimensions can never be smaller than the padding and border\n node.layout[dim[axis]] = fmaxf(\n boundAxis(node, axis, node.style[dim[axis]]),\n getPaddingAndBorderAxis(node, axis)\n );\n }\n\n function setTrailingPosition(node, child, axis) {\n child.layout[trailing[axis]] = node.layout[dim[axis]] -\n child.layout[dim[axis]] - child.layout[pos[axis]];\n }\n\n // If both left and right are defined, then use left. Otherwise return\n // +left or -right depending on which is defined.\n function getRelativePosition(node, axis) {\n if (leading[axis] in node.style) {\n return getPosition(node, leading[axis]);\n }\n return -getPosition(node, trailing[axis]);\n }\n\n function layoutNode(node, parentMaxWidth, /*css_direction_t*/parentDirection) {\n var/*css_direction_t*/ direction = resolveDirection(node, parentDirection);\n var/*css_flex_direction_t*/ mainAxis = resolveAxis(getFlexDirection(node), direction);\n var/*css_flex_direction_t*/ crossAxis = getCrossFlexDirection(mainAxis, direction);\n var/*css_flex_direction_t*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);\n\n // Handle width and height style attributes\n setDimensionFromStyle(node, mainAxis);\n setDimensionFromStyle(node, crossAxis);\n\n // Set the resolved resolution in the node's layout\n node.layout.direction = direction;\n\n // The position is set by the parent, but we need to complete it with a\n // delta composed of the margin and left/top/right/bottom\n node.layout[leading[mainAxis]] += getLeadingMargin(node, mainAxis) +\n getRelativePosition(node, mainAxis);\n node.layout[trailing[mainAxis]] += getTrailingMargin(node, mainAxis) +\n getRelativePosition(node, mainAxis);\n node.layout[leading[crossAxis]] += getLeadingMargin(node, crossAxis) +\n getRelativePosition(node, crossAxis);\n node.layout[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) +\n getRelativePosition(node, crossAxis);\n\n if (isMeasureDefined(node)) {\n var/*float*/ width = CSS_UNDEFINED;\n if (isDimDefined(node, resolvedRowAxis)) {\n width = node.style.width;\n } else if (!isUndefined(node.layout[dim[resolvedRowAxis]])) {\n width = node.layout[dim[resolvedRowAxis]];\n } else {\n width = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis);\n }\n width -= getPaddingAndBorderAxis(node, resolvedRowAxis);\n\n // We only need to give a dimension for the text if we haven't got any\n // for it computed yet. It can either be from the style attribute or because\n // the element is flexible.\n var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) &&\n isUndefined(node.layout[dim[resolvedRowAxis]]);\n var/*bool*/ isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) &&\n isUndefined(node.layout[dim[CSS_FLEX_DIRECTION_COLUMN]]);\n\n // Let's not measure the text if we already know both dimensions\n if (isRowUndefined || isColumnUndefined) {\n var/*css_dim_t*/ measureDim = node.style.measure(\n /*(c)!node->context,*/\n /*(java)!layoutContext.measureOutput,*/\n width\n );\n if (isRowUndefined) {\n node.layout.width = measureDim.width +\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n if (isColumnUndefined) {\n node.layout.height = measureDim.height +\n getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN);\n }\n }\n if (node.children.length === 0) {\n return;\n }\n }\n\n var/*int*/ i;\n var/*int*/ ii;\n var/*css_node_t**/ child;\n var/*css_flex_direction_t*/ axis;\n\n // Pre-fill some dimensions straight from the parent\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n // Pre-fill cross axis dimensions when the child is using stretch before\n // we call the recursive layout pass\n if (getAlignItem(node, child) === CSS_ALIGN_STRETCH &&\n getPositionType(child) === CSS_POSITION_RELATIVE &&\n !isUndefined(node.layout[dim[crossAxis]]) &&\n !isDimDefined(child, crossAxis)) {\n child.layout[dim[crossAxis]] = fmaxf(\n boundAxis(child, crossAxis, node.layout[dim[crossAxis]] -\n getPaddingAndBorderAxis(node, crossAxis) -\n getMarginAxis(child, crossAxis)),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, crossAxis)\n );\n } else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {\n // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both\n // left and right or top and bottom).\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (!isUndefined(node.layout[dim[axis]]) &&\n !isDimDefined(child, axis) &&\n isPosDefined(child, leading[axis]) &&\n isPosDefined(child, trailing[axis])) {\n child.layout[dim[axis]] = fmaxf(\n boundAxis(child, axis, node.layout[dim[axis]] -\n getPaddingAndBorderAxis(node, axis) -\n getMarginAxis(child, axis) -\n getPosition(child, leading[axis]) -\n getPosition(child, trailing[axis])),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, axis)\n );\n }\n }\n }\n }\n\n var/*float*/ definedMainDim = CSS_UNDEFINED;\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n definedMainDim = node.layout[dim[mainAxis]] -\n getPaddingAndBorderAxis(node, mainAxis);\n }\n\n // We want to execute the next two loops one per line with flex-wrap\n var/*int*/ startLine = 0;\n var/*int*/ endLine = 0;\n // var/*int*/ nextOffset = 0;\n var/*int*/ alreadyComputedNextLayout = 0;\n // We aggregate the total dimensions of the container in those two variables\n var/*float*/ linesCrossDim = 0;\n var/*float*/ linesMainDim = 0;\n var/*int*/ linesCount = 0;\n while (endLine < node.children.length) {\n // Layout non flexible children and count children by type\n\n // mainContentDim is accumulation of the dimensions and margin of all the\n // non flexible children. This will be used in order to either set the\n // dimensions of the node if none already exist, or to compute the\n // remaining space left for the flexible children.\n var/*float*/ mainContentDim = 0;\n\n // There are three kind of children, non flexible, flexible and absolute.\n // We need to know how many there are in order to distribute the space.\n var/*int*/ flexibleChildrenCount = 0;\n var/*float*/ totalFlexible = 0;\n var/*int*/ nonFlexibleChildrenCount = 0;\n\n var/*float*/ maxWidth;\n for (i = startLine; i < node.children.length; ++i) {\n child = node.children[i];\n var/*float*/ nextContentDim = 0;\n\n // It only makes sense to consider a child flexible if we have a computed\n // dimension for the node.\n if (!isUndefined(node.layout[dim[mainAxis]]) && isFlex(child)) {\n flexibleChildrenCount++;\n totalFlexible += getFlex(child);\n\n // Even if we don't know its exact size yet, we already know the padding,\n // border and margin. We'll use this partial information, which represents\n // the smallest possible size for the child, to compute the remaining\n // available space.\n nextContentDim = getPaddingAndBorderAxis(child, mainAxis) +\n getMarginAxis(child, mainAxis);\n\n } else {\n maxWidth = CSS_UNDEFINED;\n if (!isRowDirection(mainAxis)) {\n maxWidth = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis) -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n\n if (isDimDefined(node, resolvedRowAxis)) {\n maxWidth = node.layout[dim[resolvedRowAxis]] -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n }\n\n // This is the main recursive call. We layout non flexible children.\n if (alreadyComputedNextLayout === 0) {\n layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);\n }\n\n // Absolute positioned elements do not take part of the layout, so we\n // don't use them to compute mainContentDim\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n nonFlexibleChildrenCount++;\n // At this point we know the final size and margin of the element.\n nextContentDim = getDimWithMargin(child, mainAxis);\n }\n }\n\n // The element we are about to add would make us go to the next line\n if (isFlexWrap(node) &&\n !isUndefined(node.layout[dim[mainAxis]]) &&\n mainContentDim + nextContentDim > definedMainDim &&\n // If there's only one element, then it's bigger than the content\n // and needs its own line\n i !== startLine) {\n nonFlexibleChildrenCount--;\n alreadyComputedNextLayout = 1;\n break;\n }\n alreadyComputedNextLayout = 0;\n mainContentDim += nextContentDim;\n endLine = i + 1;\n }\n\n // Layout flexible children and allocate empty space\n\n // In order to position the elements in the main axis, we have two\n // controls. The space between the beginning and the first element\n // and the space between each two elements.\n var/*float*/ leadingMainDim = 0;\n var/*float*/ betweenMainDim = 0;\n\n // The remaining available space that needs to be allocated\n var/*float*/ remainingMainDim = 0;\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n remainingMainDim = definedMainDim - mainContentDim;\n } else {\n remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim;\n }\n\n // If there are flexible children in the mix, they are going to fill the\n // remaining space\n if (flexibleChildrenCount !== 0) {\n var/*float*/ flexibleMainDim = remainingMainDim / totalFlexible;\n var/*float*/ baseMainDim;\n var/*float*/ boundMainDim;\n\n // Iterate over every child in the axis. If the flex share of remaining\n // space doesn't meet min/max bounds, remove this child from flex\n // calculations.\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n if (isFlex(child)) {\n baseMainDim = flexibleMainDim * getFlex(child) +\n getPaddingAndBorderAxis(child, mainAxis);\n boundMainDim = boundAxis(child, mainAxis, baseMainDim);\n\n if (baseMainDim !== boundMainDim) {\n remainingMainDim -= boundMainDim;\n totalFlexible -= getFlex(child);\n }\n }\n }\n flexibleMainDim = remainingMainDim / totalFlexible;\n\n // The non flexible children can overflow the container, in this case\n // we should just assume that there is no space available.\n if (flexibleMainDim < 0) {\n flexibleMainDim = 0;\n }\n // We iterate over the full array and only apply the action on flexible\n // children. This is faster than actually allocating a new array that\n // contains only flexible children.\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n if (isFlex(child)) {\n // At this point we know the final size of the element in the main\n // dimension\n child.layout[dim[mainAxis]] = boundAxis(child, mainAxis,\n flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis)\n );\n\n maxWidth = CSS_UNDEFINED;\n if (isDimDefined(node, resolvedRowAxis)) {\n maxWidth = node.layout[dim[resolvedRowAxis]] -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n } else if (!isRowDirection(mainAxis)) {\n maxWidth = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis) -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n\n // And we recursively call the layout algorithm for this child\n layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);\n }\n }\n\n // We use justifyContent to figure out how to allocate the remaining\n // space available\n } else {\n var/*css_justify_t*/ justifyContent = getJustifyContent(node);\n if (justifyContent === CSS_JUSTIFY_CENTER) {\n leadingMainDim = remainingMainDim / 2;\n } else if (justifyContent === CSS_JUSTIFY_FLEX_END) {\n leadingMainDim = remainingMainDim;\n } else if (justifyContent === CSS_JUSTIFY_SPACE_BETWEEN) {\n remainingMainDim = fmaxf(remainingMainDim, 0);\n if (flexibleChildrenCount + nonFlexibleChildrenCount - 1 !== 0) {\n betweenMainDim = remainingMainDim /\n (flexibleChildrenCount + nonFlexibleChildrenCount - 1);\n } else {\n betweenMainDim = 0;\n }\n } else if (justifyContent === CSS_JUSTIFY_SPACE_AROUND) {\n // Space on the edges is half of the space between elements\n betweenMainDim = remainingMainDim /\n (flexibleChildrenCount + nonFlexibleChildrenCount);\n leadingMainDim = betweenMainDim / 2;\n }\n }\n\n // Position elements in the main axis and compute dimensions\n\n // At this point, all the children have their dimensions set. We need to\n // find their position. In order to do that, we accumulate data in\n // variables that are also useful to compute the total dimensions of the\n // container!\n var/*float*/ crossDim = 0;\n var/*float*/ mainDim = leadingMainDim +\n getLeadingPaddingAndBorder(node, mainAxis);\n\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n child.lineIndex = linesCount;\n\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&\n isPosDefined(child, leading[mainAxis])) {\n // In case the child is position absolute and has left/top being\n // defined, we override the position to whatever the user said\n // (and margin/border).\n child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]) +\n getLeadingBorder(node, mainAxis) +\n getLeadingMargin(child, mainAxis);\n } else {\n // If the child is position absolute (without top/left) or relative,\n // we put it at the current accumulated offset.\n child.layout[pos[mainAxis]] += mainDim;\n\n // Define the trailing position accordingly.\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n setTrailingPosition(node, child, mainAxis);\n }\n }\n\n // Now that we placed the element, we need to update the variables\n // We only need to do that for relative elements. Absolute elements\n // do not take part in that phase.\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n // The main dimension is the sum of all the elements dimension plus\n // the spacing.\n mainDim += betweenMainDim + getDimWithMargin(child, mainAxis);\n // The cross dimension is the max of the elements dimension since there\n // can only be one element in that cross dimension.\n crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));\n }\n }\n\n var/*float*/ containerCrossAxis = node.layout[dim[crossAxis]];\n if (isUndefined(node.layout[dim[crossAxis]])) {\n containerCrossAxis = fmaxf(\n // For the cross dim, we add both sides at the end because the value\n // is aggregate via a max function. Intermediate negative values\n // can mess this computation otherwise\n boundAxis(node, crossAxis, crossDim + getPaddingAndBorderAxis(node, crossAxis)),\n getPaddingAndBorderAxis(node, crossAxis)\n );\n }\n\n // Position elements in the cross axis\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&\n isPosDefined(child, leading[crossAxis])) {\n // In case the child is absolutely positionned and has a\n // top/left/bottom/right being set, we override all the previously\n // computed positions to set it correctly.\n child.layout[pos[crossAxis]] = getPosition(child, leading[crossAxis]) +\n getLeadingBorder(node, crossAxis) +\n getLeadingMargin(child, crossAxis);\n\n } else {\n var/*float*/ leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis);\n\n // For a relative children, we're either using alignItems (parent) or\n // alignSelf (child) in order to determine the position in the cross axis\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n var/*css_align_t*/ alignItem = getAlignItem(node, child);\n if (alignItem === CSS_ALIGN_STRETCH) {\n // You can only stretch if the dimension has not already been set\n // previously.\n if (!isDimDefined(child, crossAxis)) {\n child.layout[dim[crossAxis]] = fmaxf(\n boundAxis(child, crossAxis, containerCrossAxis -\n getPaddingAndBorderAxis(node, crossAxis) -\n getMarginAxis(child, crossAxis)),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, crossAxis)\n );\n }\n } else if (alignItem !== CSS_ALIGN_FLEX_START) {\n // The remaining space between the parent dimensions+padding and child\n // dimensions+margin.\n var/*float*/ remainingCrossDim = containerCrossAxis -\n getPaddingAndBorderAxis(node, crossAxis) -\n getDimWithMargin(child, crossAxis);\n\n if (alignItem === CSS_ALIGN_CENTER) {\n leadingCrossDim += remainingCrossDim / 2;\n } else { // CSS_ALIGN_FLEX_END\n leadingCrossDim += remainingCrossDim;\n }\n }\n }\n\n // And we apply the position\n child.layout[pos[crossAxis]] += linesCrossDim + leadingCrossDim;\n\n // Define the trailing position accordingly.\n if (!isUndefined(node.layout[dim[crossAxis]])) {\n setTrailingPosition(node, child, crossAxis);\n }\n }\n }\n\n linesCrossDim += crossDim;\n linesMainDim = fmaxf(linesMainDim, mainDim);\n linesCount += 1;\n startLine = endLine;\n }\n\n // \n //\n // Note(prenaux): More than one line, we need to layout the crossAxis\n // according to alignContent.\n //\n // Note that we could probably remove and handle the one line case\n // here too, but for the moment this is safer since it won't interfere with\n // previously working code.\n //\n // See specs:\n // http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm\n // section 9.4\n //\n if (linesCount > 1 &&\n !isUndefined(node.layout[dim[crossAxis]])) {\n var/*float*/ nodeCrossAxisInnerSize = node.layout[dim[crossAxis]] -\n getPaddingAndBorderAxis(node, crossAxis);\n var/*float*/ remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;\n\n var/*float*/ crossDimLead = 0;\n var/*float*/ currentLead = getLeadingPaddingAndBorder(node, crossAxis);\n\n var/*css_align_t*/ alignContent = getAlignContent(node);\n if (alignContent === CSS_ALIGN_FLEX_END) {\n currentLead += remainingAlignContentDim;\n } else if (alignContent === CSS_ALIGN_CENTER) {\n currentLead += remainingAlignContentDim / 2;\n } else if (alignContent === CSS_ALIGN_STRETCH) {\n if (nodeCrossAxisInnerSize > linesCrossDim) {\n crossDimLead = (remainingAlignContentDim / linesCount);\n }\n }\n\n var/*int*/ endIndex = 0;\n for (i = 0; i < linesCount; ++i) {\n var/*int*/ startIndex = endIndex;\n\n // compute the line's height and find the endIndex\n var/*float*/ lineHeight = 0;\n for (ii = startIndex; ii < node.children.length; ++ii) {\n child = node.children[ii];\n if (getPositionType(child) !== CSS_POSITION_RELATIVE) {\n continue;\n }\n if (child.lineIndex !== i) {\n break;\n }\n if (!isUndefined(child.layout[dim[crossAxis]])) {\n lineHeight = fmaxf(\n lineHeight,\n child.layout[dim[crossAxis]] + getMarginAxis(child, crossAxis)\n );\n }\n }\n endIndex = ii;\n lineHeight += crossDimLead;\n\n for (ii = startIndex; ii < endIndex; ++ii) {\n child = node.children[ii];\n if (getPositionType(child) !== CSS_POSITION_RELATIVE) {\n continue;\n }\n\n var/*css_align_t*/ alignContentAlignItem = getAlignItem(node, child);\n if (alignContentAlignItem === CSS_ALIGN_FLEX_START) {\n child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);\n } else if (alignContentAlignItem === CSS_ALIGN_FLEX_END) {\n child.layout[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child.layout[dim[crossAxis]];\n } else if (alignContentAlignItem === CSS_ALIGN_CENTER) {\n var/*float*/ childHeight = child.layout[dim[crossAxis]];\n child.layout[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2;\n } else if (alignContentAlignItem === CSS_ALIGN_STRETCH) {\n child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);\n // TODO(prenaux): Correctly set the height of items with undefined\n // (auto) crossAxis dimension.\n }\n }\n\n currentLead += lineHeight;\n }\n }\n\n var/*bool*/ needsMainTrailingPos = false;\n var/*bool*/ needsCrossTrailingPos = false;\n\n // If the user didn't specify a width or height, and it has not been set\n // by the container, then we set it via the children.\n if (isUndefined(node.layout[dim[mainAxis]])) {\n node.layout[dim[mainAxis]] = fmaxf(\n // We're missing the last padding at this point to get the final\n // dimension\n boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)),\n // We can never assign a width smaller than the padding and borders\n getPaddingAndBorderAxis(node, mainAxis)\n );\n\n needsMainTrailingPos = true;\n }\n\n if (isUndefined(node.layout[dim[crossAxis]])) {\n node.layout[dim[crossAxis]] = fmaxf(\n // For the cross dim, we add both sides at the end because the value\n // is aggregate via a max function. Intermediate negative values\n // can mess this computation otherwise\n boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)),\n getPaddingAndBorderAxis(node, crossAxis)\n );\n\n needsCrossTrailingPos = true;\n }\n\n // Set trailing position if necessary\n if (needsMainTrailingPos || needsCrossTrailingPos) {\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n\n if (needsMainTrailingPos) {\n setTrailingPosition(node, child, mainAxis);\n }\n\n if (needsCrossTrailingPos) {\n setTrailingPosition(node, child, crossAxis);\n }\n }\n }\n\n // Calculate dimensions for absolutely positioned elements\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {\n // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both\n // left and right or top and bottom).\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (!isUndefined(node.layout[dim[axis]]) &&\n !isDimDefined(child, axis) &&\n isPosDefined(child, leading[axis]) &&\n isPosDefined(child, trailing[axis])) {\n child.layout[dim[axis]] = fmaxf(\n boundAxis(child, axis, node.layout[dim[axis]] -\n getBorderAxis(node, axis) -\n getMarginAxis(child, axis) -\n getPosition(child, leading[axis]) -\n getPosition(child, trailing[axis])\n ),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, axis)\n );\n }\n }\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (isPosDefined(child, trailing[axis]) &&\n !isPosDefined(child, leading[axis])) {\n child.layout[leading[axis]] =\n node.layout[dim[axis]] -\n child.layout[dim[axis]] -\n getPosition(child, trailing[axis]);\n }\n }\n }\n }\n }\n\n return {\n computeLayout: layoutNode,\n fillNodes: fillNodes,\n extractNodes: extractNodes\n };\n})();\n\nif (typeof exports === 'object') {\n module.exports = computeLayout;\n}\n\n return function(node) {\n node = computeLayout.fillNodes(node);\n computeLayout.computeLayout(node);\n node = computeLayout.extractNodes(node);\n return node;\n };\n}));\n"]} \ No newline at end of file +{"version":3,"file":"css-layout.min.js","sources":["css-layout.js"],"names":["root","factory","define","amd","exports","module","computeLayout","this","capitalizeFirst","str","charAt","toUpperCase","slice","getSpacing","node","type","suffix","locations","i","length","location","key","style","fillNodes","layout","width","undefined","height","top","left","right","bottom","children","forEach","getPositiveSpacing","isUndefined","value","isRowDirection","flexDirection","CSS_FLEX_DIRECTION_ROW","CSS_FLEX_DIRECTION_ROW_REVERSE","isColumnDirection","CSS_FLEX_DIRECTION_COLUMN","CSS_FLEX_DIRECTION_COLUMN_REVERSE","getLeadingLocations","axis","leading","unshift","getTrailingLocations","trailing","getMargin","getLeadingMargin","getTrailingMargin","getPadding","getLeadingPadding","getTrailingPadding","getBorder","getLeadingBorder","getTrailingBorder","getLeadingPaddingAndBorder","getTrailingPaddingAndBorder","getBorderAxis","getMarginAxis","getPaddingAndBorderAxis","getJustifyContent","justifyContent","getAlignContent","alignContent","getAlignItem","child","alignSelf","alignItems","resolveAxis","direction","CSS_DIRECTION_RTL","resolveDirection","parentDirection","CSS_DIRECTION_INHERIT","CSS_DIRECTION_LTR","getFlexDirection","getCrossFlexDirection","getPositionType","position","getFlex","flex","isFlex","CSS_POSITION_RELATIVE","isFlexWrap","flexWrap","getDimWithMargin","dim","isDimDefined","isPosDefined","pos","isMeasureDefined","getPosition","boundAxis","min","row","minWidth","row-reverse","column","minHeight","column-reverse","max","maxWidth","maxHeight","boundValue","fmaxf","a","b","setDimensionFromStyle","setTrailingPosition","getRelativePosition","layoutNode","parentMaxWidth","mainAxis","crossAxis","resolvedRowAxis","CSS_UNDEFINED","isRowUndefined","isColumnUndefined","measureDim","measure","ii","CSS_ALIGN_STRETCH","CSS_POSITION_ABSOLUTE","definedMainDim","startLine","endLine","alreadyComputedNextLayout","linesCrossDim","linesMainDim","linesCount","mainContentDim","flexibleChildrenCount","totalFlexible","nonFlexibleChildrenCount","nextContentDim","leadingMainDim","betweenMainDim","remainingMainDim","baseMainDim","boundMainDim","flexibleMainDim","CSS_JUSTIFY_CENTER","CSS_JUSTIFY_FLEX_END","CSS_JUSTIFY_SPACE_BETWEEN","CSS_JUSTIFY_SPACE_AROUND","crossDim","mainDim","lineIndex","containerCrossAxis","leadingCrossDim","alignItem","CSS_ALIGN_FLEX_START","remainingCrossDim","CSS_ALIGN_CENTER","nodeCrossAxisInnerSize","remainingAlignContentDim","crossDimLead","currentLead","CSS_ALIGN_FLEX_END","endIndex","startIndex","lineHeight","alignContentAlignItem","childHeight","needsMainTrailingPos","needsCrossTrailingPos"],"mappings":"CAKC,SAAUA,EAAMC,GACO,kBAAXC,SAAyBA,OAAOC,IAEzCD,UAAWD,GACiB,gBAAZG,SAIhBC,OAAOD,QAAUH,IAGjBD,EAAKM,cAAgBL,KAEvBM,KAAM,WAUR,GAAID,GAAgB,WAoDlB,QAASE,GAAgBC,GACvB,MAAOA,GAAIC,OAAO,GAAGC,cAAgBF,EAAIG,MAAM,GAGjD,QAASC,GAAWC,EAAMC,EAAMC,EAAQC,GACtC,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAUE,SAAUD,EAAG,CACzC,GAAIE,GAAWH,EAAUC,GAErBG,EAAMN,EAAOP,EAAgBY,GAAYJ,CAC7C,IAAIK,IAAOP,GAAKQ,MACd,MAAOR,GAAKQ,MAAMD,EAIpB,IADAA,EAAMN,EAAOC,EACTK,IAAOP,GAAKQ,MACd,MAAOR,GAAKQ,MAAMD,GAItB,MAAO,GAMT,QAASE,GAAUT,GAoBjB,MAnBKA,GAAKU,SACRV,EAAKU,QACHC,MAAOC,OACPC,OAAQD,OACRE,IAAK,EACLC,KAAM,EACNC,MAAO,EACPC,OAAQ,IAIPjB,EAAKQ,QACRR,EAAKQ,UAGFR,EAAKkB,WACRlB,EAAKkB,aAEPlB,EAAKkB,SAASC,QAAQV,GACfT,EAGT,QAASoB,GAAmBpB,EAAMC,EAAMC,EAAQC,GAC9C,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAUE,SAAUD,EAAG,CACzC,GAAIE,GAAWH,E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AOpB,GAASJ,MA17BxC,GAAI0E,GAEA1C,EAAwB,UACxBC,EAAoB,MACpBJ,EAAoB,MAEpBnC,EAAyB,MACzBC,EAAiC,cACjCE,EAA4B,SAC5BC,EAAoC,iBAGpCsG,EAAqB,SACrBC,GAAuB,WACvBC,GAA4B,gBAC5BC,GAA2B,eAE3BO,GAAuB,aACvBE,GAAmB,SACnBK,GAAqB,WACrBrC,GAAoB,UAEpBvC,GAAwB,WACxBwC,GAAwB,WAExBhF,IACFoD,IAAO,OACPE,cAAe,QACfC,OAAU,MACVE,iBAAkB,UAEhBtD,IACFiD,IAAO,QACPE,cAAe,OACfC,OAAU,SACVE,iBAAkB,OAEhBV,IACFK,IAAO,OACPE,cAAe,QACfC,OAAU,MACVE,iBAAkB,UAEhBb,IACFQ,IAAO,QACPE,cAAe,QACfC,OAAU,SACVE,iBAAkB,SAk5BpB,QACEjG,cAAe4G,EACf3F,UAAWA,KAWX,OAJmB,gBAAZnB,WACTC,OAAOD,QAAUE,GAGR,SAASQ,GACdR,EAAciB,UAAUT,GACxBR,EAAcA,cAAcQ","sourcesContent":["// UMD (Universal Module Definition)\n// See https://github.com/umdjs/umd for reference\n//\n// This file uses the following specific UMD implementation:\n// https://github.com/umdjs/umd/blob/master/returnExports.js\n(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define([], factory);\n } else if (typeof exports === 'object') {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory();\n } else {\n // Browser globals (root is window)\n root.computeLayout = factory();\n }\n}(this, function () {\n /**\n * Copyright (c) 2014, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\nvar computeLayout = (function() {\n\n var CSS_UNDEFINED;\n\n var CSS_DIRECTION_INHERIT = 'inherit';\n var CSS_DIRECTION_LTR = 'ltr';\n var CSS_DIRECTION_RTL = 'rtl';\n\n var CSS_FLEX_DIRECTION_ROW = 'row';\n var CSS_FLEX_DIRECTION_ROW_REVERSE = 'row-reverse';\n var CSS_FLEX_DIRECTION_COLUMN = 'column';\n var CSS_FLEX_DIRECTION_COLUMN_REVERSE = 'column-reverse';\n\n // var CSS_JUSTIFY_FLEX_START = 'flex-start';\n var CSS_JUSTIFY_CENTER = 'center';\n var CSS_JUSTIFY_FLEX_END = 'flex-end';\n var CSS_JUSTIFY_SPACE_BETWEEN = 'space-between';\n var CSS_JUSTIFY_SPACE_AROUND = 'space-around';\n\n var CSS_ALIGN_FLEX_START = 'flex-start';\n var CSS_ALIGN_CENTER = 'center';\n var CSS_ALIGN_FLEX_END = 'flex-end';\n var CSS_ALIGN_STRETCH = 'stretch';\n\n var CSS_POSITION_RELATIVE = 'relative';\n var CSS_POSITION_ABSOLUTE = 'absolute';\n\n var leading = {\n 'row': 'left',\n 'row-reverse': 'right',\n 'column': 'top',\n 'column-reverse': 'bottom'\n };\n var trailing = {\n 'row': 'right',\n 'row-reverse': 'left',\n 'column': 'bottom',\n 'column-reverse': 'top'\n };\n var pos = {\n 'row': 'left',\n 'row-reverse': 'right',\n 'column': 'top',\n 'column-reverse': 'bottom'\n };\n var dim = {\n 'row': 'width',\n 'row-reverse': 'width',\n 'column': 'height',\n 'column-reverse': 'height'\n };\n\n function capitalizeFirst(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n\n function getSpacing(node, type, suffix, locations) {\n for (var i = 0; i < locations.length; ++i) {\n var location = locations[i];\n\n var key = type + capitalizeFirst(location) + suffix;\n if (key in node.style) {\n return node.style[key];\n }\n\n key = type + suffix;\n if (key in node.style) {\n return node.style[key];\n }\n }\n\n return 0;\n }\n\n // When transpiled to Java / C the node type has layout, children and style\n // properties. For the JavaScript version this function adds these properties\n // if they don't already exist.\n function fillNodes(node) {\n if (!node.layout) {\n node.layout = {\n width: undefined,\n height: undefined,\n top: 0,\n left: 0,\n right: 0,\n bottom: 0\n };\n }\n\n if (!node.style) {\n node.style = {};\n }\n\n if (!node.children) {\n node.children = [];\n }\n node.children.forEach(fillNodes);\n return node;\n }\n\n function getPositiveSpacing(node, type, suffix, locations) {\n for (var i = 0; i < locations.length; ++i) {\n var location = locations[i];\n\n var key = type + capitalizeFirst(location) + suffix;\n if (key in node.style && node.style[key] >= 0) {\n return node.style[key];\n }\n\n key = type + suffix;\n if (key in node.style && node.style[key] >= 0) {\n return node.style[key];\n }\n }\n\n return 0;\n }\n\n function isUndefined(value) {\n return value === undefined;\n }\n\n function isRowDirection(flexDirection) {\n return flexDirection === CSS_FLEX_DIRECTION_ROW ||\n flexDirection === CSS_FLEX_DIRECTION_ROW_REVERSE;\n }\n\n function isColumnDirection(flexDirection) {\n return flexDirection === CSS_FLEX_DIRECTION_COLUMN ||\n flexDirection === CSS_FLEX_DIRECTION_COLUMN_REVERSE;\n }\n\n function getLeadingLocations(axis) {\n var locations = [leading[axis]];\n if (isRowDirection(axis)) {\n locations.unshift('start');\n }\n\n return locations;\n }\n\n function getTrailingLocations(axis) {\n var locations = [trailing[axis]];\n if (isRowDirection(axis)) {\n locations.unshift('end');\n }\n\n return locations;\n }\n\n function getMargin(node, locations) {\n return getSpacing(node, 'margin', '', locations);\n }\n\n function getLeadingMargin(node, axis) {\n return getMargin(node, getLeadingLocations(axis));\n }\n\n function getTrailingMargin(node, axis) {\n return getMargin(node, getTrailingLocations(axis));\n }\n\n function getPadding(node, locations) {\n return getPositiveSpacing(node, 'padding', '', locations);\n }\n\n function getLeadingPadding(node, axis) {\n return getPadding(node, getLeadingLocations(axis));\n }\n\n function getTrailingPadding(node, axis) {\n return getPadding(node, getTrailingLocations(axis));\n }\n\n function getBorder(node, locations) {\n return getPositiveSpacing(node, 'border', 'Width', locations);\n }\n\n function getLeadingBorder(node, axis) {\n return getBorder(node, getLeadingLocations(axis));\n }\n\n function getTrailingBorder(node, axis) {\n return getBorder(node, getTrailingLocations(axis));\n }\n\n function getLeadingPaddingAndBorder(node, axis) {\n return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);\n }\n\n function getTrailingPaddingAndBorder(node, axis) {\n return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);\n }\n\n function getBorderAxis(node, axis) {\n return getLeadingBorder(node, axis) + getTrailingBorder(node, axis);\n }\n\n function getMarginAxis(node, axis) {\n return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);\n }\n\n function getPaddingAndBorderAxis(node, axis) {\n return getLeadingPaddingAndBorder(node, axis) +\n getTrailingPaddingAndBorder(node, axis);\n }\n\n function getJustifyContent(node) {\n if ('justifyContent' in node.style) {\n return node.style.justifyContent;\n }\n return 'flex-start';\n }\n\n function getAlignContent(node) {\n if ('alignContent' in node.style) {\n return node.style.alignContent;\n }\n return 'flex-start';\n }\n\n function getAlignItem(node, child) {\n if ('alignSelf' in child.style) {\n return child.style.alignSelf;\n }\n if ('alignItems' in node.style) {\n return node.style.alignItems;\n }\n return 'stretch';\n }\n\n function resolveAxis(axis, direction) {\n if (direction === CSS_DIRECTION_RTL) {\n if (axis === CSS_FLEX_DIRECTION_ROW) {\n return CSS_FLEX_DIRECTION_ROW_REVERSE;\n } else if (axis === CSS_FLEX_DIRECTION_ROW_REVERSE) {\n return CSS_FLEX_DIRECTION_ROW;\n }\n }\n\n return axis;\n }\n\n function resolveDirection(node, parentDirection) {\n var direction;\n if ('direction' in node.style) {\n direction = node.style.direction;\n } else {\n direction = CSS_DIRECTION_INHERIT;\n }\n\n if (direction === CSS_DIRECTION_INHERIT) {\n direction = (parentDirection === undefined ? CSS_DIRECTION_LTR : parentDirection);\n }\n\n return direction;\n }\n\n function getFlexDirection(node) {\n if ('flexDirection' in node.style) {\n return node.style.flexDirection;\n }\n return CSS_FLEX_DIRECTION_COLUMN;\n }\n\n function getCrossFlexDirection(flexDirection, direction) {\n if (isColumnDirection(flexDirection)) {\n return resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);\n } else {\n return CSS_FLEX_DIRECTION_COLUMN;\n }\n }\n\n function getPositionType(node) {\n if ('position' in node.style) {\n return node.style.position;\n }\n return 'relative';\n }\n\n function getFlex(node) {\n return node.style.flex;\n }\n\n function isFlex(node) {\n return (\n getPositionType(node) === CSS_POSITION_RELATIVE &&\n getFlex(node) > 0\n );\n }\n\n function isFlexWrap(node) {\n return node.style.flexWrap === 'wrap';\n }\n\n function getDimWithMargin(node, axis) {\n return node.layout[dim[axis]] + getMarginAxis(node, axis);\n }\n\n function isDimDefined(node, axis) {\n return !isUndefined(node.style[dim[axis]]) && node.style[dim[axis]] >= 0;\n }\n\n function isPosDefined(node, pos) {\n return !isUndefined(node.style[pos]);\n }\n\n function isMeasureDefined(node) {\n return 'measure' in node.style;\n }\n\n function getPosition(node, pos) {\n if (pos in node.style) {\n return node.style[pos];\n }\n return 0;\n }\n\n function boundAxis(node, axis, value) {\n var min = {\n 'row': node.style.minWidth,\n 'row-reverse': node.style.minWidth,\n 'column': node.style.minHeight,\n 'column-reverse': node.style.minHeight\n }[axis];\n\n var max = {\n 'row': node.style.maxWidth,\n 'row-reverse': node.style.maxWidth,\n 'column': node.style.maxHeight,\n 'column-reverse': node.style.maxHeight\n }[axis];\n\n var boundValue = value;\n if (!isUndefined(max) && max >= 0 && boundValue > max) {\n boundValue = max;\n }\n if (!isUndefined(min) && min >= 0 && boundValue < min) {\n boundValue = min;\n }\n return boundValue;\n }\n\n function fmaxf(a, b) {\n if (a > b) {\n return a;\n }\n return b;\n }\n\n // When the user specifically sets a value for width or height\n function setDimensionFromStyle(node, axis) {\n // The parent already computed us a width or height. We just skip it\n if (!isUndefined(node.layout[dim[axis]])) {\n return;\n }\n // We only run if there's a width or height defined\n if (!isDimDefined(node, axis)) {\n return;\n }\n\n // The dimensions can never be smaller than the padding and border\n node.layout[dim[axis]] = fmaxf(\n boundAxis(node, axis, node.style[dim[axis]]),\n getPaddingAndBorderAxis(node, axis)\n );\n }\n\n function setTrailingPosition(node, child, axis) {\n child.layout[trailing[axis]] = node.layout[dim[axis]] -\n child.layout[dim[axis]] - child.layout[pos[axis]];\n }\n\n // If both left and right are defined, then use left. Otherwise return\n // +left or -right depending on which is defined.\n function getRelativePosition(node, axis) {\n if (leading[axis] in node.style) {\n return getPosition(node, leading[axis]);\n }\n return -getPosition(node, trailing[axis]);\n }\n\n function layoutNode(node, parentMaxWidth, /*css_direction_t*/parentDirection) {\n var/*css_direction_t*/ direction = resolveDirection(node, parentDirection);\n var/*css_flex_direction_t*/ mainAxis = resolveAxis(getFlexDirection(node), direction);\n var/*css_flex_direction_t*/ crossAxis = getCrossFlexDirection(mainAxis, direction);\n var/*css_flex_direction_t*/ resolvedRowAxis = resolveAxis(CSS_FLEX_DIRECTION_ROW, direction);\n\n // Handle width and height style attributes\n setDimensionFromStyle(node, mainAxis);\n setDimensionFromStyle(node, crossAxis);\n\n // Set the resolved resolution in the node's layout\n node.layout.direction = direction;\n\n // The position is set by the parent, but we need to complete it with a\n // delta composed of the margin and left/top/right/bottom\n node.layout[leading[mainAxis]] += getLeadingMargin(node, mainAxis) +\n getRelativePosition(node, mainAxis);\n node.layout[trailing[mainAxis]] += getTrailingMargin(node, mainAxis) +\n getRelativePosition(node, mainAxis);\n node.layout[leading[crossAxis]] += getLeadingMargin(node, crossAxis) +\n getRelativePosition(node, crossAxis);\n node.layout[trailing[crossAxis]] += getTrailingMargin(node, crossAxis) +\n getRelativePosition(node, crossAxis);\n\n if (isMeasureDefined(node)) {\n var/*float*/ width = CSS_UNDEFINED;\n if (isDimDefined(node, resolvedRowAxis)) {\n width = node.style.width;\n } else if (!isUndefined(node.layout[dim[resolvedRowAxis]])) {\n width = node.layout[dim[resolvedRowAxis]];\n } else {\n width = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis);\n }\n width -= getPaddingAndBorderAxis(node, resolvedRowAxis);\n\n // We only need to give a dimension for the text if we haven't got any\n // for it computed yet. It can either be from the style attribute or because\n // the element is flexible.\n var/*bool*/ isRowUndefined = !isDimDefined(node, resolvedRowAxis) &&\n isUndefined(node.layout[dim[resolvedRowAxis]]);\n var/*bool*/ isColumnUndefined = !isDimDefined(node, CSS_FLEX_DIRECTION_COLUMN) &&\n isUndefined(node.layout[dim[CSS_FLEX_DIRECTION_COLUMN]]);\n\n // Let's not measure the text if we already know both dimensions\n if (isRowUndefined || isColumnUndefined) {\n var/*css_dim_t*/ measureDim = node.style.measure(\n /*(c)!node->context,*/\n /*(java)!layoutContext.measureOutput,*/\n width\n );\n if (isRowUndefined) {\n node.layout.width = measureDim.width +\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n if (isColumnUndefined) {\n node.layout.height = measureDim.height +\n getPaddingAndBorderAxis(node, CSS_FLEX_DIRECTION_COLUMN);\n }\n }\n if (node.children.length === 0) {\n return;\n }\n }\n\n var/*int*/ i;\n var/*int*/ ii;\n var/*css_node_t**/ child;\n var/*css_flex_direction_t*/ axis;\n\n // Pre-fill some dimensions straight from the parent\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n // Pre-fill cross axis dimensions when the child is using stretch before\n // we call the recursive layout pass\n if (getAlignItem(node, child) === CSS_ALIGN_STRETCH &&\n getPositionType(child) === CSS_POSITION_RELATIVE &&\n !isUndefined(node.layout[dim[crossAxis]]) &&\n !isDimDefined(child, crossAxis)) {\n child.layout[dim[crossAxis]] = fmaxf(\n boundAxis(child, crossAxis, node.layout[dim[crossAxis]] -\n getPaddingAndBorderAxis(node, crossAxis) -\n getMarginAxis(child, crossAxis)),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, crossAxis)\n );\n } else if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {\n // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both\n // left and right or top and bottom).\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (!isUndefined(node.layout[dim[axis]]) &&\n !isDimDefined(child, axis) &&\n isPosDefined(child, leading[axis]) &&\n isPosDefined(child, trailing[axis])) {\n child.layout[dim[axis]] = fmaxf(\n boundAxis(child, axis, node.layout[dim[axis]] -\n getPaddingAndBorderAxis(node, axis) -\n getMarginAxis(child, axis) -\n getPosition(child, leading[axis]) -\n getPosition(child, trailing[axis])),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, axis)\n );\n }\n }\n }\n }\n\n var/*float*/ definedMainDim = CSS_UNDEFINED;\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n definedMainDim = node.layout[dim[mainAxis]] -\n getPaddingAndBorderAxis(node, mainAxis);\n }\n\n // We want to execute the next two loops one per line with flex-wrap\n var/*int*/ startLine = 0;\n var/*int*/ endLine = 0;\n // var/*int*/ nextOffset = 0;\n var/*int*/ alreadyComputedNextLayout = 0;\n // We aggregate the total dimensions of the container in those two variables\n var/*float*/ linesCrossDim = 0;\n var/*float*/ linesMainDim = 0;\n var/*int*/ linesCount = 0;\n while (endLine < node.children.length) {\n // Layout non flexible children and count children by type\n\n // mainContentDim is accumulation of the dimensions and margin of all the\n // non flexible children. This will be used in order to either set the\n // dimensions of the node if none already exist, or to compute the\n // remaining space left for the flexible children.\n var/*float*/ mainContentDim = 0;\n\n // There are three kind of children, non flexible, flexible and absolute.\n // We need to know how many there are in order to distribute the space.\n var/*int*/ flexibleChildrenCount = 0;\n var/*float*/ totalFlexible = 0;\n var/*int*/ nonFlexibleChildrenCount = 0;\n\n var/*float*/ maxWidth;\n for (i = startLine; i < node.children.length; ++i) {\n child = node.children[i];\n var/*float*/ nextContentDim = 0;\n\n // It only makes sense to consider a child flexible if we have a computed\n // dimension for the node.\n if (!isUndefined(node.layout[dim[mainAxis]]) && isFlex(child)) {\n flexibleChildrenCount++;\n totalFlexible += getFlex(child);\n\n // Even if we don't know its exact size yet, we already know the padding,\n // border and margin. We'll use this partial information, which represents\n // the smallest possible size for the child, to compute the remaining\n // available space.\n nextContentDim = getPaddingAndBorderAxis(child, mainAxis) +\n getMarginAxis(child, mainAxis);\n\n } else {\n maxWidth = CSS_UNDEFINED;\n if (!isRowDirection(mainAxis)) {\n maxWidth = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis) -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n\n if (isDimDefined(node, resolvedRowAxis)) {\n maxWidth = node.layout[dim[resolvedRowAxis]] -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n }\n\n // This is the main recursive call. We layout non flexible children.\n if (alreadyComputedNextLayout === 0) {\n layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);\n }\n\n // Absolute positioned elements do not take part of the layout, so we\n // don't use them to compute mainContentDim\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n nonFlexibleChildrenCount++;\n // At this point we know the final size and margin of the element.\n nextContentDim = getDimWithMargin(child, mainAxis);\n }\n }\n\n // The element we are about to add would make us go to the next line\n if (isFlexWrap(node) &&\n !isUndefined(node.layout[dim[mainAxis]]) &&\n mainContentDim + nextContentDim > definedMainDim &&\n // If there's only one element, then it's bigger than the content\n // and needs its own line\n i !== startLine) {\n nonFlexibleChildrenCount--;\n alreadyComputedNextLayout = 1;\n break;\n }\n alreadyComputedNextLayout = 0;\n mainContentDim += nextContentDim;\n endLine = i + 1;\n }\n\n // Layout flexible children and allocate empty space\n\n // In order to position the elements in the main axis, we have two\n // controls. The space between the beginning and the first element\n // and the space between each two elements.\n var/*float*/ leadingMainDim = 0;\n var/*float*/ betweenMainDim = 0;\n\n // The remaining available space that needs to be allocated\n var/*float*/ remainingMainDim = 0;\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n remainingMainDim = definedMainDim - mainContentDim;\n } else {\n remainingMainDim = fmaxf(mainContentDim, 0) - mainContentDim;\n }\n\n // If there are flexible children in the mix, they are going to fill the\n // remaining space\n if (flexibleChildrenCount !== 0) {\n var/*float*/ flexibleMainDim = remainingMainDim / totalFlexible;\n var/*float*/ baseMainDim;\n var/*float*/ boundMainDim;\n\n // Iterate over every child in the axis. If the flex share of remaining\n // space doesn't meet min/max bounds, remove this child from flex\n // calculations.\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n if (isFlex(child)) {\n baseMainDim = flexibleMainDim * getFlex(child) +\n getPaddingAndBorderAxis(child, mainAxis);\n boundMainDim = boundAxis(child, mainAxis, baseMainDim);\n\n if (baseMainDim !== boundMainDim) {\n remainingMainDim -= boundMainDim;\n totalFlexible -= getFlex(child);\n }\n }\n }\n flexibleMainDim = remainingMainDim / totalFlexible;\n\n // The non flexible children can overflow the container, in this case\n // we should just assume that there is no space available.\n if (flexibleMainDim < 0) {\n flexibleMainDim = 0;\n }\n // We iterate over the full array and only apply the action on flexible\n // children. This is faster than actually allocating a new array that\n // contains only flexible children.\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n if (isFlex(child)) {\n // At this point we know the final size of the element in the main\n // dimension\n child.layout[dim[mainAxis]] = boundAxis(child, mainAxis,\n flexibleMainDim * getFlex(child) + getPaddingAndBorderAxis(child, mainAxis)\n );\n\n maxWidth = CSS_UNDEFINED;\n if (isDimDefined(node, resolvedRowAxis)) {\n maxWidth = node.layout[dim[resolvedRowAxis]] -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n } else if (!isRowDirection(mainAxis)) {\n maxWidth = parentMaxWidth -\n getMarginAxis(node, resolvedRowAxis) -\n getPaddingAndBorderAxis(node, resolvedRowAxis);\n }\n\n // And we recursively call the layout algorithm for this child\n layoutNode(/*(java)!layoutContext, */child, maxWidth, direction);\n }\n }\n\n // We use justifyContent to figure out how to allocate the remaining\n // space available\n } else {\n var/*css_justify_t*/ justifyContent = getJustifyContent(node);\n if (justifyContent === CSS_JUSTIFY_CENTER) {\n leadingMainDim = remainingMainDim / 2;\n } else if (justifyContent === CSS_JUSTIFY_FLEX_END) {\n leadingMainDim = remainingMainDim;\n } else if (justifyContent === CSS_JUSTIFY_SPACE_BETWEEN) {\n remainingMainDim = fmaxf(remainingMainDim, 0);\n if (flexibleChildrenCount + nonFlexibleChildrenCount - 1 !== 0) {\n betweenMainDim = remainingMainDim /\n (flexibleChildrenCount + nonFlexibleChildrenCount - 1);\n } else {\n betweenMainDim = 0;\n }\n } else if (justifyContent === CSS_JUSTIFY_SPACE_AROUND) {\n // Space on the edges is half of the space between elements\n betweenMainDim = remainingMainDim /\n (flexibleChildrenCount + nonFlexibleChildrenCount);\n leadingMainDim = betweenMainDim / 2;\n }\n }\n\n // Position elements in the main axis and compute dimensions\n\n // At this point, all the children have their dimensions set. We need to\n // find their position. In order to do that, we accumulate data in\n // variables that are also useful to compute the total dimensions of the\n // container!\n var/*float*/ crossDim = 0;\n var/*float*/ mainDim = leadingMainDim +\n getLeadingPaddingAndBorder(node, mainAxis);\n\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n child.lineIndex = linesCount;\n\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&\n isPosDefined(child, leading[mainAxis])) {\n // In case the child is position absolute and has left/top being\n // defined, we override the position to whatever the user said\n // (and margin/border).\n child.layout[pos[mainAxis]] = getPosition(child, leading[mainAxis]) +\n getLeadingBorder(node, mainAxis) +\n getLeadingMargin(child, mainAxis);\n } else {\n // If the child is position absolute (without top/left) or relative,\n // we put it at the current accumulated offset.\n child.layout[pos[mainAxis]] += mainDim;\n\n // Define the trailing position accordingly.\n if (!isUndefined(node.layout[dim[mainAxis]])) {\n setTrailingPosition(node, child, mainAxis);\n }\n }\n\n // Now that we placed the element, we need to update the variables\n // We only need to do that for relative elements. Absolute elements\n // do not take part in that phase.\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n // The main dimension is the sum of all the elements dimension plus\n // the spacing.\n mainDim += betweenMainDim + getDimWithMargin(child, mainAxis);\n // The cross dimension is the max of the elements dimension since there\n // can only be one element in that cross dimension.\n crossDim = fmaxf(crossDim, boundAxis(child, crossAxis, getDimWithMargin(child, crossAxis)));\n }\n }\n\n var/*float*/ containerCrossAxis = node.layout[dim[crossAxis]];\n if (isUndefined(node.layout[dim[crossAxis]])) {\n containerCrossAxis = fmaxf(\n // For the cross dim, we add both sides at the end because the value\n // is aggregate via a max function. Intermediate negative values\n // can mess this computation otherwise\n boundAxis(node, crossAxis, crossDim + getPaddingAndBorderAxis(node, crossAxis)),\n getPaddingAndBorderAxis(node, crossAxis)\n );\n }\n\n // Position elements in the cross axis\n for (i = startLine; i < endLine; ++i) {\n child = node.children[i];\n\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE &&\n isPosDefined(child, leading[crossAxis])) {\n // In case the child is absolutely positionned and has a\n // top/left/bottom/right being set, we override all the previously\n // computed positions to set it correctly.\n child.layout[pos[crossAxis]] = getPosition(child, leading[crossAxis]) +\n getLeadingBorder(node, crossAxis) +\n getLeadingMargin(child, crossAxis);\n\n } else {\n var/*float*/ leadingCrossDim = getLeadingPaddingAndBorder(node, crossAxis);\n\n // For a relative children, we're either using alignItems (parent) or\n // alignSelf (child) in order to determine the position in the cross axis\n if (getPositionType(child) === CSS_POSITION_RELATIVE) {\n var/*css_align_t*/ alignItem = getAlignItem(node, child);\n if (alignItem === CSS_ALIGN_STRETCH) {\n // You can only stretch if the dimension has not already been set\n // previously.\n if (!isDimDefined(child, crossAxis)) {\n child.layout[dim[crossAxis]] = fmaxf(\n boundAxis(child, crossAxis, containerCrossAxis -\n getPaddingAndBorderAxis(node, crossAxis) -\n getMarginAxis(child, crossAxis)),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, crossAxis)\n );\n }\n } else if (alignItem !== CSS_ALIGN_FLEX_START) {\n // The remaining space between the parent dimensions+padding and child\n // dimensions+margin.\n var/*float*/ remainingCrossDim = containerCrossAxis -\n getPaddingAndBorderAxis(node, crossAxis) -\n getDimWithMargin(child, crossAxis);\n\n if (alignItem === CSS_ALIGN_CENTER) {\n leadingCrossDim += remainingCrossDim / 2;\n } else { // CSS_ALIGN_FLEX_END\n leadingCrossDim += remainingCrossDim;\n }\n }\n }\n\n // And we apply the position\n child.layout[pos[crossAxis]] += linesCrossDim + leadingCrossDim;\n\n // Define the trailing position accordingly.\n if (!isUndefined(node.layout[dim[crossAxis]])) {\n setTrailingPosition(node, child, crossAxis);\n }\n }\n }\n\n linesCrossDim += crossDim;\n linesMainDim = fmaxf(linesMainDim, mainDim);\n linesCount += 1;\n startLine = endLine;\n }\n\n // \n //\n // Note(prenaux): More than one line, we need to layout the crossAxis\n // according to alignContent.\n //\n // Note that we could probably remove and handle the one line case\n // here too, but for the moment this is safer since it won't interfere with\n // previously working code.\n //\n // See specs:\n // http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/#layout-algorithm\n // section 9.4\n //\n if (linesCount > 1 &&\n !isUndefined(node.layout[dim[crossAxis]])) {\n var/*float*/ nodeCrossAxisInnerSize = node.layout[dim[crossAxis]] -\n getPaddingAndBorderAxis(node, crossAxis);\n var/*float*/ remainingAlignContentDim = nodeCrossAxisInnerSize - linesCrossDim;\n\n var/*float*/ crossDimLead = 0;\n var/*float*/ currentLead = getLeadingPaddingAndBorder(node, crossAxis);\n\n var/*css_align_t*/ alignContent = getAlignContent(node);\n if (alignContent === CSS_ALIGN_FLEX_END) {\n currentLead += remainingAlignContentDim;\n } else if (alignContent === CSS_ALIGN_CENTER) {\n currentLead += remainingAlignContentDim / 2;\n } else if (alignContent === CSS_ALIGN_STRETCH) {\n if (nodeCrossAxisInnerSize > linesCrossDim) {\n crossDimLead = (remainingAlignContentDim / linesCount);\n }\n }\n\n var/*int*/ endIndex = 0;\n for (i = 0; i < linesCount; ++i) {\n var/*int*/ startIndex = endIndex;\n\n // compute the line's height and find the endIndex\n var/*float*/ lineHeight = 0;\n for (ii = startIndex; ii < node.children.length; ++ii) {\n child = node.children[ii];\n if (getPositionType(child) !== CSS_POSITION_RELATIVE) {\n continue;\n }\n if (child.lineIndex !== i) {\n break;\n }\n if (!isUndefined(child.layout[dim[crossAxis]])) {\n lineHeight = fmaxf(\n lineHeight,\n child.layout[dim[crossAxis]] + getMarginAxis(child, crossAxis)\n );\n }\n }\n endIndex = ii;\n lineHeight += crossDimLead;\n\n for (ii = startIndex; ii < endIndex; ++ii) {\n child = node.children[ii];\n if (getPositionType(child) !== CSS_POSITION_RELATIVE) {\n continue;\n }\n\n var/*css_align_t*/ alignContentAlignItem = getAlignItem(node, child);\n if (alignContentAlignItem === CSS_ALIGN_FLEX_START) {\n child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);\n } else if (alignContentAlignItem === CSS_ALIGN_FLEX_END) {\n child.layout[pos[crossAxis]] = currentLead + lineHeight - getTrailingMargin(child, crossAxis) - child.layout[dim[crossAxis]];\n } else if (alignContentAlignItem === CSS_ALIGN_CENTER) {\n var/*float*/ childHeight = child.layout[dim[crossAxis]];\n child.layout[pos[crossAxis]] = currentLead + (lineHeight - childHeight) / 2;\n } else if (alignContentAlignItem === CSS_ALIGN_STRETCH) {\n child.layout[pos[crossAxis]] = currentLead + getLeadingMargin(child, crossAxis);\n // TODO(prenaux): Correctly set the height of items with undefined\n // (auto) crossAxis dimension.\n }\n }\n\n currentLead += lineHeight;\n }\n }\n\n var/*bool*/ needsMainTrailingPos = false;\n var/*bool*/ needsCrossTrailingPos = false;\n\n // If the user didn't specify a width or height, and it has not been set\n // by the container, then we set it via the children.\n if (isUndefined(node.layout[dim[mainAxis]])) {\n node.layout[dim[mainAxis]] = fmaxf(\n // We're missing the last padding at this point to get the final\n // dimension\n boundAxis(node, mainAxis, linesMainDim + getTrailingPaddingAndBorder(node, mainAxis)),\n // We can never assign a width smaller than the padding and borders\n getPaddingAndBorderAxis(node, mainAxis)\n );\n\n needsMainTrailingPos = true;\n }\n\n if (isUndefined(node.layout[dim[crossAxis]])) {\n node.layout[dim[crossAxis]] = fmaxf(\n // For the cross dim, we add both sides at the end because the value\n // is aggregate via a max function. Intermediate negative values\n // can mess this computation otherwise\n boundAxis(node, crossAxis, linesCrossDim + getPaddingAndBorderAxis(node, crossAxis)),\n getPaddingAndBorderAxis(node, crossAxis)\n );\n\n needsCrossTrailingPos = true;\n }\n\n // Set trailing position if necessary\n if (needsMainTrailingPos || needsCrossTrailingPos) {\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n\n if (needsMainTrailingPos) {\n setTrailingPosition(node, child, mainAxis);\n }\n\n if (needsCrossTrailingPos) {\n setTrailingPosition(node, child, crossAxis);\n }\n }\n }\n\n // Calculate dimensions for absolutely positioned elements\n for (i = 0; i < node.children.length; ++i) {\n child = node.children[i];\n if (getPositionType(child) === CSS_POSITION_ABSOLUTE) {\n // Pre-fill dimensions when using absolute position and both offsets for the axis are defined (either both\n // left and right or top and bottom).\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (!isUndefined(node.layout[dim[axis]]) &&\n !isDimDefined(child, axis) &&\n isPosDefined(child, leading[axis]) &&\n isPosDefined(child, trailing[axis])) {\n child.layout[dim[axis]] = fmaxf(\n boundAxis(child, axis, node.layout[dim[axis]] -\n getBorderAxis(node, axis) -\n getMarginAxis(child, axis) -\n getPosition(child, leading[axis]) -\n getPosition(child, trailing[axis])\n ),\n // You never want to go smaller than padding\n getPaddingAndBorderAxis(child, axis)\n );\n }\n }\n for (ii = 0; ii < 2; ii++) {\n axis = (ii !== 0) ? CSS_FLEX_DIRECTION_ROW : CSS_FLEX_DIRECTION_COLUMN;\n if (isPosDefined(child, trailing[axis]) &&\n !isPosDefined(child, leading[axis])) {\n child.layout[leading[axis]] =\n node.layout[dim[axis]] -\n child.layout[dim[axis]] -\n getPosition(child, trailing[axis]);\n }\n }\n }\n }\n }\n\n return {\n computeLayout: layoutNode,\n fillNodes: fillNodes\n };\n})();\n\n// This module export is only used for the purposes of unit testing this file. When\n// the library is packaged this file is included within css-layout.js which forms \n// the public API.\nif (typeof exports === 'object') {\n module.exports = computeLayout;\n}\n\n return function(node) {\n computeLayout.fillNodes(node);\n computeLayout.computeLayout(node);\n };\n}));\n"]} \ No newline at end of file diff --git a/src/Layout-test-utils.js b/src/Layout-test-utils.js index c37e6b5b..be912e0f 100644 --- a/src/Layout-test-utils.js +++ b/src/Layout-test-utils.js @@ -114,10 +114,25 @@ var layoutTestUtils = (function() { if (typeof computeLayout === 'object') { var fillNodes = computeLayout.fillNodes; - var extractNodes = computeLayout.extractNodes; var realComputeLayout = computeLayout.computeLayout; } + function extractNodes(node) { + var layout = node.layout; + delete node.layout; + if (node.children && node.children.length > 0) { + layout.children = node.children.map(extractNodes); + } else { + delete node.children; + } + + delete layout.right; + delete layout.bottom; + delete layout.direction; + + return layout; + } + function roundLayout(layout) { // Chrome rounds all the numbers with a precision of 1/64 // Reproduce the same behavior diff --git a/src/Layout.js b/src/Layout.js index f5ee1953..a70e205e 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -80,42 +80,33 @@ var computeLayout = (function() { return 0; } + + // When transpiled to Java / C the node type has layout, children and style + // properties. For the JavaScript version this function adds these properties + // if they don't already exist. function fillNodes(node) { - node.layout = { - width: undefined, - height: undefined, - top: 0, - left: 0, - right: 0, - bottom: 0 - }; + if (!node.layout) { + node.layout = { + width: undefined, + height: undefined, + top: 0, + left: 0, + right: 0, + bottom: 0 + }; + } + if (!node.style) { node.style = {}; } - if (!node.children || node.style.measure) { + if (!node.children) { node.children = []; } node.children.forEach(fillNodes); return node; } - function extractNodes(node) { - var layout = node.layout; - delete node.layout; - if (node.children && node.children.length > 0) { - layout.children = node.children.map(extractNodes); - } else { - delete node.children; - } - - delete layout.right; - delete layout.bottom; - delete layout.direction; - - return layout; - } - function getPositiveSpacing(node, type, suffix, locations) { for (var i = 0; i < locations.length; ++i) { var location = locations[i]; @@ -981,11 +972,13 @@ var computeLayout = (function() { return { computeLayout: layoutNode, - fillNodes: fillNodes, - extractNodes: extractNodes + fillNodes: fillNodes }; })(); +// This module export is only used for the purposes of unit testing this file. When +// the library is packaged this file is included within css-layout.js which forms +// the public API. if (typeof exports === 'object') { module.exports = computeLayout; } \ No newline at end of file diff --git a/src/__tests__/Layout-test.js b/src/__tests__/Layout-test.js index 3c4c7bb9..45d4a2a0 100755 --- a/src/__tests__/Layout-test.js +++ b/src/__tests__/Layout-test.js @@ -31,20 +31,10 @@ describe('Javascript Only', function() { ]} ); }); - it('should pull out just the layout object from root', function() { - testExtractNodes( - {layout: {width: undefined, height: undefined, top: 0, left: 0}}, - {width: undefined, height: undefined, top: 0, left: 0} - ); - }); - it('should pull out just the layout object from root and children', function() { - testExtractNodes( - {layout: {width: undefined, height: undefined, top: 0, left: 0}, children: [ - {layout: {width: undefined, height: undefined, top: 0, left: 0}} - ]}, - {width: undefined, height: undefined, top: 0, left: 0, children: [ - {width: undefined, height: undefined, top: 0, left: 0} - ]} + it('should not replace user-provided layout information', function() { + testFillNodes( + {layout: {width: 200}}, + {layout: {width: 200}, style: {}, children: []} ); }); }); diff --git a/src/css-layout.js b/src/css-layout.js index 02514160..46f37b10 100644 --- a/src/css-layout.js +++ b/src/css-layout.js @@ -20,9 +20,7 @@ // @@include('./Layout.js') return function(node) { - node = computeLayout.fillNodes(node); + computeLayout.fillNodes(node); computeLayout.computeLayout(node); - node = computeLayout.extractNodes(node); - return node; }; }));