| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 | 233 |
| 234 RenderBox* newChildBox = toRenderBox(newChild); | 234 RenderBox* newChildBox = toRenderBox(newChild); |
| 235 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr
omStyle(*style(), *newChildBox, ForRows); | 235 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr
omStyle(*style(), *newChildBox, ForRows); |
| 236 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition
sFromStyle(*style(), *newChildBox, ForColumns); | 236 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition
sFromStyle(*style(), *newChildBox, ForColumns); |
| 237 if (!rowPositions || !columnPositions) { | 237 if (!rowPositions || !columnPositions) { |
| 238 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. | 238 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. |
| 239 dirtyGrid(); | 239 dirtyGrid(); |
| 240 return; | 240 return; |
| 241 } else { | 241 } else { |
| 242 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPos
itions)); | 242 insertItemIntoGrid(*newChildBox, GridCoordinate(*rowPositions, *columnPo
sitions)); |
| 243 addChildToIndexesMap(newChildBox); | 243 addChildToIndexesMap(*newChildBox); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 void RenderGrid::addChildToIndexesMap(RenderBox* child) | 247 void RenderGrid::addChildToIndexesMap(RenderBox& child) |
| 248 { | 248 { |
| 249 ASSERT(!m_gridItemsIndexesMap.contains(child)); | 249 ASSERT(!m_gridItemsIndexesMap.contains(&child)); |
| 250 RenderBox* sibling = child->nextSiblingBox(); | 250 RenderBox* sibling = child.nextSiblingBox(); |
| 251 bool lastSibling = !sibling; | 251 bool lastSibling = !sibling; |
| 252 | 252 |
| 253 if (lastSibling) | 253 if (lastSibling) |
| 254 sibling = child->previousSiblingBox(); | 254 sibling = child.previousSiblingBox(); |
| 255 | 255 |
| 256 size_t index = 0; | 256 size_t index = 0; |
| 257 if (sibling) | 257 if (sibling) |
| 258 index = lastSibling ? m_gridItemsIndexesMap.get(sibling) + 1 : m_gridIte
msIndexesMap.get(sibling); | 258 index = lastSibling ? m_gridItemsIndexesMap.get(sibling) + 1 : m_gridIte
msIndexesMap.get(sibling); |
| 259 | 259 |
| 260 if (sibling && !lastSibling) { | 260 if (sibling && !lastSibling) { |
| 261 for (; sibling; sibling = sibling->nextSiblingBox()) | 261 for (; sibling; sibling = sibling->nextSiblingBox()) |
| 262 m_gridItemsIndexesMap.set(sibling, m_gridItemsIndexesMap.get(sibling
) + 1); | 262 m_gridItemsIndexesMap.set(sibling, m_gridItemsIndexesMap.get(sibling
) + 1); |
| 263 } | 263 } |
| 264 | 264 |
| 265 m_gridItemsIndexesMap.set(child, index); | 265 m_gridItemsIndexesMap.set(&child, index); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void RenderGrid::removeChild(RenderObject* child) | 268 void RenderGrid::removeChild(RenderObject* child) |
| 269 { | 269 { |
| 270 RenderBlock::removeChild(child); | 270 RenderBlock::removeChild(child); |
| 271 | 271 |
| 272 if (gridIsDirty()) | 272 if (gridIsDirty()) |
| 273 return; | 273 return; |
| 274 | 274 |
| 275 ASSERT(child->isBox()); | 275 ASSERT(child->isBox()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } else { | 478 } else { |
| 479 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 479 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
| 480 const size_t trackIndex = flexibleSizedTracksIndex[i]; | 480 const size_t trackIndex = flexibleSizedTracksIndex[i]; |
| 481 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex
); | 481 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex
); |
| 482 normalizedFractionBreadth = std::max(normalizedFractionBreadth, trac
ks[trackIndex].m_usedBreadth / trackSize.maxTrackBreadth().flex()); | 482 normalizedFractionBreadth = std::max(normalizedFractionBreadth, trac
ks[trackIndex].m_usedBreadth / trackSize.maxTrackBreadth().flex()); |
| 483 } | 483 } |
| 484 | 484 |
| 485 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 485 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
| 486 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); | 486 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); |
| 487 while (RenderBox* gridItem = iterator.nextGridItem()) { | 487 while (RenderBox* gridItem = iterator.nextGridItem()) { |
| 488 const GridCoordinate coordinate = cachedGridCoordinate(gridItem)
; | 488 const GridCoordinate coordinate = cachedGridCoordinate(*gridItem
); |
| 489 const GridSpan span = (direction == ForColumns) ? coordinate.col
umns : coordinate.rows; | 489 const GridSpan span = (direction == ForColumns) ? coordinate.col
umns : coordinate.rows; |
| 490 | 490 |
| 491 // Do not include already processed items. | 491 // Do not include already processed items. |
| 492 if (i > 0 && span.resolvedInitialPosition.toInt() <= flexibleSiz
edTracksIndex[i - 1]) | 492 if (i > 0 && span.resolvedInitialPosition.toInt() <= flexibleSiz
edTracksIndex[i - 1]) |
| 493 continue; | 493 continue; |
| 494 | 494 |
| 495 double itemNormalizedFlexBreadth = computeNormalizedFractionBrea
dth(tracks, span, direction, maxContentForChild(gridItem, direction, sizingData.
columnTracks)); | 495 double itemNormalizedFlexBreadth = computeNormalizedFractionBrea
dth(tracks, span, direction, maxContentForChild(*gridItem, direction, sizingData
.columnTracks)); |
| 496 normalizedFractionBreadth = std::max(normalizedFractionBreadth,
itemNormalizedFlexBreadth); | 496 normalizedFractionBreadth = std::max(normalizedFractionBreadth,
itemNormalizedFlexBreadth); |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 501 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
| 502 const size_t trackIndex = flexibleSizedTracksIndex[i]; | 502 const size_t trackIndex = flexibleSizedTracksIndex[i]; |
| 503 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex); | 503 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex); |
| 504 | 504 |
| 505 tracks[trackIndex].m_usedBreadth = std::max<LayoutUnit>(tracks[trackInde
x].m_usedBreadth, normalizedFractionBreadth * trackSize.maxTrackBreadth().flex()
); | 505 tracks[trackIndex].m_usedBreadth = std::max<LayoutUnit>(tracks[trackInde
x].m_usedBreadth, normalizedFractionBreadth * trackSize.maxTrackBreadth().flex()
); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 Length logicalSize = direction == ForColumns ? style()->logicalWidth() :
style()->logicalHeight(); | 605 Length logicalSize = direction == ForColumns ? style()->logicalWidth() :
style()->logicalHeight(); |
| 606 if (logicalSize.isIntrinsicOrAuto()) { | 606 if (logicalSize.isIntrinsicOrAuto()) { |
| 607 DEFINE_STATIC_LOCAL(GridTrackSize, autoTrackSize, (Length(Auto))); | 607 DEFINE_STATIC_LOCAL(GridTrackSize, autoTrackSize, (Length(Auto))); |
| 608 return autoTrackSize; | 608 return autoTrackSize; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 return trackSize; | 612 return trackSize; |
| 613 } | 613 } |
| 614 | 614 |
| 615 LayoutUnit RenderGrid::logicalHeightForChild(RenderBox* child, Vector<GridTrack>
& columnTracks) | 615 LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, Vector<GridTrack>
& columnTracks) |
| 616 { | 616 { |
| 617 SubtreeLayoutScope layoutScope(*child); | 617 SubtreeLayoutScope layoutScope(child); |
| 618 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOverrid
eContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogicalWid
th() : LayoutUnit(); | 618 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride
ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth
() : LayoutUnit(); |
| 619 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh
ild(child, ForColumns, columnTracks); | 619 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh
ild(child, ForColumns, columnTracks); |
| 620 if (child->style()->logicalHeight().isPercent() || oldOverrideContainingBloc
kContentLogicalWidth != overrideContainingBlockContentLogicalWidth) | 620 if (child.style()->logicalHeight().isPercent() || oldOverrideContainingBlock
ContentLogicalWidth != overrideContainingBlockContentLogicalWidth) |
| 621 layoutScope.setNeedsLayout(child); | 621 layoutScope.setNeedsLayout(&child); |
| 622 | 622 |
| 623 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingBlock
ContentLogicalWidth); | 623 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); |
| 624 // If |child| has a percentage logical height, we shouldn't let it override
its intrinsic height, which is | 624 // If |child| has a percentage logical height, we shouldn't let it override
its intrinsic height, which is |
| 625 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). | 625 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). |
| 626 child->setOverrideContainingBlockContentLogicalHeight(-1); | 626 child.setOverrideContainingBlockContentLogicalHeight(-1); |
| 627 child->layoutIfNeeded(); | 627 child.layoutIfNeeded(); |
| 628 return child->logicalHeight() + child->marginLogicalHeight(); | 628 return child.logicalHeight() + child.marginLogicalHeight(); |
| 629 } | 629 } |
| 630 | 630 |
| 631 LayoutUnit RenderGrid::minContentForChild(RenderBox* child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 631 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
| 632 { | 632 { |
| 633 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo
ntalWritingMode(); | 633 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 634 // FIXME: Properly support orthogonal writing mode. | 634 // FIXME: Properly support orthogonal writing mode. |
| 635 if (hasOrthogonalWritingMode) | 635 if (hasOrthogonalWritingMode) |
| 636 return 0; | 636 return 0; |
| 637 | 637 |
| 638 if (direction == ForColumns) { | 638 if (direction == ForColumns) { |
| 639 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 639 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
| 640 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 640 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 641 return child->minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFo
rChild(child); | 641 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(&child); |
| 642 } | 642 } |
| 643 | 643 |
| 644 return logicalHeightForChild(child, columnTracks); | 644 return logicalHeightForChild(child, columnTracks); |
| 645 } | 645 } |
| 646 | 646 |
| 647 LayoutUnit RenderGrid::maxContentForChild(RenderBox* child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 647 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
| 648 { | 648 { |
| 649 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo
ntalWritingMode(); | 649 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 650 // FIXME: Properly support orthogonal writing mode. | 650 // FIXME: Properly support orthogonal writing mode. |
| 651 if (hasOrthogonalWritingMode) | 651 if (hasOrthogonalWritingMode) |
| 652 return LayoutUnit(); | 652 return LayoutUnit(); |
| 653 | 653 |
| 654 if (direction == ForColumns) { | 654 if (direction == ForColumns) { |
| 655 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 655 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
| 656 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 656 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 657 return child->maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFo
rChild(child); | 657 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(&child); |
| 658 } | 658 } |
| 659 | 659 |
| 660 return logicalHeightForChild(child, columnTracks); | 660 return logicalHeightForChild(child, columnTracks); |
| 661 } | 661 } |
| 662 | 662 |
| 663 size_t RenderGrid::gridItemSpan(const RenderBox* child, GridTrackSizingDirection
direction) | 663 size_t RenderGrid::gridItemSpan(const RenderBox& child, GridTrackSizingDirection
direction) |
| 664 { | 664 { |
| 665 GridCoordinate childCoordinate = cachedGridCoordinate(child); | 665 GridCoordinate childCoordinate = cachedGridCoordinate(child); |
| 666 GridSpan childSpan = (direction == ForRows) ? childCoordinate.rows : childCo
ordinate.columns; | 666 GridSpan childSpan = (direction == ForRows) ? childCoordinate.rows : childCo
ordinate.columns; |
| 667 | 667 |
| 668 return childSpan.resolvedFinalPosition.toInt() - childSpan.resolvedInitialPo
sition.toInt() + 1; | 668 return childSpan.resolvedFinalPosition.toInt() - childSpan.resolvedInitialPo
sition.toInt() + 1; |
| 669 } | 669 } |
| 670 | 670 |
| 671 typedef std::pair<RenderBox*, size_t> GridItemWithSpan; | 671 typedef std::pair<RenderBox*, size_t> GridItemWithSpan; |
| 672 | 672 |
| 673 // This function sorts by span (.second in the pair) but also places pointers (.
first in the pair) to the same object in | 673 // This function sorts by span (.second in the pair) but also places pointers (.
first in the pair) to the same object in |
| (...skipping 14 matching lines...) Expand all Loading... |
| 688 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) | 688 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) |
| 689 { | 689 { |
| 690 // FIXME: Split the grid tracks into groups that doesn't overlap a <flex> gr
id track (crbug.com/235258). | 690 // FIXME: Split the grid tracks into groups that doesn't overlap a <flex> gr
id track (crbug.com/235258). |
| 691 | 691 |
| 692 for (size_t i = 0; i < sizingData.contentSizedTracksIndex.size(); ++i) { | 692 for (size_t i = 0; i < sizingData.contentSizedTracksIndex.size(); ++i) { |
| 693 size_t trackIndex = sizingData.contentSizedTracksIndex[i]; | 693 size_t trackIndex = sizingData.contentSizedTracksIndex[i]; |
| 694 GridIterator iterator(m_grid, direction, trackIndex); | 694 GridIterator iterator(m_grid, direction, trackIndex); |
| 695 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; | 695 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; |
| 696 | 696 |
| 697 while (RenderBox* gridItem = iterator.nextGridItem()) | 697 while (RenderBox* gridItem = iterator.nextGridItem()) |
| 698 itemsSortedByIncreasingSpan.append(std::make_pair(gridItem, gridItem
Span(gridItem, direction))); | 698 itemsSortedByIncreasingSpan.append(std::make_pair(gridItem, gridItem
Span(*gridItem, direction))); |
| 699 std::stable_sort(itemsSortedByIncreasingSpan.begin(), itemsSortedByIncre
asingSpan.end(), gridItemWithSpanSorter); | 699 std::stable_sort(itemsSortedByIncreasingSpan.begin(), itemsSortedByIncre
asingSpan.end(), gridItemWithSpanSorter); |
| 700 Vector<GridItemWithSpan>::iterator end = std::unique(itemsSortedByIncrea
singSpan.begin(), itemsSortedByIncreasingSpan.end(), uniquePointerInPair); | 700 Vector<GridItemWithSpan>::iterator end = std::unique(itemsSortedByIncrea
singSpan.begin(), itemsSortedByIncreasingSpan.end(), uniquePointerInPair); |
| 701 | 701 |
| 702 for (Vector<GridItemWithSpan>::iterator it = itemsSortedByIncreasingSpan
.begin(); it != end; ++it) { | 702 for (Vector<GridItemWithSpan>::iterator it = itemsSortedByIncreasingSpan
.begin(); it != end; ++it) { |
| 703 RenderBox* gridItem = it->first; | 703 RenderBox* gridItem = it->first; |
| 704 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, gridItem, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); | 704 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, *gridItem, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::mi
nContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); |
| 705 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, gridItem, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); | 705 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, *gridItem, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxCont
entForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); |
| 706 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, gridItem, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth
); | 706 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, *gridItem, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::mi
nContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadt
h); |
| 707 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, gridItem, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); | 707 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat
a, *gridItem, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxCont
entForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); |
| 708 } | 708 } |
| 709 | 709 |
| 710 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; | 710 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; |
| 711 if (track.m_maxBreadth == infinity) | 711 if (track.m_maxBreadth == infinity) |
| 712 track.m_maxBreadth = track.m_usedBreadth; | 712 track.m_maxBreadth = track.m_usedBreadth; |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing
Direction direction, GridSizingData& sizingData, RenderBox* gridItem, FilterFunc
tion filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGette
r, AccumulatorGrowFunction trackGrowthFunction) | 716 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing
Direction direction, GridSizingData& sizingData, RenderBox& gridItem, FilterFunc
tion filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGette
r, AccumulatorGrowFunction trackGrowthFunction) |
| 717 { | 717 { |
| 718 const GridCoordinate coordinate = cachedGridCoordinate(gridItem); | 718 const GridCoordinate coordinate = cachedGridCoordinate(gridItem); |
| 719 const GridResolvedPosition initialTrackPosition = (direction == ForColumns)
? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo
sition; | 719 const GridResolvedPosition initialTrackPosition = (direction == ForColumns)
? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo
sition; |
| 720 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ?
coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition
; | 720 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ?
coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition
; |
| 721 | 721 |
| 722 sizingData.filteredTracks.shrink(0); | 722 sizingData.filteredTracks.shrink(0); |
| 723 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio
n <= finalTrackPosition; ++trackPosition) { | 723 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio
n <= finalTrackPosition; ++trackPosition) { |
| 724 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); | 724 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); |
| 725 if (!(trackSize.*filterFunction)()) | 725 if (!(trackSize.*filterFunction)()) |
| 726 continue; | 726 continue; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 for (size_t row = oldRowSize; row < gridRowCount(); ++row) | 818 for (size_t row = oldRowSize; row < gridRowCount(); ++row) |
| 819 m_grid[row].grow(gridColumnCount()); | 819 m_grid[row].grow(gridColumnCount()); |
| 820 } | 820 } |
| 821 | 821 |
| 822 if (maximumColumnIndex >= gridColumnCount()) { | 822 if (maximumColumnIndex >= gridColumnCount()) { |
| 823 for (size_t row = 0; row < gridRowCount(); ++row) | 823 for (size_t row = 0; row < gridRowCount(); ++row) |
| 824 m_grid[row].grow(maximumColumnIndex + 1); | 824 m_grid[row].grow(maximumColumnIndex + 1); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor
dinate) | 828 void RenderGrid::insertItemIntoGrid(RenderBox& child, const GridCoordinate& coor
dinate) |
| 829 { | 829 { |
| 830 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); | 830 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); |
| 831 | 831 |
| 832 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { | 832 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { |
| 833 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) | 833 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) |
| 834 m_grid[row.toInt()][column.toInt()].append(child); | 834 m_grid[row.toInt()][column.toInt()].append(&child); |
| 835 } | 835 } |
| 836 | 836 |
| 837 RELEASE_ASSERT(!m_gridItemCoordinate.contains(child)); | 837 RELEASE_ASSERT(!m_gridItemCoordinate.contains(&child)); |
| 838 m_gridItemCoordinate.set(child, coordinate); | 838 m_gridItemCoordinate.set(&child, coordinate); |
| 839 } | 839 } |
| 840 | 840 |
| 841 void RenderGrid::placeItemsOnGrid() | 841 void RenderGrid::placeItemsOnGrid() |
| 842 { | 842 { |
| 843 if (!gridIsDirty()) | 843 if (!gridIsDirty()) |
| 844 return; | 844 return; |
| 845 | 845 |
| 846 ASSERT(m_gridItemCoordinate.isEmpty()); | 846 ASSERT(m_gridItemCoordinate.isEmpty()); |
| 847 | 847 |
| 848 populateExplicitGridAndOrderIterator(); | 848 populateExplicitGridAndOrderIterator(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 859 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); | 859 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); |
| 860 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); | 860 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); |
| 861 if (!rowPositions || !columnPositions) { | 861 if (!rowPositions || !columnPositions) { |
| 862 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); | 862 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); |
| 863 if (!majorAxisPositions) | 863 if (!majorAxisPositions) |
| 864 autoMajorAxisAutoGridItems.append(child); | 864 autoMajorAxisAutoGridItems.append(child); |
| 865 else | 865 else |
| 866 specifiedMajorAxisAutoGridItems.append(child); | 866 specifiedMajorAxisAutoGridItems.append(child); |
| 867 continue; | 867 continue; |
| 868 } | 868 } |
| 869 insertItemIntoGrid(child, GridCoordinate(*rowPositions, *columnPositions
)); | 869 insertItemIntoGrid(*child, GridCoordinate(*rowPositions, *columnPosition
s)); |
| 870 } | 870 } |
| 871 | 871 |
| 872 ASSERT(gridRowCount() >= style()->gridTemplateRows().size()); | 872 ASSERT(gridRowCount() >= style()->gridTemplateRows().size()); |
| 873 ASSERT(gridColumnCount() >= style()->gridTemplateColumns().size()); | 873 ASSERT(gridColumnCount() >= style()->gridTemplateColumns().size()); |
| 874 | 874 |
| 875 // FIXME: Implement properly "stack" value in auto-placement algorithm. | 875 // FIXME: Implement properly "stack" value in auto-placement algorithm. |
| 876 if (style()->isGridAutoFlowAlgorithmStack()) { | 876 if (style()->isGridAutoFlowAlgorithmStack()) { |
| 877 // If we did collect some grid items, they won't be placed thus never la
id out. | 877 // If we did collect some grid items, they won't be placed thus never la
id out. |
| 878 ASSERT(!autoMajorAxisAutoGridItems.size()); | 878 ASSERT(!autoMajorAxisAutoGridItems.size()); |
| 879 ASSERT(!specifiedMajorAxisAutoGridItems.size()); | 879 ASSERT(!specifiedMajorAxisAutoGridItems.size()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); | 919 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); |
| 920 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.next().toInt()); | 920 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.next().toInt()); |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 | 923 |
| 924 m_grid.grow(maximumRowIndex); | 924 m_grid.grow(maximumRowIndex); |
| 925 for (size_t i = 0; i < m_grid.size(); ++i) | 925 for (size_t i = 0; i < m_grid.size(); ++i) |
| 926 m_grid[i].grow(maximumColumnIndex); | 926 m_grid[i].grow(maximumColumnIndex); |
| 927 } | 927 } |
| 928 | 928 |
| 929 PassOwnPtr<GridCoordinate> RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const RenderBox* gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const | 929 PassOwnPtr<GridCoordinate> RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const RenderBox& gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const |
| 930 { | 930 { |
| 931 GridTrackSizingDirection crossDirection = specifiedDirection == ForColumns ?
ForRows : ForColumns; | 931 GridTrackSizingDirection crossDirection = specifiedDirection == ForColumns ?
ForRows : ForColumns; |
| 932 const size_t endOfCrossDirection = crossDirection == ForColumns ? gridColumn
Count() : gridRowCount(); | 932 const size_t endOfCrossDirection = crossDirection == ForColumns ? gridColumn
Count() : gridRowCount(); |
| 933 GridSpan crossDirectionPositions = GridResolvedPosition::resolveGridPosition
sFromAutoPlacementPosition(*style(), *gridItem, crossDirection, GridResolvedPosi
tion(endOfCrossDirection)); | 933 GridSpan crossDirectionPositions = GridResolvedPosition::resolveGridPosition
sFromAutoPlacementPosition(*style(), gridItem, crossDirection, GridResolvedPosit
ion(endOfCrossDirection)); |
| 934 return adoptPtr(new GridCoordinate(specifiedDirection == ForColumns ? crossD
irectionPositions : specifiedPositions, specifiedDirection == ForColumns ? speci
fiedPositions : crossDirectionPositions)); | 934 return adoptPtr(new GridCoordinate(specifiedDirection == ForColumns ? crossD
irectionPositions : specifiedPositions, specifiedDirection == ForColumns ? speci
fiedPositions : crossDirectionPositions)); |
| 935 } | 935 } |
| 936 | 936 |
| 937 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>& au
toGridItems) | 937 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>& au
toGridItems) |
| 938 { | 938 { |
| 939 for (size_t i = 0; i < autoGridItems.size(); ++i) { | 939 for (size_t i = 0; i < autoGridItems.size(); ++i) { |
| 940 OwnPtr<GridSpan> majorAxisPositions = GridResolvedPosition::resolveGridP
ositionsFromStyle(*style(), *autoGridItems[i], autoPlacementMajorAxisDirection()
); | 940 OwnPtr<GridSpan> majorAxisPositions = GridResolvedPosition::resolveGridP
ositionsFromStyle(*style(), *autoGridItems[i], autoPlacementMajorAxisDirection()
); |
| 941 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), *autoGridItems[i], autoPlacementMinorAxisDir
ection(), GridResolvedPosition(0)); | 941 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), *autoGridItems[i], autoPlacementMinorAxisDir
ection(), GridResolvedPosition(0)); |
| 942 | 942 |
| 943 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAx
isPositions->resolvedInitialPosition.toInt()); | 943 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAx
isPositions->resolvedInitialPosition.toInt()); |
| 944 OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea(majorA
xisPositions->integerSpan(), minorAxisPositions.integerSpan()); | 944 OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea(majorA
xisPositions->integerSpan(), minorAxisPositions.integerSpan()); |
| 945 if (!emptyGridArea) | 945 if (!emptyGridArea) |
| 946 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(a
utoGridItems[i], autoPlacementMajorAxisDirection(), *majorAxisPositions); | 946 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(*
autoGridItems[i], autoPlacementMajorAxisDirection(), *majorAxisPositions); |
| 947 insertItemIntoGrid(autoGridItems[i], *emptyGridArea); | 947 insertItemIntoGrid(*autoGridItems[i], *emptyGridArea); |
| 948 } | 948 } |
| 949 } | 949 } |
| 950 | 950 |
| 951 void RenderGrid::placeAutoMajorAxisItemsOnGrid(const Vector<RenderBox*>& autoGri
dItems) | 951 void RenderGrid::placeAutoMajorAxisItemsOnGrid(const Vector<RenderBox*>& autoGri
dItems) |
| 952 { | 952 { |
| 953 std::pair<size_t, size_t> autoPlacementCursor = std::make_pair(0, 0); | 953 std::pair<size_t, size_t> autoPlacementCursor = std::make_pair(0, 0); |
| 954 bool isGridAutoFlowDense = style()->isGridAutoFlowAlgorithmDense(); | 954 bool isGridAutoFlowDense = style()->isGridAutoFlowAlgorithmDense(); |
| 955 | 955 |
| 956 for (size_t i = 0; i < autoGridItems.size(); ++i) { | 956 for (size_t i = 0; i < autoGridItems.size(); ++i) { |
| 957 placeAutoMajorAxisItemOnGrid(autoGridItems[i], autoPlacementCursor); | 957 placeAutoMajorAxisItemOnGrid(*autoGridItems[i], autoPlacementCursor); |
| 958 | 958 |
| 959 // If grid-auto-flow is dense, reset auto-placement cursor. | 959 // If grid-auto-flow is dense, reset auto-placement cursor. |
| 960 if (isGridAutoFlowDense) { | 960 if (isGridAutoFlowDense) { |
| 961 autoPlacementCursor.first = 0; | 961 autoPlacementCursor.first = 0; |
| 962 autoPlacementCursor.second = 0; | 962 autoPlacementCursor.second = 0; |
| 963 } | 963 } |
| 964 } | 964 } |
| 965 } | 965 } |
| 966 | 966 |
| 967 void RenderGrid::placeAutoMajorAxisItemOnGrid(RenderBox* gridItem, std::pair<siz
e_t, size_t>& autoPlacementCursor) | 967 void RenderGrid::placeAutoMajorAxisItemOnGrid(RenderBox& gridItem, std::pair<siz
e_t, size_t>& autoPlacementCursor) |
| 968 { | 968 { |
| 969 OwnPtr<GridSpan> minorAxisPositions = GridResolvedPosition::resolveGridPosit
ionsFromStyle(*style(), *gridItem, autoPlacementMinorAxisDirection()); | 969 OwnPtr<GridSpan> minorAxisPositions = GridResolvedPosition::resolveGridPosit
ionsFromStyle(*style(), gridItem, autoPlacementMinorAxisDirection()); |
| 970 ASSERT(!GridResolvedPosition::resolveGridPositionsFromStyle(*style(), *gridI
tem, autoPlacementMajorAxisDirection())); | 970 ASSERT(!GridResolvedPosition::resolveGridPositionsFromStyle(*style(), gridIt
em, autoPlacementMajorAxisDirection())); |
| 971 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPositionsFrom
AutoPlacementPosition(*style(), *gridItem, autoPlacementMajorAxisDirection(), Gr
idResolvedPosition(0)); | 971 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPositionsFrom
AutoPlacementPosition(*style(), gridItem, autoPlacementMajorAxisDirection(), Gri
dResolvedPosition(0)); |
| 972 | 972 |
| 973 const size_t endOfMajorAxis = (autoPlacementMajorAxisDirection() == ForColum
ns) ? gridColumnCount() : gridRowCount(); | 973 const size_t endOfMajorAxis = (autoPlacementMajorAxisDirection() == ForColum
ns) ? gridColumnCount() : gridRowCount(); |
| 974 size_t majorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.second : autoPlacementCursor.first; | 974 size_t majorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.second : autoPlacementCursor.first; |
| 975 size_t minorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.first : autoPlacementCursor.second; | 975 size_t minorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.first : autoPlacementCursor.second; |
| 976 | 976 |
| 977 OwnPtr<GridCoordinate> emptyGridArea; | 977 OwnPtr<GridCoordinate> emptyGridArea; |
| 978 if (minorAxisPositions) { | 978 if (minorAxisPositions) { |
| 979 // Move to the next track in major axis if initial position in minor axi
s is before auto-placement cursor. | 979 // Move to the next track in major axis if initial position in minor axi
s is before auto-placement cursor. |
| 980 if (minorAxisPositions->resolvedInitialPosition.toInt() < minorAxisAutoP
lacementCursor) | 980 if (minorAxisPositions->resolvedInitialPosition.toInt() < minorAxisAutoP
lacementCursor) |
| 981 majorAxisAutoPlacementCursor++; | 981 majorAxisAutoPlacementCursor++; |
| 982 | 982 |
| 983 if (majorAxisAutoPlacementCursor < endOfMajorAxis) { | 983 if (majorAxisAutoPlacementCursor < endOfMajorAxis) { |
| 984 GridIterator iterator(m_grid, autoPlacementMinorAxisDirection(), min
orAxisPositions->resolvedInitialPosition.toInt(), majorAxisAutoPlacementCursor); | 984 GridIterator iterator(m_grid, autoPlacementMinorAxisDirection(), min
orAxisPositions->resolvedInitialPosition.toInt(), majorAxisAutoPlacementCursor); |
| 985 emptyGridArea = iterator.nextEmptyGridArea(minorAxisPositions->integ
erSpan(), majorAxisPositions.integerSpan()); | 985 emptyGridArea = iterator.nextEmptyGridArea(minorAxisPositions->integ
erSpan(), majorAxisPositions.integerSpan()); |
| 986 } | 986 } |
| 987 | 987 |
| 988 if (!emptyGridArea) | 988 if (!emptyGridArea) |
| 989 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g
ridItem, autoPlacementMinorAxisDirection(), *minorAxisPositions); | 989 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g
ridItem, autoPlacementMinorAxisDirection(), *minorAxisPositions); |
| 990 } else { | 990 } else { |
| 991 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), *gridItem, autoPlacementMinorAxisDirection()
, GridResolvedPosition(0)); | 991 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), gridItem, autoPlacementMinorAxisDirection(),
GridResolvedPosition(0)); |
| 992 | 992 |
| 993 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde
x < endOfMajorAxis; ++majorAxisIndex) { | 993 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde
x < endOfMajorAxis; ++majorAxisIndex) { |
| 994 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj
orAxisIndex, minorAxisAutoPlacementCursor); | 994 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj
orAxisIndex, minorAxisAutoPlacementCursor); |
| 995 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege
rSpan(), minorAxisPositions.integerSpan()); | 995 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege
rSpan(), minorAxisPositions.integerSpan()); |
| 996 | 996 |
| 997 if (emptyGridArea) { | 997 if (emptyGridArea) { |
| 998 // Check that it fits in the minor axis direction, as we shouldn
't grow in that direction here (it was already managed in populateExplicitGridAn
dOrderIterator()). | 998 // Check that it fits in the minor axis direction, as we shouldn
't grow in that direction here (it was already managed in populateExplicitGridAn
dOrderIterator()). |
| 999 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement
MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio
n : emptyGridArea->rows.resolvedFinalPosition; | 999 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement
MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio
n : emptyGridArea->rows.resolvedFinalPosition; |
| 1000 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection()
== ForColumns ? gridColumnCount() : gridRowCount(); | 1000 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection()
== ForColumns ? gridColumnCount() : gridRowCount(); |
| 1001 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis) | 1001 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1051 |
| 1052 populateGridPositions(sizingData); | 1052 populateGridPositions(sizingData); |
| 1053 m_gridItemsOverflowingGridArea.resize(0); | 1053 m_gridItemsOverflowingGridArea.resize(0); |
| 1054 | 1054 |
| 1055 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1055 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
| 1056 // Because the grid area cannot be styled, we don't need to adjust | 1056 // Because the grid area cannot be styled, we don't need to adjust |
| 1057 // the grid breadth to account for 'box-sizing'. | 1057 // the grid breadth to account for 'box-sizing'. |
| 1058 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); | 1058 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); |
| 1059 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); | 1059 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); |
| 1060 | 1060 |
| 1061 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF
orChild(child, ForColumns, sizingData.columnTracks); | 1061 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF
orChild(*child, ForColumns, sizingData.columnTracks); |
| 1062 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth
ForChild(child, ForRows, sizingData.rowTracks); | 1062 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth
ForChild(*child, ForRows, sizingData.rowTracks); |
| 1063 | 1063 |
| 1064 SubtreeLayoutScope layoutScope(*child); | 1064 SubtreeLayoutScope layoutScope(*child); |
| 1065 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB
lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov
errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) | 1065 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB
lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov
errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) |
| 1066 layoutScope.setNeedsLayout(child); | 1066 layoutScope.setNeedsLayout(child); |
| 1067 | 1067 |
| 1068 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB
lockContentLogicalWidth); | 1068 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB
lockContentLogicalWidth); |
| 1069 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining
BlockContentLogicalHeight); | 1069 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining
BlockContentLogicalHeight); |
| 1070 | 1070 |
| 1071 // FIXME: Grid items should stretch to fill their cells. Once we | 1071 // FIXME: Grid items should stretch to fill their cells. Once we |
| 1072 // implement grid-{column,row}-align, we can also shrink to fit. For | 1072 // implement grid-{column,row}-align, we can also shrink to fit. For |
| 1073 // now, just size as if we were a regular child. | 1073 // now, just size as if we were a regular child. |
| 1074 child->layoutIfNeeded(); | 1074 child->layoutIfNeeded(); |
| 1075 | 1075 |
| 1076 #if ENABLE(ASSERT) | 1076 #if ENABLE(ASSERT) |
| 1077 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1077 const GridCoordinate& coordinate = cachedGridCoordinate(*child); |
| 1078 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c
olumnTracks.size()); | 1078 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c
olumnTracks.size()); |
| 1079 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT
racks.size()); | 1079 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT
racks.size()); |
| 1080 #endif | 1080 #endif |
| 1081 child->setLogicalLocation(findChildLogicalPosition(child)); | 1081 child->setLogicalLocation(findChildLogicalPosition(*child)); |
| 1082 | 1082 |
| 1083 // Keep track of children overflowing their grid area as we might need t
o paint them even if the grid-area is | 1083 // Keep track of children overflowing their grid area as we might need t
o paint them even if the grid-area is |
| 1084 // not visible | 1084 // not visible |
| 1085 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight | 1085 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight |
| 1086 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt
h) | 1086 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt
h) |
| 1087 m_gridItemsOverflowingGridArea.append(child); | 1087 m_gridItemsOverflowingGridArea.append(child); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 for (size_t i = 0; i < sizingData.rowTracks.size(); ++i) | 1090 for (size_t i = 0; i < sizingData.rowTracks.size(); ++i) |
| 1091 setLogicalHeight(logicalHeight() + sizingData.rowTracks[i].m_usedBreadth
); | 1091 setLogicalHeight(logicalHeight() + sizingData.rowTracks[i].m_usedBreadth
); |
| 1092 | 1092 |
| 1093 // Min / max logical height is handled by the call to updateLogicalHeight in
layoutBlock. | 1093 // Min / max logical height is handled by the call to updateLogicalHeight in
layoutBlock. |
| 1094 | 1094 |
| 1095 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); | 1095 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox* gridItem) const | 1098 GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox& gridItem) const |
| 1099 { | 1099 { |
| 1100 ASSERT(m_gridItemCoordinate.contains(gridItem)); | 1100 ASSERT(m_gridItemCoordinate.contains(&gridItem)); |
| 1101 return m_gridItemCoordinate.get(gridItem); | 1101 return m_gridItemCoordinate.get(&gridItem); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const | 1104 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox& child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const |
| 1105 { | 1105 { |
| 1106 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1106 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1107 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; | 1107 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; |
| 1108 LayoutUnit gridAreaBreadth = 0; | 1108 LayoutUnit gridAreaBreadth = 0; |
| 1109 for (GridSpan::iterator trackPosition = span.begin(); trackPosition != span.
end(); ++trackPosition) | 1109 for (GridSpan::iterator trackPosition = span.begin(); trackPosition != span.
end(); ++trackPosition) |
| 1110 gridAreaBreadth += tracks[trackPosition.toInt()].m_usedBreadth; | 1110 gridAreaBreadth += tracks[trackPosition.toInt()].m_usedBreadth; |
| 1111 return gridAreaBreadth; | 1111 return gridAreaBreadth; |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) | 1114 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) |
| 1115 { | 1115 { |
| 1116 m_columnPositions.resize(sizingData.columnTracks.size() + 1); | 1116 m_columnPositions.resize(sizingData.columnTracks.size() + 1); |
| 1117 m_columnPositions[0] = borderAndPaddingStart(); | 1117 m_columnPositions[0] = borderAndPaddingStart(); |
| 1118 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) | 1118 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) |
| 1119 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack
s[i].m_usedBreadth; | 1119 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack
s[i].m_usedBreadth; |
| 1120 | 1120 |
| 1121 m_rowPositions.resize(sizingData.rowTracks.size() + 1); | 1121 m_rowPositions.resize(sizingData.rowTracks.size() + 1); |
| 1122 m_rowPositions[0] = borderAndPaddingBefore(); | 1122 m_rowPositions[0] = borderAndPaddingBefore(); |
| 1123 for (size_t i = 0; i < m_rowPositions.size() - 1; ++i) | 1123 for (size_t i = 0; i < m_rowPositions.size() - 1; ++i) |
| 1124 m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowTracks[i].m_us
edBreadth; | 1124 m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowTracks[i].m_us
edBreadth; |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 LayoutUnit RenderGrid::startOfColumnForChild(const RenderBox* child) const | 1127 LayoutUnit RenderGrid::startOfColumnForChild(const RenderBox& child) const |
| 1128 { | 1128 { |
| 1129 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1129 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1130 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1130 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
| 1131 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1131 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
| 1132 // FIXME: This should account for the grid item's <overflow-position>. | 1132 // FIXME: This should account for the grid item's <overflow-position>. |
| 1133 return startOfColumn + marginStartForChild(child); | 1133 return startOfColumn + marginStartForChild(&child); |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 LayoutUnit RenderGrid::endOfColumnForChild(const RenderBox* child) const | 1136 LayoutUnit RenderGrid::endOfColumnForChild(const RenderBox& child) const |
| 1137 { | 1137 { |
| 1138 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1138 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1139 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1139 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
| 1140 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1140 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
| 1141 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | 1141 LayoutUnit columnPosition = startOfColumn + marginStartForChild(&child); |
| 1142 | 1142 |
| 1143 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | 1143 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; |
| 1144 // FIXME: This should account for the grid item's <overflow-position>. | 1144 // FIXME: This should account for the grid item's <overflow-position>. |
| 1145 return columnPosition + std::max<LayoutUnit>(0, endOfColumn - m_columnPositi
ons[coordinate.columns.resolvedInitialPosition.toInt()] - child->logicalWidth())
; | 1145 return columnPosition + std::max<LayoutUnit>(0, endOfColumn - m_columnPositi
ons[coordinate.columns.resolvedInitialPosition.toInt()] - child.logicalWidth()); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerStart(const RenderB
ox* child) const | 1148 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerStart(const RenderB
ox& child) const |
| 1149 { | 1149 { |
| 1150 if (style()->isLeftToRightDirection()) | 1150 if (style()->isLeftToRightDirection()) |
| 1151 return startOfColumnForChild(child); | 1151 return startOfColumnForChild(child); |
| 1152 | 1152 |
| 1153 return endOfColumnForChild(child); | 1153 return endOfColumnForChild(child); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerEnd(const RenderBox
* child) const | 1156 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerEnd(const RenderBox
& child) const |
| 1157 { | 1157 { |
| 1158 if (!style()->isLeftToRightDirection()) | 1158 if (!style()->isLeftToRightDirection()) |
| 1159 return startOfColumnForChild(child); | 1159 return startOfColumnForChild(child); |
| 1160 | 1160 |
| 1161 return endOfColumnForChild(child); | 1161 return endOfColumnForChild(child); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox* child) co
nst | 1164 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox& child) co
nst |
| 1165 { | 1165 { |
| 1166 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1166 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1167 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1167 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
| 1168 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | 1168 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; |
| 1169 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | 1169 LayoutUnit columnPosition = startOfColumn + marginStartForChild(&child); |
| 1170 // FIXME: This should account for the grid item's <overflow-position>. | 1170 // FIXME: This should account for the grid item's <overflow-position>. |
| 1171 return columnPosition + std::max<LayoutUnit>(0, endOfColumn - startOfColumn
- child->logicalWidth()) / 2; | 1171 return columnPosition + std::max<LayoutUnit>(0, endOfColumn - startOfColumn
- child.logicalWidth()) / 2; |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 static ItemPosition resolveJustification(const RenderStyle* parentStyle, const R
enderStyle* childStyle) | 1174 static ItemPosition resolveJustification(const RenderStyle* parentStyle, const R
enderStyle* childStyle) |
| 1175 { | 1175 { |
| 1176 ItemPosition justify = childStyle->justifySelf(); | 1176 ItemPosition justify = childStyle->justifySelf(); |
| 1177 if (justify == ItemPositionAuto) | 1177 if (justify == ItemPositionAuto) |
| 1178 justify = (parentStyle->justifyItems() == ItemPositionAuto) ? ItemPositi
onStretch : parentStyle->justifyItems(); | 1178 justify = (parentStyle->justifyItems() == ItemPositionAuto) ? ItemPositi
onStretch : parentStyle->justifyItems(); |
| 1179 | 1179 |
| 1180 return justify; | 1180 return justify; |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox* child) const | 1183 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox& child) const |
| 1184 { | 1184 { |
| 1185 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo
ntalWritingMode(); | 1185 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 1186 | 1186 |
| 1187 switch (resolveJustification(style(), child->style())) { | 1187 switch (resolveJustification(style(), child.style())) { |
| 1188 case ItemPositionSelfStart: | 1188 case ItemPositionSelfStart: |
| 1189 // For orthogonal writing-modes, this computes to 'start' | 1189 // For orthogonal writing-modes, this computes to 'start' |
| 1190 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1190 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1191 if (hasOrthogonalWritingMode) | 1191 if (hasOrthogonalWritingMode) |
| 1192 return columnPositionAlignedWithGridContainerStart(child); | 1192 return columnPositionAlignedWithGridContainerStart(child); |
| 1193 | 1193 |
| 1194 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. | 1194 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. |
| 1195 if (child->style()->direction() != style()->direction()) | 1195 if (child.style()->direction() != style()->direction()) |
| 1196 return columnPositionAlignedWithGridContainerEnd(child); | 1196 return columnPositionAlignedWithGridContainerEnd(child); |
| 1197 | 1197 |
| 1198 return columnPositionAlignedWithGridContainerStart(child); | 1198 return columnPositionAlignedWithGridContainerStart(child); |
| 1199 case ItemPositionSelfEnd: | 1199 case ItemPositionSelfEnd: |
| 1200 // For orthogonal writing-modes, this computes to 'start' | 1200 // For orthogonal writing-modes, this computes to 'start' |
| 1201 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1201 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1202 if (hasOrthogonalWritingMode) | 1202 if (hasOrthogonalWritingMode) |
| 1203 return columnPositionAlignedWithGridContainerEnd(child); | 1203 return columnPositionAlignedWithGridContainerEnd(child); |
| 1204 | 1204 |
| 1205 // self-end is based on the child's direction. That's why we need to che
ck against the grid container's direction. | 1205 // self-end is based on the child's direction. That's why we need to che
ck against the grid container's direction. |
| 1206 if (child->style()->direction() != style()->direction()) | 1206 if (child.style()->direction() != style()->direction()) |
| 1207 return columnPositionAlignedWithGridContainerStart(child); | 1207 return columnPositionAlignedWithGridContainerStart(child); |
| 1208 | 1208 |
| 1209 return columnPositionAlignedWithGridContainerEnd(child); | 1209 return columnPositionAlignedWithGridContainerEnd(child); |
| 1210 | 1210 |
| 1211 case ItemPositionFlexStart: | 1211 case ItemPositionFlexStart: |
| 1212 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | 1212 // Only used in flex layout, for other layout, it's equivalent to 'start
'. |
| 1213 return columnPositionAlignedWithGridContainerStart(child); | 1213 return columnPositionAlignedWithGridContainerStart(child); |
| 1214 case ItemPositionFlexEnd: | 1214 case ItemPositionFlexEnd: |
| 1215 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | 1215 // Only used in flex layout, for other layout, it's equivalent to 'start
'. |
| 1216 return columnPositionAlignedWithGridContainerEnd(child); | 1216 return columnPositionAlignedWithGridContainerEnd(child); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1247 case ItemPositionBaseline: | 1247 case ItemPositionBaseline: |
| 1248 case ItemPositionLastBaseline: | 1248 case ItemPositionLastBaseline: |
| 1249 // FIXME: Implement the previous values. For now, we always start align
the child. | 1249 // FIXME: Implement the previous values. For now, we always start align
the child. |
| 1250 return startOfColumnForChild(child); | 1250 return startOfColumnForChild(child); |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 ASSERT_NOT_REACHED(); | 1253 ASSERT_NOT_REACHED(); |
| 1254 return 0; | 1254 return 0; |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox* child) const | 1257 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox& child) const |
| 1258 { | 1258 { |
| 1259 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1259 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1260 | 1260 |
| 1261 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1261 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
| 1262 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1262 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
| 1263 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1263 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(&child); |
| 1264 | 1264 |
| 1265 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | 1265 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; |
| 1266 // FIXME: This should account for the grid item's <overflow-position>. | 1266 // FIXME: This should account for the grid item's <overflow-position>. |
| 1267 return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->
logicalHeight()); | 1267 return rowPosition + std::max<LayoutUnit>(0, endOfRow - startOfRow - child.l
ogicalHeight()); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox* child) const | 1270 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox& child) const |
| 1271 { | 1271 { |
| 1272 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1272 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1273 | 1273 |
| 1274 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1274 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
| 1275 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1275 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
| 1276 // FIXME: This should account for the grid item's <overflow-position>. | 1276 // FIXME: This should account for the grid item's <overflow-position>. |
| 1277 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1277 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(&child); |
| 1278 | 1278 |
| 1279 return rowPosition; | 1279 return rowPosition; |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox* child) const | 1282 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox& child) const |
| 1283 { | 1283 { |
| 1284 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1284 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1285 | 1285 |
| 1286 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1286 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
| 1287 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()] + marginBeforeForChild(child); | 1287 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()] + marginBeforeForChild(&child); |
| 1288 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | 1288 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; |
| 1289 | 1289 |
| 1290 // FIXME: This should account for the grid item's <overflow-position>. | 1290 // FIXME: This should account for the grid item's <overflow-position>. |
| 1291 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child->l
ogicalHeight()) / 2; | 1291 return startOfRow + std::max<LayoutUnit>(0, endOfRow - startOfRow - child.lo
gicalHeight()) / 2; |
| 1292 } | 1292 } |
| 1293 | 1293 |
| 1294 // FIXME: We should move this logic to the StyleAdjuster or the StyleBuilder. | 1294 // FIXME: We should move this logic to the StyleAdjuster or the StyleBuilder. |
| 1295 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
rStyle* childStyle) | 1295 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
rStyle* childStyle) |
| 1296 { | 1296 { |
| 1297 ItemPosition align = childStyle->alignSelf(); | 1297 ItemPosition align = childStyle->alignSelf(); |
| 1298 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". | 1298 // The auto keyword computes to the parent's align-items computed value, or
to "stretch", if not set or "auto". |
| 1299 if (align == ItemPositionAuto) | 1299 if (align == ItemPositionAuto) |
| 1300 align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
retch : parentStyle->alignItems(); | 1300 align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
retch : parentStyle->alignItems(); |
| 1301 return align; | 1301 return align; |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox* child) const | 1304 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox& child) const |
| 1305 { | 1305 { |
| 1306 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo
ntalWritingMode(); | 1306 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 1307 ItemPosition alignSelf = resolveAlignment(style(), child->style()); | 1307 ItemPosition alignSelf = resolveAlignment(style(), child.style()); |
| 1308 | 1308 |
| 1309 switch (alignSelf) { | 1309 switch (alignSelf) { |
| 1310 case ItemPositionSelfStart: | 1310 case ItemPositionSelfStart: |
| 1311 // If orthogonal writing-modes, this computes to 'Start'. | 1311 // If orthogonal writing-modes, this computes to 'Start'. |
| 1312 // FIXME: grid track sizing and positioning does not support orthogonal
modes yet. | 1312 // FIXME: grid track sizing and positioning does not support orthogonal
modes yet. |
| 1313 if (hasOrthogonalWritingMode) | 1313 if (hasOrthogonalWritingMode) |
| 1314 return startOfRowForChild(child); | 1314 return startOfRowForChild(child); |
| 1315 | 1315 |
| 1316 // self-start is based on the child's block axis direction. That's why w
e need to check against the grid container's block flow. | 1316 // self-start is based on the child's block axis direction. That's why w
e need to check against the grid container's block flow. |
| 1317 if (child->style()->writingMode() != style()->writingMode()) | 1317 if (child.style()->writingMode() != style()->writingMode()) |
| 1318 return endOfRowForChild(child); | 1318 return endOfRowForChild(child); |
| 1319 | 1319 |
| 1320 return startOfRowForChild(child); | 1320 return startOfRowForChild(child); |
| 1321 case ItemPositionSelfEnd: | 1321 case ItemPositionSelfEnd: |
| 1322 // If orthogonal writing-modes, this computes to 'End'. | 1322 // If orthogonal writing-modes, this computes to 'End'. |
| 1323 // FIXME: grid track sizing and positioning does not support orthogonal
modes yet. | 1323 // FIXME: grid track sizing and positioning does not support orthogonal
modes yet. |
| 1324 if (hasOrthogonalWritingMode) | 1324 if (hasOrthogonalWritingMode) |
| 1325 return endOfRowForChild(child); | 1325 return endOfRowForChild(child); |
| 1326 | 1326 |
| 1327 // self-end is based on the child's block axis direction. That's why we
need to check against the grid container's block flow. | 1327 // self-end is based on the child's block axis direction. That's why we
need to check against the grid container's block flow. |
| 1328 if (child->style()->writingMode() != style()->writingMode()) | 1328 if (child.style()->writingMode() != style()->writingMode()) |
| 1329 return startOfRowForChild(child); | 1329 return startOfRowForChild(child); |
| 1330 | 1330 |
| 1331 return endOfRowForChild(child); | 1331 return endOfRowForChild(child); |
| 1332 | 1332 |
| 1333 case ItemPositionLeft: | 1333 case ItemPositionLeft: |
| 1334 // orthogonal modes make property and inline axes to be parallel, but in
any case | 1334 // orthogonal modes make property and inline axes to be parallel, but in
any case |
| 1335 // this is always equivalent to 'Start'. | 1335 // this is always equivalent to 'Start'. |
| 1336 // | 1336 // |
| 1337 // self-align's axis is never parallel to the inline axis, except in ort
hogonal | 1337 // self-align's axis is never parallel to the inline axis, except in ort
hogonal |
| 1338 // writing-mode, so this is equivalent to 'Start’. | 1338 // writing-mode, so this is equivalent to 'Start’. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1366 // FIXME: Implement the ItemPositionBaseline value. For now, we always s
tart align the child. | 1366 // FIXME: Implement the ItemPositionBaseline value. For now, we always s
tart align the child. |
| 1367 return startOfRowForChild(child); | 1367 return startOfRowForChild(child); |
| 1368 case ItemPositionAuto: | 1368 case ItemPositionAuto: |
| 1369 break; | 1369 break; |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 ASSERT_NOT_REACHED(); | 1372 ASSERT_NOT_REACHED(); |
| 1373 return 0; | 1373 return 0; |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox* child) const | 1376 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child) const |
| 1377 { | 1377 { |
| 1378 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child)
); | 1378 return LayoutPoint(columnPositionForChild(child), rowPositionForChild(child)
); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn
it start, LayoutUnit end) | 1381 static GridSpan dirtiedGridAreas(const Vector<LayoutUnit>& coordinates, LayoutUn
it start, LayoutUnit end) |
| 1382 { | 1382 { |
| 1383 // This function does a binary search over the coordinates. | 1383 // This function does a binary search over the coordinates. |
| 1384 // This doesn't work with grid items overflowing their grid areas, but that
is managed with m_gridItemsOverflowingGridArea. | 1384 // This doesn't work with grid items overflowing their grid areas, but that
is managed with m_gridItemsOverflowingGridArea. |
| 1385 | 1385 |
| 1386 size_t startGridAreaIndex = std::upper_bound(coordinates.begin(), coordinate
s.end() - 1, start) - coordinates.begin(); | 1386 size_t startGridAreaIndex = std::upper_bound(coordinates.begin(), coordinate
s.end() - 1, start) - coordinates.begin(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 if (isOutOfFlowPositioned()) | 1454 if (isOutOfFlowPositioned()) |
| 1455 return "RenderGrid (positioned)"; | 1455 return "RenderGrid (positioned)"; |
| 1456 if (isAnonymous()) | 1456 if (isAnonymous()) |
| 1457 return "RenderGrid (generated)"; | 1457 return "RenderGrid (generated)"; |
| 1458 if (isRelPositioned()) | 1458 if (isRelPositioned()) |
| 1459 return "RenderGrid (relative positioned)"; | 1459 return "RenderGrid (relative positioned)"; |
| 1460 return "RenderGrid"; | 1460 return "RenderGrid"; |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 } // namespace blink | 1463 } // namespace blink |
| OLD | NEW |