W3C home > Mailing lists > Public > www-style@w3.org > March 2016

Re: [css-box] shrink-to-fit and floats

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 7 Mar 2016 11:17:20 -0800
Message-ID: <CAAWBYDAX-b7Xc-m_4ktfOSEjaSvRz8TKFAOwBENJGFxyi8P+Uw@mail.gmail.com>
To: Pavel Panchekha <me@pavpanchekha.com>
Cc: www-style list <www-style@w3.org>
On Mon, Mar 7, 2016 at 12:31 AM, Pavel Panchekha <me@pavpanchekha.com> wrote:
> I am implementing shrink-to-fit for float width computation and had a
> question..
> Suppose I have an div inside a section; the section is floating with width:
> auto while the div has a fixed width of 10px, and no borders or margins
> specified. Naturally, the section ought to shrink to 10px wide.
> However, a malicious reading of the spec seems to allow the section to have
> any width, say 0 pixels. For suppose the section is 0 pixels wide. Then by
> the rules for block-level, non-replaced elements, the margin-right of the
> div is ignored, so that the used value is -10px. But then the preferred
> width, and thus the shrink-to-fit width, of the div is 0.
> How does the specification prevent this reading? Are margins always assumed
> not to overflow during rendering?

You can't just set the section to whatever size you want, and then run
the sizing algorithm with that assumption.  The section's size is
well-described by the specs already.  In particular, section 10.3.5
defines how to calculate the shrink-to-fit width of the section: the
"preferred width" and "preferred minimum width" are both 10px, the
"available width" is the width of the content box of the section's
containing block (which isn't provided in your example, but it's
reasonable to assume that this is larger than 10px); then
min(max(10px, XXXpx), 10px) yields "10px" as the shrink-to-fit width
of the section.

Some details of your question seem to indicate a bit of confusion over
how these algorithms are applied, tho - according to your example, the
div is *not* floated, and its width is "10px", so the shrink-to-fit
width of the div has no relevance here.  The div's width is just 10px,
because that's what you specified, and it isn't in any situation that
would complicate our calculations.

Received on Monday, 7 March 2016 19:18:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:01 UTC