@@ -295,9 +295,9 @@ ALMCSS.template = function() {
295295 } ;
296296
297297 var MinMax = function ( p , q ) {
298- warn ( 'min-max is not yet supported by ALMCSS' ) ;
299298 Width . call ( this , 'min-max' ) ;
300- // TODO
299+ this . p = p ;
300+ this . q = q ;
301301 } ;
302302
303303 // Auxiliary functions
@@ -353,44 +353,62 @@ ALMCSS.template = function() {
353353 var intrinsicMinimumWidth ,
354354 intrinsicPreferredWidth ;
355355
356- var computeWidthForLength = function ( ) {
357- assert ( columnWidth instanceof Length ) ;
358- } ;
356+ var computeIntrinsicMinimumAndIntrinsicPreferredWidths = function ( ) {
359357
360- var computeWidthForEqual = function ( ) {
361- assert ( columnWidth === Width . equal ) ;
362- intrinsicMinimumWidth = 0 ;
363- intrinsicPreferredWidth = Number . MAX_VALUE ;
364- } ;
358+ var i , largestIntrinsicMinimumWidth = 0 , largestIntrinsicPreferredWidth = 0 ;
365359
366- var computeWidthForMinContent = function ( ) {
367- assert ( columnWidth === Width . minContent ) ;
368- var i , largestIntrinsicMinimumWidth = 0 ;
369- for ( i = 0 ; i < slots . length ; i ++ ) {
370- if ( slots [ i ] . getIntrinsicMinimumWidth ( ) > largestIntrinsicMinimumWidth ) {
371- largestIntrinsicMinimumWidth = slots [ i ] . getIntrinsicMinimumWidth ( ) ;
372- }
373- }
374- intrinsicMinimumWidth = intrinsicPreferredWidth = largestIntrinsicMinimumWidth ;
375- } ;
360+ // A column with a `columnWidth` of a given length has intrinsic minimum and
361+ // intrinsic preferred widths both equal to that length.
376362
377- var computeWidth = function ( ) {
378363 if ( columnWidth instanceof Length ) {
379364 intrinsicMinimumWidth = Length ;
380365 intrinsicPreferredWidth = Length ;
381- } else if ( columnWidth === Width . equal ) {
366+ }
367+
368+ // A column with a `columnWidth` of '*' has an infinite intrinsic preferred
369+ // width. Its intrinsic minimum width is 0.
370+
371+ else if ( columnWidth === Width . equal ) {
382372 intrinsicMinimumWidth = 0 ;
383373 intrinsicPreferredWidth = Number . MAX_VALUE ;
384- } else if ( columnWidth === Width . minContent ) {
385- var i , largestIntrinsicMinimumWidth = 0 ;
374+ }
375+
376+ // A column with a `columnWidth` of 'min-content' has an intrinsic minimum
377+ // width and intrinsic preferred width that are both equal to the largest
378+ // of the *intrinsic minimum* widths of all the slots in that column.
379+
380+ else if ( columnWidth === Width . minContent ) {
386381 for ( i = 0 ; i < slots . length ; i ++ ) {
387382 if ( slots [ i ] . getIntrinsicMinimumWidth ( ) > largestIntrinsicMinimumWidth ) {
388383 largestIntrinsicMinimumWidth = slots [ i ] . getIntrinsicMinimumWidth ( ) ;
389384 }
390385 }
391386 intrinsicMinimumWidth = intrinsicPreferredWidth = largestIntrinsicMinimumWidth ;
392- } else if ( columnWidth === Width . maxContent ) {
387+ }
388+
389+ // A column with a `columnWidth` of 'max-content' has an intrinsic minimum
390+ // width and intrinsic preferred width that are both equal to the largest
391+ // of the *intrinsic preferred* widths of all the slots in that column.
392+
393+ else if ( columnWidth === Width . maxContent ) {
394+ for ( i = 0 ; i < slots . length ; i ++ ) {
395+ if ( slots [ i ] . getIntrinsicPreferredWidth ( ) > largestIntrinsicPreferredWidth ) {
396+ largestIntrinsicPreferredWidth = slots [ i ] . getIntrinsicPreferredWidth ( ) ;
397+ }
398+ }
399+ intrinsicMinimumWidth = intrinsicPreferredWidth = largestIntrinsicPreferredWidth ;
400+ }
401+
402+ // A column with a `columnWidth` of 'minmax(p, q)' has an intrinsic
403+ // minimum width equal to p and an intrinsic preferred width equal to q.
404+
405+ else if ( columnWidth instanceof MinMax ) {
406+ intrinsicMinimumWidth = columnWidth . p ;
407+ intrinsicPreferredWidth = columnWidth . q ;
408+ }
393409
410+ else {
411+ assert ( false , 'A non recognised value for column width: ' + columnWidth ) ;
394412 }
395413 } ;
396414
0 commit comments