<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201516] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201516">201516</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2016-05-31 11:42:17 -0700 (Tue, 31 May 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/189567">r189567</a>): Elements with aspect ratios not handled correctly inside flexbox.
https://bugs.webkit.org/show_bug.cgi?id=158040
Reviewed by Zalan Bujtas.
Source/WebCore:
Added new tests in fast/flexbox.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::clientLogicalBottomAfterRepositioning):
(WebCore::RenderFlexibleBox::hasOrthogonalFlow):
(WebCore::RenderFlexibleBox::mainAxisContentExtent):
(WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):
(WebCore::RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild):
(WebCore::RenderFlexibleBox::mainAxisLengthIsDefinite):
(WebCore::RenderFlexibleBox::mainAxisScrollbarExtentForChild):
(WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins):
(WebCore::RenderFlexibleBox::crossAxisLengthIsDefinite):
(WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing):
(WebCore::RenderFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax):
(WebCore::RenderFlexibleBox::useChildAspectRatio):
(WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax):
(WebCore::RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis):
(WebCore::RenderFlexibleBox::mainAxisOverflowForChild):
(WebCore::RenderFlexibleBox::mainAxisExtentIsDefinite): Deleted.
(WebCore::RenderFlexibleBox::mainAxisLengthIsIndefinite): Deleted.
* rendering/RenderFlexibleBox.h:
(WebCore::RenderFlexibleBox::isFlexibleBoxImpl):
LayoutTests:
* fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html: Added.
* fast/flexbox/aspect-ratio-intrinsic-adjust.html: Added.
* fast/flexbox/resources/subjects_sm.png: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFlexibleBoxcpp">trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderFlexibleBoxh">trunk/Source/WebCore/rendering/RenderFlexibleBox.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastflexboxaspectratiointrinsicadjustexpectedhtml">trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastflexboxaspectratiointrinsicadjusthtml">trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust.html</a></li>
<li><a href="#trunkLayoutTestsfastflexboxresourcessubjects_smpng">trunk/LayoutTests/fast/flexbox/resources/subjects_sm.png</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201515 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-31 17:53:20 UTC (rev 201515)
+++ trunk/LayoutTests/ChangeLog        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-05-31 Dave Hyatt <hyatt@apple.com>
+
+ REGRESSION (r189567): Elements with aspect ratios not handled correctly inside flexbox.
+ https://bugs.webkit.org/show_bug.cgi?id=158040
+
+ Reviewed by Zalan Bujtas.
+
+ * fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html: Added.
+ * fast/flexbox/aspect-ratio-intrinsic-adjust.html: Added.
+ * fast/flexbox/resources/subjects_sm.png: Added.
+
</ins><span class="cx"> 2016-05-25 Sergio Villar Senin <svillar@igalia.com>
</span><span class="cx">
</span><span class="cx"> [css-grid] Empty grid without explicit tracks shouldn't have any size
</span></span></pre></div>
<a id="trunkLayoutTestsfastflexboxaspectratiointrinsicadjustexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html (0 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust-expected.html        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<!doctype html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8" />
+ <title>img.weird-stretch</title>
+ <style>
+ body {
+         width: 400px;
+         margin: 0 auto;
+ }
+ .weird-stretch-container {
+ float: right;
+ width: 400px;
+ height: 250px;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-align: center;
+ -webkit-align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
+ -webkit-box-pack: center;
+ -webkit-justify-content: center;
+ -ms-flex-pack: center;
+ justify-content: center
+ }
+
+ </style>
+</head>
+
+<body>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" width="100px" />
+ </div>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" width="63px" />
+ </div>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" width="132px" height="210px" />
+ </div>
+</body>
+
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastflexboxaspectratiointrinsicadjusthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust.html (0 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust.html         (rev 0)
+++ trunk/LayoutTests/fast/flexbox/aspect-ratio-intrinsic-adjust.html        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+<!doctype html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8" />
+ <title>img.weird-stretch</title>
+ <style>
+ body {
+         width: 400px;
+         margin: 0 auto;
+ }
+ .weird-stretch-container {
+ float: right;
+ width: 400px;
+ height: 250px;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-align: center;
+ -webkit-align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
+ -webkit-box-pack: center;
+ -webkit-justify-content: center;
+ -ms-flex-pack: center;
+ justify-content: center
+ }
+
+ img.weird-stretch {
+ max-width: 100%;
+ max-height: 100%
+ }
+ </style>
+</head>
+
+<body>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" width="100px" />
+ </div>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" height="100px" />
+ </div>
+
+ <div class="weird-stretch-container">
+ <img class="weird-stretch" alt="" src="resources/subjects_sm.png" width="132px" height="210px" />
+ </div>
+</body>
+
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastflexboxresourcessubjects_smpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/flexbox/resources/subjects_sm.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/flexbox/resources/subjects_sm.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201515 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-31 17:53:20 UTC (rev 201515)
+++ trunk/Source/WebCore/ChangeLog        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-05-31 Dave Hyatt <hyatt@apple.com>
+
+ REGRESSION (r189567): Elements with aspect ratios not handled correctly inside flexbox.
+ https://bugs.webkit.org/show_bug.cgi?id=158040
+
+ Reviewed by Zalan Bujtas.
+
+ Added new tests in fast/flexbox.
+
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::clientLogicalBottomAfterRepositioning):
+ (WebCore::RenderFlexibleBox::hasOrthogonalFlow):
+ (WebCore::RenderFlexibleBox::mainAxisContentExtent):
+ (WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):
+ (WebCore::RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild):
+ (WebCore::RenderFlexibleBox::mainAxisLengthIsDefinite):
+ (WebCore::RenderFlexibleBox::mainAxisScrollbarExtentForChild):
+ (WebCore::RenderFlexibleBox::prepareOrderIteratorAndMargins):
+ (WebCore::RenderFlexibleBox::crossAxisLengthIsDefinite):
+ (WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing):
+ (WebCore::RenderFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax):
+ (WebCore::RenderFlexibleBox::useChildAspectRatio):
+ (WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax):
+ (WebCore::RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis):
+ (WebCore::RenderFlexibleBox::mainAxisOverflowForChild):
+ (WebCore::RenderFlexibleBox::mainAxisExtentIsDefinite): Deleted.
+ (WebCore::RenderFlexibleBox::mainAxisLengthIsIndefinite): Deleted.
+ * rendering/RenderFlexibleBox.h:
+ (WebCore::RenderFlexibleBox::isFlexibleBoxImpl):
+
</ins><span class="cx"> 2016-05-31 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Build fix after r201482.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFlexibleBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (201515 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2016-05-31 17:53:20 UTC (rev 201515)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -367,7 +367,7 @@
</span><span class="cx"> return std::max(clientLogicalBottom(), maxChildLogicalBottom);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox& child) const
</del><ins>+bool RenderFlexibleBox::hasOrthogonalFlow(const RenderBox& child) const
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow.
</span><span class="cx"> return isHorizontalFlow() != child.isHorizontalWritingMode();
</span><span class="lines">@@ -454,14 +454,14 @@
</span><span class="cx"> return contentLogicalWidth();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox& child, SizeType sizeType, const Length& size)
</del><ins>+Optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(const RenderBox& child, SizeType sizeType, const Length& size)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: This is wrong for orthogonal flows. It should use the flexbox's writing-mode, not the child's in order
</span><span class="cx"> // to figure out the logical height/width.
</span><span class="cx"> if (isColumnFlow()) {
</span><span class="cx"> // We don't have to check for "auto" here - computeContentLogicalHeight will just return Nullopt for that case anyway.
</span><span class="cx"> if (size.isIntrinsic())
</span><del>- child.layoutIfNeeded();
</del><ins>+ const_cast<RenderBox&>(child).layoutIfNeeded(); // FIXME: Should not need to do a layout here.
</ins><span class="cx"> return child.computeContentLogicalHeight(sizeType, size, child.logicalHeight() - child.borderAndPaddingLogicalHeight());
</span><span class="cx"> }
</span><span class="cx"> // FIXME: Figure out how this should work for regions and pass in the appropriate values.
</span><span class="lines">@@ -652,17 +652,16 @@
</span><span class="cx"> {
</span><span class="cx"> return isHorizontalFlow() ? child.horizontalBorderAndPaddingExtent() : child.verticalBorderAndPaddingExtent();
</span><span class="cx"> }
</span><del>-
-bool RenderFlexibleBox::mainAxisExtentIsDefinite() const
</del><ins>+
+bool RenderFlexibleBox::mainAxisLengthIsDefinite(const RenderBox& child, const Length& flexBasis) const
</ins><span class="cx"> {
</span><del>- return isColumnFlow() ? hasDefiniteLogicalHeight() : hasDefiniteLogicalWidth();
</del><ins>+ if (flexBasis.isAuto())
+ return false;
+ if (flexBasis.isPercentOrCalculated())
+ return isColumnFlow() ? bool(child.computePercentageLogicalHeight(flexBasis)) : hasDefiniteLogicalWidth();
+ return true;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-bool RenderFlexibleBox::mainAxisLengthIsIndefinite(const Length& flexBasis) const
-{
- return flexBasis.isAuto() || (flexBasis.isPercentOrCalculated() && !mainAxisExtentIsDefinite());
-}
-
</del><span class="cx"> LayoutUnit RenderFlexibleBox::mainAxisScrollbarExtentForChild(RenderBox& child) const
</span><span class="cx"> {
</span><span class="cx"> return isHorizontalFlow() ? child.verticalScrollbarWidth() : child.horizontalScrollbarHeight();
</span><span class="lines">@@ -859,19 +858,84 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize)
</del><ins>+bool RenderFlexibleBox::crossAxisLengthIsDefinite(const RenderBox& child, const Length& length) const
</ins><span class="cx"> {
</span><ins>+ if (length.isAuto())
+ return false;
+ if (length.isPercentOrCalculated())
+ return hasOrthogonalFlow(child) ? hasDefiniteLogicalWidth() : bool(child.computePercentageLogicalHeight(length));
+ return length.isFixed();
+}
+
+
+Optional<LayoutUnit> RenderFlexibleBox::computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const
+{
+ ASSERT(child.hasAspectRatio());
+ ASSERT(child.intrinsicSize().height() > 0);
+
+ Optional<LayoutUnit> crossSize;
+ if (crossSizeLength.isFixed())
+ crossSize = LayoutUnit(crossSizeLength.value());
+ else {
+ ASSERT(crossSizeLength.isPercentOrCalculated());
+ crossSize = hasOrthogonalFlow(child) ?
+ adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(crossSizeLength, contentWidth())) :
+ child.computePercentageLogicalHeight(crossSizeLength);
+ }
+
+ if (!crossSize)
+ return crossSize;
+
+ const LayoutSize& childIntrinsicSize = child.intrinsicSize();
+ double ratio = childIntrinsicSize.width().toFloat() / childIntrinsicSize.height().toFloat();
+ if (isHorizontalFlow())
+ return LayoutUnit(crossSize.value() * ratio);
+ return LayoutUnit(crossSize.value() / ratio);
+}
+
+LayoutUnit RenderFlexibleBox::adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox& child, LayoutUnit childSize)
+{
+ Length crossMin = isHorizontalFlow() ? child.style().minHeight() : child.style().minWidth();
+ Length crossMax = isHorizontalFlow() ? child.style().maxHeight() : child.style().maxWidth();
+
+ if (crossAxisLengthIsDefinite(child, crossMax)) {
+ Optional<LayoutUnit> maxValue = computeMainSizeFromAspectRatioUsing(child, crossMax);
+ if (maxValue)
+ childSize = std::min(maxValue.value(), childSize);
+ }
+
+ if (crossAxisLengthIsDefinite(child, crossMin)) {
+ Optional<LayoutUnit> minValue = computeMainSizeFromAspectRatioUsing(child, crossMin);
+ if (minValue)
+ childSize = std::max(minValue.value(), childSize);
+ }
+
+ return childSize;
+}
+
+bool RenderFlexibleBox::useChildAspectRatio(const RenderBox& child) const
+{
+ if (!child.hasAspectRatio())
+ return false;
+ if (!child.intrinsicSize().height())
+ return false;
+ Length crossSize = isHorizontalFlow() ? child.style().height() : child.style().width();
+ return crossAxisLengthIsDefinite(child, crossSize);
+}
+
+LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(const RenderBox& child, LayoutUnit childSize)
+{
</ins><span class="cx"> Length max = isHorizontalFlow() ? child.style().maxWidth() : child.style().maxHeight();
</span><span class="cx"> Optional<LayoutUnit> maxExtent = Nullopt;
</span><span class="cx"> if (max.isSpecifiedOrIntrinsic()) {
</span><span class="cx"> maxExtent = computeMainAxisExtentForChild(child, MaxSize, max);
</span><span class="cx"> childSize = std::min(childSize, maxExtent.valueOr(childSize));
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> Length min = isHorizontalFlow() ? child.style().minWidth() : child.style().minHeight();
</span><span class="cx"> if (min.isSpecifiedOrIntrinsic())
</span><span class="cx"> return std::max(childSize, computeMainAxisExtentForChild(child, MinSize, min).valueOr(childSize));
</span><del>-
</del><ins>+
</ins><span class="cx"> if (!isFlexibleBoxImpl() && min.isAuto() && mainAxisOverflowForChild(child) == OVISIBLE && !(isColumnFlow() && is<RenderFlexibleBox>(child))) {
</span><span class="cx"> // This is the implementation of CSS flexbox section 4.5 which defines the minimum size of "pure" flex
</span><span class="cx"> // items. For any other item the value should be 0, this also includes RenderFlexibleBox's derived clases
</span><span class="lines">@@ -880,15 +944,23 @@
</span><span class="cx"> // size handling from the flex box spec first (4.5).
</span><span class="cx"> LayoutUnit contentSize = computeMainAxisExtentForChild(child, MinSize, Length(MinContent)).value();
</span><span class="cx"> ASSERT(contentSize >= 0);
</span><ins>+ if (child.hasAspectRatio() && child.intrinsicSize().height() > 0)
+ contentSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, contentSize);
</ins><span class="cx"> contentSize = std::min(contentSize, maxExtent.valueOr(contentSize));
</span><del>-
</del><ins>+
</ins><span class="cx"> Length mainSize = isHorizontalFlow() ? child.style().width() : child.style().height();
</span><del>- if (!mainAxisLengthIsIndefinite(mainSize)) {
</del><ins>+ if (mainAxisLengthIsDefinite(child, mainSize)) {
</ins><span class="cx"> LayoutUnit resolvedMainSize = computeMainAxisExtentForChild(child, MainOrPreferredSize, mainSize).value();
</span><span class="cx"> ASSERT(resolvedMainSize >= 0);
</span><span class="cx"> LayoutUnit specifiedSize = std::min(resolvedMainSize, maxExtent.valueOr(resolvedMainSize));
</span><del>-
</del><span class="cx"> return std::max(childSize, std::min(specifiedSize, contentSize));
</span><ins>+ } else if (useChildAspectRatio(child)) {
+ Length crossSizeLength = isHorizontalFlow() ? child.style().height() : child.style().width();
+ Optional<LayoutUnit> transferredSize = computeMainSizeFromAspectRatioUsing(child, crossSizeLength);
+ if (transferredSize) {
+ transferredSize = adjustChildSizeForAspectRatioCrossAxisMinAndMax(child, transferredSize.value());
+ return std::max(childSize, std::min(transferredSize.value(), contentSize));
+ }
</ins><span class="cx"> }
</span><span class="cx"> return std::max(childSize, contentSize);
</span><span class="cx"> }
</span><span class="lines">@@ -1091,7 +1163,7 @@
</span><span class="cx"> child.updateLogicalHeight();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-EOverflow RenderFlexibleBox::mainAxisOverflowForChild(RenderBox& child) const
</del><ins>+EOverflow RenderFlexibleBox::mainAxisOverflowForChild(const RenderBox& child) const
</ins><span class="cx"> {
</span><span class="cx"> if (isHorizontalFlow())
</span><span class="cx"> return child.style().overflowX();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderFlexibleBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (201515 => 201516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h        2016-05-31 17:53:20 UTC (rev 201515)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h        2016-05-31 18:42:17 UTC (rev 201516)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx"> typedef Vector<LayoutRect, 8> ChildFrameRects;
</span><span class="cx">
</span><span class="cx"> bool isFlexibleBox() const final { return true; }
</span><del>- bool hasOrthogonalFlow(RenderBox& child) const;
</del><ins>+ bool hasOrthogonalFlow(const RenderBox& child) const;
</ins><span class="cx"> bool isColumnFlow() const;
</span><span class="cx"> bool isLeftToRightFlow() const;
</span><span class="cx"> bool isMultiline() const;
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> LayoutUnit mainAxisExtent() const;
</span><span class="cx"> LayoutUnit crossAxisContentExtent() const;
</span><span class="cx"> LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight);
</span><del>- Optional<LayoutUnit> computeMainAxisExtentForChild(RenderBox& child, SizeType, const Length& size);
</del><ins>+ Optional<LayoutUnit> computeMainAxisExtentForChild(const RenderBox& child, SizeType, const Length& size);
</ins><span class="cx"> WritingMode transformedWritingMode() const;
</span><span class="cx"> LayoutUnit flowAwareBorderStart() const;
</span><span class="cx"> LayoutUnit flowAwareBorderEnd() const;
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> LayoutUnit mainAxisBorderAndPaddingExtentForChild(RenderBox& child) const;
</span><span class="cx"> LayoutUnit mainAxisScrollbarExtentForChild(RenderBox& child) const;
</span><span class="cx"> LayoutUnit preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength);
</span><del>- EOverflow mainAxisOverflowForChild(RenderBox&) const;
</del><ins>+ EOverflow mainAxisOverflowForChild(const RenderBox&) const;
</ins><span class="cx">
</span><span class="cx"> void layoutFlexItems(bool relayoutChildren, Vector<LineContext>&);
</span><span class="cx"> LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace);
</span><span class="lines">@@ -139,7 +139,8 @@
</span><span class="cx">
</span><span class="cx"> LayoutUnit computeChildMarginValue(const Length& margin);
</span><span class="cx"> void prepareOrderIteratorAndMargins();
</span><del>- LayoutUnit adjustChildSizeForMinAndMax(RenderBox&, LayoutUnit childSize);
</del><ins>+ LayoutUnit adjustChildSizeForMinAndMax(const RenderBox&, LayoutUnit childSize);
+ LayoutUnit adjustChildSizeForAspectRatioCrossAxisMinAndMax(const RenderBox&, LayoutUnit childSize);
</ins><span class="cx"> bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent, bool& hasInfiniteLineLength);
</span><span class="cx">
</span><span class="cx"> bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&, Vector<LayoutUnit>& childSizes, bool hasInfiniteLineLength);
</span><span class="lines">@@ -158,9 +159,11 @@
</span><span class="cx"> void flipForRightToLeftColumn();
</span><span class="cx"> void flipForWrapReverse(const Vector<LineContext>&, LayoutUnit crossAxisStartEdge);
</span><span class="cx">
</span><del>- bool mainAxisExtentIsDefinite() const;
- bool mainAxisLengthIsIndefinite(const Length& flexBasis) const;
-
</del><ins>+ bool mainAxisLengthIsDefinite(const RenderBox&, const Length&) const;
+ bool crossAxisLengthIsDefinite(const RenderBox&, const Length&) const;
+ bool useChildAspectRatio(const RenderBox&) const;
+ Optional<LayoutUnit> computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const;
+
</ins><span class="cx"> virtual bool isFlexibleBoxImpl() const { return false; };
</span><span class="cx">
</span><span class="cx"> mutable OrderIterator m_orderIterator;
</span></span></pre>
</div>
</div>
</body>
</html>