W3C home > Mailing lists > Public > www-style@w3.org > October 2010

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 28 Oct 2010 12:32:20 -0400
Message-ID: <4CC9A594.90800@mit.edu>
To: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
CC: WWW Style <www-style@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:33 GMT