| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 public: | 131 public: |
| 132 ContentAlignmentData() {}; | 132 ContentAlignmentData() {}; |
| 133 ContentAlignmentData(LayoutUnit position, LayoutUnit distribution) | 133 ContentAlignmentData(LayoutUnit position, LayoutUnit distribution) |
| 134 : positionOffset(position) | 134 : positionOffset(position) |
| 135 , distributionOffset(distribution) | 135 , distributionOffset(distribution) |
| 136 { | 136 { |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool isValid() { return positionOffset >= 0 && distributionOffset >= 0; } | 139 bool isValid() { return positionOffset >= 0 && distributionOffset >= 0; } |
| 140 | 140 |
| 141 LayoutUnit positionOffset = -1; | 141 LayoutUnit positionOffset = LayoutUnit(-1); |
| 142 LayoutUnit distributionOffset = -1; | 142 LayoutUnit distributionOffset = LayoutUnit(-1); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 enum TrackSizeRestriction { | 145 enum TrackSizeRestriction { |
| 146 AllowInfinity, | 146 AllowInfinity, |
| 147 ForbidInfinity, | 147 ForbidInfinity, |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 class LayoutGrid::GridIterator { | 150 class LayoutGrid::GridIterator { |
| 151 WTF_MAKE_NONCOPYABLE(GridIterator); | 151 WTF_MAKE_NONCOPYABLE(GridIterator); |
| 152 public: | 152 public: |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return; | 344 return; |
| 345 | 345 |
| 346 { | 346 { |
| 347 // LayoutState needs this deliberate scope to pop before updating scroll
information (which | 347 // LayoutState needs this deliberate scope to pop before updating scroll
information (which |
| 348 // may trigger relayout). | 348 // may trigger relayout). |
| 349 LayoutState state(*this, locationOffset()); | 349 LayoutState state(*this, locationOffset()); |
| 350 | 350 |
| 351 LayoutSize previousSize = size(); | 351 LayoutSize previousSize = size(); |
| 352 | 352 |
| 353 updateLogicalWidth(); | 353 updateLogicalWidth(); |
| 354 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref
erredSize, style()->logicalHeight(), -1) == -1; | 354 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref
erredSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1); |
| 355 | 355 |
| 356 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); | 356 TextAutosizer::LayoutScope textAutosizerLayoutScope(this); |
| 357 | 357 |
| 358 placeItemsOnGrid(); | 358 placeItemsOnGrid(); |
| 359 | 359 |
| 360 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 360 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 361 | 361 |
| 362 // At this point the logical width is always definite as the above call
to updateLogicalWidth() | 362 // At this point the logical width is always definite as the above call
to updateLogicalWidth() |
| 363 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code | 363 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code |
| 364 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve | 364 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 updateScrollInfoAfterLayout(); | 400 updateScrollInfoAfterLayout(); |
| 401 | 401 |
| 402 clearNeedsLayout(); | 402 clearNeedsLayout(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t sp
an) const | 405 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, size_t sp
an) const |
| 406 { | 406 { |
| 407 ASSERT(span >= 1); | 407 ASSERT(span >= 1); |
| 408 | 408 |
| 409 if (span == 1) | 409 if (span == 1) |
| 410 return 0; | 410 return LayoutUnit(); |
| 411 | 411 |
| 412 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap(
) : styleRef().gridRowGap(); | 412 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap(
) : styleRef().gridRowGap(); |
| 413 return valueForLength(trackGap, 0) * (span - 1); | 413 return valueForLength(trackGap, LayoutUnit()) * (span - 1); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const | 416 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const |
| 417 { | 417 { |
| 418 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | 418 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); |
| 419 | 419 |
| 420 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 420 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 421 sizingData.freeSpaceForDirection(ForColumns) = 0; | 421 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); |
| 422 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si
zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite); | 422 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si
zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite); |
| 423 | 423 |
| 424 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack
s.size()); | 424 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack
s.size()); |
| 425 minLogicalWidth += totalGuttersSize; | 425 minLogicalWidth += totalGuttersSize; |
| 426 maxLogicalWidth += totalGuttersSize; | 426 maxLogicalWidth += totalGuttersSize; |
| 427 | 427 |
| 428 LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth(); | 428 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); |
| 429 minLogicalWidth += scrollbarWidth; | 429 minLogicalWidth += scrollbarWidth; |
| 430 maxLogicalWidth += scrollbarWidth; | 430 maxLogicalWidth += scrollbarWidth; |
| 431 } | 431 } |
| 432 | 432 |
| 433 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) | 433 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) |
| 434 { | 434 { |
| 435 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); | 435 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); |
| 436 sizingData.freeSpaceForDirection(ForRows) = 0; | 436 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); |
| 437 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma
xContentHeight, AvailableSpaceIndefinite); | 437 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma
xContentHeight, AvailableSpaceIndefinite); |
| 438 | 438 |
| 439 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); | 439 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); |
| 440 m_minContentHeight += totalGuttersSize; | 440 m_minContentHeight += totalGuttersSize; |
| 441 m_maxContentHeight += totalGuttersSize; | 441 m_maxContentHeight += totalGuttersSize; |
| 442 | 442 |
| 443 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); | 443 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); |
| 444 } | 444 } |
| 445 | 445 |
| 446 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l
ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi
ng) const | 446 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l
ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi
ng) const |
| 447 { | 447 { |
| 448 if (logicalHeightLength.isMinContent()) | 448 if (logicalHeightLength.isMinContent()) |
| 449 return m_minContentHeight; | 449 return m_minContentHeight; |
| 450 | 450 |
| 451 if (logicalHeightLength.isMaxContent()) | 451 if (logicalHeightLength.isMaxContent()) |
| 452 return m_maxContentHeight; | 452 return m_maxContentHeight; |
| 453 | 453 |
| 454 if (logicalHeightLength.isFitContent()) { | 454 if (logicalHeightLength.isFitContent()) { |
| 455 if (m_minContentHeight == -1 || m_maxContentHeight == -1) | 455 if (m_minContentHeight == -1 || m_maxContentHeight == -1) |
| 456 return -1; | 456 return LayoutUnit(-1); |
| 457 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); | 457 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); |
| 458 return std::min<LayoutUnit>(m_maxContentHeight, std::max(m_minContentHei
ght, fillAvailableExtent)); | 458 return std::min<LayoutUnit>(m_maxContentHeight, std::max(m_minContentHei
ght, fillAvailableExtent)); |
| 459 } | 459 } |
| 460 | 460 |
| 461 if (logicalHeightLength.isFillAvailable()) | 461 if (logicalHeightLength.isFillAvailable()) |
| 462 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; | 462 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; |
| 463 ASSERT_NOT_REACHED(); | 463 ASSERT_NOT_REACHED(); |
| 464 return 0; | 464 return LayoutUnit(); |
| 465 } | 465 } |
| 466 | 466 |
| 467 static inline double normalizedFlexFraction(const GridTrack& track, double flexF
actor) | 467 static inline double normalizedFlexFraction(const GridTrack& track, double flexF
actor) |
| 468 { | 468 { |
| 469 return track.baseSize() / std::max<double>(1, flexFactor); | 469 return track.baseSize() / std::max<double>(1, flexFactor); |
| 470 } | 470 } |
| 471 | 471 |
| 472 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout
Unit& growthLimitsWithoutMaximization, AvailableSpaceType availableSpaceType) | 472 void LayoutGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi
on, GridSizingData& sizingData, LayoutUnit& baseSizesWithoutMaximization, Layout
Unit& growthLimitsWithoutMaximization, AvailableSpaceType availableSpaceType) |
| 473 { | 473 { |
| 474 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); | 474 LayoutUnit& freeSpace = sizingData.freeSpaceForDirection(direction); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 492 if (trackSize.isContentSized()) | 492 if (trackSize.isContentSized()) |
| 493 sizingData.contentSizedTracksIndex.append(i); | 493 sizingData.contentSizedTracksIndex.append(i); |
| 494 if (trackSize.maxTrackBreadth().isFlex()) | 494 if (trackSize.maxTrackBreadth().isFlex()) |
| 495 flexibleSizedTracksIndex.append(i); | 495 flexibleSizedTracksIndex.append(i); |
| 496 } | 496 } |
| 497 | 497 |
| 498 // 2. Resolve content-based TrackSizingFunctions. | 498 // 2. Resolve content-based TrackSizingFunctions. |
| 499 if (!sizingData.contentSizedTracksIndex.isEmpty()) | 499 if (!sizingData.contentSizedTracksIndex.isEmpty()) |
| 500 resolveContentBasedTrackSizingFunctions(direction, sizingData); | 500 resolveContentBasedTrackSizingFunctions(direction, sizingData); |
| 501 | 501 |
| 502 baseSizesWithoutMaximization = growthLimitsWithoutMaximization = 0; | 502 baseSizesWithoutMaximization = growthLimitsWithoutMaximization = LayoutUnit(
); |
| 503 | 503 |
| 504 for (const auto& track: tracks) { | 504 for (const auto& track: tracks) { |
| 505 ASSERT(!track.infiniteGrowthPotential()); | 505 ASSERT(!track.infiniteGrowthPotential()); |
| 506 baseSizesWithoutMaximization += track.baseSize(); | 506 baseSizesWithoutMaximization += track.baseSize(); |
| 507 growthLimitsWithoutMaximization += track.growthLimit(); | 507 growthLimitsWithoutMaximization += track.growthLimit(); |
| 508 } | 508 } |
| 509 freeSpace = initialFreeSpace - baseSizesWithoutMaximization; | 509 freeSpace = initialFreeSpace - baseSizesWithoutMaximization; |
| 510 | 510 |
| 511 bool hasDefiniteFreeSpace = availableSpaceType == AvailableSpaceDefinite; | 511 bool hasDefiniteFreeSpace = availableSpaceType == AvailableSpaceDefinite; |
| 512 if (hasDefiniteFreeSpace && freeSpace <= 0) | 512 if (hasDefiniteFreeSpace && freeSpace <= 0) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 566 |
| 567 baseSizesWithoutMaximization += increment; | 567 baseSizesWithoutMaximization += increment; |
| 568 growthLimitsWithoutMaximization += increment; | 568 growthLimitsWithoutMaximization += increment; |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 | 572 |
| 573 LayoutUnit LayoutGrid::computeUsedBreadthOfMinLength(const GridLength& gridLengt
h, LayoutUnit maxSize) const | 573 LayoutUnit LayoutGrid::computeUsedBreadthOfMinLength(const GridLength& gridLengt
h, LayoutUnit maxSize) const |
| 574 { | 574 { |
| 575 if (gridLength.isFlex()) | 575 if (gridLength.isFlex()) |
| 576 return 0; | 576 return LayoutUnit(); |
| 577 | 577 |
| 578 const Length& trackLength = gridLength.length(); | 578 const Length& trackLength = gridLength.length(); |
| 579 if (trackLength.isSpecified()) | 579 if (trackLength.isSpecified()) |
| 580 return valueForLength(trackLength, maxSize); | 580 return valueForLength(trackLength, maxSize); |
| 581 | 581 |
| 582 ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isM
axContent()); | 582 ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isM
axContent()); |
| 583 return 0; | 583 return LayoutUnit(); |
| 584 } | 584 } |
| 585 | 585 |
| 586 LayoutUnit LayoutGrid::computeUsedBreadthOfMaxLength(const GridLength& gridLengt
h, LayoutUnit usedBreadth, LayoutUnit maxSize) const | 586 LayoutUnit LayoutGrid::computeUsedBreadthOfMaxLength(const GridLength& gridLengt
h, LayoutUnit usedBreadth, LayoutUnit maxSize) const |
| 587 { | 587 { |
| 588 if (gridLength.isFlex()) | 588 if (gridLength.isFlex()) |
| 589 return usedBreadth; | 589 return usedBreadth; |
| 590 | 590 |
| 591 const Length& trackLength = gridLength.length(); | 591 const Length& trackLength = gridLength.length(); |
| 592 if (trackLength.isSpecified()) | 592 if (trackLength.isSpecified()) |
| 593 return valueForLength(trackLength, maxSize); | 593 return valueForLength(trackLength, maxSize); |
| 594 | 594 |
| 595 ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isM
axContent()); | 595 ASSERT(trackLength.isMinContent() || trackLength.isAuto() || trackLength.isM
axContent()); |
| 596 return infinity; | 596 return LayoutUnit(infinity); |
| 597 } | 597 } |
| 598 | 598 |
| 599 double LayoutGrid::computeFlexFactorUnitSize(const Vector<GridTrack>& tracks, Gr
idTrackSizingDirection direction, double flexFactorSum, LayoutUnit& leftOverSpac
e, const Vector<size_t, 8>& flexibleTracksIndexes, PassOwnPtr<TrackIndexSet> tra
cksToTreatAsInflexible) const | 599 double LayoutGrid::computeFlexFactorUnitSize(const Vector<GridTrack>& tracks, Gr
idTrackSizingDirection direction, double flexFactorSum, LayoutUnit& leftOverSpac
e, const Vector<size_t, 8>& flexibleTracksIndexes, PassOwnPtr<TrackIndexSet> tra
cksToTreatAsInflexible) const |
| 600 { | 600 { |
| 601 // We want to avoid the effect of flex factors sum below 1 making the factor
unit size to grow exponentially. | 601 // We want to avoid the effect of flex factors sum below 1 making the factor
unit size to grow exponentially. |
| 602 double hypotheticalFactorUnitSize = leftOverSpace / std::max<double>(1, flex
FactorSum); | 602 double hypotheticalFactorUnitSize = leftOverSpace / std::max<double>(1, flex
FactorSum); |
| 603 | 603 |
| 604 // product of the hypothetical "flex factor unit" and any flexible track's "
flex factor" must be grater than such track's "base size". | 604 // product of the hypothetical "flex factor unit" and any flexible track's "
flex factor" must be grater than such track's "base size". |
| 605 OwnPtr<TrackIndexSet> additionalTracksToTreatAsInflexible = tracksToTreatAsI
nflexible; | 605 OwnPtr<TrackIndexSet> additionalTracksToTreatAsInflexible = tracksToTreatAsI
nflexible; |
| 606 bool validFlexFactorUnit = true; | 606 bool validFlexFactorUnit = true; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 687 |
| 688 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); | 688 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); |
| 689 // We need to clear the stretched height to properly compute logical height
during layout. | 689 // We need to clear the stretched height to properly compute logical height
during layout. |
| 690 if (hasOverrideHeight && child.needsLayout()) | 690 if (hasOverrideHeight && child.needsLayout()) |
| 691 child.clearOverrideLogicalContentHeight(); | 691 child.clearOverrideLogicalContentHeight(); |
| 692 | 692 |
| 693 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); | 693 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); |
| 694 // If |child| has a relative logical height, we shouldn't let it override it
s intrinsic height, which is | 694 // If |child| has a relative logical height, we shouldn't let it override it
s intrinsic height, which is |
| 695 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). | 695 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). |
| 696 if (child.hasRelativeLogicalHeight()) | 696 if (child.hasRelativeLogicalHeight()) |
| 697 child.setOverrideContainingBlockContentLogicalHeight(-1); | 697 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); |
| 698 child.layoutIfNeeded(); | 698 child.layoutIfNeeded(); |
| 699 // If the child was stretched we should use its intrinsic height. | 699 // If the child was stretched we should use its intrinsic height. |
| 700 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh
t()) + child.marginLogicalHeight(); | 700 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh
t()) + child.marginLogicalHeight(); |
| 701 } | 701 } |
| 702 | 702 |
| 703 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio
n direction, Vector<GridTrack>& columnTracks) | 703 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio
n direction, Vector<GridTrack>& columnTracks) |
| 704 { | 704 { |
| 705 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 705 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 706 // TODO(svillar): Properly support orthogonal writing mode. | 706 // TODO(svillar): Properly support orthogonal writing mode. |
| 707 if (hasOrthogonalWritingMode) | 707 if (hasOrthogonalWritingMode) |
| 708 return LayoutUnit(); | 708 return LayoutUnit(); |
| 709 | 709 |
| 710 const Length& childMinSize = direction == ForColumns ? child.style()->logica
lMinWidth() : child.style()->logicalMinHeight(); | 710 const Length& childMinSize = direction == ForColumns ? child.style()->logica
lMinWidth() : child.style()->logicalMinHeight(); |
| 711 if (childMinSize.isAuto()) { | 711 if (childMinSize.isAuto()) { |
| 712 // TODO(svillar): Implement intrinsic aspect ratio support (transferred
size in specs). | 712 // TODO(svillar): Implement intrinsic aspect ratio support (transferred
size in specs). |
| 713 return minContentForChild(child, direction, columnTracks); | 713 return minContentForChild(child, direction, columnTracks); |
| 714 } | 714 } |
| 715 | 715 |
| 716 if (direction == ForColumns) | 716 if (direction == ForColumns) |
| 717 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi
calWidth(), this); | 717 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi
calWidth(), this); |
| 718 | 718 |
| 719 return child.computeContentLogicalHeight(MinSize, childMinSize, child.logica
lHeight()) + child.scrollbarLogicalHeight(); | 719 return child.computeContentLogicalHeight(MinSize, childMinSize, child.logica
lHeight()) + child.scrollbarLogicalHeight(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 722 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
| 723 { | 723 { |
| 724 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 724 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 725 // FIXME: Properly support orthogonal writing mode. | 725 // FIXME: Properly support orthogonal writing mode. |
| 726 if (hasOrthogonalWritingMode) | 726 if (hasOrthogonalWritingMode) |
| 727 return 0; | 727 return LayoutUnit(); |
| 728 | 728 |
| 729 if (direction == ForColumns) { | 729 if (direction == ForColumns) { |
| 730 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is | 730 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is |
| 731 // what we are interested in here. Thus we need to set the override logi
cal width to -1 (no possible resolution). | 731 // what we are interested in here. Thus we need to set the override logi
cal width to -1 (no possible resolution). |
| 732 if (child.hasRelativeLogicalWidth()) | 732 if (child.hasRelativeLogicalWidth()) |
| 733 child.setOverrideContainingBlockContentLogicalWidth(-1); | 733 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
| 734 | 734 |
| 735 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 735 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
| 736 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 736 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 737 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); | 737 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); |
| 738 } | 738 } |
| 739 | 739 |
| 740 return logicalHeightForChild(child, columnTracks); | 740 return logicalHeightForChild(child, columnTracks); |
| 741 } | 741 } |
| 742 | 742 |
| 743 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 743 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
| 744 { | 744 { |
| 745 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 745 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 746 // FIXME: Properly support orthogonal writing mode. | 746 // FIXME: Properly support orthogonal writing mode. |
| 747 if (hasOrthogonalWritingMode) | 747 if (hasOrthogonalWritingMode) |
| 748 return LayoutUnit(); | 748 return LayoutUnit(); |
| 749 | 749 |
| 750 if (direction == ForColumns) { | 750 if (direction == ForColumns) { |
| 751 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is | 751 // If |child| has a relative logical width, we shouldn't let it override
its intrinsic width, which is |
| 752 // what we are interested in here. Thus we need to set the override logi
cal width to -1 (no possible resolution). | 752 // what we are interested in here. Thus we need to set the override logi
cal width to -1 (no possible resolution). |
| 753 if (child.hasRelativeLogicalWidth()) | 753 if (child.hasRelativeLogicalWidth()) |
| 754 child.setOverrideContainingBlockContentLogicalWidth(-1); | 754 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); |
| 755 | 755 |
| 756 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 756 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
| 757 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 757 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 758 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); | 758 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); |
| 759 } | 759 } |
| 760 | 760 |
| 761 return logicalHeightForChild(child, columnTracks); | 761 return logicalHeightForChild(child, columnTracks); |
| 762 } | 762 } |
| 763 | 763 |
| 764 // We're basically using a class instead of a std::pair because of accessing gri
dItem() or gridSpan() is much more | 764 // We're basically using a class instead of a std::pair because of accessing gri
dItem() or gridSpan() is much more |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 case ResolveIntrinsicMinimums: | 962 case ResolveIntrinsicMinimums: |
| 963 return minSizeForChild(gridItem, direction, columnTracks); | 963 return minSizeForChild(gridItem, direction, columnTracks); |
| 964 case ResolveContentBasedMinimums: | 964 case ResolveContentBasedMinimums: |
| 965 case ResolveIntrinsicMaximums: | 965 case ResolveIntrinsicMaximums: |
| 966 return minContentForChild(gridItem, direction, columnTracks); | 966 return minContentForChild(gridItem, direction, columnTracks); |
| 967 case ResolveMaxContentMinimums: | 967 case ResolveMaxContentMinimums: |
| 968 case ResolveMaxContentMaximums: | 968 case ResolveMaxContentMaximums: |
| 969 return maxContentForChild(gridItem, direction, columnTracks); | 969 return maxContentForChild(gridItem, direction, columnTracks); |
| 970 case MaximizeTracks: | 970 case MaximizeTracks: |
| 971 ASSERT_NOT_REACHED(); | 971 ASSERT_NOT_REACHED(); |
| 972 return 0; | 972 return LayoutUnit(); |
| 973 } | 973 } |
| 974 | 974 |
| 975 ASSERT_NOT_REACHED(); | 975 ASSERT_NOT_REACHED(); |
| 976 return 0; | 976 return LayoutUnit(); |
| 977 } | 977 } |
| 978 | 978 |
| 979 template <TrackSizeComputationPhase phase> | 979 template <TrackSizeComputationPhase phase> |
| 980 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing
Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange&
gridItemsWithSpan) | 980 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing
Direction direction, GridSizingData& sizingData, const GridItemsSpanGroupRange&
gridItemsWithSpan) |
| 981 { | 981 { |
| 982 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; | 982 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra
cks : sizingData.rowTracks; |
| 983 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 983 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 984 GridTrack& track = tracks[trackIndex]; | 984 GridTrack& track = tracks[trackIndex]; |
| 985 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track,
AllowInfinity)); | 985 track.setPlannedSize(trackSizeForTrackSizeComputationPhase(phase, track,
AllowInfinity)); |
| 986 } | 986 } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 unsigned numberOfAutoSizedTracks = autoSizedTracksIndex.size(); | 1381 unsigned numberOfAutoSizedTracks = autoSizedTracksIndex.size(); |
| 1382 if (numberOfAutoSizedTracks < 1) | 1382 if (numberOfAutoSizedTracks < 1) |
| 1383 return; | 1383 return; |
| 1384 | 1384 |
| 1385 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks; | 1385 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks; |
| 1386 for (const auto& trackIndex : autoSizedTracksIndex) { | 1386 for (const auto& trackIndex : autoSizedTracksIndex) { |
| 1387 GridTrack* track = tracks.data() + trackIndex; | 1387 GridTrack* track = tracks.data() + trackIndex; |
| 1388 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; | 1388 LayoutUnit baseSize = track->baseSize() + sizeToIncrease; |
| 1389 track->setBaseSize(baseSize); | 1389 track->setBaseSize(baseSize); |
| 1390 } | 1390 } |
| 1391 availableSpace = 0; | 1391 availableSpace = LayoutUnit(); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) | 1394 void LayoutGrid::layoutGridItems(GridSizingData& sizingData) |
| 1395 { | 1395 { |
| 1396 populateGridPositions(sizingData); | 1396 populateGridPositions(sizingData); |
| 1397 m_gridItemsOverflowingGridArea.resize(0); | 1397 m_gridItemsOverflowingGridArea.resize(0); |
| 1398 | 1398 |
| 1399 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1399 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
| 1400 if (child->isOutOfFlowPositioned()) { | 1400 if (child->isOutOfFlowPositioned()) { |
| 1401 prepareChildForPositionedLayout(*child); | 1401 prepareChildForPositionedLayout(*child); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 return offset.clampNegativeToZero(); | 1624 return offset.clampNegativeToZero(); |
| 1625 case OverflowAlignmentUnsafe: | 1625 case OverflowAlignmentUnsafe: |
| 1626 case OverflowAlignmentDefault: | 1626 case OverflowAlignmentDefault: |
| 1627 // If we overflow our alignment container and overflow is 'true' (defaul
t), we | 1627 // If we overflow our alignment container and overflow is 'true' (defaul
t), we |
| 1628 // ignore the overflow and just return the value regardless (which may c
ause data | 1628 // ignore the overflow and just return the value regardless (which may c
ause data |
| 1629 // loss as we overflow the 'start' edge). | 1629 // loss as we overflow the 'start' edge). |
| 1630 return offset; | 1630 return offset; |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 ASSERT_NOT_REACHED(); | 1633 ASSERT_NOT_REACHED(); |
| 1634 return 0; | 1634 return LayoutUnit(); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) | 1637 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) |
| 1638 { | 1638 { |
| 1639 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); | 1639 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); |
| 1640 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); | 1640 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
| 1641 } | 1641 } |
| 1642 | 1642 |
| 1643 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | 1643 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. |
| 1644 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const | 1644 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1673 | 1673 |
| 1674 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | 1674 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. |
| 1675 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const | 1675 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const |
| 1676 { | 1676 { |
| 1677 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); | 1677 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child
) const | 1680 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child
) const |
| 1681 { | 1681 { |
| 1682 if (!child.styleRef().hasMargin()) | 1682 if (!child.styleRef().hasMargin()) |
| 1683 return 0; | 1683 return LayoutUnit(); |
| 1684 | 1684 |
| 1685 LayoutUnit marginBefore; | 1685 LayoutUnit marginBefore; |
| 1686 LayoutUnit marginAfter; | 1686 LayoutUnit marginAfter; |
| 1687 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock
LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, | 1687 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock
LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, |
| 1688 child.style()->marginBeforeUsing(style()), | 1688 child.style()->marginBeforeUsing(style()), |
| 1689 child.style()->marginAfterUsing(style())); | 1689 child.style()->marginAfterUsing(style())); |
| 1690 | 1690 |
| 1691 return marginBefore + marginAfter; | 1691 return marginBefore + marginAfter; |
| 1692 } | 1692 } |
| 1693 | 1693 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1708 | 1708 |
| 1709 auto& childStyle = child.styleRef(); | 1709 auto& childStyle = child.styleRef(); |
| 1710 bool isHorizontalMode = isHorizontalWritingMode(); | 1710 bool isHorizontalMode = isHorizontalWritingMode(); |
| 1711 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto
() : childStyle.width().isAuto(); | 1711 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto
() : childStyle.width().isAuto(); |
| 1712 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil
dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style
()).isAuto(); | 1712 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil
dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style
()).isAuto(); |
| 1713 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment(
styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { | 1713 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment(
styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { |
| 1714 // TODO (lajava): If the child has orthogonal flow, then it already has
an override height set, so use it. | 1714 // TODO (lajava): If the child has orthogonal flow, then it already has
an override height set, so use it. |
| 1715 // TODO (lajava): grid track sizing and positioning do not support ortho
gonal modes yet. | 1715 // TODO (lajava): grid track sizing and positioning do not support ortho
gonal modes yet. |
| 1716 if (child.isHorizontalWritingMode() == isHorizontalMode) { | 1716 if (child.isHorizontalWritingMode() == isHorizontalMode) { |
| 1717 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB
eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); | 1717 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB
eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); |
| 1718 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, -1); | 1718 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, LayoutUnit(-1)); |
| 1719 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); | 1719 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); |
| 1720 if (desiredLogicalHeight != child.logicalHeight()) { | 1720 if (desiredLogicalHeight != child.logicalHeight()) { |
| 1721 // TODO (lajava): Can avoid laying out here in some cases. See h
ttps://webkit.org/b/87905. | 1721 // TODO (lajava): Can avoid laying out here in some cases. See h
ttps://webkit.org/b/87905. |
| 1722 child.setLogicalHeight(0); | 1722 child.setLogicalHeight(0); |
| 1723 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1723 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 1724 } | 1724 } |
| 1725 } | 1725 } |
| 1726 } | 1726 } |
| 1727 } | 1727 } |
| 1728 | 1728 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 endOfRow -= guttersSize(ForRows, 2); | 1904 endOfRow -= guttersSize(ForRows, 2); |
| 1905 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); | 1905 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); |
| 1906 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) | 1906 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) |
| 1907 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution(
), m_rowPositions, childBreadth); | 1907 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution(
), m_rowPositions, childBreadth); |
| 1908 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); | 1908 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); |
| 1909 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1909 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
| 1910 } | 1910 } |
| 1911 } | 1911 } |
| 1912 | 1912 |
| 1913 ASSERT_NOT_REACHED(); | 1913 ASSERT_NOT_REACHED(); |
| 1914 return 0; | 1914 return LayoutUnit(); |
| 1915 } | 1915 } |
| 1916 | 1916 |
| 1917 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const | 1917 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const |
| 1918 { | 1918 { |
| 1919 const GridSpan& columnsSpan = cachedGridSpan(child, ForColumns); | 1919 const GridSpan& columnsSpan = cachedGridSpan(child, ForColumns); |
| 1920 size_t childStartLine = columnsSpan.resolvedInitialPosition(); | 1920 size_t childStartLine = columnsSpan.resolvedInitialPosition(); |
| 1921 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; | 1921 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; |
| 1922 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); | 1922 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
| 1923 if (hasAutoMarginsInRowAxis(child)) | 1923 if (hasAutoMarginsInRowAxis(child)) |
| 1924 return startPosition; | 1924 return startPosition; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1936 endOfColumn -= guttersSize(ForRows, 2); | 1936 endOfColumn -= guttersSize(ForRows, 2); |
| 1937 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); | 1937 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); |
| 1938 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) | 1938 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) |
| 1939 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu
tion(), m_columnPositions, childBreadth); | 1939 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu
tion(), m_columnPositions, childBreadth); |
| 1940 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); | 1940 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); |
| 1941 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1941 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
| 1942 } | 1942 } |
| 1943 } | 1943 } |
| 1944 | 1944 |
| 1945 ASSERT_NOT_REACHED(); | 1945 ASSERT_NOT_REACHED(); |
| 1946 return 0; | 1946 return LayoutUnit(); |
| 1947 } | 1947 } |
| 1948 | 1948 |
| 1949 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) | 1949 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) |
| 1950 { | 1950 { |
| 1951 switch (distribution) { | 1951 switch (distribution) { |
| 1952 case ContentDistributionSpaceBetween: | 1952 case ContentDistributionSpaceBetween: |
| 1953 return ContentPositionStart; | 1953 return ContentPositionStart; |
| 1954 case ContentDistributionSpaceAround: | 1954 case ContentDistributionSpaceAround: |
| 1955 return ContentPositionCenter; | 1955 return ContentPositionCenter; |
| 1956 case ContentDistributionSpaceEvenly: | 1956 case ContentDistributionSpaceEvenly: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1982 fallbackPosition = resolveContentDistributionFallback(distribution); | 1982 fallbackPosition = resolveContentDistributionFallback(distribution); |
| 1983 | 1983 |
| 1984 if (availableFreeSpace <= 0) | 1984 if (availableFreeSpace <= 0) |
| 1985 return {}; | 1985 return {}; |
| 1986 | 1986 |
| 1987 LayoutUnit distributionOffset; | 1987 LayoutUnit distributionOffset; |
| 1988 switch (distribution) { | 1988 switch (distribution) { |
| 1989 case ContentDistributionSpaceBetween: | 1989 case ContentDistributionSpaceBetween: |
| 1990 if (numberOfGridTracks < 2) | 1990 if (numberOfGridTracks < 2) |
| 1991 return {}; | 1991 return {}; |
| 1992 return {0, availableFreeSpace / (numberOfGridTracks - 1)}; | 1992 return {LayoutUnit(), availableFreeSpace / (numberOfGridTracks - 1)}; |
| 1993 case ContentDistributionSpaceAround: | 1993 case ContentDistributionSpaceAround: |
| 1994 if (numberOfGridTracks < 1) | 1994 if (numberOfGridTracks < 1) |
| 1995 return {}; | 1995 return {}; |
| 1996 distributionOffset = availableFreeSpace / numberOfGridTracks; | 1996 distributionOffset = availableFreeSpace / numberOfGridTracks; |
| 1997 return {distributionOffset / 2, distributionOffset}; | 1997 return {distributionOffset / 2, distributionOffset}; |
| 1998 case ContentDistributionSpaceEvenly: | 1998 case ContentDistributionSpaceEvenly: |
| 1999 distributionOffset = availableFreeSpace / (numberOfGridTracks + 1); | 1999 distributionOffset = availableFreeSpace / (numberOfGridTracks + 1); |
| 2000 return {distributionOffset, distributionOffset}; | 2000 return {distributionOffset, distributionOffset}; |
| 2001 case ContentDistributionStretch: | 2001 case ContentDistributionStretch: |
| 2002 return {0, 0}; | 2002 return {LayoutUnit(), LayoutUnit()}; |
| 2003 case ContentDistributionDefault: | 2003 case ContentDistributionDefault: |
| 2004 return {}; | 2004 return {}; |
| 2005 } | 2005 } |
| 2006 | 2006 |
| 2007 ASSERT_NOT_REACHED(); | 2007 ASSERT_NOT_REACHED(); |
| 2008 return {}; | 2008 return {}; |
| 2009 } | 2009 } |
| 2010 | 2010 |
| 2011 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const | 2011 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const |
| 2012 { | 2012 { |
| 2013 bool isRowAxis = direction == ForColumns; | 2013 bool isRowAxis = direction == ForColumns; |
| 2014 ContentPosition position = isRowAxis ? styleRef().justifyContentPosition() :
styleRef().alignContentPosition(); | 2014 ContentPosition position = isRowAxis ? styleRef().justifyContentPosition() :
styleRef().alignContentPosition(); |
| 2015 ContentDistributionType distribution = isRowAxis ? styleRef().justifyContent
Distribution() : styleRef().alignContentDistribution(); | 2015 ContentDistributionType distribution = isRowAxis ? styleRef().justifyContent
Distribution() : styleRef().alignContentDistribution(); |
| 2016 // If <content-distribution> value can't be applied, 'position' will become
the associated | 2016 // If <content-distribution> value can't be applied, 'position' will become
the associated |
| 2017 // <content-position> fallback value. | 2017 // <content-position> fallback value. |
| 2018 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); | 2018 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); |
| 2019 if (contentAlignment.isValid()) | 2019 if (contentAlignment.isValid()) |
| 2020 return contentAlignment; | 2020 return contentAlignment; |
| 2021 | 2021 |
| 2022 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); | 2022 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); |
| 2023 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) | 2023 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) |
| 2024 return {0, 0}; | 2024 return {LayoutUnit(), LayoutUnit()}; |
| 2025 | 2025 |
| 2026 switch (position) { | 2026 switch (position) { |
| 2027 case ContentPositionLeft: | 2027 case ContentPositionLeft: |
| 2028 // The align-content's axis is always orthogonal to the inline-axis. | 2028 // The align-content's axis is always orthogonal to the inline-axis. |
| 2029 return {0, 0}; | 2029 return {LayoutUnit(), LayoutUnit()}; |
| 2030 case ContentPositionRight: | 2030 case ContentPositionRight: |
| 2031 if (isRowAxis) | 2031 if (isRowAxis) |
| 2032 return {availableFreeSpace, 0}; | 2032 return {availableFreeSpace, LayoutUnit()}; |
| 2033 // The align-content's axis is always orthogonal to the inline-axis. | 2033 // The align-content's axis is always orthogonal to the inline-axis. |
| 2034 return {0, 0}; | 2034 return {LayoutUnit(), LayoutUnit()}; |
| 2035 case ContentPositionCenter: | 2035 case ContentPositionCenter: |
| 2036 return {availableFreeSpace / 2, 0}; | 2036 return {availableFreeSpace / 2, LayoutUnit()}; |
| 2037 case ContentPositionFlexEnd: // Only used in flex layout, for other layout,
it's equivalent to 'End'. | 2037 case ContentPositionFlexEnd: // Only used in flex layout, for other layout,
it's equivalent to 'End'. |
| 2038 case ContentPositionEnd: | 2038 case ContentPositionEnd: |
| 2039 if (isRowAxis) | 2039 if (isRowAxis) |
| 2040 return {offsetToEndEdge(styleRef().isLeftToRightDirection(), availab
leFreeSpace), 0}; | 2040 return {offsetToEndEdge(styleRef().isLeftToRightDirection(), availab
leFreeSpace), LayoutUnit()}; |
| 2041 return {availableFreeSpace, 0}; | 2041 return {availableFreeSpace, LayoutUnit()}; |
| 2042 case ContentPositionFlexStart: // Only used in flex layout, for other layout
, it's equivalent to 'Start'. | 2042 case ContentPositionFlexStart: // Only used in flex layout, for other layout
, it's equivalent to 'Start'. |
| 2043 case ContentPositionStart: | 2043 case ContentPositionStart: |
| 2044 if (isRowAxis) | 2044 if (isRowAxis) |
| 2045 return {offsetToStartEdge(styleRef().isLeftToRightDirection(), avail
ableFreeSpace), 0}; | 2045 return {offsetToStartEdge(styleRef().isLeftToRightDirection(), avail
ableFreeSpace), LayoutUnit()}; |
| 2046 return {0, 0}; | 2046 return {LayoutUnit(), LayoutUnit()}; |
| 2047 case ContentPositionBaseline: | 2047 case ContentPositionBaseline: |
| 2048 case ContentPositionLastBaseline: | 2048 case ContentPositionLastBaseline: |
| 2049 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. | 2049 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
| 2050 // crbug.com/234191 | 2050 // crbug.com/234191 |
| 2051 if (isRowAxis) | 2051 if (isRowAxis) |
| 2052 return {offsetToStartEdge(styleRef().isLeftToRightDirection(), avail
ableFreeSpace), 0}; | 2052 return {offsetToStartEdge(styleRef().isLeftToRightDirection(), avail
ableFreeSpace), LayoutUnit()}; |
| 2053 return {0, 0}; | 2053 return {LayoutUnit(), LayoutUnit()}; |
| 2054 case ContentPositionAuto: | 2054 case ContentPositionAuto: |
| 2055 break; | 2055 break; |
| 2056 } | 2056 } |
| 2057 | 2057 |
| 2058 ASSERT_NOT_REACHED(); | 2058 ASSERT_NOT_REACHED(); |
| 2059 return {0, 0}; | 2059 return {LayoutUnit(), LayoutUnit()}; |
| 2060 } | 2060 } |
| 2061 | 2061 |
| 2062 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const | 2062 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const |
| 2063 { | 2063 { |
| 2064 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child); | 2064 LayoutUnit rowAxisOffset = rowAxisOffsetForChild(child); |
| 2065 // We stored m_columnPosition s's data ignoring the direction, hence we migh
t need now | 2065 // We stored m_columnPosition s's data ignoring the direction, hence we migh
t need now |
| 2066 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. | 2066 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. |
| 2067 if (!style()->isLeftToRightDirection()) { | 2067 if (!style()->isLeftToRightDirection()) { |
| 2068 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta
rt(); | 2068 LayoutUnit alignmentOffset = m_columnPositions[0] - borderAndPaddingSta
rt(); |
| 2069 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s
ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft(); | 2069 LayoutUnit rightGridEdgePosition = m_columnPositions[m_columnPositions.s
ize() - 1] + alignmentOffset + borderAndPaddingLogicalLeft(); |
| 2070 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi
dth()); | 2070 rowAxisOffset = rightGridEdgePosition - (rowAxisOffset + child.logicalWi
dth()); |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2073 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
| 2074 } | 2074 } |
| 2075 | 2075 |
| 2076 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2076 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2077 { | 2077 { |
| 2078 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2078 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 } // namespace blink | 2081 } // namespace blink |
| OLD | NEW |