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

Side by Side Diff: Source/core/rendering/RenderFlexibleBox.cpp

Issue 331203002: Blink doesn't honor percent heights on children of "align-self:stretch" flex items in a fixed-height (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength ); 602 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength );
603 } 603 }
604 604
605 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box& child, bool hasInfiniteLineLength) const 605 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box& child, bool hasInfiniteLineLength) const
606 { 606 {
607 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); 607 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child);
608 } 608 }
609 609
610 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren) 610 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren)
611 { 611 {
612 child.clearOverrideSize(); 612 clearLogicalOverrideSize(child);
613 613
614 if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas()) 614 if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas())
615 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); 615 UseCounter::count(document(), UseCounter::AspectRatioFlexItem);
616 616
617 Length flexBasis = flexBasisForChild(child); 617 Length flexBasis = flexBasisForChild(child);
618 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { 618 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) {
619 LayoutUnit mainAxisExtent; 619 LayoutUnit mainAxisExtent;
620 if (hasOrthogonalFlow(child)) { 620 if (hasOrthogonalFlow(child)) {
621 if (child.needsLayout() || relayoutChildren) { 621 if (child.needsLayout() || relayoutChildren) {
622 m_intrinsicSizeAlongMainAxis.remove(&child); 622 m_intrinsicSizeAlongMainAxis.remove(&child);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 } 984 }
985 985
986 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil dPreferredSize) 986 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil dPreferredSize)
987 { 987 {
988 if (hasOrthogonalFlow(child)) 988 if (hasOrthogonalFlow(child))
989 child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA ndPaddingLogicalHeight()); 989 child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA ndPaddingLogicalHeight());
990 else 990 else
991 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn dPaddingLogicalWidth()); 991 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn dPaddingLogicalWidth());
992 } 992 }
993 993
994 void RenderFlexibleBox::clearLogicalOverrideSize(RenderBox& child)
995 {
996 if (hasOrthogonalFlow(child))
997 child.clearOverrideLogicalContentHeight();
998 else
999 child.clearOverrideLogicalContentWidth();
1000 }
1001
994 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode ) 1002 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode )
995 { 1003 {
996 ASSERT(child.isOutOfFlowPositioned()); 1004 ASSERT(child.isOutOfFlowPositioned());
997 child.containingBlock()->insertPositionedObject(&child); 1005 child.containingBlock()->insertPositionedObject(&child);
998 RenderLayer* childLayer = child.layer(); 1006 RenderLayer* childLayer = child.layer();
999 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; 1007 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t;
1000 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) 1008 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse)
1001 inlinePosition = mainAxisExtent() - mainAxisOffset; 1009 inlinePosition = mainAxisExtent() - mainAxisOffset;
1002 childLayer->setStaticInlinePosition(inlinePosition); 1010 childLayer->setStaticInlinePosition(inlinePosition);
1003 1011
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1352
1345 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUni t lineCrossAxisExtent) 1353 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUni t lineCrossAxisExtent)
1346 { 1354 {
1347 if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) { 1355 if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) {
1348 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. 1356 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it.
1349 if (!hasOrthogonalFlow(child)) { 1357 if (!hasOrthogonalFlow(child)) {
1350 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei ght(); 1358 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei ght();
1351 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); 1359 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child);
1352 ASSERT(!child.needsLayout()); 1360 ASSERT(!child.needsLayout());
1353 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica lHeight()); 1361 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica lHeight());
1362 LayoutUnit desiredLogicalContentHeight = desiredLogicalHeight - chil d.borderAndPaddingLogicalHeight();
1354 1363
1355 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. 1364 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905.
1356 if (desiredLogicalHeight != child.logicalHeight()) { 1365 if (desiredLogicalHeight != child.logicalHeight() || (!child.hasOver rideHeight() && toRenderBlock(child).hasPercentHeightDescendants())) {
1357 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); 1366 child.setOverrideLogicalContentHeight(desiredLogicalContentHeigh t);
1358 child.setLogicalHeight(0); 1367 child.setLogicalHeight(0);
1359 child.forceChildLayout(); 1368 child.forceChildLayout();
1360 } 1369 }
1361 } 1370 }
1362 } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) { 1371 } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) {
1363 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. 1372 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it.
1364 if (hasOrthogonalFlow(child)) { 1373 if (hasOrthogonalFlow(child)) {
1365 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); 1374 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child));
1366 childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWi dth, this); 1375 childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWi dth, this);
1367 1376
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 ASSERT(child); 1408 ASSERT(child);
1400 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1409 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1401 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1410 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1402 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1411 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1403 adjustAlignmentForChild(*child, newOffset - originalOffset); 1412 adjustAlignmentForChild(*child, newOffset - originalOffset);
1404 } 1413 }
1405 } 1414 }
1406 } 1415 }
1407 1416
1408 } 1417 }
OLDNEW
« 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