Re: question on width calculation for floats and tables nested inside a div

On Thursday 2009-07-02 06:28 +0000, Dirk Pranke wrote:
> That sentence is a bit hard to parse, so this is best illustrated by
> looking at the example:
> https://bugs.webkit.org/attachment.cgi?id=32157

> In my interpretation, option #1 is probably what everyone should be
> doing (but no one does). Anyone want to give reasons as to why options
> #2 or #3 make more sense?

I think option #3 is the correct behavior.

After a quick glance at the relevant Gecko code, I don't see why
it's doing #2 rather than #3.  It wouldn't surprise me if it was
because we ran into compatibility problems somewhere, but it also
wouldn't surprise me if it was an accident.

The reason option #1 (and, in general, making width calculation
depend on the available space next to floats) is bad is that it
tends to produce layouts that vary in extremely unstable ways under
resizing.  For example, a series of floats that, without that
behavior, would wrap into multiple "lines":

     +-----+ +-----+ +-----+ +-----+
     |     | |     | |     | |     |
     +-----+ +-----+ +-----+ +-----+
     +-----+ +-----+ +-----+
     |     | |     | |     |
     +-----+ +-----+ +-----+

might, with width calculations that depend on the available space
next to floats, behave exactly as above at some browser widths, but
at an ever-so-slightly wider browser width would instead act like
this:

     +-----+ +-----+ +-----+ +-----+ +-+
     |     | |     | |     | |     | | |
     +-----+ +-----+ +-----+ +-----+ | |
                                     | |
                                     | |
                                     | |
                                     | |
                                     | |
                                     | |
                                     | |
                                     +-+
     +-----+ +-----+
     |     | |     |
     +-----+ +-----+

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/

Received on Thursday, 2 July 2009 17:10:40 UTC