Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Unified Diff: Source/core/rendering/RenderFlexibleBox.cpp

Issue 343103003: Flexbox: Allow intrinsic aspect ratios to inform main-size calculation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP Patch 2 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderFlexibleBox.cpp
diff --git a/Source/core/rendering/RenderFlexibleBox.cpp b/Source/core/rendering/RenderFlexibleBox.cpp
index 8e0730e60799e36f1102860555d8a7070e7d0047..1dc0f995cdaae30667c665a7c9b6b45759be99fc 100644
--- a/Source/core/rendering/RenderFlexibleBox.cpp
+++ b/Source/core/rendering/RenderFlexibleBox.cpp
@@ -608,11 +608,49 @@ bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render
return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasInfiniteLineLength) && hasOrthogonalFlow(child);
}
+bool RenderFlexibleBox::childHasFiniteCrossSize(RenderBox* child) const
+{
+ if (child->style()->logicalHeight().isFixed())
+ return true;
+
+ if (!style()->logicalHeight().isFixed())
+ return false;
+
+ if (child->style()->logicalHeight().isPercent())
+ return true;
+
+ if (!isMultiline() && needToStretchChildLogicalHeight(child))
+ return true;
+
+ return false;
+}
+
+void RenderFlexibleBox::computeAspectRatioOfChild(RenderBox* child, double& aspectRatio, bool& hasAspectRatio)
tony 2014/06/26 16:31:28 The bool seems unnecessary. Set the initial value
harpreet.sk 2014/06/30 09:26:07 Done.
+{
+ if (child->style()->hasAspectRatio()) {
+ hasAspectRatio = true;
+ aspectRatio = child->style()->aspectRatio();
+ } else if (child->isRenderImage() && child->intrinsicLogicalHeight()) {
tony 2014/06/26 16:31:28 Is checking for a RenderImage really the right thi
harpreet.sk 2014/06/30 09:26:07 Sorry only checking for RenderImage is not the rig
+ hasAspectRatio = true;
+ aspectRatio = child->intrinsicLogicalWidth().rawValue() / child->intrinsicLogicalHeight().rawValue();
+ }
+}
+
LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren)
{
child->clearOverrideSize();
Length flexBasis = flexBasisForChild(child);
+ double aspectRatio = 1.0f;
+ bool hasAspectRatio = false;
+ computeAspectRatioOfChild(child, aspectRatio, hasAspectRatio);
+
+ if (hasAspectRatio && flexBasis.isAuto() && childHasFiniteCrossSize(child)) {
+ if (!isMultiline() && needToStretchChildLogicalHeight(child))
+ return aspectRatio * style()->logicalHeight().value();
+ return aspectRatio * crossAxisIntrinsicExtentForChild(child);
+ }
+
if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength)) {
LayoutUnit mainAxisExtent;
if (hasOrthogonalFlow(child)) {
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698