Chromium Code Reviews| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 child.clearOverrideLogicalContentHeight(); | 601 child.clearOverrideLogicalContentHeight(); |
| 602 | 602 |
| 603 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); | 603 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); |
| 604 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is | 604 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is |
| 605 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). | 605 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). |
| 606 child.setOverrideContainingBlockContentLogicalHeight(-1); | 606 child.setOverrideContainingBlockContentLogicalHeight(-1); |
| 607 child.layoutIfNeeded(); | 607 child.layoutIfNeeded(); |
| 608 return child.logicalHeight() + child.marginLogicalHeight(); | 608 return child.logicalHeight() + child.marginLogicalHeight(); |
| 609 } | 609 } |
| 610 | 610 |
| 611 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) | 611 LayoutUnit RenderGrid::logicalHeightForOrthogonalChild(RenderBox& child, Vector< GridTrack>& rowTracks) |
| 612 { | |
| 613 SubtreeLayoutScope layoutScope(child); | |
| 614 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child.hasOverrid eContainingBlockLogicalHeight() ? child.overrideContainingBlockContentLogicalHei ght() : LayoutUnit(); | |
| 615 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadthForC hild(child, ForRows, rowTracks); | |
| 616 if (oldOverrideContainingBlockContentLogicalHeight != overrideContainingBloc kContentLogicalHeight) | |
| 617 layoutScope.setNeedsLayout(&child); | |
| 618 | |
| 619 child.clearOverrideLogicalContentHeight(); | |
| 620 | |
| 621 child.setOverrideContainingBlockContentLogicalHeight(overrideContainingBlock ContentLogicalHeight); | |
| 622 child.layoutIfNeeded(); | |
| 623 return child.logicalHeight() + child.marginLogicalHeight(); | |
| 624 } | |
|
Julien - ping for review
2015/01/29 13:43:48
I don't think we should fork this function as it's
jfernandez
2015/02/06 22:59:58
Done.
| |
| 625 | |
| 626 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& tracksInTheInlineDirection) | |
| 612 { | 627 { |
| 613 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 628 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
| 614 // FIXME: Properly support orthogonal writing mode. | 629 if (hasOrthogonalWritingMode) { |
| 615 if (hasOrthogonalWritingMode) | 630 if (direction == ForColumns) |
| 616 return 0; | 631 return logicalHeightForOrthogonalChild(child, tracksInTheInlineDirec tion); |
| 632 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | |
| 633 } | |
| 617 | 634 |
| 618 if (direction == ForColumns) { | 635 if (direction == ForColumns) { |
| 619 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 636 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. |
| 620 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 637 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 621 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 638 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
| 622 } | 639 } |
| 623 | 640 |
| 624 return logicalHeightForChild(child, columnTracks); | 641 return logicalHeightForChild(child, tracksInTheInlineDirection); |
| 625 } | 642 } |
| 626 | 643 |
| 627 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) | 644 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& tracksInTheInlineDirection) |
| 628 { | 645 { |
| 629 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 646 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
| 630 // FIXME: Properly support orthogonal writing mode. | 647 if (hasOrthogonalWritingMode) { |
| 631 if (hasOrthogonalWritingMode) | 648 if (direction == ForColumns) |
| 632 return LayoutUnit(); | 649 return logicalHeightForOrthogonalChild(child, tracksInTheInlineDirec tion); |
| 650 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | |
| 651 } | |
| 633 | 652 |
| 634 if (direction == ForColumns) { | 653 if (direction == ForColumns) { |
| 635 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 654 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. |
| 636 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 655 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
| 637 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 656 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
| 638 } | 657 } |
| 639 | 658 |
| 640 return logicalHeightForChild(child, columnTracks); | 659 return logicalHeightForChild(child, tracksInTheInlineDirection); |
| 641 } | 660 } |
| 642 | 661 |
| 643 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or | 662 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or |
| 644 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class | 663 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class |
| 645 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a | 664 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a |
| 646 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an | 665 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an |
| 647 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). | 666 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). |
| 648 class GridItemWithSpan { | 667 class GridItemWithSpan { |
| 649 ALLOW_ONLY_INLINE_ALLOCATION(); | 668 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 650 public: | 669 public: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 } | 714 } |
| 696 | 715 |
| 697 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) | 716 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) |
| 698 { | 717 { |
| 699 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 718 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
| 700 HashSet<RenderBox*> itemsSet; | 719 HashSet<RenderBox*> itemsSet; |
| 701 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 720 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 702 GridIterator iterator(m_grid, direction, trackIndex); | 721 GridIterator iterator(m_grid, direction, trackIndex); |
| 703 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; | 722 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; |
| 704 while (RenderBox* gridItem = iterator.nextGridItem()) { | 723 while (RenderBox* gridItem = iterator.nextGridItem()) { |
| 724 bool hasOrthogonalWritingMode = gridItem->isHorizontalWritingMode() != isHorizontalWritingMode(); | |
| 705 if (itemsSet.add(gridItem).isNewEntry) { | 725 if (itemsSet.add(gridItem).isNewEntry) { |
| 706 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte m); | 726 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte m); |
| 707 if (integerSpanForDirection(coordinate, direction) == 1) { | 727 if (integerSpanForDirection(coordinate, direction) == 1) { |
| 708 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, coordinate, *gridItem, track, sizingData.columnTracks); | 728 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, coordinate, *gridItem, track, hasOrthogonalWritingMode ? sizingData.ro wTracks : sizingData.columnTracks); |
| 709 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d irection)) { | 729 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d irection)) { |
| 710 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, coordinate, direction)); | 730 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, coordinate, direction)); |
| 711 } | 731 } |
| 712 } | 732 } |
| 713 } | 733 } |
| 714 } | 734 } |
| 715 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end()); | 735 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end()); |
| 716 | 736 |
| 717 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS pan.end(); | 737 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS pan.end(); |
| 718 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas ingSpan.begin(); it != end; ++it) { | 738 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas ingSpan.begin(); it != end; ++it) { |
| 719 GridItemWithSpan itemWithSpan = *it; | 739 GridItemWithSpan itemWithSpan = *it; |
| 720 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize: :hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); | 740 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize: :hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); |
| 721 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); | 741 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); |
| 722 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim it); | 742 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim it); |
| 723 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); | 743 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); |
| 724 } | 744 } |
| 725 | 745 |
| 726 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 746 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
| 727 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; | 747 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; |
| 728 if (track.growthLimitIsInfinite()) | 748 if (track.growthLimitIsInfinite()) |
| 729 track.setGrowthLimit(track.baseSize()); | 749 track.setGrowthLimit(track.baseSize()); |
| 730 } | 750 } |
| 731 } | 751 } |
| 732 | 752 |
| 733 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gri dItem, GridTrack& track, Vector<GridTrack>& columnTracks) | 753 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gri dItem, GridTrack& track, Vector<GridTrack>& tracksInTheInlineDirection) |
| 734 { | 754 { |
| 735 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; | 755 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; |
| 736 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); | 756 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); |
| 737 | 757 |
| 738 if (trackSize.hasMinContentMinTrackBreadth()) | 758 if (trackSize.hasMinContentMinTrackBreadth()) |
| 739 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, columnTracks))); | 759 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, tracksInTheInlineDirection))); |
| 740 else if (trackSize.hasMaxContentMinTrackBreadth()) | 760 else if (trackSize.hasMaxContentMinTrackBreadth()) |
| 741 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, columnTracks))); | 761 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, tracksInTheInlineDirection))); |
| 742 | 762 |
| 743 if (trackSize.hasMinContentMaxTrackBreadth()) | 763 if (trackSize.hasMinContentMaxTrackBreadth()) |
| 744 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, columnTracks))); | 764 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, tracksInTheInlineDirection))); |
| 745 else if (trackSize.hasMaxContentMaxTrackBreadth()) | 765 else if (trackSize.hasMaxContentMaxTrackBreadth()) |
| 746 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, columnTracks))); | 766 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, tracksInTheInlineDirection))); |
| 747 } | 767 } |
| 748 | 768 |
| 749 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithS pan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGe tter trackGetter, AccumulatorGrowFunction trackGrowthFunction, FilterFunction gr owAboveMaxBreadthFilterFunction) | 769 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithS pan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGe tter trackGetter, AccumulatorGrowFunction trackGrowthFunction, FilterFunction gr owAboveMaxBreadthFilterFunction) |
| 750 { | 770 { |
| 751 ASSERT(gridItemWithSpan.span() > 1); | 771 ASSERT(gridItemWithSpan.span() > 1); |
| 752 const GridCoordinate coordinate = gridItemWithSpan.coordinate(); | 772 const GridCoordinate coordinate = gridItemWithSpan.coordinate(); |
| 753 const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo sition; | 773 const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo sition; |
| 754 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition ; | 774 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition ; |
| 755 | 775 |
| 756 sizingData.growAboveMaxBreadthTrackIndexes.shrink(0); | 776 sizingData.growAboveMaxBreadthTrackIndexes.shrink(0); |
| 757 sizingData.filteredTracks.shrink(0); | 777 sizingData.filteredTracks.shrink(0); |
| 758 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n <= finalTrackPosition; ++trackPosition) { | 778 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n <= finalTrackPosition; ++trackPosition) { |
| 759 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt() ); | 779 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt() ); |
| 760 if (!(trackSize.*filterFunction)()) | 780 if (!(trackSize.*filterFunction)()) |
| 761 continue; | 781 continue; |
| 762 | 782 |
| 763 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackPosition.toInt()] : sizingData.rowTracks[trackPosition.toInt()]; | 783 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackPosition.toInt()] : sizingData.rowTracks[trackPosition.toInt()]; |
| 764 sizingData.filteredTracks.append(&track); | 784 sizingData.filteredTracks.append(&track); |
| 765 | 785 |
| 766 if (growAboveMaxBreadthFilterFunction && (trackSize.*growAboveMaxBreadth FilterFunction)()) | 786 if (growAboveMaxBreadthFilterFunction && (trackSize.*growAboveMaxBreadth FilterFunction)()) |
| 767 sizingData.growAboveMaxBreadthTrackIndexes.append(sizingData.filtere dTracks.size() - 1); | 787 sizingData.growAboveMaxBreadthTrackIndexes.append(sizingData.filtere dTracks.size() - 1); |
| 768 } | 788 } |
| 769 | 789 |
| 770 if (sizingData.filteredTracks.isEmpty()) | 790 if (sizingData.filteredTracks.isEmpty()) |
| 771 return; | 791 return; |
| 772 | 792 |
| 773 LayoutUnit additionalBreadthSpace = (this->*sizingFunction)(gridItemWithSpan .gridItem(), direction, sizingData.columnTracks); | 793 bool hasOrthogonalWritingMode = gridItemWithSpan.gridItem().isHorizontalWrit ingMode() != isHorizontalWritingMode(); |
| 794 LayoutUnit additionalBreadthSpace = (this->*sizingFunction)(gridItemWithSpan .gridItem(), direction, hasOrthogonalWritingMode ? sizingData.rowTracks : sizing Data.columnTracks); | |
| 774 for (GridResolvedPosition trackIndexForSpace = initialTrackPosition; trackIn dexForSpace <= finalTrackPosition; ++trackIndexForSpace) { | 795 for (GridResolvedPosition trackIndexForSpace = initialTrackPosition; trackIn dexForSpace <= finalTrackPosition; ++trackIndexForSpace) { |
| 775 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndexForSpace.toInt()] : sizingData.rowTracks[trackIndexForSpace.toInt()]; | 796 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndexForSpace.toInt()] : sizingData.rowTracks[trackIndexForSpace.toInt()]; |
| 776 additionalBreadthSpace -= (track.*trackGetter)(); | 797 additionalBreadthSpace -= (track.*trackGetter)(); |
| 777 } | 798 } |
| 778 | 799 |
| 779 // Specs mandate to floor additionalBreadthSpace (extra-space in specs) to 0 . Instead we directly avoid the function | 800 // Specs mandate to floor additionalBreadthSpace (extra-space in specs) to 0 . Instead we directly avoid the function |
| 780 // call in those cases as it will be a noop in terms of track sizing. | 801 // call in those cases as it will be a noop in terms of track sizing. |
| 781 if (additionalBreadthSpace > 0) | 802 if (additionalBreadthSpace > 0) |
| 782 distributeSpaceToTracks(sizingData.filteredTracks, &sizingData.growAbove MaxBreadthTrackIndexes, trackGetter, trackGrowthFunction, sizingData, additional BreadthSpace); | 803 distributeSpaceToTracks(sizingData.filteredTracks, &sizingData.growAbove MaxBreadthTrackIndexes, trackGetter, trackGrowthFunction, sizingData, additional BreadthSpace); |
| 783 } | 804 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 m_gridItemsIndexesMap.clear(); | 1094 m_gridItemsIndexesMap.clear(); |
| 1074 } | 1095 } |
| 1075 | 1096 |
| 1076 void RenderGrid::layoutGridItems() | 1097 void RenderGrid::layoutGridItems() |
| 1077 { | 1098 { |
| 1078 placeItemsOnGrid(); | 1099 placeItemsOnGrid(); |
| 1079 | 1100 |
| 1080 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 1101 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); |
| 1081 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding); | 1102 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding); |
| 1082 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 1103 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 1104 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns. | |
| 1083 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns); | 1105 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns); |
| 1084 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); | 1106 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); |
| 1107 // 2- Next, the track sizing algorithm resolves the sizes of the grid rows, using the | |
| 1108 // grid column sizes calculated in the previous step. | |
| 1085 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); | 1109 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); |
| 1086 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1110 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
| 1111 // 3- If the min-content contribution of any grid items have changed based o n the row | |
| 1112 // sizes calculated in step 2, steps 1 and 2 are repeated with the new min-c ontent | |
| 1113 // contribution (once only). | |
|
Julien - ping for review
2015/01/29 13:43:48
I wonder if we shouldn't just do this step if we k
jfernandez
2015/02/06 22:59:58
I think it's a better approach, indeed.
| |
| 1114 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | |
| 1115 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); | |
| 1116 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks); | |
| 1117 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode(); | |
| 1118 // In orthogonal flow cases column tracks size is determined based on th e computed | |
| 1119 // row track sizes, hence we need to repeat computeUsedBreadthOfGridTrac ks for columns. | |
| 1120 if (hasOrthogonalWritingMode && oldOverrideContainingBlockContentLogical Height != overrideContainingBlockContentLogicalHeight) { | |
| 1121 availableSpaceForColumns = availableLogicalWidth(); | |
| 1122 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpac eForColumns); | |
| 1123 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.colu mnTracks)); | |
| 1124 break; | |
| 1125 } | |
| 1126 } | |
| 1087 | 1127 |
| 1088 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo rRows); | 1128 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo rRows); |
| 1089 m_gridItemsOverflowingGridArea.resize(0); | 1129 m_gridItemsOverflowingGridArea.resize(0); |
| 1090 | 1130 |
| 1091 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio n(), m_columnPositions.size() - 1); | 1131 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio n(), m_columnPositions.size() - 1); |
| 1092 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac eForRows, style()->alignContent(), style()->alignContentDistribution(), m_rowPos itions.size() - 1); | 1132 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac eForRows, style()->alignContent(), style()->alignContentDistribution(), m_rowPos itions.size() - 1); |
| 1093 LayoutSize contentPositionOffset(columnOffset, rowOffset); | 1133 LayoutSize contentPositionOffset(columnOffset, rowOffset); |
| 1094 | 1134 |
| 1095 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | 1135 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { |
| 1096 if (child->isOutOfFlowPositioned()) { | 1136 if (child->isOutOfFlowPositioned()) { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1123 | 1163 |
| 1124 #if ENABLE(ASSERT) | 1164 #if ENABLE(ASSERT) |
| 1125 const GridCoordinate& coordinate = cachedGridCoordinate(*child); | 1165 const GridCoordinate& coordinate = cachedGridCoordinate(*child); |
| 1126 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); | 1166 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); |
| 1127 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); | 1167 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); |
| 1128 #endif | 1168 #endif |
| 1129 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset)); | 1169 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset)); |
| 1130 | 1170 |
| 1131 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is | 1171 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is |
| 1132 // not visible | 1172 // not visible |
| 1133 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight | 1173 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode(); |
| 1134 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt h) | 1174 bool overflowingContainingBlockHeight = hasOrthogonalWritingMode ? child ->logicalWidth() > overrideContainingBlockContentLogicalHeight : child->logicalH eight() > overrideContainingBlockContentLogicalHeight; |
| 1175 bool overflowingContainingBlockWidth = hasOrthogonalWritingMode ? child- >logicalHeight() > overrideContainingBlockContentLogicalWidth : child->logicalHe ight() > overrideContainingBlockContentLogicalWidth; | |
| 1176 if (overflowingContainingBlockHeight || overflowingContainingBlockWidth) | |
| 1135 m_gridItemsOverflowingGridArea.append(child); | 1177 m_gridItemsOverflowingGridArea.append(child); |
| 1136 } | 1178 } |
| 1137 | 1179 |
| 1138 for (const auto& row : sizingData.rowTracks) | 1180 for (const auto& row : sizingData.rowTracks) |
| 1139 setLogicalHeight(logicalHeight() + row.baseSize()); | 1181 setLogicalHeight(logicalHeight() + row.baseSize()); |
| 1140 | 1182 |
| 1141 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock. | 1183 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock. |
| 1142 | 1184 |
| 1143 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); | 1185 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); |
| 1144 } | 1186 } |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1685 LayoutUnit columnPosition = columnPositionForChild(child); | 1727 LayoutUnit columnPosition = columnPositionForChild(child); |
| 1686 // We stored m_columnPositions's data ignoring the direction, hence we might need now | 1728 // We stored m_columnPositions's data ignoring the direction, hence we might need now |
| 1687 // to translate positions from RTL to LTR, as it's more convenient for paint ing. | 1729 // to translate positions from RTL to LTR, as it's more convenient for paint ing. |
| 1688 if (!style()->isLeftToRightDirection()) | 1730 if (!style()->isLeftToRightDirection()) |
| 1689 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); | 1731 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); |
| 1690 | 1732 |
| 1691 // The Content Alignment offset accounts for the RTL to LTR flip. | 1733 // The Content Alignment offset accounts for the RTL to LTR flip. |
| 1692 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); | 1734 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); |
| 1693 childLocation.move(contentAlignmentOffset); | 1735 childLocation.move(contentAlignmentOffset); |
| 1694 | 1736 |
| 1695 return childLocation; | 1737 // "In the positioning phase [...] calculations are performed according to t he writing mode |
| 1738 // of the containing block of the box establishing the orthogonal flow." How ever, the | |
| 1739 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's | |
|
Julien - ping for review
2015/01/29 13:43:48
setLogicalPosition?
jfernandez
2015/02/06 22:59:58
Sorry, I meant setLogicalLocation. This function t
| |
| 1740 // logical position, which will only take into account the child's writing-m ode. | |
| 1741 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
| 1742 return hasOrthogonalWritingMode ? childLocation.transposedPoint() : childLoc ation; | |
| 1696 } | 1743 } |
| 1697 | 1744 |
| 1698 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) | 1745 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) |
| 1699 { | 1746 { |
| 1700 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1747 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 1701 } | 1748 } |
| 1702 | 1749 |
| 1703 const char* RenderGrid::renderName() const | 1750 const char* RenderGrid::renderName() const |
| 1704 { | 1751 { |
| 1705 if (isFloating()) | 1752 if (isFloating()) |
| 1706 return "RenderGrid (floating)"; | 1753 return "RenderGrid (floating)"; |
| 1707 if (isOutOfFlowPositioned()) | 1754 if (isOutOfFlowPositioned()) |
| 1708 return "RenderGrid (positioned)"; | 1755 return "RenderGrid (positioned)"; |
| 1709 if (isAnonymous()) | 1756 if (isAnonymous()) |
| 1710 return "RenderGrid (generated)"; | 1757 return "RenderGrid (generated)"; |
| 1711 if (isRelPositioned()) | 1758 if (isRelPositioned()) |
| 1712 return "RenderGrid (relative positioned)"; | 1759 return "RenderGrid (relative positioned)"; |
| 1713 return "RenderGrid"; | 1760 return "RenderGrid"; |
| 1714 } | 1761 } |
| 1715 | 1762 |
| 1716 } // namespace blink | 1763 } // namespace blink |
| OLD | NEW |