Bug 1090031: Apply CSS 'align-content' in flex containers if they *could* wrap (rather than if they *have* wrapped). r=mats

The spec says that single-line flex containers should stretch their one flex
line to the flex container's cross size, and should ignore 'align-content'.

Initially, the spec defined 'single-line' to include any flex container that
happens to have only 1 line (even if it's got 'flex-wrap:wrap' or
'wrap-reverse'). But later, the term 'single-line' was intentionally redefined
to *only* include flex containers that have 'flex-wrap: nowrap'.  So, instead
of checking the line-count, we should instead check 'flex-wrap', when deciding
whether to stretch our one line & ignore 'align-content'.


MozReview-Commit-ID: D2ZMIBS16ui

--HG--
extra : rebase_source : 835a64e0f9cdaa375f8e57f55ffe5b011525cbeb
This commit is contained in:
Daniel Holbert 2016-10-12 09:04:03 -07:00
Родитель 54d1778d66
Коммит 5ea7b37dd6
3 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -2781,11 +2781,15 @@ CrossAxisPositionTracker::
// XXX strip of the <overflow-position> bit until we implement that
mAlignContent &= ~NS_STYLE_ALIGN_FLAG_BITS;
if (!aFirstLine->getNext()) {
const bool isSingleLine =
NS_STYLE_FLEX_WRAP_NOWRAP == aReflowInput.mStylePosition->mFlexWrap;
if (isSingleLine) {
MOZ_ASSERT(!aFirstLine->getNext(),
"If we're styled as single-line, we should only have 1 line");
// "If the flex container is single-line and has a definite cross size, the
// cross size of the flex line is the flex container's inner cross size."
//
// SOURCE: http://dev.w3.org/csswg/css-flexbox/#algo-line-break
// SOURCE: https://drafts.csswg.org/css-flexbox/#algo-cross-line
// NOTE: This means (by definition) that there's no packing space, which
// means we don't need to be concerned with "align-conent" at all and we
// can return early. This is handy, because this is the usual case (for

Просмотреть файл

@ -71,7 +71,7 @@
<!-- flex-end -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-top: 190px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-top: 160px"/>
@ -85,7 +85,7 @@
<!-- center -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-top: 95px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-top: 80px"/>
@ -113,7 +113,7 @@
<!-- space-around -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-top: 95px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-top: 40px"/>

Просмотреть файл

@ -74,7 +74,7 @@
<!-- flex-end -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-left: 190px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-left: 160px"/>
@ -88,7 +88,7 @@
<!-- center -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-left: 95px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-left: 80px"/>
@ -116,7 +116,7 @@
<!-- space-around -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-left: 95px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-left: 40px"/>
@ -144,7 +144,7 @@
<!-- right -->
<div class="flexbox">
<div class="a"/>
<div class="a" style="margin-left: 190px"/>
</div>
<div class="flexbox">
<div class="a" style="margin-left: 160px"/>