| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 int RenderFlexibleBox::firstLineBoxBaseline() const | 145 int RenderFlexibleBox::firstLineBoxBaseline() const |
| 146 { | 146 { |
| 147 if (isWritingModeRoot() || m_numberOfInFlowChildrenOnFirstLine <= 0) | 147 if (isWritingModeRoot() || m_numberOfInFlowChildrenOnFirstLine <= 0) |
| 148 return -1; | 148 return -1; |
| 149 RenderBox* baselineChild = 0; | 149 RenderBox* baselineChild = 0; |
| 150 int childNumber = 0; | 150 int childNumber = 0; |
| 151 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { | 151 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { |
| 152 if (child->isOutOfFlowPositioned()) | 152 if (child->isOutOfFlowPositioned()) |
| 153 continue; | 153 continue; |
| 154 if (alignmentForChild(child) == ItemPositionBaseline && !hasAutoMarginsI
nCrossAxis(child)) { | 154 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
InCrossAxis(child)) { |
| 155 baselineChild = child; | 155 baselineChild = child; |
| 156 break; | 156 break; |
| 157 } | 157 } |
| 158 if (!baselineChild) | 158 if (!baselineChild) |
| 159 baselineChild = child; | 159 baselineChild = child; |
| 160 | 160 |
| 161 ++childNumber; | 161 ++childNumber; |
| 162 if (childNumber == m_numberOfInFlowChildrenOnFirstLine) | 162 if (childNumber == m_numberOfInFlowChildrenOnFirstLine) |
| 163 break; | 163 break; |
| 164 } | 164 } |
| 165 | 165 |
| 166 if (!baselineChild) | 166 if (!baselineChild) |
| 167 return -1; | 167 return -1; |
| 168 | 168 |
| 169 if (!isColumnFlow() && hasOrthogonalFlow(baselineChild)) | 169 if (!isColumnFlow() && hasOrthogonalFlow(*baselineChild)) |
| 170 return crossAxisExtentForChild(baselineChild) + baselineChild->logicalTo
p(); | 170 return crossAxisExtentForChild(*baselineChild) + baselineChild->logicalT
op(); |
| 171 if (isColumnFlow() && !hasOrthogonalFlow(baselineChild)) | 171 if (isColumnFlow() && !hasOrthogonalFlow(*baselineChild)) |
| 172 return mainAxisExtentForChild(baselineChild) + baselineChild->logicalTop
(); | 172 return mainAxisExtentForChild(*baselineChild) + baselineChild->logicalTo
p(); |
| 173 | 173 |
| 174 int baseline = baselineChild->firstLineBoxBaseline(); | 174 int baseline = baselineChild->firstLineBoxBaseline(); |
| 175 if (baseline == -1) { | 175 if (baseline == -1) { |
| 176 // FIXME: We should pass |direction| into firstLineBoxBaseline and stop
bailing out if we're a writing mode root. | 176 // FIXME: We should pass |direction| into firstLineBoxBaseline and stop
bailing out if we're a writing mode root. |
| 177 // This would also fix some cases where the flexbox is orthogonal to its
container. | 177 // This would also fix some cases where the flexbox is orthogonal to its
container. |
| 178 LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine
: VerticalLine; | 178 LineDirectionMode direction = isHorizontalWritingMode() ? HorizontalLine
: VerticalLine; |
| 179 return synthesizedBaselineFromContentBox(baselineChild, direction) + bas
elineChild->logicalTop(); | 179 return synthesizedBaselineFromContentBox(baselineChild, direction) + bas
elineChild->logicalTop(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 return baseline + baselineChild->logicalTop(); | 182 return baseline + baselineChild->logicalTop(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 LayoutUnit maxChildLogicalBottom = 0; | 304 LayoutUnit maxChildLogicalBottom = 0; |
| 305 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 305 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
| 306 if (child->isOutOfFlowPositioned()) | 306 if (child->isOutOfFlowPositioned()) |
| 307 continue; | 307 continue; |
| 308 LayoutUnit childLogicalBottom = logicalTopForChild(child) + logicalHeigh
tForChild(child) + marginAfterForChild(child); | 308 LayoutUnit childLogicalBottom = logicalTopForChild(child) + logicalHeigh
tForChild(child) + marginAfterForChild(child); |
| 309 maxChildLogicalBottom = std::max(maxChildLogicalBottom, childLogicalBott
om); | 309 maxChildLogicalBottom = std::max(maxChildLogicalBottom, childLogicalBott
om); |
| 310 } | 310 } |
| 311 return std::max(clientLogicalBottom(), maxChildLogicalBottom + paddingAfter(
)); | 311 return std::max(clientLogicalBottom(), maxChildLogicalBottom + paddingAfter(
)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox* child) const | 314 bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox& child) const |
| 315 { | 315 { |
| 316 // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow. | 316 // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow. |
| 317 return isHorizontalFlow() != child->isHorizontalWritingMode(); | 317 return isHorizontalFlow() != child.isHorizontalWritingMode(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 bool RenderFlexibleBox::isColumnFlow() const | 320 bool RenderFlexibleBox::isColumnFlow() const |
| 321 { | 321 { |
| 322 return style()->isColumnFlexDirection(); | 322 return style()->isColumnFlexDirection(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 bool RenderFlexibleBox::isHorizontalFlow() const | 325 bool RenderFlexibleBox::isHorizontalFlow() const |
| 326 { | 326 { |
| 327 if (isHorizontalWritingMode()) | 327 if (isHorizontalWritingMode()) |
| 328 return !isColumnFlow(); | 328 return !isColumnFlow(); |
| 329 return isColumnFlow(); | 329 return isColumnFlow(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool RenderFlexibleBox::isLeftToRightFlow() const | 332 bool RenderFlexibleBox::isLeftToRightFlow() const |
| 333 { | 333 { |
| 334 if (isColumnFlow()) | 334 if (isColumnFlow()) |
| 335 return style()->writingMode() == TopToBottomWritingMode || style()->writ
ingMode() == LeftToRightWritingMode; | 335 return style()->writingMode() == TopToBottomWritingMode || style()->writ
ingMode() == LeftToRightWritingMode; |
| 336 return style()->isLeftToRightDirection() ^ (style()->flexDirection() == Flow
RowReverse); | 336 return style()->isLeftToRightDirection() ^ (style()->flexDirection() == Flow
RowReverse); |
| 337 } | 337 } |
| 338 | 338 |
| 339 bool RenderFlexibleBox::isMultiline() const | 339 bool RenderFlexibleBox::isMultiline() const |
| 340 { | 340 { |
| 341 return style()->flexWrap() != FlexNoWrap; | 341 return style()->flexWrap() != FlexNoWrap; |
| 342 } | 342 } |
| 343 | 343 |
| 344 Length RenderFlexibleBox::flexBasisForChild(RenderBox* child) const | 344 Length RenderFlexibleBox::flexBasisForChild(RenderBox& child) const |
| 345 { | 345 { |
| 346 Length flexLength = child->style()->flexBasis(); | 346 Length flexLength = child.style()->flexBasis(); |
| 347 if (flexLength.isAuto()) | 347 if (flexLength.isAuto()) |
| 348 flexLength = isHorizontalFlow() ? child->style()->width() : child->style
()->height(); | 348 flexLength = isHorizontalFlow() ? child.style()->width() : child.style()
->height(); |
| 349 return flexLength; | 349 return flexLength; |
| 350 } | 350 } |
| 351 | 351 |
| 352 LayoutUnit RenderFlexibleBox::crossAxisExtentForChild(RenderBox* child) const | 352 LayoutUnit RenderFlexibleBox::crossAxisExtentForChild(RenderBox& child) const |
| 353 { | 353 { |
| 354 return isHorizontalFlow() ? child->height() : child->width(); | 354 return isHorizontalFlow() ? child.height() : child.width(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(RenderBox
* child) | 357 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(RenderBox
& child) |
| 358 { | 358 { |
| 359 LayoutUnit childIntrinsicContentLogicalHeight = child->intrinsicContentLogic
alHeight(); | 359 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); |
| 360 return child->constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHei
ght + child->borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight
); | 360 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
| 361 } | 361 } |
| 362 | 362 |
| 363 LayoutUnit RenderFlexibleBox::childIntrinsicHeight(RenderBox* child) const | 363 LayoutUnit RenderFlexibleBox::childIntrinsicHeight(RenderBox& child) const |
| 364 { | 364 { |
| 365 if (child->isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil
d)) | 365 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child
)) |
| 366 return constrainedChildIntrinsicContentLogicalHeight(child); | 366 return constrainedChildIntrinsicContentLogicalHeight(child); |
| 367 return child->height(); | 367 return child.height(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 LayoutUnit RenderFlexibleBox::childIntrinsicWidth(RenderBox* child) const | 370 LayoutUnit RenderFlexibleBox::childIntrinsicWidth(RenderBox& child) const |
| 371 { | 371 { |
| 372 if (!child->isHorizontalWritingMode() && needToStretchChildLogicalHeight(chi
ld)) | 372 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil
d)) |
| 373 return constrainedChildIntrinsicContentLogicalHeight(child); | 373 return constrainedChildIntrinsicContentLogicalHeight(child); |
| 374 return child->width(); | 374 return child.width(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 LayoutUnit RenderFlexibleBox::crossAxisIntrinsicExtentForChild(RenderBox* child)
const | 377 LayoutUnit RenderFlexibleBox::crossAxisIntrinsicExtentForChild(RenderBox& child)
const |
| 378 { | 378 { |
| 379 return isHorizontalFlow() ? childIntrinsicHeight(child) : childIntrinsicWidt
h(child); | 379 return isHorizontalFlow() ? childIntrinsicHeight(child) : childIntrinsicWidt
h(child); |
| 380 } | 380 } |
| 381 | 381 |
| 382 LayoutUnit RenderFlexibleBox::mainAxisExtentForChild(RenderBox* child) const | 382 LayoutUnit RenderFlexibleBox::mainAxisExtentForChild(RenderBox& child) const |
| 383 { | 383 { |
| 384 return isHorizontalFlow() ? child->width() : child->height(); | 384 return isHorizontalFlow() ? child.width() : child.height(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 LayoutUnit RenderFlexibleBox::crossAxisExtent() const | 387 LayoutUnit RenderFlexibleBox::crossAxisExtent() const |
| 388 { | 388 { |
| 389 return isHorizontalFlow() ? height() : width(); | 389 return isHorizontalFlow() ? height() : width(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 LayoutUnit RenderFlexibleBox::mainAxisExtent() const | 392 LayoutUnit RenderFlexibleBox::mainAxisExtent() const |
| 393 { | 393 { |
| 394 return isHorizontalFlow() ? width() : height(); | 394 return isHorizontalFlow() ? width() : height(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 406 LayoutUnit borderPaddingAndScrollbar = borderAndPaddingLogicalHeight() +
scrollbarLogicalHeight(); | 406 LayoutUnit borderPaddingAndScrollbar = borderAndPaddingLogicalHeight() +
scrollbarLogicalHeight(); |
| 407 LayoutUnit borderBoxLogicalHeight = contentLogicalHeight + borderPadding
AndScrollbar; | 407 LayoutUnit borderBoxLogicalHeight = contentLogicalHeight + borderPadding
AndScrollbar; |
| 408 computeLogicalHeight(borderBoxLogicalHeight, logicalTop(), computedValue
s); | 408 computeLogicalHeight(borderBoxLogicalHeight, logicalTop(), computedValue
s); |
| 409 if (computedValues.m_extent == LayoutUnit::max()) | 409 if (computedValues.m_extent == LayoutUnit::max()) |
| 410 return computedValues.m_extent; | 410 return computedValues.m_extent; |
| 411 return std::max(LayoutUnit(0), computedValues.m_extent - borderPaddingAn
dScrollbar); | 411 return std::max(LayoutUnit(0), computedValues.m_extent - borderPaddingAn
dScrollbar); |
| 412 } | 412 } |
| 413 return contentLogicalWidth(); | 413 return contentLogicalWidth(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 LayoutUnit RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox* child, Si
zeType sizeType, const Length& size) | 416 LayoutUnit RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox& child, Si
zeType sizeType, const Length& size) |
| 417 { | 417 { |
| 418 // FIXME: This is wrong for orthogonal flows. It should use the flexbox's wr
iting-mode, not the child's in order | 418 // FIXME: This is wrong for orthogonal flows. It should use the flexbox's wr
iting-mode, not the child's in order |
| 419 // to figure out the logical height/width. | 419 // to figure out the logical height/width. |
| 420 if (isColumnFlow()) { | 420 if (isColumnFlow()) { |
| 421 // We don't have to check for "auto" here - computeContentLogicalHeight
will just return -1 for that case anyway. | 421 // We don't have to check for "auto" here - computeContentLogicalHeight
will just return -1 for that case anyway. |
| 422 if (size.isIntrinsic()) | 422 if (size.isIntrinsic()) |
| 423 child->layoutIfNeeded(); | 423 child.layoutIfNeeded(); |
| 424 return child->computeContentLogicalHeight(size, child->logicalHeight() -
child->borderAndPaddingLogicalHeight()) + child->scrollbarLogicalHeight(); | 424 return child.computeContentLogicalHeight(size, child.logicalHeight() - c
hild.borderAndPaddingLogicalHeight()) + child.scrollbarLogicalHeight(); |
| 425 } | 425 } |
| 426 return child->computeLogicalWidthUsing(sizeType, size, contentLogicalWidth()
, this) - child->borderAndPaddingLogicalWidth(); | 426 return child.computeLogicalWidthUsing(sizeType, size, contentLogicalWidth(),
this) - child.borderAndPaddingLogicalWidth(); |
| 427 } | 427 } |
| 428 | 428 |
| 429 WritingMode RenderFlexibleBox::transformedWritingMode() const | 429 WritingMode RenderFlexibleBox::transformedWritingMode() const |
| 430 { | 430 { |
| 431 WritingMode mode = style()->writingMode(); | 431 WritingMode mode = style()->writingMode(); |
| 432 if (!isColumnFlow()) | 432 if (!isColumnFlow()) |
| 433 return mode; | 433 return mode; |
| 434 | 434 |
| 435 switch (mode) { | 435 switch (mode) { |
| 436 case TopToBottomWritingMode: | 436 case TopToBottomWritingMode: |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox*
child) const | 597 LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox*
child) const |
| 598 { | 598 { |
| 599 return isHorizontalFlow() ? child->borderAndPaddingWidth() : child->borderAn
dPaddingHeight(); | 599 return isHorizontalFlow() ? child->borderAndPaddingWidth() : child->borderAn
dPaddingHeight(); |
| 600 } | 600 } |
| 601 | 601 |
| 602 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi
s, bool hasInfiniteLineLength) | 602 static inline bool preferredMainAxisExtentDependsOnLayout(const Length& flexBasi
s, bool hasInfiniteLineLength) |
| 603 { | 603 { |
| 604 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength
); | 604 return flexBasis.isAuto() || (flexBasis.isPercent() && hasInfiniteLineLength
); |
| 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 child->clearOverrideSize(); |
| 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); |
| 625 child->forceChildLayout(); | 625 child->forceChildLayout(); |
| 626 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); | 626 m_intrinsicSizeAlongMainAxis.set(child, child->logicalHeight()); |
| 627 } | 627 } |
| 628 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); | 628 ASSERT(m_intrinsicSizeAlongMainAxis.contains(child)); |
| 629 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); | 629 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(child); |
| 630 } else { | 630 } else { |
| 631 mainAxisExtent = child->maxPreferredLogicalWidth(); | 631 mainAxisExtent = child->maxPreferredLogicalWidth(); |
| 632 } | 632 } |
| 633 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >=
0); | 633 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >=
0); |
| 634 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); | 634 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child); |
| 635 } | 635 } |
| 636 return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPr
eferredSize, flexBasis)); | 636 return std::max(LayoutUnit(0), computeMainAxisExtentForChild(*child, MainOrP
referredSize, flexBasis)); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) | 639 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) |
| 640 { | 640 { |
| 641 Vector<LineContext> lineContexts; | 641 Vector<LineContext> lineContexts; |
| 642 OrderedFlexItemList orderedChildren; | 642 OrderedFlexItemList orderedChildren; |
| 643 LayoutUnit sumFlexBaseSize; | 643 LayoutUnit sumFlexBaseSize; |
| 644 double totalFlexGrow; | 644 double totalFlexGrow; |
| 645 double totalWeightedFlexShrink; | 645 double totalWeightedFlexShrink; |
| 646 LayoutUnit sumHypotheticalMainSize; | 646 LayoutUnit sumHypotheticalMainSize; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 bool RenderFlexibleBox::hasAutoMarginsInCrossAxis(RenderBox* child) const | 730 bool RenderFlexibleBox::hasAutoMarginsInCrossAxis(RenderBox* child) const |
| 731 { | 731 { |
| 732 if (isHorizontalFlow()) | 732 if (isHorizontalFlow()) |
| 733 return child->style()->marginTop().isAuto() || child->style()->marginBot
tom().isAuto(); | 733 return child->style()->marginTop().isAuto() || child->style()->marginBot
tom().isAuto(); |
| 734 return child->style()->marginLeft().isAuto() || child->style()->marginRight(
).isAuto(); | 734 return child->style()->marginLeft().isAuto() || child->style()->marginRight(
).isAuto(); |
| 735 } | 735 } |
| 736 | 736 |
| 737 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCro
ssAxisExtent, RenderBox* child) | 737 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCro
ssAxisExtent, RenderBox* child) |
| 738 { | 738 { |
| 739 ASSERT(!child->isOutOfFlowPositioned()); | 739 ASSERT(!child->isOutOfFlowPositioned()); |
| 740 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(child); | 740 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(*child); |
| 741 return lineCrossAxisExtent - childCrossExtent; | 741 return lineCrossAxisExtent - childCrossExtent; |
| 742 } | 742 } |
| 743 | 743 |
| 744 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChildBeforeStretching(La
youtUnit lineCrossAxisExtent, RenderBox* child) | 744 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChildBeforeStretching(La
youtUnit lineCrossAxisExtent, RenderBox* child) |
| 745 { | 745 { |
| 746 ASSERT(!child->isOutOfFlowPositioned()); | 746 ASSERT(!child->isOutOfFlowPositioned()); |
| 747 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
isIntrinsicExtentForChild(child); | 747 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAx
isIntrinsicExtentForChild(*child); |
| 748 return lineCrossAxisExtent - childCrossExtent; | 748 return lineCrossAxisExtent - childCrossExtent; |
| 749 } | 749 } |
| 750 | 750 |
| 751 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUni
t availableAlignmentSpace) | 751 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUni
t availableAlignmentSpace) |
| 752 { | 752 { |
| 753 ASSERT(!child->isOutOfFlowPositioned()); | 753 ASSERT(!child->isOutOfFlowPositioned()); |
| 754 ASSERT(availableAlignmentSpace >= 0); | 754 ASSERT(availableAlignmentSpace >= 0); |
| 755 | 755 |
| 756 bool isHorizontal = isHorizontalFlow(); | 756 bool isHorizontal = isHorizontalFlow(); |
| 757 Length topOrLeft = isHorizontal ? child->style()->marginTop() : child->style
()->marginLeft(); | 757 Length topOrLeft = isHorizontal ? child->style()->marginTop() : child->style
()->marginLeft(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 child->setMarginRight(availableAlignmentSpace); | 799 child->setMarginRight(availableAlignmentSpace); |
| 800 return true; | 800 return true; |
| 801 } | 801 } |
| 802 return false; | 802 return false; |
| 803 } | 803 } |
| 804 | 804 |
| 805 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child) | 805 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox* child) |
| 806 { | 806 { |
| 807 LayoutUnit ascent = child->firstLineBoxBaseline(); | 807 LayoutUnit ascent = child->firstLineBoxBaseline(); |
| 808 if (ascent == -1) | 808 if (ascent == -1) |
| 809 ascent = crossAxisExtentForChild(child); | 809 ascent = crossAxisExtentForChild(*child); |
| 810 return ascent + flowAwareMarginBeforeForChild(child); | 810 return ascent + flowAwareMarginBeforeForChild(child); |
| 811 } | 811 } |
| 812 | 812 |
| 813 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin) | 813 LayoutUnit RenderFlexibleBox::computeChildMarginValue(Length margin) |
| 814 { | 814 { |
| 815 // When resolving the margins, we use the content size for resolving percent
and calc (for percents in calc expressions) margins. | 815 // When resolving the margins, we use the content size for resolving percent
and calc (for percents in calc expressions) margins. |
| 816 // Fortunately, percent margins are always computed with respect to the bloc
k's width, even for margin-top and margin-bottom. | 816 // Fortunately, percent margins are always computed with respect to the bloc
k's width, even for margin-top and margin-bottom. |
| 817 LayoutUnit availableSize = contentLogicalWidth(); | 817 LayoutUnit availableSize = contentLogicalWidth(); |
| 818 return minimumValueForLength(margin, availableSize); | 818 return minimumValueForLength(margin, availableSize); |
| 819 } | 819 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 837 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p())); | 837 child->setMarginTop(computeChildMarginValue(child->style()->marginTo
p())); |
| 838 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom())); | 838 child->setMarginBottom(computeChildMarginValue(child->style()->margi
nBottom())); |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 | 842 |
| 843 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) | 843 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, Layo
utUnit childSize) |
| 844 { | 844 { |
| 845 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); | 845 Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style(
)->maxHeight(); |
| 846 if (max.isSpecifiedOrIntrinsic()) { | 846 if (max.isSpecifiedOrIntrinsic()) { |
| 847 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max
); | 847 LayoutUnit maxExtent = computeMainAxisExtentForChild(*child, MaxSize, ma
x); |
| 848 if (maxExtent != -1 && childSize > maxExtent) | 848 if (maxExtent != -1 && childSize > maxExtent) |
| 849 childSize = maxExtent; | 849 childSize = maxExtent; |
| 850 } | 850 } |
| 851 | 851 |
| 852 Length min = isHorizontalFlow() ? child->style()->minWidth() : child->style(
)->minHeight(); | 852 Length min = isHorizontalFlow() ? child->style()->minWidth() : child->style(
)->minHeight(); |
| 853 LayoutUnit minExtent = 0; | 853 LayoutUnit minExtent = 0; |
| 854 if (min.isSpecifiedOrIntrinsic()) | 854 if (min.isSpecifiedOrIntrinsic()) |
| 855 minExtent = computeMainAxisExtentForChild(child, MinSize, min); | 855 minExtent = computeMainAxisExtentForChild(*child, MinSize, min); |
| 856 return std::max(childSize, minExtent); | 856 return std::max(childSize, minExtent); |
| 857 } | 857 } |
| 858 | 858 |
| 859 bool RenderFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexS
hrink, LayoutUnit& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool re
layoutChildren) | 859 bool RenderFlexibleBox::computeNextFlexLine(OrderedFlexItemList& orderedChildren
, LayoutUnit& sumFlexBaseSize, double& totalFlexGrow, double& totalWeightedFlexS
hrink, LayoutUnit& sumHypotheticalMainSize, bool& hasInfiniteLineLength, bool re
layoutChildren) |
| 860 { | 860 { |
| 861 orderedChildren.clear(); | 861 orderedChildren.clear(); |
| 862 sumFlexBaseSize = 0; | 862 sumFlexBaseSize = 0; |
| 863 totalFlexGrow = totalWeightedFlexShrink = 0; | 863 totalFlexGrow = totalWeightedFlexShrink = 0; |
| 864 sumHypotheticalMainSize = 0; | 864 sumHypotheticalMainSize = 0; |
| 865 | 865 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 { | 978 { |
| 979 if (availableFreeSpace > 0 && numberOfChildren > 1) { | 979 if (availableFreeSpace > 0 && numberOfChildren > 1) { |
| 980 if (justifyContent == JustifySpaceBetween) | 980 if (justifyContent == JustifySpaceBetween) |
| 981 return availableFreeSpace / (numberOfChildren - 1); | 981 return availableFreeSpace / (numberOfChildren - 1); |
| 982 if (justifyContent == JustifySpaceAround) | 982 if (justifyContent == JustifySpaceAround) |
| 983 return availableFreeSpace / numberOfChildren; | 983 return availableFreeSpace / numberOfChildren; |
| 984 } | 984 } |
| 985 return 0; | 985 return 0; |
| 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.borderA
ndPaddingLogicalHeight()); |
| 992 else | 992 else |
| 993 child->setOverrideLogicalContentWidth(childPreferredSize - child->border
AndPaddingLogicalWidth()); | 993 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAn
dPaddingLogicalWidth()); |
| 994 } | 994 } |
| 995 | 995 |
| 996 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout
Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode
) | 996 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox* child, Layout
Unit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode
) |
| 997 { | 997 { |
| 998 ASSERT(child->isOutOfFlowPositioned()); | 998 ASSERT(child->isOutOfFlowPositioned()); |
| 999 child->containingBlock()->insertPositionedObject(child); | 999 child->containingBlock()->insertPositionedObject(child); |
| 1000 RenderLayer* childLayer = child->layer(); | 1000 RenderLayer* childLayer = child->layer(); |
| 1001 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
t; | 1001 LayoutUnit inlinePosition = isColumnFlow() ? crossAxisOffset : mainAxisOffse
t; |
| 1002 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe
verse) | 1002 if (layoutMode == FlipForRowReverse && style()->flexDirection() == FlowRowRe
verse) |
| 1003 inlinePosition = mainAxisExtent() - mainAxisOffset; | 1003 inlinePosition = mainAxisExtent() - mainAxisOffset; |
| 1004 childLayer->setStaticInlinePosition(inlinePosition); | 1004 childLayer->setStaticInlinePosition(inlinePosition); |
| 1005 | 1005 |
| 1006 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; | 1006 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; |
| 1007 if (childLayer->staticBlockPosition() != staticBlockPosition) { | 1007 if (childLayer->staticBlockPosition() != staticBlockPosition) { |
| 1008 childLayer->setStaticBlockPosition(staticBlockPosition); | 1008 childLayer->setStaticBlockPosition(staticBlockPosition); |
| 1009 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) | 1009 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) |
| 1010 child->setChildNeedsLayout(MarkOnlyThis); | 1010 child->setChildNeedsLayout(MarkOnlyThis); |
| 1011 } | 1011 } |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox* child) const | 1014 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const |
| 1015 { | 1015 { |
| 1016 ItemPosition align = resolveAlignment(style(), child->style()); | 1016 ItemPosition align = resolveAlignment(style(), child.style()); |
| 1017 | 1017 |
| 1018 if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) | 1018 if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) |
| 1019 align = ItemPositionFlexStart; | 1019 align = ItemPositionFlexStart; |
| 1020 | 1020 |
| 1021 if (style()->flexWrap() == FlexWrapReverse) { | 1021 if (style()->flexWrap() == FlexWrapReverse) { |
| 1022 if (align == ItemPositionFlexStart) | 1022 if (align == ItemPositionFlexStart) |
| 1023 align = ItemPositionFlexEnd; | 1023 align = ItemPositionFlexEnd; |
| 1024 else if (align == ItemPositionFlexEnd) | 1024 else if (align == ItemPositionFlexEnd) |
| 1025 align = ItemPositionFlexStart; | 1025 align = ItemPositionFlexStart; |
| 1026 } | 1026 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1050 child->setMarginBottom(0); | 1050 child->setMarginBottom(0); |
| 1051 } else { | 1051 } else { |
| 1052 if (child->style()->marginLeft().isAuto()) | 1052 if (child->style()->marginLeft().isAuto()) |
| 1053 child->setMarginLeft(0); | 1053 child->setMarginLeft(0); |
| 1054 if (child->style()->marginRight().isAuto()) | 1054 if (child->style()->marginRight().isAuto()) |
| 1055 child->setMarginRight(0); | 1055 child->setMarginRight(0); |
| 1056 } | 1056 } |
| 1057 } | 1057 } |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 bool RenderFlexibleBox::needToStretchChildLogicalHeight(RenderBox* child) const | 1060 bool RenderFlexibleBox::needToStretchChildLogicalHeight(RenderBox& child) const |
| 1061 { | 1061 { |
| 1062 if (alignmentForChild(child) != ItemPositionStretch) | 1062 if (alignmentForChild(child) != ItemPositionStretch) |
| 1063 return false; | 1063 return false; |
| 1064 | 1064 |
| 1065 return isHorizontalFlow() && child->style()->height().isAuto(); | 1065 return isHorizontalFlow() && child.style()->height().isAuto(); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons
t OrderedFlexItemList& children, const Vector<LayoutUnit, 16>& childSizes, Layou
tUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContex
ts, bool hasInfiniteLineLength) | 1068 void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, cons
t OrderedFlexItemList& children, const Vector<LayoutUnit, 16>& childSizes, Layou
tUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContex
ts, bool hasInfiniteLineLength) |
| 1069 { | 1069 { |
| 1070 ASSERT(childSizes.size() == children.size()); | 1070 ASSERT(childSizes.size() == children.size()); |
| 1071 | 1071 |
| 1072 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren(
children); | 1072 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren(
children); |
| 1073 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available
FreeSpace); | 1073 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available
FreeSpace); |
| 1074 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart()
; | 1074 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart()
; |
| 1075 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, style()->j
ustifyContent(), numberOfChildrenForJustifyContent); | 1075 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, style()->j
ustifyContent(), numberOfChildrenForJustifyContent); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1086 | 1086 |
| 1087 if (child->isOutOfFlowPositioned()) { | 1087 if (child->isOutOfFlowPositioned()) { |
| 1088 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
et, FlipForRowReverse); | 1088 prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffs
et, FlipForRowReverse); |
| 1089 continue; | 1089 continue; |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 // FIXME Investigate if this can be removed based on other flags. crbug.
com/370010 | 1092 // FIXME Investigate if this can be removed based on other flags. crbug.
com/370010 |
| 1093 child->setMayNeedPaintInvalidation(true); | 1093 child->setMayNeedPaintInvalidation(true); |
| 1094 | 1094 |
| 1095 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); | 1095 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPadding
ExtentForChild(child); |
| 1096 setLogicalOverrideSize(child, childPreferredSize); | 1096 setLogicalOverrideSize(*child, childPreferredSize); |
| 1097 if (childPreferredSize != mainAxisExtentForChild(child)) { | 1097 if (childPreferredSize != mainAxisExtentForChild(*child)) { |
| 1098 child->setChildNeedsLayout(MarkOnlyThis); | 1098 child->setChildNeedsLayout(MarkOnlyThis); |
| 1099 } else { | 1099 } else { |
| 1100 // To avoid double applying margin changes in updateAutoMarginsInCro
ssAxis, we reset the margins here. | 1100 // To avoid double applying margin changes in updateAutoMarginsInCro
ssAxis, we reset the margins here. |
| 1101 resetAutoMarginsAndLogicalTopInCrossAxis(child); | 1101 resetAutoMarginsAndLogicalTopInCrossAxis(child); |
| 1102 } | 1102 } |
| 1103 // We may have already forced relayout for orthogonal flowing children i
n preferredMainAxisContentExtentForChild. | 1103 // We may have already forced relayout for orthogonal flowing children i
n preferredMainAxisContentExtentForChild. |
| 1104 bool forceChildRelayout = relayoutChildren && !childPreferredMainAxisCon
tentExtentRequiresLayout(child, hasInfiniteLineLength); | 1104 bool forceChildRelayout = relayoutChildren && !childPreferredMainAxisCon
tentExtentRequiresLayout(*child, hasInfiniteLineLength); |
| 1105 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, child); | 1105 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, child); |
| 1106 child->layoutIfNeeded(); | 1106 child->layoutIfNeeded(); |
| 1107 | 1107 |
| 1108 updateAutoMarginsInMainAxis(child, autoMarginOffset); | 1108 updateAutoMarginsInMainAxis(child, autoMarginOffset); |
| 1109 | 1109 |
| 1110 LayoutUnit childCrossAxisMarginBoxExtent; | 1110 LayoutUnit childCrossAxisMarginBoxExtent; |
| 1111 if (alignmentForChild(child) == ItemPositionBaseline && !hasAutoMarginsI
nCrossAxis(child)) { | 1111 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMargins
InCrossAxis(child)) { |
| 1112 LayoutUnit ascent = marginBoxAscentForChild(child); | 1112 LayoutUnit ascent = marginBoxAscentForChild(child); |
| 1113 LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(child)) - ascent; | 1113 LayoutUnit descent = (crossAxisMarginExtentForChild(child) + crossAx
isExtentForChild(*child)) - ascent; |
| 1114 | 1114 |
| 1115 maxAscent = std::max(maxAscent, ascent); | 1115 maxAscent = std::max(maxAscent, ascent); |
| 1116 maxDescent = std::max(maxDescent, descent); | 1116 maxDescent = std::max(maxDescent, descent); |
| 1117 | 1117 |
| 1118 childCrossAxisMarginBoxExtent = maxAscent + maxDescent; | 1118 childCrossAxisMarginBoxExtent = maxAscent + maxDescent; |
| 1119 } else { | 1119 } else { |
| 1120 childCrossAxisMarginBoxExtent = crossAxisIntrinsicExtentForChild(chi
ld) + crossAxisMarginExtentForChild(child) + crossAxisScrollbarExtentForChild(ch
ild); | 1120 childCrossAxisMarginBoxExtent = crossAxisIntrinsicExtentForChild(*ch
ild) + crossAxisMarginExtentForChild(child) + crossAxisScrollbarExtentForChild(c
hild); |
| 1121 } | 1121 } |
| 1122 if (!isColumnFlow()) | 1122 if (!isColumnFlow()) |
| 1123 setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa
reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros
sAxisScrollbarExtent())); | 1123 setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa
reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros
sAxisScrollbarExtent())); |
| 1124 maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx
isMarginBoxExtent); | 1124 maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx
isMarginBoxExtent); |
| 1125 | 1125 |
| 1126 mainAxisOffset += flowAwareMarginStartForChild(child); | 1126 mainAxisOffset += flowAwareMarginStartForChild(child); |
| 1127 | 1127 |
| 1128 LayoutUnit childMainExtent = mainAxisExtentForChild(child); | 1128 LayoutUnit childMainExtent = mainAxisExtentForChild(*child); |
| 1129 // In an RTL column situation, this will apply the margin-right/margin-e
nd on the left. | 1129 // In an RTL column situation, this will apply the margin-right/margin-e
nd on the left. |
| 1130 // This will be fixed later in flipForRightToLeftColumn. | 1130 // This will be fixed later in flipForRightToLeftColumn. |
| 1131 LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi
sOffset - childMainExtent : mainAxisOffset, | 1131 LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi
sOffset - childMainExtent : mainAxisOffset, |
| 1132 crossAxisOffset + flowAwareMarginBeforeForChild(child)); | 1132 crossAxisOffset + flowAwareMarginBeforeForChild(child)); |
| 1133 | 1133 |
| 1134 // FIXME: Supporting layout deltas. | 1134 // FIXME: Supporting layout deltas. |
| 1135 setFlowAwareLocationForChild(child, childLocation); | 1135 setFlowAwareLocationForChild(child, childLocation); |
| 1136 mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(child); | 1136 mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(child); |
| 1137 | 1137 |
| 1138 ++seenInFlowPositionedChildren; | 1138 ++seenInFlowPositionedChildren; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1167 mainAxisOffset -= isHorizontalFlow() ? verticalScrollbarWidth() : horizontal
ScrollbarHeight(); | 1167 mainAxisOffset -= isHorizontalFlow() ? verticalScrollbarWidth() : horizontal
ScrollbarHeight(); |
| 1168 | 1168 |
| 1169 size_t seenInFlowPositionedChildren = 0; | 1169 size_t seenInFlowPositionedChildren = 0; |
| 1170 for (size_t i = 0; i < children.size(); ++i) { | 1170 for (size_t i = 0; i < children.size(); ++i) { |
| 1171 RenderBox* child = children[i]; | 1171 RenderBox* child = children[i]; |
| 1172 | 1172 |
| 1173 if (child->isOutOfFlowPositioned()) { | 1173 if (child->isOutOfFlowPositioned()) { |
| 1174 child->layer()->setStaticBlockPosition(mainAxisOffset); | 1174 child->layer()->setStaticBlockPosition(mainAxisOffset); |
| 1175 continue; | 1175 continue; |
| 1176 } | 1176 } |
| 1177 mainAxisOffset -= mainAxisExtentForChild(child) + flowAwareMarginEndForC
hild(child); | 1177 mainAxisOffset -= mainAxisExtentForChild(*child) + flowAwareMarginEndFor
Child(child); |
| 1178 | 1178 |
| 1179 setFlowAwareLocationForChild(child, LayoutPoint(mainAxisOffset, crossAxi
sOffset + flowAwareMarginBeforeForChild(child))); | 1179 setFlowAwareLocationForChild(child, LayoutPoint(mainAxisOffset, crossAxi
sOffset + flowAwareMarginBeforeForChild(child))); |
| 1180 | 1180 |
| 1181 mainAxisOffset -= flowAwareMarginStartForChild(child); | 1181 mainAxisOffset -= flowAwareMarginStartForChild(child); |
| 1182 | 1182 |
| 1183 ++seenInFlowPositionedChildren; | 1183 ++seenInFlowPositionedChildren; |
| 1184 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) | 1184 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) |
| 1185 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp
ace, style()->justifyContent(), numberOfChildrenForJustifyContent); | 1185 mainAxisOffset -= justifyContentSpaceBetweenChildren(availableFreeSp
ace, style()->justifyContent(), numberOfChildrenForJustifyContent); |
| 1186 } | 1186 } |
| 1187 } | 1187 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 ASSERT(child); | 1275 ASSERT(child); |
| 1276 if (child->isOutOfFlowPositioned()) { | 1276 if (child->isOutOfFlowPositioned()) { |
| 1277 if (style()->flexWrap() == FlexWrapReverse) | 1277 if (style()->flexWrap() == FlexWrapReverse) |
| 1278 adjustAlignmentForChild(child, lineCrossAxisExtent); | 1278 adjustAlignmentForChild(child, lineCrossAxisExtent); |
| 1279 continue; | 1279 continue; |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 if (updateAutoMarginsInCrossAxis(child, std::max(LayoutUnit(0), avai
lableAlignmentSpaceForChild(lineCrossAxisExtent, child)))) | 1282 if (updateAutoMarginsInCrossAxis(child, std::max(LayoutUnit(0), avai
lableAlignmentSpaceForChild(lineCrossAxisExtent, child)))) |
| 1283 continue; | 1283 continue; |
| 1284 | 1284 |
| 1285 switch (alignmentForChild(child)) { | 1285 switch (alignmentForChild(*child)) { |
| 1286 case ItemPositionAuto: | 1286 case ItemPositionAuto: |
| 1287 ASSERT_NOT_REACHED(); | 1287 ASSERT_NOT_REACHED(); |
| 1288 break; | 1288 break; |
| 1289 case ItemPositionStretch: { | 1289 case ItemPositionStretch: { |
| 1290 applyStretchAlignmentToChild(child, lineCrossAxisExtent); | 1290 applyStretchAlignmentToChild(child, lineCrossAxisExtent); |
| 1291 // Since wrap-reverse flips cross start and cross end, strech ch
ildren should be aligned with the cross end. | 1291 // Since wrap-reverse flips cross start and cross end, strech ch
ildren should be aligned with the cross end. |
| 1292 if (style()->flexWrap() == FlexWrapReverse) | 1292 if (style()->flexWrap() == FlexWrapReverse) |
| 1293 adjustAlignmentForChild(child, availableAlignmentSpaceForChi
ld(lineCrossAxisExtent, child)); | 1293 adjustAlignmentForChild(child, availableAlignmentSpaceForChi
ld(lineCrossAxisExtent, child)); |
| 1294 break; | 1294 break; |
| 1295 } | 1295 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 if (style()->flexWrap() != FlexWrapReverse) | 1331 if (style()->flexWrap() != FlexWrapReverse) |
| 1332 return; | 1332 return; |
| 1333 | 1333 |
| 1334 // wrap-reverse flips the cross axis start and end. For baseline alignment,
this means we | 1334 // wrap-reverse flips the cross axis start and end. For baseline alignment,
this means we |
| 1335 // need to align the after edge of baseline elements with the after edge of
the flex line. | 1335 // need to align the after edge of baseline elements with the after edge of
the flex line. |
| 1336 child = m_orderIterator.first(); | 1336 child = m_orderIterator.first(); |
| 1337 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber)
{ | 1337 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber)
{ |
| 1338 LayoutUnit minMarginAfterBaseline = minMarginAfterBaselines[lineNumber]; | 1338 LayoutUnit minMarginAfterBaseline = minMarginAfterBaselines[lineNumber]; |
| 1339 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 1339 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
erOfChildren; ++childNumber, child = m_orderIterator.next()) { |
| 1340 ASSERT(child); | 1340 ASSERT(child); |
| 1341 if (alignmentForChild(child) == ItemPositionBaseline && !hasAutoMarg
insInCrossAxis(child) && minMarginAfterBaseline) | 1341 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMar
ginsInCrossAxis(child) && minMarginAfterBaseline) |
| 1342 adjustAlignmentForChild(child, minMarginAfterBaseline); | 1342 adjustAlignmentForChild(child, minMarginAfterBaseline); |
| 1343 } | 1343 } |
| 1344 } | 1344 } |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni
t lineCrossAxisExtent) | 1347 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUni
t lineCrossAxisExtent) |
| 1348 { | 1348 { |
| 1349 if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) { | 1349 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. | 1350 // FIXME: If the child has orthogonal flow, then it already has an overr
ide height set, so use it. |
| 1351 if (!hasOrthogonalFlow(child)) { | 1351 if (!hasOrthogonalFlow(*child)) { |
| 1352 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child->logicalHe
ight(); | 1352 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
*child) ? constrainedChildIntrinsicContentLogicalHeight(*child) : child->logical
Height(); |
| 1353 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); | 1353 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
leAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child); |
| 1354 ASSERT(!child->needsLayout()); | 1354 ASSERT(!child->needsLayout()); |
| 1355 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin
Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi
calHeight()); | 1355 LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMin
Max(stretchedLogicalHeight, heightBeforeStretching - child->borderAndPaddingLogi
calHeight()); |
| 1356 | 1356 |
| 1357 // FIXME: Can avoid laying out here in some cases. See https://webki
t.org/b/87905. | 1357 // FIXME: Can avoid laying out here in some cases. See https://webki
t.org/b/87905. |
| 1358 if (desiredLogicalHeight != child->logicalHeight()) { | 1358 if (desiredLogicalHeight != child->logicalHeight()) { |
| 1359 child->setOverrideLogicalContentHeight(desiredLogicalHeight - ch
ild->borderAndPaddingLogicalHeight()); | 1359 child->setOverrideLogicalContentHeight(desiredLogicalHeight - ch
ild->borderAndPaddingLogicalHeight()); |
| 1360 child->setLogicalHeight(0); | 1360 child->setLogicalHeight(0); |
| 1361 child->forceChildLayout(); | 1361 child->forceChildLayout(); |
| 1362 } | 1362 } |
| 1363 } | 1363 } |
| 1364 } else if (isColumnFlow() && child->style()->logicalWidth().isAuto()) { | 1364 } 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. | 1365 // FIXME: If the child doesn't have orthogonal flow, then it already has
an override width set, so use it. |
| 1366 if (hasOrthogonalFlow(child)) { | 1366 if (hasOrthogonalFlow(*child)) { |
| 1367 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent
- crossAxisMarginExtentForChild(child)); | 1367 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent
- crossAxisMarginExtentForChild(child)); |
| 1368 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW
idth, this); | 1368 childWidth = child->constrainLogicalWidthByMinMax(childWidth, childW
idth, this); |
| 1369 | 1369 |
| 1370 if (childWidth != child->logicalWidth()) { | 1370 if (childWidth != child->logicalWidth()) { |
| 1371 child->setOverrideLogicalContentWidth(childWidth - child->border
AndPaddingLogicalWidth()); | 1371 child->setOverrideLogicalContentWidth(childWidth - child->border
AndPaddingLogicalWidth()); |
| 1372 child->forceChildLayout(); | 1372 child->forceChildLayout(); |
| 1373 } | 1373 } |
| 1374 } | 1374 } |
| 1375 } | 1375 } |
| 1376 } | 1376 } |
| 1377 | 1377 |
| 1378 void RenderFlexibleBox::flipForRightToLeftColumn() | 1378 void RenderFlexibleBox::flipForRightToLeftColumn() |
| 1379 { | 1379 { |
| 1380 if (style()->isLeftToRightDirection() || !isColumnFlow()) | 1380 if (style()->isLeftToRightDirection() || !isColumnFlow()) |
| 1381 return; | 1381 return; |
| 1382 | 1382 |
| 1383 LayoutUnit crossExtent = crossAxisExtent(); | 1383 LayoutUnit crossExtent = crossAxisExtent(); |
| 1384 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { | 1384 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { |
| 1385 if (child->isOutOfFlowPositioned()) | 1385 if (child->isOutOfFlowPositioned()) |
| 1386 continue; | 1386 continue; |
| 1387 LayoutPoint location = flowAwareLocationForChild(child); | 1387 LayoutPoint location = flowAwareLocationForChild(child); |
| 1388 // For vertical flows, setFlowAwareLocationForChild will transpose x and
y, | 1388 // For vertical flows, setFlowAwareLocationForChild will transpose x and
y, |
| 1389 // so using the y axis for a column cross axis extent is correct. | 1389 // so using the y axis for a column cross axis extent is correct. |
| 1390 location.setY(crossExtent - crossAxisExtentForChild(child) - location.y(
)); | 1390 location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y
()); |
| 1391 setFlowAwareLocationForChild(child, location); | 1391 setFlowAwareLocationForChild(child, location); |
| 1392 } | 1392 } |
| 1393 } | 1393 } |
| 1394 | 1394 |
| 1395 void RenderFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex
ts, LayoutUnit crossAxisStartEdge) | 1395 void RenderFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex
ts, LayoutUnit crossAxisStartEdge) |
| 1396 { | 1396 { |
| 1397 LayoutUnit contentExtent = crossAxisContentExtent(); | 1397 LayoutUnit contentExtent = crossAxisContentExtent(); |
| 1398 RenderBox* child = m_orderIterator.first(); | 1398 RenderBox* child = m_orderIterator.first(); |
| 1399 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber)
{ | 1399 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber)
{ |
| 1400 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 1400 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb
erOfChildren; ++childNumber, child = m_orderIterator.next()) { |
| 1401 ASSERT(child); | 1401 ASSERT(child); |
| 1402 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1402 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
| 1403 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1403 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
| 1404 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1404 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
| 1405 adjustAlignmentForChild(child, newOffset - originalOffset); | 1405 adjustAlignmentForChild(child, newOffset - originalOffset); |
| 1406 } | 1406 } |
| 1407 } | 1407 } |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 } | 1410 } |
| OLD | NEW |