Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength ); | 605 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength ); |
| 606 } | 606 } |
| 607 | 607 |
| 608 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box& child, bool hasInfiniteLineLength) const | 608 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box& child, bool hasInfiniteLineLength) const |
| 609 { | 609 { |
| 610 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); | 610 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); |
| 611 } | 611 } |
| 612 | 612 |
| 613 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren) | 613 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren) |
| 614 { | 614 { |
| 615 child.clearOverrideSize(); | 615 clearLogicalOverrideSize(child); |
| 616 | 616 |
| 617 if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas()) | 617 if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas()) |
| 618 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 618 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
| 619 | 619 |
| 620 Length flexBasis = flexBasisForChild(child); | 620 Length flexBasis = flexBasisForChild(child); |
| 621 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { | 621 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { |
| 622 LayoutUnit mainAxisExtent; | 622 LayoutUnit mainAxisExtent; |
| 623 if (hasOrthogonalFlow(child)) { | 623 if (hasOrthogonalFlow(child)) { |
| 624 if (child.needsLayout() || relayoutChildren) { | 624 if (child.needsLayout() || relayoutChildren) { |
| 625 m_intrinsicSizeAlongMainAxis.remove(&child); | 625 m_intrinsicSizeAlongMainAxis.remove(&child); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 } | 987 } |
| 988 | 988 |
| 989 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil dPreferredSize) | 989 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit chil dPreferredSize) |
| 990 { | 990 { |
| 991 if (hasOrthogonalFlow(child)) | 991 if (hasOrthogonalFlow(child)) |
| 992 child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA ndPaddingLogicalHeight()); | 992 child.setOverrideLogicalContentHeight(childPreferredSize - child.borderA ndPaddingLogicalHeight()); |
| 993 else | 993 else |
| 994 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn dPaddingLogicalWidth()); | 994 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn dPaddingLogicalWidth()); |
| 995 } | 995 } |
| 996 | 996 |
| 997 void RenderFlexibleBox::clearLogicalOverrideSize(RenderBox& child) | |
| 998 { | |
| 999 if (hasOrthogonalFlow(child)) | |
| 1000 child.clearOverrideLogicalContentHeight(); | |
| 1001 else | |
| 1002 child.clearOverrideLogicalContentWidth(); | |
| 1003 } | |
| 1004 | |
| 997 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode ) | 1005 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode ) |
| 998 { | 1006 { |
| 999 ASSERT(child.isOutOfFlowPositioned()); | 1007 ASSERT(child.isOutOfFlowPositioned()); |
| 1000 child.containingBlock()->insertPositionedObject(&child); | 1008 child.containingBlock()->insertPositionedObject(&child); |
| 1001 RenderLayer* childLayer = child.layer(); | 1009 RenderLayer* childLayer = child.layer(); |
| 1002 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; | 1010 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; |
| 1003 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) | 1011 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) |
| 1004 inlinePosition = mainAxisExtent() - mainAxisOffset; | 1012 inlinePosition = mainAxisExtent() - mainAxisOffset; |
| 1005 childLayer->setStaticInlinePosition(inlinePosition); | 1013 childLayer->setStaticInlinePosition(inlinePosition); |
| 1006 | 1014 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1349 { | 1357 { |
| 1350 if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) { | 1358 if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) { |
| 1351 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. | 1359 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. |
| 1352 if (!hasOrthogonalFlow(child)) { | 1360 if (!hasOrthogonalFlow(child)) { |
| 1353 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei ght(); | 1361 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei ght(); |
| 1354 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); | 1362 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |
| 1355 ASSERT(!child.needsLayout()); | 1363 ASSERT(!child.needsLayout()); |
| 1356 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica lHeight()); | 1364 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica lHeight()); |
| 1357 | 1365 |
| 1358 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. | 1366 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. |
| 1359 if (desiredLogicalHeight != child.logicalHeight()) { | 1367 if (!child.hasOverrideHeight() || ((desiredLogicalHeight - child.bor derAndPaddingLogicalHeight()) != child.overrideLogicalContentHeight())) { |
|
cbiesinger
2014/09/25 00:50:31
I think you have to *also* keep desiredLogicalHeig
harpreet.sk
2014/09/25 12:58:57
Done.
| |
| 1360 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); | 1368 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); |
| 1361 child.setLogicalHeight(0); | 1369 child.setLogicalHeight(0); |
| 1362 child.forceChildLayout(); | 1370 child.forceChildLayout(); |
| 1363 } | 1371 } |
| 1364 } | 1372 } |
| 1365 } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) { | 1373 } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) { |
| 1366 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. | 1374 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. |
| 1367 if (hasOrthogonalFlow(child)) { | 1375 if (hasOrthogonalFlow(child)) { |
| 1368 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); | 1376 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); |
| 1369 childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWi dth, this); | 1377 childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWi dth, this); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1402 ASSERT(child); | 1410 ASSERT(child); |
| 1403 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1411 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
| 1404 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1412 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 1405 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1413 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
| 1406 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1414 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1407 } | 1415 } |
| 1408 } | 1416 } |
| 1409 } | 1417 } |
| 1410 | 1418 |
| 1411 } | 1419 } |
| OLD | NEW |