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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 : m_grid(grid) | 162 : m_grid(grid) |
163 , m_direction(direction) | 163 , m_direction(direction) |
164 , m_rowIndex((direction == ForColumns) ? varyingTrackIndex : fixedTrackI
ndex) | 164 , m_rowIndex((direction == ForColumns) ? varyingTrackIndex : fixedTrackI
ndex) |
165 , m_columnIndex((direction == ForColumns) ? fixedTrackIndex : varyingTra
ckIndex) | 165 , m_columnIndex((direction == ForColumns) ? fixedTrackIndex : varyingTra
ckIndex) |
166 , m_childIndex(0) | 166 , m_childIndex(0) |
167 { | 167 { |
168 ASSERT(m_rowIndex < m_grid.size()); | 168 ASSERT(m_rowIndex < m_grid.size()); |
169 ASSERT(m_columnIndex < m_grid[0].size()); | 169 ASSERT(m_columnIndex < m_grid[0].size()); |
170 } | 170 } |
171 | 171 |
172 RenderBox* nextGridItem() | 172 LayoutBox* nextGridItem() |
173 { | 173 { |
174 ASSERT(!m_grid.isEmpty()); | 174 ASSERT(!m_grid.isEmpty()); |
175 | 175 |
176 size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m
_columnIndex; | 176 size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m
_columnIndex; |
177 const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_gr
id.size() : m_grid[0].size(); | 177 const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_gr
id.size() : m_grid[0].size(); |
178 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex)
{ | 178 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex)
{ |
179 const GridCell& children = m_grid[m_rowIndex][m_columnIndex]; | 179 const GridCell& children = m_grid[m_rowIndex][m_columnIndex]; |
180 if (m_childIndex < children.size()) | 180 if (m_childIndex < children.size()) |
181 return children[m_childIndex++]; | 181 return children[m_childIndex++]; |
182 | 182 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); | 317 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); |
318 } | 318 } |
319 | 319 |
320 void RenderGrid::layoutBlock(bool relayoutChildren) | 320 void RenderGrid::layoutBlock(bool relayoutChildren) |
321 { | 321 { |
322 ASSERT(needsLayout()); | 322 ASSERT(needsLayout()); |
323 | 323 |
324 if (!relayoutChildren && simplifiedLayout()) | 324 if (!relayoutChildren && simplifiedLayout()) |
325 return; | 325 return; |
326 | 326 |
327 // FIXME: Much of this method is boiler plate that matches RenderBox::layout
Block and Render*FlexibleBox::layoutBlock. | 327 // FIXME: Much of this method is boiler plate that matches LayoutBox::layout
Block and Render*FlexibleBox::layoutBlock. |
328 // It would be nice to refactor some of the duplicate code. | 328 // It would be nice to refactor some of the duplicate code. |
329 { | 329 { |
330 // LayoutState needs this deliberate scope to pop before updating scroll
information (which | 330 // LayoutState needs this deliberate scope to pop before updating scroll
information (which |
331 // may trigger relayout). | 331 // may trigger relayout). |
332 LayoutState state(*this, locationOffset()); | 332 LayoutState state(*this, locationOffset()); |
333 | 333 |
334 LayoutSize previousSize = size(); | 334 LayoutSize previousSize = size(); |
335 | 335 |
336 setLogicalHeight(0); | 336 setLogicalHeight(0); |
337 updateLogicalWidth(); | 337 updateLogicalWidth(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 if (!hasUndefinedRemainingSpace) { | 470 if (!hasUndefinedRemainingSpace) { |
471 normalizedFractionBreadth = computeNormalizedFractionBreadth(tracks, Gri
dSpan(0, tracks.size() - 1), direction, initialFreeSpace); | 471 normalizedFractionBreadth = computeNormalizedFractionBreadth(tracks, Gri
dSpan(0, tracks.size() - 1), direction, initialFreeSpace); |
472 } else { | 472 } else { |
473 for (const auto& trackIndex : flexibleSizedTracksIndex) { | 473 for (const auto& trackIndex : flexibleSizedTracksIndex) { |
474 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); | 474 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); |
475 normalizedFractionBreadth = std::max(normalizedFractionBreadth, trac
ks[trackIndex].baseSize() / trackSize.maxTrackBreadth().flex()); | 475 normalizedFractionBreadth = std::max(normalizedFractionBreadth, trac
ks[trackIndex].baseSize() / trackSize.maxTrackBreadth().flex()); |
476 } | 476 } |
477 | 477 |
478 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 478 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
479 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); | 479 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); |
480 while (RenderBox* gridItem = iterator.nextGridItem()) { | 480 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
481 const GridCoordinate coordinate = cachedGridCoordinate(*gridItem
); | 481 const GridCoordinate coordinate = cachedGridCoordinate(*gridItem
); |
482 const GridSpan span = (direction == ForColumns) ? coordinate.col
umns : coordinate.rows; | 482 const GridSpan span = (direction == ForColumns) ? coordinate.col
umns : coordinate.rows; |
483 | 483 |
484 // Do not include already processed items. | 484 // Do not include already processed items. |
485 if (i > 0 && span.resolvedInitialPosition.toInt() <= flexibleSiz
edTracksIndex[i - 1]) | 485 if (i > 0 && span.resolvedInitialPosition.toInt() <= flexibleSiz
edTracksIndex[i - 1]) |
486 continue; | 486 continue; |
487 | 487 |
488 double itemNormalizedFlexBreadth = computeNormalizedFractionBrea
dth(tracks, span, direction, maxContentForChild(*gridItem, direction, sizingData
.columnTracks)); | 488 double itemNormalizedFlexBreadth = computeNormalizedFractionBrea
dth(tracks, span, direction, maxContentForChild(*gridItem, direction, sizingData
.columnTracks)); |
489 normalizedFractionBreadth = std::max(normalizedFractionBreadth,
itemNormalizedFlexBreadth); | 489 normalizedFractionBreadth = std::max(normalizedFractionBreadth,
itemNormalizedFlexBreadth); |
490 } | 490 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // the case of minmax() as min-content for the first position and max-conten
t for the second). | 605 // the case of minmax() as min-content for the first position and max-conten
t for the second). |
606 if (!hasDefiniteLogicalSize(direction)) { | 606 if (!hasDefiniteLogicalSize(direction)) { |
607 const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth(); | 607 const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth(); |
608 const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth(); | 608 const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth(); |
609 return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinConte
nt) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent)
: oldMaxTrackBreadth); | 609 return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinConte
nt) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent)
: oldMaxTrackBreadth); |
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(LayoutBox& child, Vector<GridTrack>
& columnTracks) |
616 { | 616 { |
617 SubtreeLayoutScope layoutScope(child); | 617 SubtreeLayoutScope layoutScope(child); |
618 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride
ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth
() : 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() || oldOverrideContainingBlock
ContentLogicalWidth != overrideContainingBlockContentLogicalWidth) | 620 if (child.style()->logicalHeight().isPercent() || oldOverrideContainingBlock
ContentLogicalWidth != overrideContainingBlockContentLogicalWidth) |
621 layoutScope.setNeedsLayout(&child); | 621 layoutScope.setNeedsLayout(&child); |
622 | 622 |
623 child.clearOverrideLogicalContentHeight(); | 623 child.clearOverrideLogicalContentHeight(); |
624 | 624 |
625 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); | 625 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); |
626 // If |child| has a percentage logical height, we shouldn't let it override
its intrinsic height, which is | 626 // If |child| has a percentage logical height, we shouldn't let it override
its intrinsic height, which is |
627 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). | 627 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). |
628 child.setOverrideContainingBlockContentLogicalHeight(-1); | 628 child.setOverrideContainingBlockContentLogicalHeight(-1); |
629 child.layoutIfNeeded(); | 629 child.layoutIfNeeded(); |
630 return child.logicalHeight() + child.marginLogicalHeight(); | 630 return child.logicalHeight() + child.marginLogicalHeight(); |
631 } | 631 } |
632 | 632 |
633 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 633 LayoutUnit RenderGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
634 { | 634 { |
635 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 635 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
636 // FIXME: Properly support orthogonal writing mode. | 636 // FIXME: Properly support orthogonal writing mode. |
637 if (hasOrthogonalWritingMode) | 637 if (hasOrthogonalWritingMode) |
638 return 0; | 638 return 0; |
639 | 639 |
640 if (direction == ForColumns) { | 640 if (direction == ForColumns) { |
641 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 641 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
642 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 642 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
643 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); | 643 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); |
644 } | 644 } |
645 | 645 |
646 return logicalHeightForChild(child, columnTracks); | 646 return logicalHeightForChild(child, columnTracks); |
647 } | 647 } |
648 | 648 |
649 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) | 649 LayoutUnit RenderGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec
tion direction, Vector<GridTrack>& columnTracks) |
650 { | 650 { |
651 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 651 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
652 // FIXME: Properly support orthogonal writing mode. | 652 // FIXME: Properly support orthogonal writing mode. |
653 if (hasOrthogonalWritingMode) | 653 if (hasOrthogonalWritingMode) |
654 return LayoutUnit(); | 654 return LayoutUnit(); |
655 | 655 |
656 if (direction == ForColumns) { | 656 if (direction == ForColumns) { |
657 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. | 657 // FIXME: It's unclear if we should return the intrinsic width or the pr
eferred width. |
658 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 658 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
659 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); | 659 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor
Child(child); |
660 } | 660 } |
661 | 661 |
662 return logicalHeightForChild(child, columnTracks); | 662 return logicalHeightForChild(child, columnTracks); |
663 } | 663 } |
664 | 664 |
665 // We're basically using a class instead of a std::pair for two reasons. First o
f all, accessing gridItem() or | 665 // We're basically using a class instead of a std::pair for two reasons. First o
f all, accessing gridItem() or |
666 // coordinate() is much more self-explanatory that using .first or .second membe
rs in the pair. Secondly the class | 666 // coordinate() is much more self-explanatory that using .first or .second membe
rs in the pair. Secondly the class |
667 // allows us to precompute the value of the span, something which is quite conve
nient for the sorting. Having a | 667 // allows us to precompute the value of the span, something which is quite conve
nient for the sorting. Having a |
668 // std::pair<RenderBox*, size_t> does not work either because we still need the
GridCoordinate so we'd have to add an | 668 // std::pair<LayoutBox*, size_t> does not work either because we still need the
GridCoordinate so we'd have to add an |
669 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten
tBasedTrackSizingFunctionsForItems(). | 669 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten
tBasedTrackSizingFunctionsForItems(). |
670 class GridItemWithSpan { | 670 class GridItemWithSpan { |
671 public: | 671 public: |
672 GridItemWithSpan(RenderBox& gridItem, const GridCoordinate& coordinate, Grid
TrackSizingDirection direction) | 672 GridItemWithSpan(LayoutBox& gridItem, const GridCoordinate& coordinate, Grid
TrackSizingDirection direction) |
673 : m_gridItem(&gridItem) | 673 : m_gridItem(&gridItem) |
674 , m_coordinate(coordinate) | 674 , m_coordinate(coordinate) |
675 { | 675 { |
676 const GridSpan& span = (direction == ForRows) ? coordinate.rows : coordi
nate.columns; | 676 const GridSpan& span = (direction == ForRows) ? coordinate.rows : coordi
nate.columns; |
677 m_span = span.resolvedFinalPosition.toInt() - span.resolvedInitialPositi
on.toInt() + 1; | 677 m_span = span.resolvedFinalPosition.toInt() - span.resolvedInitialPositi
on.toInt() + 1; |
678 } | 678 } |
679 | 679 |
680 RenderBox& gridItem() const { return *m_gridItem; } | 680 LayoutBox& gridItem() const { return *m_gridItem; } |
681 GridCoordinate coordinate() const { return m_coordinate; } | 681 GridCoordinate coordinate() const { return m_coordinate; } |
682 #if ENABLE(ASSERT) | 682 #if ENABLE(ASSERT) |
683 size_t span() const { return m_span; } | 683 size_t span() const { return m_span; } |
684 #endif | 684 #endif |
685 | 685 |
686 bool operator<(const GridItemWithSpan other) const { return m_span < other.m
_span; } | 686 bool operator<(const GridItemWithSpan other) const { return m_span < other.m
_span; } |
687 | 687 |
688 private: | 688 private: |
689 RenderBox* m_gridItem; | 689 LayoutBox* m_gridItem; |
690 GridCoordinate m_coordinate; | 690 GridCoordinate m_coordinate; |
691 size_t m_span; | 691 size_t m_span; |
692 }; | 692 }; |
693 | 693 |
694 bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridCoordinate& co
ordinate, GridTrackSizingDirection direction) const | 694 bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridCoordinate& co
ordinate, GridTrackSizingDirection direction) const |
695 { | 695 { |
696 const GridResolvedPosition initialTrackPosition = (direction == ForColumns)
? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo
sition; | 696 const GridResolvedPosition initialTrackPosition = (direction == ForColumns)
? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo
sition; |
697 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ?
coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition
; | 697 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ?
coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition
; |
698 | 698 |
699 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio
n <= finalTrackPosition; ++trackPosition) { | 699 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio
n <= finalTrackPosition; ++trackPosition) { |
700 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); | 700 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); |
701 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) | 701 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) |
702 return true; | 702 return true; |
703 } | 703 } |
704 | 704 |
705 return false; | 705 return false; |
706 } | 706 } |
707 | 707 |
708 static inline size_t integerSpanForDirection(const GridCoordinate& coordinate, G
ridTrackSizingDirection direction) | 708 static inline size_t integerSpanForDirection(const GridCoordinate& coordinate, G
ridTrackSizingDirection direction) |
709 { | 709 { |
710 return (direction == ForRows) ? coordinate.rows.integerSpan() : coordinate.c
olumns.integerSpan(); | 710 return (direction == ForRows) ? coordinate.rows.integerSpan() : coordinate.c
olumns.integerSpan(); |
711 } | 711 } |
712 | 712 |
713 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) | 713 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) |
714 { | 714 { |
715 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 715 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
716 HashSet<RenderBox*> itemsSet; | 716 HashSet<LayoutBox*> itemsSet; |
717 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 717 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
718 GridIterator iterator(m_grid, direction, trackIndex); | 718 GridIterator iterator(m_grid, direction, trackIndex); |
719 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; | 719 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; |
720 while (RenderBox* gridItem = iterator.nextGridItem()) { | 720 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
721 if (itemsSet.add(gridItem).isNewEntry) { | 721 if (itemsSet.add(gridItem).isNewEntry) { |
722 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte
m); | 722 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte
m); |
723 if (integerSpanForDirection(coordinate, direction) == 1) { | 723 if (integerSpanForDirection(coordinate, direction) == 1) { |
724 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d
irection, coordinate, *gridItem, track, sizingData.columnTracks); | 724 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d
irection, coordinate, *gridItem, track, sizingData.columnTracks); |
725 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d
irection)) { | 725 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d
irection)) { |
726 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp
an(*gridItem, coordinate, direction)); | 726 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp
an(*gridItem, coordinate, direction)); |
727 } | 727 } |
728 } | 728 } |
729 } | 729 } |
730 } | 730 } |
731 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo
rtedByIncreasingSpan.end()); | 731 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo
rtedByIncreasingSpan.end()); |
732 | 732 |
733 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS
pan.end(); | 733 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS
pan.end(); |
734 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas
ingSpan.begin(); it != end; ++it) { | 734 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas
ingSpan.begin(); it != end; ++it) { |
735 GridItemWithSpan itemWithSpan = *it; | 735 GridItemWithSpan itemWithSpan = *it; |
736 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize:
:hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); | 736 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize:
:hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); |
737 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM
axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); | 737 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM
axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); |
738 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim
it); | 738 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min
ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim
it); |
739 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); | 739 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i
temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte
ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); |
740 } | 740 } |
741 | 741 |
742 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 742 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
743 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; | 743 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t
rackIndex] : sizingData.rowTracks[trackIndex]; |
744 if (track.growthLimitIsInfinite()) | 744 if (track.growthLimitIsInfinite()) |
745 track.setGrowthLimit(track.baseSize()); | 745 track.setGrowthLimit(track.baseSize()); |
746 } | 746 } |
747 } | 747 } |
748 | 748 |
749 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid
TrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gri
dItem, GridTrack& track, Vector<GridTrack>& columnTracks) | 749 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid
TrackSizingDirection direction, const GridCoordinate& coordinate, LayoutBox& gri
dItem, GridTrack& track, Vector<GridTrack>& columnTracks) |
750 { | 750 { |
751 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord
inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; | 751 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord
inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; |
752 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); | 752 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); |
753 | 753 |
754 if (trackSize.hasMinContentMinTrackBreadth()) | 754 if (trackSize.hasMinContentMinTrackBreadth()) |
755 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem
, direction, columnTracks))); | 755 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem
, direction, columnTracks))); |
756 else if (trackSize.hasMaxContentMinTrackBreadth()) | 756 else if (trackSize.hasMaxContentMinTrackBreadth()) |
757 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem
, direction, columnTracks))); | 757 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem
, direction, columnTracks))); |
758 | 758 |
759 if (trackSize.hasMinContentMaxTrackBreadth()) | 759 if (trackSize.hasMinContentMaxTrackBreadth()) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 for (size_t row = oldRowSize; row < gridRowCount(); ++row) | 865 for (size_t row = oldRowSize; row < gridRowCount(); ++row) |
866 m_grid[row].grow(gridColumnCount()); | 866 m_grid[row].grow(gridColumnCount()); |
867 } | 867 } |
868 | 868 |
869 if (maximumColumnIndex >= gridColumnCount()) { | 869 if (maximumColumnIndex >= gridColumnCount()) { |
870 for (size_t row = 0; row < gridRowCount(); ++row) | 870 for (size_t row = 0; row < gridRowCount(); ++row) |
871 m_grid[row].grow(maximumColumnIndex + 1); | 871 m_grid[row].grow(maximumColumnIndex + 1); |
872 } | 872 } |
873 } | 873 } |
874 | 874 |
875 void RenderGrid::insertItemIntoGrid(RenderBox& child, const GridCoordinate& coor
dinate) | 875 void RenderGrid::insertItemIntoGrid(LayoutBox& child, const GridCoordinate& coor
dinate) |
876 { | 876 { |
877 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); | 877 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); |
878 | 878 |
879 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { | 879 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { |
880 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) | 880 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) |
881 m_grid[row.toInt()][column.toInt()].append(&child); | 881 m_grid[row.toInt()][column.toInt()].append(&child); |
882 } | 882 } |
883 | 883 |
884 RELEASE_ASSERT(!m_gridItemCoordinate.contains(&child)); | 884 RELEASE_ASSERT(!m_gridItemCoordinate.contains(&child)); |
885 m_gridItemCoordinate.set(&child, coordinate); | 885 m_gridItemCoordinate.set(&child, coordinate); |
886 } | 886 } |
887 | 887 |
888 void RenderGrid::placeItemsOnGrid() | 888 void RenderGrid::placeItemsOnGrid() |
889 { | 889 { |
890 if (!gridIsDirty()) | 890 if (!gridIsDirty()) |
891 return; | 891 return; |
892 | 892 |
893 ASSERT(m_gridItemCoordinate.isEmpty()); | 893 ASSERT(m_gridItemCoordinate.isEmpty()); |
894 | 894 |
895 populateExplicitGridAndOrderIterator(); | 895 populateExplicitGridAndOrderIterator(); |
896 | 896 |
897 // We clear the dirty bit here as the grid sizes have been updated, this mea
ns | 897 // We clear the dirty bit here as the grid sizes have been updated, this mea
ns |
898 // that we can safely call gridRowCount() / gridColumnCount(). | 898 // that we can safely call gridRowCount() / gridColumnCount(). |
899 m_gridIsDirty = false; | 899 m_gridIsDirty = false; |
900 | 900 |
901 Vector<RenderBox*> autoMajorAxisAutoGridItems; | 901 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
902 Vector<RenderBox*> specifiedMajorAxisAutoGridItems; | 902 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
903 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { | 903 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { |
904 if (child->isOutOfFlowPositioned()) | 904 if (child->isOutOfFlowPositioned()) |
905 continue; | 905 continue; |
906 | 906 |
907 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); | 907 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); |
908 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); | 908 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); |
909 if (!rowPositions || !columnPositions) { | 909 if (!rowPositions || !columnPositions) { |
910 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); | 910 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); |
911 if (!majorAxisPositions) | 911 if (!majorAxisPositions) |
912 autoMajorAxisAutoGridItems.append(child); | 912 autoMajorAxisAutoGridItems.append(child); |
913 else | 913 else |
(...skipping 14 matching lines...) Expand all Loading... |
928 | 928 |
929 void RenderGrid::populateExplicitGridAndOrderIterator() | 929 void RenderGrid::populateExplicitGridAndOrderIterator() |
930 { | 930 { |
931 OrderIteratorPopulator populator(m_orderIterator); | 931 OrderIteratorPopulator populator(m_orderIterator); |
932 | 932 |
933 size_t maximumRowIndex = std::max<size_t>(1, GridResolvedPosition::explicitG
ridRowCount(*style())); | 933 size_t maximumRowIndex = std::max<size_t>(1, GridResolvedPosition::explicitG
ridRowCount(*style())); |
934 size_t maximumColumnIndex = std::max<size_t>(1, GridResolvedPosition::explic
itGridColumnCount(*style())); | 934 size_t maximumColumnIndex = std::max<size_t>(1, GridResolvedPosition::explic
itGridColumnCount(*style())); |
935 | 935 |
936 ASSERT(m_gridItemsIndexesMap.isEmpty()); | 936 ASSERT(m_gridItemsIndexesMap.isEmpty()); |
937 size_t childIndex = 0; | 937 size_t childIndex = 0; |
938 for (RenderBox* child = firstChildBox(); child; child = child->nextInFlowSib
lingBox()) { | 938 for (LayoutBox* child = firstChildBox(); child; child = child->nextInFlowSib
lingBox()) { |
939 populator.collectChild(child); | 939 populator.collectChild(child); |
940 m_gridItemsIndexesMap.set(child, childIndex++); | 940 m_gridItemsIndexesMap.set(child, childIndex++); |
941 | 941 |
942 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. | 942 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. |
943 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); | 943 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); |
944 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); | 944 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); |
945 | 945 |
946 // |positions| is 0 if we need to run the auto-placement algorithm. | 946 // |positions| is 0 if we need to run the auto-placement algorithm. |
947 if (rowPositions) { | 947 if (rowPositions) { |
948 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re
solvedFinalPosition.next().toInt()); | 948 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re
solvedFinalPosition.next().toInt()); |
(...skipping 10 matching lines...) Expand all Loading... |
959 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); | 959 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); |
960 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.next().toInt()); | 960 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.next().toInt()); |
961 } | 961 } |
962 } | 962 } |
963 | 963 |
964 m_grid.grow(maximumRowIndex); | 964 m_grid.grow(maximumRowIndex); |
965 for (auto& column : m_grid) | 965 for (auto& column : m_grid) |
966 column.grow(maximumColumnIndex); | 966 column.grow(maximumColumnIndex); |
967 } | 967 } |
968 | 968 |
969 PassOwnPtr<GridCoordinate> RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const RenderBox& gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const | 969 PassOwnPtr<GridCoordinate> RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const LayoutBox& gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const |
970 { | 970 { |
971 GridTrackSizingDirection crossDirection = specifiedDirection == ForColumns ?
ForRows : ForColumns; | 971 GridTrackSizingDirection crossDirection = specifiedDirection == ForColumns ?
ForRows : ForColumns; |
972 const size_t endOfCrossDirection = crossDirection == ForColumns ? gridColumn
Count() : gridRowCount(); | 972 const size_t endOfCrossDirection = crossDirection == ForColumns ? gridColumn
Count() : gridRowCount(); |
973 GridSpan crossDirectionPositions = GridResolvedPosition::resolveGridPosition
sFromAutoPlacementPosition(*style(), gridItem, crossDirection, GridResolvedPosit
ion(endOfCrossDirection)); | 973 GridSpan crossDirectionPositions = GridResolvedPosition::resolveGridPosition
sFromAutoPlacementPosition(*style(), gridItem, crossDirection, GridResolvedPosit
ion(endOfCrossDirection)); |
974 return adoptPtr(new GridCoordinate(specifiedDirection == ForColumns ? crossD
irectionPositions : specifiedPositions, specifiedDirection == ForColumns ? speci
fiedPositions : crossDirectionPositions)); | 974 return adoptPtr(new GridCoordinate(specifiedDirection == ForColumns ? crossD
irectionPositions : specifiedPositions, specifiedDirection == ForColumns ? speci
fiedPositions : crossDirectionPositions)); |
975 } | 975 } |
976 | 976 |
977 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>& au
toGridItems) | 977 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<LayoutBox*>& au
toGridItems) |
978 { | 978 { |
979 for (const auto& autoGridItem : autoGridItems) { | 979 for (const auto& autoGridItem : autoGridItems) { |
980 OwnPtr<GridSpan> majorAxisPositions = GridResolvedPosition::resolveGridP
ositionsFromStyle(*style(), *autoGridItem, autoPlacementMajorAxisDirection()); | 980 OwnPtr<GridSpan> majorAxisPositions = GridResolvedPosition::resolveGridP
ositionsFromStyle(*style(), *autoGridItem, autoPlacementMajorAxisDirection()); |
981 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), *autoGridItem, autoPlacementMinorAxisDirecti
on(), GridResolvedPosition(0)); | 981 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), *autoGridItem, autoPlacementMinorAxisDirecti
on(), GridResolvedPosition(0)); |
982 | 982 |
983 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAx
isPositions->resolvedInitialPosition.toInt()); | 983 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), majorAx
isPositions->resolvedInitialPosition.toInt()); |
984 OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea(majorA
xisPositions->integerSpan(), minorAxisPositions.integerSpan()); | 984 OwnPtr<GridCoordinate> emptyGridArea = iterator.nextEmptyGridArea(majorA
xisPositions->integerSpan(), minorAxisPositions.integerSpan()); |
985 if (!emptyGridArea) | 985 if (!emptyGridArea) |
986 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(*
autoGridItem, autoPlacementMajorAxisDirection(), *majorAxisPositions); | 986 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(*
autoGridItem, autoPlacementMajorAxisDirection(), *majorAxisPositions); |
987 insertItemIntoGrid(*autoGridItem, *emptyGridArea); | 987 insertItemIntoGrid(*autoGridItem, *emptyGridArea); |
988 } | 988 } |
989 } | 989 } |
990 | 990 |
991 void RenderGrid::placeAutoMajorAxisItemsOnGrid(const Vector<RenderBox*>& autoGri
dItems) | 991 void RenderGrid::placeAutoMajorAxisItemsOnGrid(const Vector<LayoutBox*>& autoGri
dItems) |
992 { | 992 { |
993 std::pair<size_t, size_t> autoPlacementCursor = std::make_pair(0, 0); | 993 std::pair<size_t, size_t> autoPlacementCursor = std::make_pair(0, 0); |
994 bool isGridAutoFlowDense = style()->isGridAutoFlowAlgorithmDense(); | 994 bool isGridAutoFlowDense = style()->isGridAutoFlowAlgorithmDense(); |
995 | 995 |
996 for (const auto& autoGridItem : autoGridItems) { | 996 for (const auto& autoGridItem : autoGridItems) { |
997 placeAutoMajorAxisItemOnGrid(*autoGridItem, autoPlacementCursor); | 997 placeAutoMajorAxisItemOnGrid(*autoGridItem, autoPlacementCursor); |
998 | 998 |
999 // If grid-auto-flow is dense, reset auto-placement cursor. | 999 // If grid-auto-flow is dense, reset auto-placement cursor. |
1000 if (isGridAutoFlowDense) { | 1000 if (isGridAutoFlowDense) { |
1001 autoPlacementCursor.first = 0; | 1001 autoPlacementCursor.first = 0; |
1002 autoPlacementCursor.second = 0; | 1002 autoPlacementCursor.second = 0; |
1003 } | 1003 } |
1004 } | 1004 } |
1005 } | 1005 } |
1006 | 1006 |
1007 void RenderGrid::placeAutoMajorAxisItemOnGrid(RenderBox& gridItem, std::pair<siz
e_t, size_t>& autoPlacementCursor) | 1007 void RenderGrid::placeAutoMajorAxisItemOnGrid(LayoutBox& gridItem, std::pair<siz
e_t, size_t>& autoPlacementCursor) |
1008 { | 1008 { |
1009 OwnPtr<GridSpan> minorAxisPositions = GridResolvedPosition::resolveGridPosit
ionsFromStyle(*style(), gridItem, autoPlacementMinorAxisDirection()); | 1009 OwnPtr<GridSpan> minorAxisPositions = GridResolvedPosition::resolveGridPosit
ionsFromStyle(*style(), gridItem, autoPlacementMinorAxisDirection()); |
1010 ASSERT(!GridResolvedPosition::resolveGridPositionsFromStyle(*style(), gridIt
em, autoPlacementMajorAxisDirection())); | 1010 ASSERT(!GridResolvedPosition::resolveGridPositionsFromStyle(*style(), gridIt
em, autoPlacementMajorAxisDirection())); |
1011 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPositionsFrom
AutoPlacementPosition(*style(), gridItem, autoPlacementMajorAxisDirection(), Gri
dResolvedPosition(0)); | 1011 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPositionsFrom
AutoPlacementPosition(*style(), gridItem, autoPlacementMajorAxisDirection(), Gri
dResolvedPosition(0)); |
1012 | 1012 |
1013 const size_t endOfMajorAxis = (autoPlacementMajorAxisDirection() == ForColum
ns) ? gridColumnCount() : gridRowCount(); | 1013 const size_t endOfMajorAxis = (autoPlacementMajorAxisDirection() == ForColum
ns) ? gridColumnCount() : gridRowCount(); |
1014 size_t majorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.second : autoPlacementCursor.first; | 1014 size_t majorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.second : autoPlacementCursor.first; |
1015 size_t minorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.first : autoPlacementCursor.second; | 1015 size_t minorAxisAutoPlacementCursor = autoPlacementMajorAxisDirection() == F
orColumns ? autoPlacementCursor.first : autoPlacementCursor.second; |
1016 | 1016 |
1017 OwnPtr<GridCoordinate> emptyGridArea; | 1017 OwnPtr<GridCoordinate> emptyGridArea; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); | 1098 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); |
1099 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1099 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
1100 | 1100 |
1101 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); | 1101 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo
rRows); |
1102 m_gridItemsOverflowingGridArea.resize(0); | 1102 m_gridItemsOverflowingGridArea.resize(0); |
1103 | 1103 |
1104 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); | 1104 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab
leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio
n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); |
1105 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), style()-
>alignContentOverflowAlignment(), m_rowPositions.size() - 1); | 1105 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac
eForRows, style()->alignContent(), style()->alignContentDistribution(), style()-
>alignContentOverflowAlignment(), m_rowPositions.size() - 1); |
1106 LayoutSize contentPositionOffset(columnOffset, rowOffset); | 1106 LayoutSize contentPositionOffset(columnOffset, rowOffset); |
1107 | 1107 |
1108 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 1108 for (LayoutBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
1109 if (child->isOutOfFlowPositioned()) { | 1109 if (child->isOutOfFlowPositioned()) { |
1110 child->containingBlock()->insertPositionedObject(child); | 1110 child->containingBlock()->insertPositionedObject(child); |
1111 continue; | 1111 continue; |
1112 } | 1112 } |
1113 | 1113 |
1114 // Because the grid area cannot be styled, we don't need to adjust | 1114 // Because the grid area cannot be styled, we don't need to adjust |
1115 // the grid breadth to account for 'box-sizing'. | 1115 // the grid breadth to account for 'box-sizing'. |
1116 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); | 1116 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve
rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica
lWidth() : LayoutUnit(); |
1117 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); | 1117 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv
errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi
calHeight() : LayoutUnit(); |
1118 | 1118 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 if (rowStartIsAuto) | 1194 if (rowStartIsAuto) |
1195 childLayer->setStaticBlockPosition(borderAndPaddingBefore()); | 1195 childLayer->setStaticBlockPosition(borderAndPaddingBefore()); |
1196 else | 1196 else |
1197 childLayer->setStaticBlockPosition(borderBefore() + rowOffset); | 1197 childLayer->setStaticBlockPosition(borderBefore() + rowOffset); |
1198 } | 1198 } |
1199 } | 1199 } |
1200 | 1200 |
1201 RenderBlock::layoutPositionedObjects(relayoutChildren, info); | 1201 RenderBlock::layoutPositionedObjects(relayoutChildren, info); |
1202 } | 1202 } |
1203 | 1203 |
1204 void RenderGrid::offsetAndBreadthForPositionedChild(const RenderBox& child, Grid
TrackSizingDirection direction, bool startIsAuto, bool endIsAuto, LayoutUnit& of
fset, LayoutUnit& breadth) | 1204 void RenderGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid
TrackSizingDirection direction, bool startIsAuto, bool endIsAuto, LayoutUnit& of
fset, LayoutUnit& breadth) |
1205 { | 1205 { |
1206 ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode()); | 1206 ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode()); |
1207 | 1207 |
1208 OwnPtr<GridSpan> positions = GridResolvedPosition::resolveGridPositionsFromS
tyle(*style(), child, direction); | 1208 OwnPtr<GridSpan> positions = GridResolvedPosition::resolveGridPositionsFromS
tyle(*style(), child, direction); |
1209 if (!positions) { | 1209 if (!positions) { |
1210 offset = LayoutUnit(0); | 1210 offset = LayoutUnit(0); |
1211 breadth = (direction == ForColumns) ? clientLogicalWidth() : clientLogic
alHeight(); | 1211 breadth = (direction == ForColumns) ? clientLogicalWidth() : clientLogic
alHeight(); |
1212 return; | 1212 return; |
1213 } | 1213 } |
1214 | 1214 |
(...skipping 17 matching lines...) Expand all Loading... |
1232 start -= ((direction == ForColumns) ? borderStart() : borderBefore()); | 1232 start -= ((direction == ForColumns) ? borderStart() : borderBefore()); |
1233 | 1233 |
1234 if (endIsAuto) { | 1234 if (endIsAuto) { |
1235 breadth -= (direction == ForColumns) ? borderEnd() : borderAfter(); | 1235 breadth -= (direction == ForColumns) ? borderEnd() : borderAfter(); |
1236 breadth -= scrollbarLogicalWidth(); | 1236 breadth -= scrollbarLogicalWidth(); |
1237 } | 1237 } |
1238 | 1238 |
1239 offset = start; | 1239 offset = start; |
1240 } | 1240 } |
1241 | 1241 |
1242 GridCoordinate RenderGrid::cachedGridCoordinate(const RenderBox& gridItem) const | 1242 GridCoordinate RenderGrid::cachedGridCoordinate(const LayoutBox& gridItem) const |
1243 { | 1243 { |
1244 ASSERT(m_gridItemCoordinate.contains(&gridItem)); | 1244 ASSERT(m_gridItemCoordinate.contains(&gridItem)); |
1245 return m_gridItemCoordinate.get(&gridItem); | 1245 return m_gridItemCoordinate.get(&gridItem); |
1246 } | 1246 } |
1247 | 1247 |
1248 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox& child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const | 1248 LayoutUnit RenderGrid::gridAreaBreadthForChild(const LayoutBox& child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const |
1249 { | 1249 { |
1250 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1250 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1251 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; | 1251 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; |
1252 LayoutUnit gridAreaBreadth = 0; | 1252 LayoutUnit gridAreaBreadth = 0; |
1253 for (GridSpan::iterator trackPosition = span.begin(); trackPosition != span.
end(); ++trackPosition) | 1253 for (GridSpan::iterator trackPosition = span.begin(); trackPosition != span.
end(); ++trackPosition) |
1254 gridAreaBreadth += tracks[trackPosition.toInt()].baseSize(); | 1254 gridAreaBreadth += tracks[trackPosition.toInt()].baseSize(); |
1255 return gridAreaBreadth; | 1255 return gridAreaBreadth; |
1256 } | 1256 } |
1257 | 1257 |
1258 void RenderGrid::populateGridPositions(const GridSizingData& sizingData, LayoutU
nit availableSpaceForColumns, LayoutUnit availableSpaceForRows) | 1258 void RenderGrid::populateGridPositions(const GridSizingData& sizingData, LayoutU
nit availableSpaceForColumns, LayoutUnit availableSpaceForRows) |
(...skipping 21 matching lines...) Expand all Loading... |
1280 // edge (potentially cause some data loss as the overflow is unreachable). | 1280 // edge (potentially cause some data loss as the overflow is unreachable). |
1281 if (overflow == OverflowAlignmentSafe) | 1281 if (overflow == OverflowAlignmentSafe) |
1282 offset = std::max<LayoutUnit>(0, offset); | 1282 offset = std::max<LayoutUnit>(0, offset); |
1283 | 1283 |
1284 // If we overflow our alignment container and overflow is 'true' (default),
we | 1284 // If we overflow our alignment container and overflow is 'true' (default),
we |
1285 // ignore the overflow and just return the value regardless (which may cause
data | 1285 // ignore the overflow and just return the value regardless (which may cause
data |
1286 // loss as we overflow the 'start' edge). | 1286 // loss as we overflow the 'start' edge). |
1287 return offset; | 1287 return offset; |
1288 } | 1288 } |
1289 | 1289 |
1290 LayoutUnit RenderGrid::startOfColumnForChild(const RenderBox& child) const | 1290 LayoutUnit RenderGrid::startOfColumnForChild(const LayoutBox& child) const |
1291 { | 1291 { |
1292 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1292 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1293 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1293 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
1294 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1294 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
1295 return startOfColumn + marginStartForChild(child); | 1295 return startOfColumn + marginStartForChild(child); |
1296 } | 1296 } |
1297 | 1297 |
1298 LayoutUnit RenderGrid::endOfColumnForChild(const RenderBox& child) const | 1298 LayoutUnit RenderGrid::endOfColumnForChild(const LayoutBox& child) const |
1299 { | 1299 { |
1300 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1300 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1301 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1301 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
1302 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1302 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
1303 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | 1303 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); |
1304 | 1304 |
1305 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | 1305 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; |
1306 // FIXME: This might not work as expected with orthogonal writing-modes. | 1306 // FIXME: This might not work as expected with orthogonal writing-modes. |
1307 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); | 1307 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); |
1308 | 1308 |
1309 return columnPosition + offsetFromColumnPosition; | 1309 return columnPosition + offsetFromColumnPosition; |
1310 } | 1310 } |
1311 | 1311 |
1312 LayoutUnit RenderGrid::columnPositionLeft(const RenderBox& child) const | 1312 LayoutUnit RenderGrid::columnPositionLeft(const LayoutBox& child) const |
1313 { | 1313 { |
1314 if (style()->isLeftToRightDirection()) | 1314 if (style()->isLeftToRightDirection()) |
1315 return startOfColumnForChild(child); | 1315 return startOfColumnForChild(child); |
1316 | 1316 |
1317 return endOfColumnForChild(child); | 1317 return endOfColumnForChild(child); |
1318 } | 1318 } |
1319 | 1319 |
1320 LayoutUnit RenderGrid::columnPositionRight(const RenderBox& child) const | 1320 LayoutUnit RenderGrid::columnPositionRight(const LayoutBox& child) const |
1321 { | 1321 { |
1322 if (!style()->isLeftToRightDirection()) | 1322 if (!style()->isLeftToRightDirection()) |
1323 return startOfColumnForChild(child); | 1323 return startOfColumnForChild(child); |
1324 | 1324 |
1325 return endOfColumnForChild(child); | 1325 return endOfColumnForChild(child); |
1326 } | 1326 } |
1327 | 1327 |
1328 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox& child) co
nst | 1328 LayoutUnit RenderGrid::centeredColumnPositionForChild(const LayoutBox& child) co
nst |
1329 { | 1329 { |
1330 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1330 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1331 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | 1331 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
1332 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | 1332 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; |
1333 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | 1333 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); |
1334 // FIXME: This might not work as expected with orthogonal writing-modes. | 1334 // FIXME: This might not work as expected with orthogonal writing-modes. |
1335 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); | 1335 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); |
1336 | 1336 |
1337 return columnPosition + offsetFromColumnPosition / 2; | 1337 return columnPosition + offsetFromColumnPosition / 2; |
1338 } | 1338 } |
1339 | 1339 |
1340 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox& child) const | 1340 LayoutUnit RenderGrid::columnPositionForChild(const LayoutBox& child) const |
1341 { | 1341 { |
1342 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 1342 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
1343 | 1343 |
1344 switch (LayoutStyle::resolveJustification(styleRef(), child.styleRef(), Item
PositionStretch)) { | 1344 switch (LayoutStyle::resolveJustification(styleRef(), child.styleRef(), Item
PositionStretch)) { |
1345 case ItemPositionSelfStart: | 1345 case ItemPositionSelfStart: |
1346 // For orthogonal writing-modes, this computes to 'start' | 1346 // For orthogonal writing-modes, this computes to 'start' |
1347 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1347 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
1348 if (hasOrthogonalWritingMode) | 1348 if (hasOrthogonalWritingMode) |
1349 return startOfColumnForChild(child); | 1349 return startOfColumnForChild(child); |
1350 | 1350 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 case ItemPositionBaseline: | 1387 case ItemPositionBaseline: |
1388 case ItemPositionLastBaseline: | 1388 case ItemPositionLastBaseline: |
1389 // FIXME: Implement the previous values. For now, we always 'start' alig
n the child. | 1389 // FIXME: Implement the previous values. For now, we always 'start' alig
n the child. |
1390 return startOfColumnForChild(child); | 1390 return startOfColumnForChild(child); |
1391 } | 1391 } |
1392 | 1392 |
1393 ASSERT_NOT_REACHED(); | 1393 ASSERT_NOT_REACHED(); |
1394 return 0; | 1394 return 0; |
1395 } | 1395 } |
1396 | 1396 |
1397 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox& child) const | 1397 LayoutUnit RenderGrid::endOfRowForChild(const LayoutBox& child) const |
1398 { | 1398 { |
1399 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1399 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1400 | 1400 |
1401 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1401 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
1402 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1402 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
1403 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1403 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); |
1404 | 1404 |
1405 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | 1405 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; |
1406 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); | 1406 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); |
1407 | 1407 |
1408 return rowPosition + offsetFromRowPosition; | 1408 return rowPosition + offsetFromRowPosition; |
1409 } | 1409 } |
1410 | 1410 |
1411 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox& child) const | 1411 LayoutUnit RenderGrid::startOfRowForChild(const LayoutBox& child) const |
1412 { | 1412 { |
1413 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1413 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1414 | 1414 |
1415 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1415 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
1416 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1416 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
1417 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1417 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); |
1418 | 1418 |
1419 return rowPosition; | 1419 return rowPosition; |
1420 } | 1420 } |
1421 | 1421 |
1422 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox& child) const | 1422 LayoutUnit RenderGrid::centeredRowPositionForChild(const LayoutBox& child) const |
1423 { | 1423 { |
1424 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1424 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1425 | 1425 |
1426 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | 1426 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. |
1427 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | 1427 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
1428 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | 1428 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; |
1429 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | 1429 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); |
1430 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); | 1430 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); |
1431 | 1431 |
1432 return rowPosition + offsetFromRowPosition / 2; | 1432 return rowPosition + offsetFromRowPosition / 2; |
1433 } | 1433 } |
1434 | 1434 |
1435 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Ren
derBox& child) | 1435 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) |
1436 { | 1436 { |
1437 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); | 1437 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); |
1438 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); | 1438 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
1439 } | 1439 } |
1440 | 1440 |
1441 bool RenderGrid::allowedToStretchLogicalHeightForChild(const RenderBox& child) c
onst | 1441 bool RenderGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c
onst |
1442 { | 1442 { |
1443 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo
reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); | 1443 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo
reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); |
1444 } | 1444 } |
1445 | 1445 |
1446 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1446 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1447 bool RenderGrid::needToStretchChildLogicalHeight(const RenderBox& child) const | 1447 bool RenderGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const |
1448 { | 1448 { |
1449 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition
Stretch) != ItemPositionStretch) | 1449 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition
Stretch) != ItemPositionStretch) |
1450 return false; | 1450 return false; |
1451 | 1451 |
1452 return isHorizontalWritingMode() && child.style()->height().isAuto(); | 1452 return isHorizontalWritingMode() && child.style()->height().isAuto(); |
1453 } | 1453 } |
1454 | 1454 |
1455 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1455 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1456 LayoutUnit RenderGrid::childIntrinsicHeight(const RenderBox& child) const | 1456 LayoutUnit RenderGrid::childIntrinsicHeight(const LayoutBox& child) const |
1457 { | 1457 { |
1458 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child
)) | 1458 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child
)) |
1459 return constrainedChildIntrinsicContentLogicalHeight(child); | 1459 return constrainedChildIntrinsicContentLogicalHeight(child); |
1460 return child.size().height(); | 1460 return child.size().height(); |
1461 } | 1461 } |
1462 | 1462 |
1463 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1463 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1464 LayoutUnit RenderGrid::childIntrinsicWidth(const RenderBox& child) const | 1464 LayoutUnit RenderGrid::childIntrinsicWidth(const LayoutBox& child) const |
1465 { | 1465 { |
1466 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil
d)) | 1466 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil
d)) |
1467 return constrainedChildIntrinsicContentLogicalHeight(child); | 1467 return constrainedChildIntrinsicContentLogicalHeight(child); |
1468 return child.size().width(); | 1468 return child.size().width(); |
1469 } | 1469 } |
1470 | 1470 |
1471 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1471 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1472 LayoutUnit RenderGrid::intrinsicLogicalHeightForChild(const RenderBox& child) co
nst | 1472 LayoutUnit RenderGrid::intrinsicLogicalHeightForChild(const LayoutBox& child) co
nst |
1473 { | 1473 { |
1474 return isHorizontalWritingMode() ? childIntrinsicHeight(child) : childIntrin
sicWidth(child); | 1474 return isHorizontalWritingMode() ? childIntrinsicHeight(child) : childIntrin
sicWidth(child); |
1475 } | 1475 } |
1476 | 1476 |
1477 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1477 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1478 LayoutUnit RenderGrid::marginLogicalHeightForChild(const RenderBox& child) const | 1478 LayoutUnit RenderGrid::marginLogicalHeightForChild(const LayoutBox& child) const |
1479 { | 1479 { |
1480 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); | 1480 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); |
1481 } | 1481 } |
1482 | 1482 |
1483 LayoutUnit RenderGrid::computeMarginLogicalHeightForChild(const RenderBox& child
) const | 1483 LayoutUnit RenderGrid::computeMarginLogicalHeightForChild(const LayoutBox& child
) const |
1484 { | 1484 { |
1485 LayoutUnit marginBefore; | 1485 LayoutUnit marginBefore; |
1486 LayoutUnit marginAfter; | 1486 LayoutUnit marginAfter; |
1487 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock
LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, | 1487 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock
LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, |
1488 child.style()->marginBeforeUsing(style()), | 1488 child.style()->marginBeforeUsing(style()), |
1489 child.style()->marginAfterUsing(style())); | 1489 child.style()->marginAfterUsing(style())); |
1490 | 1490 |
1491 return marginBefore + marginAfter; | 1491 return marginBefore + marginAfter; |
1492 } | 1492 } |
1493 | 1493 |
1494 LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni
t gridAreaBreadthForChild, const RenderBox& child) const | 1494 LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni
t gridAreaBreadthForChild, const LayoutBox& child) const |
1495 { | 1495 { |
1496 LayoutUnit childMarginLogicalHeight = marginLogicalHeightForChild(child); | 1496 LayoutUnit childMarginLogicalHeight = marginLogicalHeightForChild(child); |
1497 | 1497 |
1498 // Because we want to avoid multiple layouts, stretching logic might be perf
ormed before | 1498 // Because we want to avoid multiple layouts, stretching logic might be perf
ormed before |
1499 // children are laid out, so we can't use the child cached values. Hence, we
need to | 1499 // children are laid out, so we can't use the child cached values. Hence, we
need to |
1500 // compute margins in order to determine the available height before stretch
ing. | 1500 // compute margins in order to determine the available height before stretch
ing. |
1501 if (childMarginLogicalHeight == 0) | 1501 if (childMarginLogicalHeight == 0) |
1502 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); | 1502 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); |
1503 | 1503 |
1504 LayoutUnit childLogicalHeight = childMarginLogicalHeight + intrinsicLogicalH
eightForChild(child); | 1504 LayoutUnit childLogicalHeight = childMarginLogicalHeight + intrinsicLogicalH
eightForChild(child); |
1505 return gridAreaBreadthForChild - childLogicalHeight; | 1505 return gridAreaBreadthForChild - childLogicalHeight; |
1506 } | 1506 } |
1507 | 1507 |
1508 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to Re
nderBox. | 1508 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to La
youtBox. |
1509 void RenderGrid::applyStretchAlignmentToChildIfNeeded(RenderBox& child, LayoutUn
it gridAreaBreadthForChild) | 1509 void RenderGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn
it gridAreaBreadthForChild) |
1510 { | 1510 { |
1511 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition
Stretch) != ItemPositionStretch) | 1511 if (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosition
Stretch) != ItemPositionStretch) |
1512 return; | 1512 return; |
1513 | 1513 |
1514 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 1514 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
1515 if (allowedToStretchLogicalHeightForChild(child)) { | 1515 if (allowedToStretchLogicalHeightForChild(child)) { |
1516 // FIXME: If the child has orthogonal flow, then it already has an overr
ide height set, so use it. | 1516 // FIXME: If the child has orthogonal flow, then it already has an overr
ide height set, so use it. |
1517 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1517 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
1518 if (!hasOrthogonalWritingMode) { | 1518 if (!hasOrthogonalWritingMode) { |
1519 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei
ght(); | 1519 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(
child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHei
ght(); |
1520 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
leAlignmentSpaceForChildBeforeStretching(gridAreaBreadthForChild, child); | 1520 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availab
leAlignmentSpaceForChildBeforeStretching(gridAreaBreadthForChild, child); |
1521 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica
lHeight()); | 1521 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM
ax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogica
lHeight()); |
1522 LayoutUnit desiredLogicalContentHeight = desiredLogicalHeight - chil
d.borderAndPaddingLogicalHeight(); | 1522 LayoutUnit desiredLogicalContentHeight = desiredLogicalHeight - chil
d.borderAndPaddingLogicalHeight(); |
1523 | 1523 |
1524 // FIXME: Can avoid laying out here in some cases. See https://webki
t.org/b/87905. | 1524 // FIXME: Can avoid laying out here in some cases. See https://webki
t.org/b/87905. |
1525 if (desiredLogicalHeight != child.logicalHeight() || !child.hasOverr
ideHeight() || desiredLogicalContentHeight != child.overrideLogicalContentHeight
()) { | 1525 if (desiredLogicalHeight != child.logicalHeight() || !child.hasOverr
ideHeight() || desiredLogicalContentHeight != child.overrideLogicalContentHeight
()) { |
1526 child.setOverrideLogicalContentHeight(desiredLogicalContentHeigh
t); | 1526 child.setOverrideLogicalContentHeight(desiredLogicalContentHeigh
t); |
1527 child.setLogicalHeight(0); | 1527 child.setLogicalHeight(0); |
1528 child.forceChildLayout(); | 1528 child.forceChildLayout(); |
1529 } | 1529 } |
1530 } | 1530 } |
1531 } | 1531 } |
1532 } | 1532 } |
1533 | 1533 |
1534 LayoutUnit RenderGrid::rowPositionForChild(const RenderBox& child) const | 1534 LayoutUnit RenderGrid::rowPositionForChild(const LayoutBox& child) const |
1535 { | 1535 { |
1536 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 1536 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
1537 switch (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosi
tionStretch)) { | 1537 switch (LayoutStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPosi
tionStretch)) { |
1538 case ItemPositionSelfStart: | 1538 case ItemPositionSelfStart: |
1539 // If orthogonal writing-modes, this computes to 'start'. | 1539 // If orthogonal writing-modes, this computes to 'start'. |
1540 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1540 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
1541 if (hasOrthogonalWritingMode) | 1541 if (hasOrthogonalWritingMode) |
1542 return startOfRowForChild(child); | 1542 return startOfRowForChild(child); |
1543 | 1543 |
1544 // 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. | 1544 // 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. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 // crbug.com/234191 | 1699 // crbug.com/234191 |
1700 return 0; | 1700 return 0; |
1701 case ContentPositionAuto: | 1701 case ContentPositionAuto: |
1702 break; | 1702 break; |
1703 } | 1703 } |
1704 | 1704 |
1705 ASSERT_NOT_REACHED(); | 1705 ASSERT_NOT_REACHED(); |
1706 return 0; | 1706 return 0; |
1707 } | 1707 } |
1708 | 1708 |
1709 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child, LayoutS
ize contentAlignmentOffset) const | 1709 LayoutPoint RenderGrid::findChildLogicalPosition(const LayoutBox& child, LayoutS
ize contentAlignmentOffset) const |
1710 { | 1710 { |
1711 LayoutUnit columnPosition = columnPositionForChild(child); | 1711 LayoutUnit columnPosition = columnPositionForChild(child); |
1712 // We stored m_columnPositions's data ignoring the direction, hence we might
need now | 1712 // We stored m_columnPositions's data ignoring the direction, hence we might
need now |
1713 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. | 1713 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. |
1714 if (!style()->isLeftToRightDirection()) | 1714 if (!style()->isLeftToRightDirection()) |
1715 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord
erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); | 1715 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord
erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); |
1716 | 1716 |
1717 // The Content Alignment offset accounts for the RTL to LTR flip. | 1717 // The Content Alignment offset accounts for the RTL to LTR flip. |
1718 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); | 1718 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); |
1719 childLocation.move(contentAlignmentOffset); | 1719 childLocation.move(contentAlignmentOffset); |
(...skipping 13 matching lines...) Expand all Loading... |
1733 if (isOutOfFlowPositioned()) | 1733 if (isOutOfFlowPositioned()) |
1734 return "RenderGrid (positioned)"; | 1734 return "RenderGrid (positioned)"; |
1735 if (isAnonymous()) | 1735 if (isAnonymous()) |
1736 return "RenderGrid (generated)"; | 1736 return "RenderGrid (generated)"; |
1737 if (isRelPositioned()) | 1737 if (isRelPositioned()) |
1738 return "RenderGrid (relative positioned)"; | 1738 return "RenderGrid (relative positioned)"; |
1739 return "RenderGrid"; | 1739 return "RenderGrid"; |
1740 } | 1740 } |
1741 | 1741 |
1742 } // namespace blink | 1742 } // namespace blink |
OLD | NEW |