Re: [css3-box] Issue with the current shrink to fit algorithm

On 10/28/10 12:22 PM, Giuseppe Bilotta wrote:
> (1) find the minimum preferred width [this is like the second step of
> the current shrink-wrap algorithm]
> (2) find the maximum available width [this is like the third step of
> the current shrink-wrap algorithm]
> (3) layout the box content assuming a containing width of
> max(minpref,available).
> (4) set the box width to the largest contained box width (plus
> margins, paddings, etc)

After step 4 you have to redo the layout, due to percentage widths.

So you have to do two full layout passes for each shrink-wrap width 
computation.  So a shrink-wrap box with N shrink-wrap ancestors needs 
2^N such passes (modulo maybe caching some layout results somewhere, but 
you'd still hit the worst case in some cases, and the caching sounds 
pretty error-prone, in addition to using additional memory).  It might 
be doable; it's all a matter of programming, obviously... ;)

Note that on real-world websites nesting 10-deep of shrink-wrap boxes is 
not uncommon.  We've seen nesting up to 30-deep on some sites that 
didn't do well with exponential growth in nesting depth... ;)

-Boris

Received on Thursday, 28 October 2010 16:32:55 UTC