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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 // of indefinite sizes. This is a broather issue as Length does not have the required context to support it. | 603 // of indefinite sizes. This is a broather issue as Length does not have the required context to support it. |
604 if (logicalSize.isIntrinsicOrAuto()) { | 604 if (logicalSize.isIntrinsicOrAuto()) { |
605 const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth(); | 605 const GridLength& oldMinTrackBreadth = trackSize.minTrackBreadth(); |
606 const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth(); | 606 const GridLength& oldMaxTrackBreadth = trackSize.maxTrackBreadth(); |
607 return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinConte nt) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent) : oldMaxTrackBreadth); | 607 return GridTrackSize(oldMinTrackBreadth.isPercentage() ? Length(MinConte nt) : oldMinTrackBreadth, oldMaxTrackBreadth.isPercentage() ? Length(MaxContent) : oldMaxTrackBreadth); |
608 } | 608 } |
609 | 609 |
610 return trackSize; | 610 return trackSize; |
611 } | 611 } |
612 | 612 |
613 LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, Vector<GridTrack> & columnTracks) | 613 LayoutUnit RenderGrid::overrideContainingBlockLogicalBreadthInlineDirection(cons t RenderBox& child) const |
614 { | |
615 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
616 if (hasOrthogonalWritingMode) | |
617 return child.hasOverrideContainingBlockLogicalHeight() ? child.overrideC ontainingBlockContentLogicalHeight() : LayoutUnit(); | |
618 return child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContai ningBlockContentLogicalWidth() : LayoutUnit(); | |
619 } | |
620 | |
621 void RenderGrid::setOverrideContainingBlockLogicalBreadthInlineDirection(RenderB ox& child, LayoutUnit breadth) | |
622 { | |
623 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
624 if (hasOrthogonalWritingMode) | |
625 child.setOverrideContainingBlockContentLogicalHeight(breadth); | |
626 else | |
627 child.setOverrideContainingBlockContentLogicalWidth(breadth); | |
628 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is | |
629 // what we are interested in here. Thus we need to set the override logical height/width to -1 (no possible resolution). | |
630 if (child.style()->logicalHeight().isPercent()) { | |
631 if (hasOrthogonalWritingMode) | |
632 child.setOverrideContainingBlockContentLogicalWidth(-1); | |
633 else | |
634 child.setOverrideContainingBlockContentLogicalHeight(-1); | |
Julien - ping for review
2015/02/18 23:00:07
We do 2 hash lookups in the percentage logical hei
jfernandez
2015/02/23 18:51:58
Actually we don't; we need to set both, xxxLogical
| |
635 } | |
636 } | |
637 | |
638 LayoutUnit RenderGrid::gridAreaBreadthForChildInlineDirection(const RenderBox& c hild, Vector<GridTrack>& tracksInlineDirection) const | |
Julien - ping for review
2015/02/18 23:00:07
This name is confusing and I still am unsure I und
jfernandez
2015/02/23 18:51:58
I took the name inspired by other methods like com
| |
639 { | |
640 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
641 if (hasOrthogonalWritingMode) | |
642 return gridAreaBreadthForChild(child, ForRows, tracksInlineDirection); | |
643 return gridAreaBreadthForChild(child, ForColumns, tracksInlineDirection); | |
644 } | |
645 | |
646 | |
647 LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, Vector<GridTrack> & tracksInlineDirection) | |
614 { | 648 { |
615 SubtreeLayoutScope layoutScope(child); | 649 SubtreeLayoutScope layoutScope(child); |
616 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit(); | 650 LayoutUnit oldOverrideContainingBlockContentLogicalBreadthInlineDirection = overrideContainingBlockLogicalBreadthInlineDirection(child); |
617 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, columnTracks); | 651 LayoutUnit overrideContainingBlockContentLogicalBreadthInlineDirection = gri dAreaBreadthForChildInlineDirection(child, tracksInlineDirection); |
618 if (child.style()->logicalHeight().isPercent() || oldOverrideContainingBlock ContentLogicalWidth != overrideContainingBlockContentLogicalWidth) | 652 if (child.style()->logicalHeight().isPercent() || oldOverrideContainingBlock ContentLogicalBreadthInlineDirection != overrideContainingBlockContentLogicalBre adthInlineDirection) |
619 layoutScope.setNeedsLayout(&child); | 653 layoutScope.setNeedsLayout(&child); |
620 | 654 |
655 // Needed to properly implement the stretch logic. | |
621 child.clearOverrideLogicalContentHeight(); | 656 child.clearOverrideLogicalContentHeight(); |
622 | 657 |
623 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth); | 658 setOverrideContainingBlockLogicalBreadthInlineDirection(child, overrideConta iningBlockContentLogicalBreadthInlineDirection); |
624 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is | |
625 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). | |
626 child.setOverrideContainingBlockContentLogicalHeight(-1); | |
627 child.layoutIfNeeded(); | 659 child.layoutIfNeeded(); |
628 return child.logicalHeight() + child.marginLogicalHeight(); | 660 return child.logicalHeight() + child.marginLogicalHeight(); |
629 } | 661 } |
630 | 662 |
631 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) | 663 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& tracksInlineDirection) |
Julien - ping for review
2015/02/18 23:00:07
In correct English, this would be tracksInInlineDi
jfernandez
2015/02/23 18:51:58
That s right. However, I saw source code using jus
| |
632 { | 664 { |
633 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 665 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
634 // FIXME: Properly support orthogonal writing mode. | |
635 if (hasOrthogonalWritingMode) | 666 if (hasOrthogonalWritingMode) |
636 return 0; | 667 direction = direction == ForColumns ? ForRows : ForColumns; |
637 | 668 |
638 if (direction == ForColumns) { | 669 if (direction == ForColumns) { |
639 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 670 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. |
640 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 671 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
641 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 672 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
642 } | 673 } |
643 | 674 |
644 return logicalHeightForChild(child, columnTracks); | 675 return logicalHeightForChild(child, tracksInlineDirection); |
645 } | 676 } |
646 | 677 |
647 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) | 678 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& tracksInlineDirection) |
648 { | 679 { |
649 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 680 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
650 // FIXME: Properly support orthogonal writing mode. | |
651 if (hasOrthogonalWritingMode) | 681 if (hasOrthogonalWritingMode) |
652 return LayoutUnit(); | 682 direction = direction == ForColumns ? ForRows : ForColumns; |
653 | 683 |
654 if (direction == ForColumns) { | 684 if (direction == ForColumns) { |
655 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. | 685 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. |
656 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html | 686 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html |
657 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); | 687 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); |
658 } | 688 } |
659 | 689 |
660 return logicalHeightForChild(child, columnTracks); | 690 return logicalHeightForChild(child, tracksInlineDirection); |
661 } | 691 } |
662 | 692 |
663 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or | 693 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or |
664 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class | 694 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class |
665 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a | 695 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a |
666 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an | 696 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an |
667 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). | 697 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). |
668 class GridItemWithSpan { | 698 class GridItemWithSpan { |
669 public: | 699 public: |
670 GridItemWithSpan(RenderBox& gridItem, const GridCoordinate& coordinate, Grid TrackSizingDirection direction) | 700 GridItemWithSpan(RenderBox& gridItem, const GridCoordinate& coordinate, Grid TrackSizingDirection direction) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 } | 739 } |
710 | 740 |
711 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) | 741 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) |
712 { | 742 { |
713 sizingData.itemsSortedByIncreasingSpan.shrink(0); | 743 sizingData.itemsSortedByIncreasingSpan.shrink(0); |
714 HashSet<RenderBox*> itemsSet; | 744 HashSet<RenderBox*> itemsSet; |
715 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 745 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
716 GridIterator iterator(m_grid, direction, trackIndex); | 746 GridIterator iterator(m_grid, direction, trackIndex); |
717 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; | 747 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; |
718 while (RenderBox* gridItem = iterator.nextGridItem()) { | 748 while (RenderBox* gridItem = iterator.nextGridItem()) { |
749 bool hasOrthogonalWritingMode = gridItem->isHorizontalWritingMode() != isHorizontalWritingMode(); | |
719 if (itemsSet.add(gridItem).isNewEntry) { | 750 if (itemsSet.add(gridItem).isNewEntry) { |
720 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte m); | 751 const GridCoordinate& coordinate = cachedGridCoordinate(*gridIte m); |
721 if (integerSpanForDirection(coordinate, direction) == 1) { | 752 if (integerSpanForDirection(coordinate, direction) == 1) { |
722 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, coordinate, *gridItem, track, sizingData.columnTracks); | 753 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(d irection, coordinate, *gridItem, track, hasOrthogonalWritingMode ? sizingData.ro wTracks : sizingData.columnTracks); |
723 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d irection)) { | 754 } else if (!spanningItemCrossesFlexibleSizedTracks(coordinate, d irection)) { |
724 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, coordinate, direction)); | 755 sizingData.itemsSortedByIncreasingSpan.append(GridItemWithSp an(*gridItem, coordinate, direction)); |
725 } | 756 } |
726 } | 757 } |
727 } | 758 } |
728 } | 759 } |
729 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end()); | 760 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), sizingData.itemsSo rtedByIncreasingSpan.end()); |
730 | 761 |
731 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS pan.end(); | 762 Vector<GridItemWithSpan>::iterator end = sizingData.itemsSortedByIncreasingS pan.end(); |
732 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas ingSpan.begin(); it != end; ++it) { | 763 for (Vector<GridItemWithSpan>::iterator it = sizingData.itemsSortedByIncreas ingSpan.begin(); it != end; ++it) { |
733 GridItemWithSpan itemWithSpan = *it; | 764 GridItemWithSpan itemWithSpan = *it; |
734 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize: :hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); | 765 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize: :hasMinContentMinTrackBreadthAndMinOrMaxContentMaxTrackBreadth); |
735 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); | 766 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::baseSize, &GridTrack::growBaseSize, &GridTrackSize::hasM axContentMinTrackBreadthAndMaxContentMaxTrackBreadth); |
736 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim it); | 767 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLim it); |
737 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); | 768 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, i temWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::growthLimitIfNotInfinite, &GridTrack::growGrowthLimit); |
738 } | 769 } |
739 | 770 |
740 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { | 771 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { |
741 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; | 772 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackIndex] : sizingData.rowTracks[trackIndex]; |
742 if (track.growthLimitIsInfinite()) | 773 if (track.growthLimitIsInfinite()) |
743 track.setGrowthLimit(track.baseSize()); | 774 track.setGrowthLimit(track.baseSize()); |
744 } | 775 } |
745 } | 776 } |
746 | 777 |
747 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gri dItem, GridTrack& track, Vector<GridTrack>& columnTracks) | 778 void RenderGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(Grid TrackSizingDirection direction, const GridCoordinate& coordinate, RenderBox& gri dItem, GridTrack& track, Vector<GridTrack>& tracksInlineDirection) |
748 { | 779 { |
749 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; | 780 const GridResolvedPosition trackPosition = (direction == ForColumns) ? coord inate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; |
750 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); | 781 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt()); |
751 | 782 |
752 if (trackSize.hasMinContentMinTrackBreadth()) | 783 if (trackSize.hasMinContentMinTrackBreadth()) |
753 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, columnTracks))); | 784 track.setBaseSize(std::max(track.baseSize(), minContentForChild(gridItem , direction, tracksInlineDirection))); |
754 else if (trackSize.hasMaxContentMinTrackBreadth()) | 785 else if (trackSize.hasMaxContentMinTrackBreadth()) |
755 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, columnTracks))); | 786 track.setBaseSize(std::max(track.baseSize(), maxContentForChild(gridItem , direction, tracksInlineDirection))); |
756 | 787 |
757 if (trackSize.hasMinContentMaxTrackBreadth()) | 788 if (trackSize.hasMinContentMaxTrackBreadth()) |
758 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, columnTracks))); | 789 track.setGrowthLimit(std::max(track.growthLimit(), minContentForChild(gr idItem, direction, tracksInlineDirection))); |
759 else if (trackSize.hasMaxContentMaxTrackBreadth()) | 790 else if (trackSize.hasMaxContentMaxTrackBreadth()) |
760 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, columnTracks))); | 791 track.setGrowthLimit(std::max(track.growthLimit(), maxContentForChild(gr idItem, direction, tracksInlineDirection))); |
761 } | 792 } |
762 | 793 |
763 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithS pan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGe tter trackGetter, AccumulatorGrowFunction trackGrowthFunction, FilterFunction gr owAboveMaxBreadthFilterFunction) | 794 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithS pan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGe tter trackGetter, AccumulatorGrowFunction trackGrowthFunction, FilterFunction gr owAboveMaxBreadthFilterFunction) |
764 { | 795 { |
765 ASSERT(gridItemWithSpan.span() > 1); | 796 ASSERT(gridItemWithSpan.span() > 1); |
766 const GridCoordinate coordinate = gridItemWithSpan.coordinate(); | 797 const GridCoordinate coordinate = gridItemWithSpan.coordinate(); |
767 const GridSpan& itemSpan = (direction == ForColumns) ? coordinate.columns : coordinate.rows; | 798 const GridSpan& itemSpan = (direction == ForColumns) ? coordinate.columns : coordinate.rows; |
768 | 799 |
769 sizingData.growBeyondGrowthLimitsTracks.shrink(0); | 800 sizingData.growBeyondGrowthLimitsTracks.shrink(0); |
770 sizingData.filteredTracks.shrink(0); | 801 sizingData.filteredTracks.shrink(0); |
771 LayoutUnit spanningTracksSize; | 802 LayoutUnit spanningTracksSize; |
772 for (const auto& trackPosition : itemSpan) { | 803 for (const auto& trackPosition : itemSpan) { |
773 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt() ); | 804 GridTrackSize trackSize = gridTrackSize(direction, trackPosition.toInt() ); |
774 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackPosition.toInt()] : sizingData.rowTracks[trackPosition.toInt()]; | 805 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[t rackPosition.toInt()] : sizingData.rowTracks[trackPosition.toInt()]; |
775 spanningTracksSize += (track.*trackGetter)(); | 806 spanningTracksSize += (track.*trackGetter)(); |
776 if (!(trackSize.*filterFunction)()) | 807 if (!(trackSize.*filterFunction)()) |
777 continue; | 808 continue; |
778 | 809 |
779 sizingData.filteredTracks.append(&track); | 810 sizingData.filteredTracks.append(&track); |
780 | 811 |
781 if (!growAboveMaxBreadthFilterFunction || (trackSize.*growAboveMaxBreadt hFilterFunction)()) | 812 if (!growAboveMaxBreadthFilterFunction || (trackSize.*growAboveMaxBreadt hFilterFunction)()) |
782 sizingData.growBeyondGrowthLimitsTracks.append(&track); | 813 sizingData.growBeyondGrowthLimitsTracks.append(&track); |
783 } | 814 } |
784 | 815 |
785 if (sizingData.filteredTracks.isEmpty()) | 816 if (sizingData.filteredTracks.isEmpty()) |
786 return; | 817 return; |
787 | 818 |
788 // Specs mandate to floor extraSpace to 0. Instead we directly avoid the fun ction call in those cases as it will be | 819 // Specs mandate to floor extraSpace to 0. Instead we directly avoid the fun ction call in those cases as it will be |
789 // a noop in terms of track sizing. | 820 // a noop in terms of track sizing. |
790 LayoutUnit extraSpace = (this->*sizingFunction)(gridItemWithSpan.gridItem(), direction, sizingData.columnTracks) - spanningTracksSize; | 821 bool hasOrthogonalWritingMode = gridItemWithSpan.gridItem().isHorizontalWrit ingMode() != isHorizontalWritingMode(); |
822 LayoutUnit extraSpace = (this->*sizingFunction)(gridItemWithSpan.gridItem(), direction, hasOrthogonalWritingMode ? sizingData.rowTracks : sizingData.columnT racks) - spanningTracksSize; | |
791 if (extraSpace > 0) { | 823 if (extraSpace > 0) { |
792 Vector<GridTrack*>* tracksToGrowBeyondGrowthLimits = sizingData.growBeyo ndGrowthLimitsTracks.isEmpty() ? &sizingData.filteredTracks : &sizingData.growBe yondGrowthLimitsTracks; | 824 Vector<GridTrack*>* tracksToGrowBeyondGrowthLimits = sizingData.growBeyo ndGrowthLimitsTracks.isEmpty() ? &sizingData.filteredTracks : &sizingData.growBe yondGrowthLimitsTracks; |
793 distributeSpaceToTracks(sizingData.filteredTracks, tracksToGrowBeyondGro wthLimits, trackGetter, trackGrowthFunction, sizingData, extraSpace); | 825 distributeSpaceToTracks(sizingData.filteredTracks, tracksToGrowBeyondGro wthLimits, trackGetter, trackGrowthFunction, sizingData, extraSpace); |
794 } | 826 } |
795 } | 827 } |
796 | 828 |
797 static bool sortByGridTrackGrowthPotential(const GridTrack* track1, const GridTr ack* track2) | 829 static bool sortByGridTrackGrowthPotential(const GridTrack* track1, const GridTr ack* track2) |
798 { | 830 { |
799 // This check ensures that we respect the irreflexivity property of the stri ct weak ordering required by std::sort | 831 // This check ensures that we respect the irreflexivity property of the stri ct weak ordering required by std::sort |
800 // (forall x: NOT x < x). | 832 // (forall x: NOT x < x). |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1072 | 1104 |
1073 void RenderGrid::dirtyGrid() | 1105 void RenderGrid::dirtyGrid() |
1074 { | 1106 { |
1075 m_grid.resize(0); | 1107 m_grid.resize(0); |
1076 m_gridItemCoordinate.clear(); | 1108 m_gridItemCoordinate.clear(); |
1077 m_gridIsDirty = true; | 1109 m_gridIsDirty = true; |
1078 m_gridItemsOverflowingGridArea.resize(0); | 1110 m_gridItemsOverflowingGridArea.resize(0); |
1079 m_gridItemsIndexesMap.clear(); | 1111 m_gridItemsIndexesMap.clear(); |
1080 } | 1112 } |
1081 | 1113 |
1114 bool RenderGrid::childOverflowingContainingBlockHeight(const RenderBox& child) c onst | |
1115 { | |
1116 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
1117 LayoutUnit overrideContainingBlockContentLogicalHeight = child.hasOverrideCo ntainingBlockLogicalHeight() ? child.overrideContainingBlockContentLogicalHeight () : LayoutUnit(); | |
1118 | |
1119 return hasOrthogonalWritingMode ? child.logicalWidth() > overrideContainingB lockContentLogicalHeight : child.logicalHeight() > overrideContainingBlockConten tLogicalHeight; | |
1120 } | |
Julien - ping for review
2015/02/18 23:00:07
This seems super complicated to me. We don't *need
jfernandez
2015/02/23 18:51:58
Oh, you are so right. I'll implement it that way i
| |
1121 | |
1122 bool RenderGrid::childOverflowingContainingBlockWidth(const RenderBox& child) co nst | |
1123 { | |
1124 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
1125 LayoutUnit overrideContainingBlockContentLogicalWidth = child.hasOverrideCon tainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); | |
1126 | |
1127 return hasOrthogonalWritingMode ? child.logicalHeight() > overrideContaining BlockContentLogicalWidth : child.logicalHeight() > overrideContainingBlockConten tLogicalWidth; | |
1128 } | |
1129 | |
1082 void RenderGrid::layoutGridItems() | 1130 void RenderGrid::layoutGridItems() |
1083 { | 1131 { |
1084 placeItemsOnGrid(); | 1132 placeItemsOnGrid(); |
1085 | 1133 |
1086 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 1134 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); |
1087 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding); | 1135 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding); |
1088 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 1136 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
1137 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns. | |
1089 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns); | 1138 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns); |
1090 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); | 1139 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.columnTracks )); |
1140 // 2- Next, the track sizing algorithm resolves the sizes of the grid rows, using the | |
1141 // grid column sizes calculated in the previous step. | |
1091 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); | 1142 computeUsedBreadthOfGridTracks(ForRows, sizingData, availableSpaceForRows); |
1092 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); | 1143 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData.rowTracks)); |
1144 // 3- If the min-content contribution of any grid items have changed based o n the row | |
1145 // sizes calculated in step 2, steps 1 and 2 are repeated with the new min-c ontent | |
1146 // contribution (once only). | |
1147 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | |
1148 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode(); | |
1149 // In orthogonal flow cases column tracks size is determined based on th e computed | |
1150 // row track sizes, hence we need to repeat computeUsedBreadthOfGridTrac ks for columns. | |
1151 if (hasOrthogonalWritingMode) { | |
1152 availableSpaceForColumns = availableLogicalWidth(); | |
1153 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpac eForColumns); | |
1154 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData.colu mnTracks)); | |
1155 break; | |
1156 } | |
1157 } | |
1093 | 1158 |
1094 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo rRows); | 1159 populateGridPositions(sizingData, availableSpaceForColumns, availableSpaceFo rRows); |
1095 m_gridItemsOverflowingGridArea.resize(0); | 1160 m_gridItemsOverflowingGridArea.resize(0); |
1096 | 1161 |
1097 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); | 1162 LayoutUnit columnOffset = contentPositionAndDistributionColumnOffset(availab leSpaceForColumns, style()->justifyContent(), style()->justifyContentDistributio n(), style()->justifyContentOverflowAlignment(), m_columnPositions.size() - 1); |
1098 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac eForRows, style()->alignContent(), style()->alignContentDistribution(), style()- >alignContentOverflowAlignment(), m_rowPositions.size() - 1); | 1163 LayoutUnit rowOffset = contentPositionAndDistributionRowOffset(availableSpac eForRows, style()->alignContent(), style()->alignContentDistribution(), style()- >alignContentOverflowAlignment(), m_rowPositions.size() - 1); |
1099 LayoutSize contentPositionOffset(columnOffset, rowOffset); | 1164 LayoutSize contentPositionOffset(columnOffset, rowOffset); |
1100 | 1165 |
1101 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { | 1166 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo x()) { |
1102 if (child->isOutOfFlowPositioned()) { | 1167 if (child->isOutOfFlowPositioned()) { |
(...skipping 25 matching lines...) Expand all Loading... | |
1128 | 1193 |
1129 #if ENABLE(ASSERT) | 1194 #if ENABLE(ASSERT) |
1130 const GridCoordinate& coordinate = cachedGridCoordinate(*child); | 1195 const GridCoordinate& coordinate = cachedGridCoordinate(*child); |
1131 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); | 1196 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); |
1132 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); | 1197 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); |
1133 #endif | 1198 #endif |
1134 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset)); | 1199 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset)); |
1135 | 1200 |
1136 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is | 1201 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is |
1137 // not visible | 1202 // not visible |
1138 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight | 1203 if (childOverflowingContainingBlockHeight(*child) |
1139 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt h) | 1204 || childOverflowingContainingBlockWidth(*child)) |
1140 m_gridItemsOverflowingGridArea.append(child); | 1205 m_gridItemsOverflowingGridArea.append(child); |
1141 } | 1206 } |
1142 | 1207 |
1143 for (const auto& row : sizingData.rowTracks) | 1208 for (const auto& row : sizingData.rowTracks) |
1144 setLogicalHeight(logicalHeight() + row.baseSize()); | 1209 setLogicalHeight(logicalHeight() + row.baseSize()); |
1145 | 1210 |
1146 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock. | 1211 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock. |
1147 | 1212 |
1148 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); | 1213 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); |
1149 } | 1214 } |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1704 LayoutUnit columnPosition = columnPositionForChild(child); | 1769 LayoutUnit columnPosition = columnPositionForChild(child); |
1705 // We stored m_columnPositions's data ignoring the direction, hence we might need now | 1770 // We stored m_columnPositions's data ignoring the direction, hence we might need now |
1706 // to translate positions from RTL to LTR, as it's more convenient for paint ing. | 1771 // to translate positions from RTL to LTR, as it's more convenient for paint ing. |
1707 if (!style()->isLeftToRightDirection()) | 1772 if (!style()->isLeftToRightDirection()) |
1708 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); | 1773 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); |
1709 | 1774 |
1710 // The Content Alignment offset accounts for the RTL to LTR flip. | 1775 // The Content Alignment offset accounts for the RTL to LTR flip. |
1711 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); | 1776 LayoutPoint childLocation(columnPosition, rowPositionForChild(child)); |
1712 childLocation.move(contentAlignmentOffset); | 1777 childLocation.move(contentAlignmentOffset); |
1713 | 1778 |
1714 return childLocation; | 1779 // "In the positioning phase [...] calculations are performed according to t he writing mode |
1780 // of the containing block of the box establishing the orthogonal flow." How ever, the | |
1781 // resulting LayoutPoint will be used in 'setLogicalPosition' in order to se t the child's | |
1782 // logical position, which will only take into account the child's writing-m ode. | |
1783 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | |
1784 return hasOrthogonalWritingMode ? childLocation.transposedPoint() : childLoc ation; | |
1715 } | 1785 } |
1716 | 1786 |
1717 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) | 1787 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) |
1718 { | 1788 { |
1719 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1789 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
1720 } | 1790 } |
1721 | 1791 |
1722 const char* RenderGrid::renderName() const | 1792 const char* RenderGrid::renderName() const |
1723 { | 1793 { |
1724 if (isFloating()) | 1794 if (isFloating()) |
1725 return "RenderGrid (floating)"; | 1795 return "RenderGrid (floating)"; |
1726 if (isOutOfFlowPositioned()) | 1796 if (isOutOfFlowPositioned()) |
1727 return "RenderGrid (positioned)"; | 1797 return "RenderGrid (positioned)"; |
1728 if (isAnonymous()) | 1798 if (isAnonymous()) |
1729 return "RenderGrid (generated)"; | 1799 return "RenderGrid (generated)"; |
1730 if (isRelPositioned()) | 1800 if (isRelPositioned()) |
1731 return "RenderGrid (relative positioned)"; | 1801 return "RenderGrid (relative positioned)"; |
1732 return "RenderGrid"; | 1802 return "RenderGrid"; |
1733 } | 1803 } |
1734 | 1804 |
1735 } // namespace blink | 1805 } // namespace blink |
OLD | NEW |