Skip to content

Commit 1164312

Browse files
committed
Farm out the sizing and linebreaking part of flex resolution to the respective chapters.
1 parent 641c866 commit 1164312

2 files changed

Lines changed: 117 additions & 294 deletions

File tree

css3-flexbox/Overview.html

Lines changed: 87 additions & 192 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
<h1 id=head-box-flexible>CSS Flexible Box Layout Module</h1>
1818

19-
<h2 class="no-num no-toc" id=w3c-working>Editor's Draft, 24 August 2011</h2>
19+
<h2 class="no-num no-toc" id=w3c-working>Editor's Draft, 25 August 2011</h2>
2020

2121
<dl>
2222
<dt>This version:
2323

24-
<dd><!-- <a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20110824/">http://www.w3.org/TR/2011/WD-css3-flexbox-20110824/</a></dd> -->
24+
<dd><!-- <a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20110825/">http://www.w3.org/TR/2011/WD-css3-flexbox-20110825/</a></dd> -->
2525
<a
2626
href="http://dev.w3.org/csswg/css3-flexbox/">http://dev.w3.org/csswg/css3-flexbox/</a>
2727

@@ -205,8 +205,8 @@ <h2 class="no-num no-toc" id=table>Table of contents</h2>
205205
<li><a href="#pagination"><span class=secno>8. </span> Page breaks in
206206
flexbox</a>
207207

208-
<li><a href="#layout-interface"><span class=secno>9. </span> Interface
209-
With Other Layout Algorithms</a>
208+
<li><a href="#layout-interface"><span class=secno>9. </span> Box
209+
Properties and Sizing</a>
210210

211211
<li><a href="#changes"><span class=secno>10. </span>Changes</a>
212212
<ul class=toc>
@@ -959,124 +959,89 @@ <h3 id=resolving-flexible-lengths><span class=secno>4.2. </span> Resolving
959959
preferred size. The following algorithm normatively describes how to do
960960
this conversion:
961961

962+
<p>First, determine the width and height of the flexbox itself, as
963+
described by the <a href="#layout-interface">Box Properties</a> chapter.
964+
The <a href="#main-size"><i>main size</i></a> of the flexbox's content box
965+
is the <i>available space</i>.
966+
967+
<p>Second, if the flexbox is <i>multi-line</i>, break the contents across
968+
multiple lines, as described by the <a href=multiline>Multiline</a>
969+
chapter.
970+
971+
<p>Then, for each line in the flexbox, do the following:
972+
962973
<ol>
963-
<li>
964-
<p>Determine the width and height of the flexbox itself.</p>
965-
966-
<p class=issue>Figure out how to do this for all combinations of flexbox
967-
direction, writing modes on the flexbox and flexbox items, and values of
968-
"width" and "height".</p>
969-
970-
<p>The <a href="#main-size"><i>main size</i></a> of the flexbox's content
971-
box is the <dfn id=available-space>available space</dfn>.</p>
972-
973-
<li>For each <a href="#flexbox-item"><i>flexbox item</i></a>, its <dfn
974-
id=pre-flex-size title="pre-flex size|pre-flex sizes">pre-flex size</dfn>
975-
is the <a href="#main-size"><i>main size</i></a> of the item's margin
976-
box, honoring the &lsquo;<code
977-
class=css>min/max-width/height</code>&rsquo; properties. If the
978-
&lsquo;<code class=property>width</code>&rsquo; or &lsquo;<code
979-
class=property>height</code>&rsquo; properties are specified with <a
980-
href="#flexible-length0"><i>flexible lengths</i></a>, do this calculation
981-
as if they were instead specified with the <a
982-
href="#flexible-length0"><i>flexible length's</i></a> <a
983-
href="#preferred-size"><i>preferred size</i></a>.
974+
<li>Subtract the sum of the <i>pre-flex sizes</i> of the <a
975+
href="#flexbox-item"><i>flexbox items</i></a> on the line from the
976+
<i>available space</i>. This is the <dfn id=free-space>free space</dfn>.
977+
This number may be negative, if the flexbox is single-line or a single <a
978+
href="#flexbox-item"><i>flexbox item</i></a> is larger than the entire
979+
flexbox.
984980

985981
<li>
986-
<p>If the flexbox is <i>multi-line</i>, line-breaking must be performed.</p>
987-
988-
<p>If the current line has more than one <a
989-
href="#flexbox-item"><i>flexbox item</i></a> and the sum of all the <a
990-
href="#pre-flex-size"><i>pre-flex sizes</i></a> of its <a
991-
href="#flexbox-item"><i>flexbox items</i></a> is greater than the <a
992-
href="#available-space"><i>available space</i></a>, a new line must be
993-
created. The current line always contains the first <a
994-
href="#flexbox-item"><i>flexbox item</i></a> within it, and as many
995-
subsequent <a href="#flexbox-item"><i>flexbox items</i></a> as possible
996-
while keeping the sum of <a href="#pre-flex-size"><i>pre-flex
997-
sizes</i></a> less than the <a href="#available-space"><i>available
998-
space</i></a>. The rest of the <a href="#flexbox-item"><i>flexbox
999-
items</i></a> move to the next line, where this step is repeated as
1000-
necessary until no new lines are created.</p>
982+
<dl>
983+
<dt>If the <a href="#free-space"><i>free space</i></a> is zero:
1001984

1002-
<li>
1003-
<p>Within each line, run the following steps:</p>
1004-
1005-
<ol>
1006-
<li>Subtract the sum of the <a href="#pre-flex-size"><i>pre-flex
1007-
sizes</i></a> of the <a href="#flexbox-item"><i>flexbox items</i></a>
1008-
on the line from the <a href="#available-space"><i>available
1009-
space</i></a>. This is the <dfn id=free-space>free space</dfn>. This
1010-
number may be negative, if the flexbox is single-line or a single <a
1011-
href="#flexbox-item"><i>flexbox item</i></a> is larger than the entire
1012-
flexbox.
985+
<dd>All <a href="#flexible-length0"><i>flexible lengths</i></a> resolve
986+
to their <a href="#preferred-size"><i>preferred size</i></a>.
987+
988+
<dt>If the <a href="#free-space"><i>free space</i></a> is positive:
989+
990+
<dd>
991+
<p>Sum the <a href="#positive-flexibility"><i>positive
992+
flexibility</i></a> of every <a href="#flexible-length0"><i>flexible
993+
length</i></a> on the line. This is the <dfn
994+
id=total-positive-flexibility>total positive flexibility</dfn>.</p>
995+
996+
<p>For each <a href="#flexible-length0"><i>flexible length</i></a>,
997+
increment its <a href="#preferred-size"><i>preferred size</i></a> by
998+
<code><a href="#free-space"><i>free space</i></a> * &lt;pos-flex> / <a
999+
href="#total-positive-flexibility"><i>total positive
1000+
flexibility</i></a></code>.</p>
1001+
1002+
<dt>If the <a href="#free-space"><i>free space</i></a> is negative:
1003+
1004+
<dd>
1005+
<p>Sum the <a href="#negative-flexibility"><i>negative
1006+
flexibility</i></a> of every <a href="#flexible-length0"><i>flexible
1007+
length</i></a> on the line. This is the <dfn
1008+
id=total-negative-flexibility>total negative flexibility</dfn>.</p>
1009+
1010+
<p>For each <a href="#flexible-length0"><i>flexible length</i></a>,
1011+
increment its <a href="#preferred-size"><i>preferred size</i></a> by
1012+
<code><a href="#free-space"><i>free space</i></a> * &lt;neg-flex> / <a
1013+
href="#total-negative-flexibility"><i>total negative
1014+
flexibility</i></a></code>. <span class=note>Note: since the free
1015+
space is negative, incrementing the preferred size by this number
1016+
makes the preferred size smaller.</span></p>
1017+
</dl>
10131018

1014-
<li>
1015-
<dl>
1016-
<dt>If the <a href="#free-space"><i>free space</i></a> is zero:
1017-
1018-
<dd>All <a href="#flexible-length0"><i>flexible lengths</i></a>
1019-
resolve to their <a href="#preferred-size"><i>preferred size</i></a>.
1020-
1021-
<dt>If the <a href="#free-space"><i>free space</i></a> is positive:
1022-
1023-
<dd>
1024-
<p>Sum the <a href="#positive-flexibility"><i>positive
1025-
flexibility</i></a> of every <a href="#flexible-length0"><i>flexible
1026-
length</i></a> on the line. This is the <dfn
1027-
id=total-positive-flexibility>total positive flexibility</dfn>.</p>
1028-
1029-
<p>For each <a href="#flexible-length0"><i>flexible length</i></a>,
1030-
increment its <a href="#preferred-size"><i>preferred size</i></a> by
1031-
<code><a href="#free-space"><i>free space</i></a> * &lt;pos-flex> /
1032-
<a href="#total-positive-flexibility"><i>total positive
1033-
flexibility</i></a></code>.</p>
1034-
1035-
<dt>If the <a href="#free-space"><i>free space</i></a> is negative:
1036-
1037-
<dd>
1038-
<p>Sum the <a href="#negative-flexibility"><i>negative
1039-
flexibility</i></a> of every <a href="#flexible-length0"><i>flexible
1040-
length</i></a> on the line. This is the <dfn
1041-
id=total-negative-flexibility>total negative flexibility</dfn>.</p>
1042-
1043-
<p>For each <a href="#flexible-length0"><i>flexible length</i></a>,
1044-
increment its <a href="#preferred-size"><i>preferred size</i></a> by
1045-
<code><a href="#free-space"><i>free space</i></a> * &lt;neg-flex> /
1046-
<a href="#total-negative-flexibility"><i>total negative
1047-
flexibility</i></a></code>. <span class=note>Note: since the free
1048-
space is negative, incrementing the preferred size by this number
1049-
makes the preferred size smaller.</span></p>
1050-
</dl>
1051-
1052-
<li>
1053-
<p>Verify that min/max constraints aren't violated: for each <a
1054-
href="#flexbox-item"><i>flexbox item</i></a> on the line with
1055-
&lsquo;<code class=property>width</code>&rsquo;/&lsquo;<code
1056-
class=property>height</code>&rsquo; specified as a <a
1057-
href="#flexible-length0"><i>flexible length</i></a>, if instead
1058-
specifying the &lsquo;<code
1059-
class=property>width</code>&rsquo;/&lsquo;<code
1060-
class=property>height</code>&rsquo; as the <a
1061-
href="#preferred-size"><i>preferred size</i></a> would cause the item
1062-
to be in violation of its &lsquo;<code
1063-
class=css>min/max-width/height</code>&rsquo; properties, resolve the
1064-
<a href="#flexible-length0"><i>flexible length</i></a> to the
1065-
smallest/largest length that would make it no longer in violation of
1066-
those properties, as defined by <a
1067-
href="http://www.w3.org/TR/CSS2/visudet.html#propdef-min-width">the
1068-
algorithm in CSS2.1</a>.</p>
1069-
1070-
<p>If any <a href="#flexbox-item"><i>flexbox item</i></a> was found to
1071-
be in violation by this step and resolved into an inflexible length,
1072-
reset the <a href="#preferred-size"><i>preferred size</i></a> of any
1073-
remaining <a href="#flexible-length0"><i>flexible lengths</i></a> to
1074-
their original values and restart this sub-algorithm.</p>
1075-
1076-
<li>Any remaining <a href="#flexible-length0"><i>flexible
1077-
lengths</i></a> resolve to their <a href="#preferred-size"><i>preferred
1078-
size</i></a>.
1079-
</ol>
1019+
<li>
1020+
<p>Verify that min/max constraints aren't violated: for each <a
1021+
href="#flexbox-item"><i>flexbox item</i></a> on the line with
1022+
&lsquo;<code class=property>width</code>&rsquo;/&lsquo;<code
1023+
class=property>height</code>&rsquo; specified as a <a
1024+
href="#flexible-length0"><i>flexible length</i></a>, if instead
1025+
specifying the &lsquo;<code
1026+
class=property>width</code>&rsquo;/&lsquo;<code
1027+
class=property>height</code>&rsquo; as the <a
1028+
href="#preferred-size"><i>preferred size</i></a> would cause the item to
1029+
be in violation of its &lsquo;<code
1030+
class=css>min/max-width/height</code>&rsquo; properties, resolve the <a
1031+
href="#flexible-length0"><i>flexible length</i></a> to the
1032+
smallest/largest length that would make it no longer in violation of
1033+
those properties, as defined by <a
1034+
href="http://www.w3.org/TR/CSS2/visudet.html#propdef-min-width">the
1035+
algorithm in CSS2.1</a>.</p>
1036+
1037+
<p>If any <a href="#flexbox-item"><i>flexbox item</i></a> was found to be
1038+
in violation by this step and resolved into an inflexible length, reset
1039+
the <a href="#preferred-size"><i>preferred size</i></a> of any remaining
1040+
<a href="#flexible-length0"><i>flexible lengths</i></a> to their
1041+
original values and restart this sub-algorithm.</p>
1042+
1043+
<li>Any remaining <a href="#flexible-length0"><i>flexible lengths</i></a>
1044+
resolve to their <a href="#preferred-size"><i>preferred size</i></a>.
10801045
</ol>
10811046

10821047
<p>Once all <a href="#flexible-length0"><i>flexible lengths</i></a> have
@@ -2067,73 +2032,12 @@ <h2 id=pagination><span class=secno>8. </span> Page breaks in flexbox</h2>
20672032
<p class=issue>TODO: add more detail: how breaking affect sizing (for
20682033
broken boxes and boxes after the break) and alignment
20692034

2070-
<h2 id=layout-interface><span class=secno>9. </span> Interface With Other
2071-
Layout Algorithms</h2>
2072-
2073-
<div class=issue>
2074-
<p>This section seems necessary, but not the precise way it's written. I
2075-
need to identify precisely what data needs to be exposed both by the
2076-
containing measure model (for the flexbox to use) and by the flexbox (for
2077-
the containing measure model to use), and then write that up. Then the
2078-
other measure models we produce can re-use the same template.</p>
2079-
2080-
<p>Need to define:</p>
2081-
2082-
<ul>
2083-
<li>The min/max/fit-content widths and heights of flexboxes in block
2084-
contents
2035+
<h2 id=layout-interface><span class=secno>9. </span> Box Properties and
2036+
Sizing</h2>
20852037

2086-
<li>Related to the above, &lsquo;<code class=css>auto</code>&rsquo;
2087-
width/height of flexbox is shrink-to-fit.
2088-
2089-
<li>Other stuff?
2090-
</ul>
2091-
</div>
2092-
<!--
2093-
<p>
2094-
A box placed in a block is considered a block level element and will be positioned
2095-
and sized according to the rules for CSS 2.1 (section 10.3 for widths). Specifically,
2096-
the following equation applies for calculating the width:
2097-
</p>
2098-
<blockquote>
2099-
<p>'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' + scrollbar width (if any) = width of containing block
2100-
</p>
2101-
</blockquote>
2102-
<p>All children of 'box' elements are block-level. If inline-level elements are nested
2103-
inside boxes, they get wrapped in an anonymous block which then takes part in the
2104-
box layout.
2105-
2106-
</p><p>
2107-
If the width of a child of a flexible box is computed as 'auto', then the used value
2108-
is the shrink-to-fit width. This calculation is done similarly to how the width of
2109-
a floating element is determined. Otherwise if the width has a computed value,
2110-
then that value is used as the width.
2111-
</p><p>
2112-
2113-
In a horizontally oriented box, the flexibility is then applied which may increase
2114-
or decrease the used width. In a vertically oriented box, the position and size
2115-
of the child may be adjusted by the value of the container's
2116-
<span class="property">'flex-align'</span> property.
2117-
</p><p>
2118-
2119-
The <span class="property">'min-width'</span>, <span class="property">'min-height'</span>,
2120-
<span class="property">'max-width'</span>, and <span class="property">'max-height'</span>
2121-
CSS properties act the same on boxes as on blocks.
2122-
</p><p>
2123-
2124-
The height of a child of a flexible box is determined in the same manner as specified
2125-
in the CSS specification. The used height may further be adjusted by the container's
2126-
<span class="property">'flex-align'</span> property in a horizontally
2127-
oriented box, or the flexibility in a vertically oriented box.
2128-
</p><p>
2129-
2130-
Note that it is possible for a horizontally oriented box that the height of a
2131-
flexible child containing an inline descendant will change when the flexibility is
2132-
applied. Similarly, in a vertically oriented box, the height of a child may change
2133-
based on the <span class="property">'flex-align'</span> property of the
2134-
box.
2135-
</p>
2136-
-->
2038+
<p class=issue>Define how flexboxes are sized, paying attention to
2039+
width/height keywords on both the flexbox and flexbox items, the writing
2040+
modes of both the flexbox and flexbox items, and the flexbox direction.
21372041

21382042
<hr title="Separator from footer">
21392043

@@ -2406,9 +2310,6 @@ <h2 class=no-num id=index>Index</h2>
24062310
<li>available free space, <a href="#available-free-space" title="available
24072311
free space"><strong>7.</strong></a>
24082312

2409-
<li>available space, <a href="#available-space" title="available
2410-
space"><strong>4.2.</strong></a>
2411-
24122313
<li>baseline, <a href="#flex-align-baseline"
24132314
title=baseline><strong>5.2.</strong></a>
24142315

@@ -2538,12 +2439,6 @@ <h2 class=no-num id=index>Index</h2>
25382439
<li>preferred size, <a href="#preferred-size" title="preferred
25392440
size"><strong>4.1.</strong></a>
25402441

2541-
<li>pre-flex size, <a href="#pre-flex-size" title="pre-flex
2542-
size"><strong>4.2.</strong></a>
2543-
2544-
<li>pre-flex sizes, <a href="#pre-flex-size" title="pre-flex
2545-
sizes"><strong>4.2.</strong></a>
2546-
25472442
<li>relevant length, <a href="#relevant-length" title="relevant
25482443
length"><strong>7.</strong></a>
25492444

0 commit comments

Comments
 (0)