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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); | 604 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); |
605 } | 605 } |
606 | 606 |
607 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const | 607 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const |
608 { | 608 { |
609 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); | 609 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); |
610 } | 610 } |
611 | 611 |
612 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) | 612 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) |
613 { | 613 { |
614 child->clearOverrideSize(); | 614 clearLogicalOverrideSize(child); |
615 | 615 |
616 if (child->style()->hasAspectRatio() || child->isImage() || child->isVideo() || child->isCanvas()) | 616 if (child->style()->hasAspectRatio() || child->isImage() || child->isVideo() || child->isCanvas()) |
617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
618 | 618 |
619 Length flexBasis = flexBasisForChild(child); | 619 Length flexBasis = flexBasisForChild(child); |
620 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { | 620 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { |
621 LayoutUnit mainAxisExtent; | 621 LayoutUnit mainAxisExtent; |
622 if (hasOrthogonalFlow(child)) { | 622 if (hasOrthogonalFlow(child)) { |
623 if (child->needsLayout() || relayoutChildren) { | 623 if (child->needsLayout() || relayoutChildren) { |
624 m_intrinsicSizeAlongMainAxis.remove(child); | 624 m_intrinsicSizeAlongMainAxis.remove(child); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 } | 986 } |
987 | 987 |
988 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize) | 988 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize) |
989 { | 989 { |
990 if (hasOrthogonalFlow(child)) | 990 if (hasOrthogonalFlow(child)) |
991 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight()); | 991 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight()); |
992 else | 992 else |
993 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth()); | 993 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth()); |
994 } | 994 } |
995 | 995 |
996 void RenderFlexibleBox::clearLogicalOverrideSize(RenderBox* child) | |
ojan
2014/08/28 03:23:09
LogicalOverrideSize doesn't tell you which size yo
harpreet.sk
2014/08/28 14:30:20
I named this api like this just to keep consistenc
| |
997 { | |
998 if (hasOrthogonalFlow(child)) | |
cbiesinger
2014/08/28 03:05:56
When the flexbox changes from a column to a row fl
harpreet.sk
2014/08/28 14:30:20
Added line to clear both override sizes.
| |
999 child->clearOverrideLogicalContentHeight(); | |
1000 else | |
1001 child->clearOverrideLogicalContentWidth(); | |
1002 } | |
1003 | |
996 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode ) | 1004 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode ) |
997 { | 1005 { |
998 ASSERT(child->isOutOfFlowPositioned()); | 1006 ASSERT(child->isOutOfFlowPositioned()); |
999 child->containingBlock()->insertPositionedObject(child); | 1007 child->containingBlock()->insertPositionedObject(child); |
1000 RenderLayer* childLayer = child->layer(); | 1008 RenderLayer* childLayer = child->layer(); |
1001 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; | 1009 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; |
1002 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) | 1010 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) |
1003 inlinePosition = mainAxisExtent() - mainAxisOffset; | 1011 inlinePosition = mainAxisExtent() - mainAxisOffset; |
1004 childLayer->setStaticInlinePosition(inlinePosition); | 1012 childLayer->setStaticInlinePosition(inlinePosition); |
1005 | 1013 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 | 1354 |
1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni t lineCrossAxisExtent) | 1355 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni t lineCrossAxisExtent) |
1348 { | 1356 { |
1349 if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) { | 1357 if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) { |
1350 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. | 1358 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. |
1351 if (!hasOrthogonalFlow(child)) { | 1359 if (!hasOrthogonalFlow(child)) { |
1352 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child->logicalHe ight(); | 1360 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child->logicalHe ight(); |
1353 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); | 1361 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |
1354 ASSERT(!child->needsLayout()); | 1362 ASSERT(!child->needsLayout()); |
1355 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi calHeight()); | 1363 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi calHeight()); |
1364 child->setOverrideLogicalContentHeight(desiredLogicalHeight - child- >borderAndPaddingLogicalHeight()); | |
cbiesinger
2014/08/28 03:05:56
I think we also have to relayout if the old overri
harpreet.sk
2014/08/28 14:30:20
@Chris: The example which you have stated i think
cbiesinger
2014/08/29 00:28:09
Apologies, you are correct. I tried to make a test
| |
1356 | 1365 |
1357 // 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. |
1358 if (desiredLogicalHeight != child->logicalHeight()) { | 1367 if (desiredLogicalHeight != child->logicalHeight()) { |
1359 child->setOverrideLogicalContentHeight(desiredLogicalHeight - ch ild->borderAndPaddingLogicalHeight()); | |
1360 child->setLogicalHeight(0); | 1368 child->setLogicalHeight(0); |
1361 child->forceChildLayout(); | 1369 child->forceChildLayout(); |
1362 } | 1370 } |
1363 } | 1371 } |
1364 } else if (isColumnFlow() && child->style()->logicalWidth().isAuto()) { | 1372 } else if (isColumnFlow() && child->style()->logicalWidth().isAuto()) { |
1365 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. | 1373 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. |
1366 if (hasOrthogonalFlow(child)) { | 1374 if (hasOrthogonalFlow(child)) { |
1367 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); | 1375 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); |
1368 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW idth, this); | 1376 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW idth, this); |
1369 | 1377 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 ASSERT(child); | 1409 ASSERT(child); |
1402 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1410 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
1403 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1411 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
1404 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1412 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
1405 adjustAlignmentForChild(child, newOffset - originalOffset); | 1413 adjustAlignmentForChild(child, newOffset - originalOffset); |
1406 } | 1414 } |
1407 } | 1415 } |
1408 } | 1416 } |
1409 | 1417 |
1410 } | 1418 } |
OLD | NEW |