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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 } | 207 } |
208 | 208 |
209 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) | 209 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) |
210 { | 210 { |
211 RenderBlock::styleDidChange(diff, oldStyle); | 211 RenderBlock::styleDidChange(diff, oldStyle); |
212 | 212 |
213 if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF ullLayout()) { | 213 if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF ullLayout()) { |
214 // Flex items that were previously stretching need to be relayed out so we can compute new available cross axis space. | 214 // Flex items that were previously stretching need to be relayed out so we can compute new available cross axis space. |
215 // This is only necessary for stretching since other alignment values do n't change the size of the box. | 215 // This is only necessary for stretching since other alignment values do n't change the size of the box. |
216 for (RenderBox* child = firstChildBox(); child; child = child->nextSibli ngBox()) { | 216 for (RenderBox* child = firstChildBox(); child; child = child->nextSibli ngBox()) { |
217 child->clearOverrideSize(); | |
cbiesinger
2014/08/29 00:28:09
Hmm, so we do need to do this in this case, but we
harpreet.sk
2014/09/01 08:10:59
Sorry Chris we do not required clearOverrideSize h
| |
217 ItemPosition previousAlignment = resolveAlignment(oldStyle, child->s tyle()); | 218 ItemPosition previousAlignment = resolveAlignment(oldStyle, child->s tyle()); |
218 if (previousAlignment == ItemPositionStretch && previousAlignment != resolveAlignment(style(), child->style())) | 219 if (previousAlignment == ItemPositionStretch && previousAlignment != resolveAlignment(style(), child->style())) |
219 child->setChildNeedsLayout(MarkOnlyThis); | 220 child->setChildNeedsLayout(MarkOnlyThis); |
220 } | 221 } |
221 } | 222 } |
222 } | 223 } |
223 | 224 |
224 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) | 225 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) |
225 { | 226 { |
226 ASSERT(needsLayout()); | 227 ASSERT(needsLayout()); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); | 605 return flexBasis.isAuto() || (flexBasis.isFixed() && !flexBasis.value() && h asInfiniteLineLength); |
605 } | 606 } |
606 | 607 |
607 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const | 608 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(Render Box* child, bool hasInfiniteLineLength) const |
608 { | 609 { |
609 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); | 610 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasI nfiniteLineLength) && hasOrthogonalFlow(child); |
610 } | 611 } |
611 | 612 |
612 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) | 613 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child, bool hasInfiniteLineLength, bool relayoutChildren) |
613 { | 614 { |
614 child->clearOverrideSize(); | 615 clearLogicalOverrideSize(child); |
615 | 616 |
616 if (child->style()->hasAspectRatio() || child->isImage() || child->isVideo() || child->isCanvas()) | 617 if (child->style()->hasAspectRatio() || child->isImage() || child->isVideo() || child->isCanvas()) |
617 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); | 618 UseCounter::count(document(), UseCounter::AspectRatioFlexItem); |
618 | 619 |
619 Length flexBasis = flexBasisForChild(child); | 620 Length flexBasis = flexBasisForChild(child); |
620 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { | 621 if (preferredMainAxisExtentDependsOnLayout(flexBasis, hasInfiniteLineLength) ) { |
621 LayoutUnit mainAxisExtent; | 622 LayoutUnit mainAxisExtent; |
622 if (hasOrthogonalFlow(child)) { | 623 if (hasOrthogonalFlow(child)) { |
623 if (child->needsLayout() || relayoutChildren) { | 624 if (child->needsLayout() || relayoutChildren) { |
624 m_intrinsicSizeAlongMainAxis.remove(child); | 625 m_intrinsicSizeAlongMainAxis.remove(child); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 } | 987 } |
987 | 988 |
988 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize) | 989 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit chil dPreferredSize) |
989 { | 990 { |
990 if (hasOrthogonalFlow(child)) | 991 if (hasOrthogonalFlow(child)) |
991 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight()); | 992 child->setOverrideLogicalContentHeight(childPreferredSize - child->borde rAndPaddingLogicalHeight()); |
992 else | 993 else |
993 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth()); | 994 child->setOverrideLogicalContentWidth(childPreferredSize - child->border AndPaddingLogicalWidth()); |
994 } | 995 } |
995 | 996 |
997 void RenderFlexibleBox::clearLogicalOverrideSize(RenderBox* child) | |
998 { | |
999 if (hasOrthogonalFlow(child)) | |
1000 child->clearOverrideLogicalContentHeight(); | |
1001 else | |
1002 child->clearOverrideLogicalContentWidth(); | |
1003 } | |
1004 | |
996 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 ) |
997 { | 1006 { |
998 ASSERT(child->isOutOfFlowPositioned()); | 1007 ASSERT(child->isOutOfFlowPositioned()); |
999 child->containingBlock()->insertPositionedObject(child); | 1008 child->containingBlock()->insertPositionedObject(child); |
1000 RenderLayer* childLayer = child->layer(); | 1009 RenderLayer* childLayer = child->layer(); |
1001 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; | 1010 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse t; |
1002 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) | 1011 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe verse) |
1003 inlinePosition = mainAxisExtent() - mainAxisOffset; | 1012 inlinePosition = mainAxisExtent() - mainAxisOffset; |
1004 childLayer->setStaticInlinePosition(inlinePosition); | 1013 childLayer->setStaticInlinePosition(inlinePosition); |
1005 | 1014 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1346 | 1355 |
1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni t lineCrossAxisExtent) | 1356 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni t lineCrossAxisExtent) |
1348 { | 1357 { |
1349 if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) { | 1358 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. | 1359 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. |
1351 if (!hasOrthogonalFlow(child)) { | 1360 if (!hasOrthogonalFlow(child)) { |
1352 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child->logicalHe ight(); | 1361 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight( child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child->logicalHe ight(); |
1353 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); | 1362 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |
1354 ASSERT(!child->needsLayout()); | 1363 ASSERT(!child->needsLayout()); |
1355 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi calHeight()); | 1364 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi calHeight()); |
1365 child->setOverrideLogicalContentHeight(desiredLogicalHeight - child- >borderAndPaddingLogicalHeight()); | |
1356 | 1366 |
1357 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. | 1367 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. |
1358 if (desiredLogicalHeight != child->logicalHeight()) { | 1368 if (desiredLogicalHeight != child->logicalHeight()) { |
1359 child->setOverrideLogicalContentHeight(desiredLogicalHeight - ch ild->borderAndPaddingLogicalHeight()); | |
1360 child->setLogicalHeight(0); | 1369 child->setLogicalHeight(0); |
1361 child->forceChildLayout(); | 1370 child->forceChildLayout(); |
1362 } | 1371 } |
1363 } | 1372 } |
1364 } else if (isColumnFlow() && child->style()->logicalWidth().isAuto()) { | 1373 } 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. | 1374 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it. |
1366 if (hasOrthogonalFlow(child)) { | 1375 if (hasOrthogonalFlow(child)) { |
1367 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); | 1376 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child)); |
1368 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW idth, this); | 1377 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW idth, this); |
1369 | 1378 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 ASSERT(child); | 1410 ASSERT(child); |
1402 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1411 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
1403 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1412 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
1404 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1413 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
1405 adjustAlignmentForChild(child, newOffset - originalOffset); | 1414 adjustAlignmentForChild(child, newOffset - originalOffset); |
1406 } | 1415 } |
1407 } | 1416 } |
1408 } | 1417 } |
1409 | 1418 |
1410 } | 1419 } |
OLD | NEW |