Skip to content

Commit 1099119

Browse files
committed
More flexbox algo work - up to linebreaking now.
1 parent a895646 commit 1099119

1 file changed

Lines changed: 31 additions & 72 deletions

File tree

css3-flexbox/Overview.src.html

Lines changed: 31 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ <h2 id='flexibility'>
627627
<td>no
628628
<tr>
629629
<th>Computed Value:
630-
<td>Two integers for positive and negative flex, and either an absolute length (if &lt;preferred-size> is given as a &lt;length>) or the specified value for &lt;preferred-size>.
630+
<td>Two integers for positive and negative flex, and a preferred size given either as an absolute length or a keyword.
631631
<tr>
632632
<th>Media:
633633
<td>visual
@@ -1055,6 +1055,10 @@ <h2 id='layout-algorithm'>
10551055
* min-extent is always the extent after layout
10561056
-->
10571057

1058+
<p>
1059+
A size is <dfn title="definite|indefinite">definite</dfn> if it is a <var>&lt;length></var>,
1060+
or it is a <var>&lt;percentage></var> that is resolved against a definite size.
1061+
10581062
<p>
10591063
To lay out a flexbox and its contents, follow these steps:
10601064

@@ -1072,45 +1076,32 @@ <h2 id='layout-algorithm'>
10721076
and how the rest of this algorithm deals with the items.
10731077

10741078
<li>
1075-
Determine the main size of the flexbox.
1079+
Determine the main size of the flexbox, based on its <i>main size property</i>.
10761080
In this calculation, the <i>min content main size</i> of the flexbox
1077-
is the maximum of the flexbox items' outer <i>min content main sizes</i>,
1081+
is the maximum of the flexbox's items' <i>min-content size contributions</i>,
10781082
and the <i>max content main size</i> of the flexbox
1079-
is the maximum of the flexbox items' outer <i>max content main sizes</i>.
1080-
For these computations, ''auto'' margins are treated as ''0''.
1083+
is the sum of the flexbox's items' <i>max-content size contributions</i>.
1084+
For these computations, ''auto'' margins are treated as ''0'',
1085+
and for flexbox items the preferred size is used in place of the <i>main size property</i>.
10811086

10821087
<li>
1083-
Determine the hypothetical main size of items:
1088+
Determine the hypothetical main size of each item.
10841089

10851090
<ul>
10861091
<li>
1087-
If item has a <i>definite</i> preferred size,
1088-
it is the hypothetical main size.
1089-
A size is <dfn title="definite|indefinite">definite</dfn> if it is a <var>&lt;length></var>,
1090-
or it is a <var>&lt;percentage></var> that is resolved against a definite size.
1092+
If the flexbox's main axis is parallel to the item's inline axis,
1093+
the hypothetical size is the item's preferred size,
1094+
treating ''auto'' as ''fit-content''.
10911095

10921096
<li>
1093-
Otherwise:
1094-
1095-
<ul>
1096-
<li>
1097-
If the flexbox's main axis is parallel to the item's inline axis,
1098-
the hypothetical size is the item's <i>fit-content measure</i>.
1097+
Otherwise,
1098+
if the item has a <i>definite</i> preferred size,
1099+
that's the hypothetical size.
10991100

1100-
<li>
1101-
Otherwise,
1102-
the item is laid out at its <i>fit-content measure</i>
1103-
and the hypothetical size is the item's extent.
1104-
</ul>
1105-
1106-
<p class='note'>
1107-
Note that the <i>available measure</i> of a flexbox
1108-
(used when calculating the <i>fit-content measure</i>)
1109-
is the size of the entire flexbox.
1110-
It does not take into account other flexbox items
1111-
or flexbox lines.
1112-
In other words, each item's hypothetical size is calculated independently,
1113-
as if it were the only item in the flexbox.
1101+
<li>
1102+
Otherwise,
1103+
the item is laid out
1104+
and the hypothetical size is the item's max-content extent.
11141105
</ul>
11151106

11161107
<p>
@@ -1126,48 +1117,16 @@ <h2 id='layout-algorithm'>
11261117
collect all the flexbox items into a single flexbox line.
11271118

11281119
<li>
1129-
Otherwise, determine the <dfn>maximum line length</dfn>, based on the flexbox's main size:
1130-
1131-
<ul>
1132-
<li>
1133-
For a <i>definite</i> main size,
1134-
use that size.
1135-
1136-
<li>
1137-
For a ''min-content'' size,
1138-
use the largest of the flexbox's item's <i>minimum size</i>.
1139-
1140-
<li>
1141-
For a ''max-content'' size,
1142-
use infinity.
1143-
1144-
<li>
1145-
For a ''fit-content'' size,
1146-
use the <i>fill-available measure</i> of the flexbox.
1147-
</ul>
1148-
1149-
<p>
1150-
In all cases, clamp the <i>maximum line length</i> according to the flexbox's <i>min main size property</i> and <i>max main size property</i>.
1151-
1152-
1153-
1154-
<li>Collect as many consecutive flexbox items as possible, starting from the first item, while keeping the sum of their
1155-
margin-box main size smaller than the flexbox's available space.
1156-
If a flexbox item is sized with a flexible length, then for the
1157-
purpose of this step, clamp its size between its minimum and maximum main sizes. The items so collected form a single flexbox line.</li>
1158-
1159-
<li>Repeat the previous step, starting each time from the first flexbox item not yet collected into a flexbox line, until all flexbox items have been collected into flexbox lines.</li>
1160-
1161-
<p>
1162-
A flexbox item's <dfn>minimum size</dfn> is:
1163-
1164-
<ul>
1165-
<li>
1166-
If the <i>preferred size</i> is <i>definite</i>, use that.
1167-
1168-
<li>
1169-
</ol>
1170-
</li>
1120+
Otherwise,
1121+
starting from the first uncollected item,
1122+
collect as many consecutive flexbox items as will fit
1123+
(but collect at least one)
1124+
into the flexbox's inner main size into a flexbox line.
1125+
For this step,
1126+
the size of a flexbox item is its hypothetical outer main size,
1127+
clamped by its min and max main size properties.
1128+
Repeat until all flexbox items have been collected into flexbox lines.
1129+
</ul>
11711130

11721131
<li>Find the actual main size of the flexbox. If the flexbox's main size doesn't rely on its contents, its actual main size is calculated per the appropriate rules. Otherwise, its main size is the length of its longest line, calculated by summing the main sizes of the margin boxes of each flexbox item in the line, constrained by the flexbox's min and max main size constraints.
11731132
If any margins are set to ''auto'', consider them to be set to zero until

0 commit comments

Comments
 (0)