Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2561073002: [css-grid] Move Grid into GridSizingData (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 size_t m_rowIndex; 387 size_t m_rowIndex;
388 size_t m_columnIndex; 388 size_t m_columnIndex;
389 size_t m_childIndex; 389 size_t m_childIndex;
390 }; 390 };
391 391
392 struct LayoutGrid::GridSizingData { 392 struct LayoutGrid::GridSizingData {
393 WTF_MAKE_NONCOPYABLE(GridSizingData); 393 WTF_MAKE_NONCOPYABLE(GridSizingData);
394 STACK_ALLOCATED(); 394 STACK_ALLOCATED();
395 395
396 public: 396 public:
397 GridSizingData(size_t gridColumnCount, size_t gridRowCount) 397 GridSizingData(size_t gridColumnCount, size_t gridRowCount, Grid& grid)
398 : columnTracks(gridColumnCount), rowTracks(gridRowCount) {} 398 : columnTracks(gridColumnCount), rowTracks(gridRowCount), m_grid(grid) {}
399 399
400 Vector<GridTrack> columnTracks; 400 Vector<GridTrack> columnTracks;
401 Vector<GridTrack> rowTracks; 401 Vector<GridTrack> rowTracks;
402 Vector<size_t> contentSizedTracksIndex; 402 Vector<size_t> contentSizedTracksIndex;
403 403
404 // Performance optimization: hold onto these Vectors until the end of Layout 404 // Performance optimization: hold onto these Vectors until the end of Layout
405 // to avoid repeated malloc / free. 405 // to avoid repeated malloc / free.
406 Vector<GridTrack*> filteredTracks; 406 Vector<GridTrack*> filteredTracks;
407 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; 407 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan;
408 Vector<GridTrack*> growBeyondGrowthLimitsTracks; 408 Vector<GridTrack*> growBeyondGrowthLimitsTracks;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 case ColumnSizingSecondIteration: 448 case ColumnSizingSecondIteration:
449 return direction == ForColumns; 449 return direction == ForColumns;
450 case RowSizingFirstIteration: 450 case RowSizingFirstIteration:
451 case RowSizingSecondIteration: 451 case RowSizingSecondIteration:
452 return direction == ForRows; 452 return direction == ForRows;
453 } 453 }
454 NOTREACHED(); 454 NOTREACHED();
455 return false; 455 return false;
456 } 456 }
457 457
458 Grid& grid() const { return m_grid; }
459
458 private: 460 private:
459 LayoutUnit freeSpaceForColumns{}; 461 LayoutUnit freeSpaceForColumns{};
460 LayoutUnit freeSpaceForRows{}; 462 LayoutUnit freeSpaceForRows{};
461 // No need to store one per direction as it will be only used for computations 463 // No need to store one per direction as it will be only used for computations
462 // during each axis track sizing. It's cached here because we need it to 464 // during each axis track sizing. It's cached here because we need it to
463 // compute relative sizes. 465 // compute relative sizes.
464 LayoutUnit m_availableSpace; 466 LayoutUnit m_availableSpace;
467
468 Grid& m_grid;
jfernandez 2016/12/14 10:41:55 Why a reference here ? Didn't we want to have inde
svillar 2016/12/14 14:23:31 A reference because it cannot be null.
465 }; 469 };
466 470
467 struct GridItemsSpanGroupRange { 471 struct GridItemsSpanGroupRange {
468 Vector<GridItemWithSpan>::iterator rangeStart; 472 Vector<GridItemWithSpan>::iterator rangeStart;
469 Vector<GridItemWithSpan>::iterator rangeEnd; 473 Vector<GridItemWithSpan>::iterator rangeEnd;
470 }; 474 };
471 475
472 LayoutGrid::LayoutGrid(Element* element) : LayoutBlock(element), m_grid(this) { 476 LayoutGrid::LayoutGrid(Element* element) : LayoutBlock(element), m_grid(this) {
473 ASSERT(!childrenInline()); 477 ASSERT(!childrenInline());
474 if (!isAnonymous()) 478 if (!isAnonymous())
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); 545 oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines();
542 } 546 }
543 547
544 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight( 548 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(
545 const GridSizingData& sizingData) const { 549 const GridSizingData& sizingData) const {
546 LayoutUnit logicalHeight; 550 LayoutUnit logicalHeight;
547 551
548 for (const auto& row : sizingData.rowTracks) 552 for (const auto& row : sizingData.rowTracks)
549 logicalHeight += row.baseSize(); 553 logicalHeight += row.baseSize();
550 554
551 logicalHeight += guttersSize(ForRows, 0, sizingData.rowTracks.size(), 555 logicalHeight +=
552 sizingData.sizingOperation); 556 guttersSize(sizingData.grid(), ForRows, 0, sizingData.rowTracks.size(),
jfernandez 2016/12/14 10:41:55 We could perhaps join grid and sizingOperation arg
svillar 2016/12/14 14:23:32 Yes I thought about that but there are usages of g
557 sizingData.sizingOperation);
553 558
554 return logicalHeight; 559 return logicalHeight;
555 } 560 }
556 561
557 void LayoutGrid::computeTrackSizesForDefiniteSize( 562 void LayoutGrid::computeTrackSizesForDefiniteSize(
558 GridTrackSizingDirection direction, 563 GridTrackSizingDirection direction,
559 GridSizingData& sizingData, 564 GridSizingData& sizingData,
560 LayoutUnit availableSpace) const { 565 LayoutUnit availableSpace) const {
561 DCHECK(sizingData.isValidTransition(direction)); 566 DCHECK(sizingData.isValidTransition(direction));
562 sizingData.setAvailableSpace(availableSpace); 567 sizingData.setAvailableSpace(availableSpace);
563 sizingData.freeSpace(direction) = 568 sizingData.freeSpace(direction) =
564 availableSpace - guttersSize(direction, 0, m_grid.numTracks(direction), 569 availableSpace - guttersSize(sizingData.grid(), direction, 0,
jfernandez 2016/12/14 10:41:54 Ditto.
570 sizingData.grid().numTracks(direction),
565 sizingData.sizingOperation); 571 sizingData.sizingOperation);
566 sizingData.sizingOperation = TrackSizing; 572 sizingData.sizingOperation = TrackSizing;
567 573
568 LayoutUnit baseSizes, growthLimits; 574 LayoutUnit baseSizes, growthLimits;
569 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, 575 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes,
570 growthLimits); 576 growthLimits);
571 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); 577 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData));
572 sizingData.nextState(); 578 sizingData.nextState();
573 } 579 }
574 580
575 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, 581 void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData,
576 LayoutUnit availableSpaceForColumns, 582 LayoutUnit availableSpaceForColumns,
577 LayoutUnit availableSpaceForRows) { 583 LayoutUnit availableSpaceForRows) {
578 DCHECK(sizingData.sizingState > GridSizingData::RowSizingFirstIteration); 584 DCHECK(sizingData.sizingState > GridSizingData::RowSizingFirstIteration);
579 585
580 // In orthogonal flow cases column track's size is determined by using the 586 // In orthogonal flow cases column track's size is determined by using the
581 // computed row track's size, which it was estimated during the first cycle of 587 // computed row track's size, which it was estimated during the first cycle of
582 // the sizing algorithm. 588 // the sizing algorithm.
583 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns 589 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns
584 // and rows, to determine the final values. 590 // and rows, to determine the final values.
585 // TODO (lajava): orthogonal flows is just one of the cases which may require 591 // TODO (lajava): orthogonal flows is just one of the cases which may require
586 // a new cycle of the sizing algorithm; there may be more. In addition, not 592 // a new cycle of the sizing algorithm; there may be more. In addition, not
587 // all the cases with orthogonal flows require this extra cycle; we need a 593 // all the cases with orthogonal flows require this extra cycle; we need a
588 // more specific condition to detect whether child's min-content contribution 594 // more specific condition to detect whether child's min-content contribution
589 // has changed or not. 595 // has changed or not.
590 if (m_grid.hasAnyOrthogonalGridItem()) { 596 if (sizingData.grid().hasAnyOrthogonalGridItem()) {
591 computeTrackSizesForDefiniteSize(ForColumns, sizingData, 597 computeTrackSizesForDefiniteSize(ForColumns, sizingData,
592 availableSpaceForColumns); 598 availableSpaceForColumns);
593 computeTrackSizesForDefiniteSize(ForRows, sizingData, 599 computeTrackSizesForDefiniteSize(ForRows, sizingData,
594 availableSpaceForRows); 600 availableSpaceForRows);
595 } 601 }
596 } 602 }
597 603
598 void LayoutGrid::layoutBlock(bool relayoutChildren) { 604 void LayoutGrid::layoutBlock(bool relayoutChildren) {
599 ASSERT(needsLayout()); 605 ASSERT(needsLayout());
600 606
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 // computation is isolated from the LayoutGrid object state (it should not 644 // computation is isolated from the LayoutGrid object state (it should not
639 // touch any attribute) (see crbug.com/627812) 645 // touch any attribute) (see crbug.com/627812)
640 size_t autoRepeatColumns = m_grid.autoRepeatTracks(ForColumns); 646 size_t autoRepeatColumns = m_grid.autoRepeatTracks(ForColumns);
641 if (autoRepeatColumns && 647 if (autoRepeatColumns &&
642 autoRepeatColumns != 648 autoRepeatColumns !=
643 computeAutoRepeatTracksCount(ForColumns, TrackSizing)) 649 computeAutoRepeatTracksCount(ForColumns, TrackSizing))
644 dirtyGrid(); 650 dirtyGrid();
645 placeItemsOnGrid(m_grid, TrackSizing); 651 placeItemsOnGrid(m_grid, TrackSizing);
646 652
647 GridSizingData sizingData(numTracks(ForColumns, m_grid), 653 GridSizingData sizingData(numTracks(ForColumns, m_grid),
648 numTracks(ForRows, m_grid)); 654 numTracks(ForRows, m_grid), m_grid);
649 655
650 // 1- First, the track sizing algorithm is used to resolve the sizes of the 656 // 1- First, the track sizing algorithm is used to resolve the sizes of the
651 // grid columns. 657 // grid columns.
652 // At this point the logical width is always definite as the above call to 658 // At this point the logical width is always definite as the above call to
653 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the 659 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the
654 // same for heights though because many code paths inside 660 // same for heights though because many code paths inside
655 // updateLogicalHeight() require a previous call to setLogicalHeight() to 661 // updateLogicalHeight() require a previous call to setLogicalHeight() to
656 // resolve heights properly (like for positioned items for example). 662 // resolve heights properly (like for positioned items for example).
657 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); 663 LayoutUnit availableSpaceForColumns = availableLogicalWidth();
658 computeTrackSizesForDefiniteSize(ForColumns, sizingData, 664 computeTrackSizesForDefiniteSize(ForColumns, sizingData,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 if (sizingOperation == TrackSizing && gap.isPercent()) 729 if (sizingOperation == TrackSizing && gap.isPercent())
724 availableSize = direction == ForColumns 730 availableSize = direction == ForColumns
725 ? availableLogicalWidth() 731 ? availableLogicalWidth()
726 : availableLogicalHeightForPercentageComputation(); 732 : availableLogicalHeightForPercentageComputation();
727 733
728 // TODO(rego): Maybe we could cache the computed percentage as a performance 734 // TODO(rego): Maybe we could cache the computed percentage as a performance
729 // improvement. 735 // improvement.
730 return valueForLength(gap, availableSize); 736 return valueForLength(gap, availableSize);
731 } 737 }
732 738
733 LayoutUnit LayoutGrid::guttersSize(GridTrackSizingDirection direction, 739 LayoutUnit LayoutGrid::guttersSize(const Grid& grid,
740 GridTrackSizingDirection direction,
734 size_t startLine, 741 size_t startLine,
735 size_t span, 742 size_t span,
736 SizingOperation sizingOperation) const { 743 SizingOperation sizingOperation) const {
737 if (span <= 1) 744 if (span <= 1)
738 return LayoutUnit(); 745 return LayoutUnit();
739 746
740 LayoutUnit gap = gridGapForDirection(direction, sizingOperation); 747 LayoutUnit gap = gridGapForDirection(direction, sizingOperation);
741 748
742 // Fast path, no collapsing tracks. 749 // Fast path, no collapsing tracks.
743 if (!m_grid.hasAutoRepeatEmptyTracks(direction)) 750 if (!grid.hasAutoRepeatEmptyTracks(direction))
744 return gap * (span - 1); 751 return gap * (span - 1);
745 752
746 // If there are collapsing tracks we need to be sure that gutters are properly 753 // If there are collapsing tracks we need to be sure that gutters are properly
747 // collapsed. Apart from that, if we have a collapsed track in the edges of 754 // collapsed. Apart from that, if we have a collapsed track in the edges of
748 // the span we're considering, we need to move forward (or backwards) in order 755 // the span we're considering, we need to move forward (or backwards) in order
749 // to know whether the collapsed tracks reach the end of the grid (so the gap 756 // to know whether the collapsed tracks reach the end of the grid (so the gap
750 // becomes 0) or there is a non empty track before that. 757 // becomes 0) or there is a non empty track before that.
751 758
752 LayoutUnit gapAccumulator; 759 LayoutUnit gapAccumulator;
753 size_t endLine = startLine + span; 760 size_t endLine = startLine + span;
754 761
755 for (size_t line = startLine; line < endLine - 1; ++line) { 762 for (size_t line = startLine; line < endLine - 1; ++line) {
756 if (!m_grid.isEmptyAutoRepeatTrack(direction, line)) 763 if (!grid.isEmptyAutoRepeatTrack(direction, line))
757 gapAccumulator += gap; 764 gapAccumulator += gap;
758 } 765 }
759 766
760 // The above loop adds one extra gap for trailing collapsed tracks. 767 // The above loop adds one extra gap for trailing collapsed tracks.
761 if (gapAccumulator && m_grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) { 768 if (gapAccumulator && grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
762 DCHECK_GE(gapAccumulator, gap); 769 DCHECK_GE(gapAccumulator, gap);
763 gapAccumulator -= gap; 770 gapAccumulator -= gap;
764 } 771 }
765 772
766 // If the startLine is the start line of a collapsed track we need to go 773 // If the startLine is the start line of a collapsed track we need to go
767 // backwards till we reach a non collapsed track. If we find a non collapsed 774 // backwards till we reach a non collapsed track. If we find a non collapsed
768 // track we need to add that gap. 775 // track we need to add that gap.
769 if (startLine && m_grid.isEmptyAutoRepeatTrack(direction, startLine)) { 776 if (startLine && grid.isEmptyAutoRepeatTrack(direction, startLine)) {
770 size_t nonEmptyTracksBeforeStartLine = startLine; 777 size_t nonEmptyTracksBeforeStartLine = startLine;
771 auto begin = m_grid.autoRepeatEmptyTracks(direction)->begin(); 778 auto begin = grid.autoRepeatEmptyTracks(direction)->begin();
772 for (auto it = begin; *it != startLine; ++it) { 779 for (auto it = begin; *it != startLine; ++it) {
773 DCHECK(nonEmptyTracksBeforeStartLine); 780 DCHECK(nonEmptyTracksBeforeStartLine);
774 --nonEmptyTracksBeforeStartLine; 781 --nonEmptyTracksBeforeStartLine;
775 } 782 }
776 if (nonEmptyTracksBeforeStartLine) 783 if (nonEmptyTracksBeforeStartLine)
777 gapAccumulator += gap; 784 gapAccumulator += gap;
778 } 785 }
779 786
780 // If the endLine is the end line of a collapsed track we need to go forward 787 // If the endLine is the end line of a collapsed track we need to go forward
781 // till we reach a non collapsed track. If we find a non collapsed track we 788 // till we reach a non collapsed track. If we find a non collapsed track we
782 // need to add that gap. 789 // need to add that gap.
783 if (m_grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) { 790 if (grid.isEmptyAutoRepeatTrack(direction, endLine - 1)) {
784 size_t nonEmptyTracksAfterEndLine = m_grid.numTracks(direction) - endLine; 791 size_t nonEmptyTracksAfterEndLine = grid.numTracks(direction) - endLine;
785 auto currentEmptyTrack = 792 auto currentEmptyTrack =
786 m_grid.autoRepeatEmptyTracks(direction)->find(endLine - 1); 793 grid.autoRepeatEmptyTracks(direction)->find(endLine - 1);
787 auto endEmptyTrack = m_grid.autoRepeatEmptyTracks(direction)->end(); 794 auto endEmptyTrack = grid.autoRepeatEmptyTracks(direction)->end();
788 // HashSet iterators do not implement operator- so we have to manually 795 // HashSet iterators do not implement operator- so we have to manually
789 // iterate to know the number of remaining empty tracks. 796 // iterate to know the number of remaining empty tracks.
790 for (auto it = ++currentEmptyTrack; it != endEmptyTrack; ++it) { 797 for (auto it = ++currentEmptyTrack; it != endEmptyTrack; ++it) {
791 DCHECK(nonEmptyTracksAfterEndLine); 798 DCHECK(nonEmptyTracksAfterEndLine);
792 --nonEmptyTracksAfterEndLine; 799 --nonEmptyTracksAfterEndLine;
793 } 800 }
794 if (nonEmptyTracksAfterEndLine) 801 if (nonEmptyTracksAfterEndLine)
795 gapAccumulator += gap; 802 gapAccumulator += gap;
796 } 803 }
797 804
798 return gapAccumulator; 805 return gapAccumulator;
799 } 806 }
800 807
801 void LayoutGrid::computeIntrinsicLogicalWidths( 808 void LayoutGrid::computeIntrinsicLogicalWidths(
802 LayoutUnit& minLogicalWidth, 809 LayoutUnit& minLogicalWidth,
803 LayoutUnit& maxLogicalWidth) const { 810 LayoutUnit& maxLogicalWidth) const {
804 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(const_cast<Grid&>(m_grid), 811 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(const_cast<Grid&>(m_grid),
805 IntrinsicSizeComputation); 812 IntrinsicSizeComputation);
806 813
807 GridSizingData sizingData(numTracks(ForColumns, m_grid), 814 GridSizingData sizingData(numTracks(ForColumns, m_grid),
808 numTracks(ForRows, m_grid)); 815 numTracks(ForRows, m_grid),
816 const_cast<Grid&>(m_grid));
jfernandez 2016/12/14 10:41:54 umm, wouldn't be a good idea to get rid of this co
svillar 2016/12/14 14:23:31 Yes it was one of the reasons. The problem is that
809 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, 817 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth,
810 maxLogicalWidth); 818 maxLogicalWidth);
811 819
812 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); 820 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth());
813 minLogicalWidth += scrollbarWidth; 821 minLogicalWidth += scrollbarWidth;
814 maxLogicalWidth += scrollbarWidth; 822 maxLogicalWidth += scrollbarWidth;
815 } 823 }
816 824
817 void LayoutGrid::computeTrackSizesForIndefiniteSize( 825 void LayoutGrid::computeTrackSizesForIndefiniteSize(
818 GridTrackSizingDirection direction, 826 GridTrackSizingDirection direction,
819 GridSizingData& sizingData, 827 GridSizingData& sizingData,
820 LayoutUnit& minIntrinsicSize, 828 LayoutUnit& minIntrinsicSize,
821 LayoutUnit& maxIntrinsicSize) const { 829 LayoutUnit& maxIntrinsicSize) const {
822 DCHECK(sizingData.isValidTransition(direction)); 830 DCHECK(sizingData.isValidTransition(direction));
823 sizingData.setAvailableSpace(LayoutUnit()); 831 sizingData.setAvailableSpace(LayoutUnit());
824 sizingData.freeSpace(direction) = LayoutUnit(); 832 sizingData.freeSpace(direction) = LayoutUnit();
825 sizingData.sizingOperation = IntrinsicSizeComputation; 833 sizingData.sizingOperation = IntrinsicSizeComputation;
826 834
827 computeUsedBreadthOfGridTracks(direction, sizingData, minIntrinsicSize, 835 computeUsedBreadthOfGridTracks(direction, sizingData, minIntrinsicSize,
828 maxIntrinsicSize); 836 maxIntrinsicSize);
829 837
830 size_t numberOfTracks = direction == ForColumns 838 size_t numberOfTracks = direction == ForColumns
831 ? sizingData.columnTracks.size() 839 ? sizingData.columnTracks.size()
832 : sizingData.rowTracks.size(); 840 : sizingData.rowTracks.size();
833 LayoutUnit totalGuttersSize = 841 LayoutUnit totalGuttersSize =
834 guttersSize(direction, 0, numberOfTracks, sizingData.sizingOperation); 842 guttersSize(sizingData.grid(), direction, 0, numberOfTracks,
843 sizingData.sizingOperation);
835 minIntrinsicSize += totalGuttersSize; 844 minIntrinsicSize += totalGuttersSize;
836 maxIntrinsicSize += totalGuttersSize; 845 maxIntrinsicSize += totalGuttersSize;
837 846
838 #if ENABLE(ASSERT) 847 #if ENABLE(ASSERT)
839 DCHECK(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); 848 DCHECK(tracksAreWiderThanMinTrackBreadth(direction, sizingData));
840 #endif 849 #endif
841 } 850 }
842 851
843 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing( 852 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(
844 const Length& logicalHeightLength, 853 const Length& logicalHeightLength,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 sizingData.contentSizedTracksIndex.shrink(0); 895 sizingData.contentSizedTracksIndex.shrink(0);
887 896
888 // Grid gutters were removed from freeSpace by the caller, but we must use 897 // Grid gutters were removed from freeSpace by the caller, but we must use
889 // them to compute relative (i.e. percentages) sizes. 898 // them to compute relative (i.e. percentages) sizes.
890 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero(); 899 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero();
891 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing; 900 bool hasDefiniteFreeSpace = sizingData.sizingOperation == TrackSizing;
892 901
893 // 1. Initialize per Grid track variables. 902 // 1. Initialize per Grid track variables.
894 for (size_t i = 0; i < tracks.size(); ++i) { 903 for (size_t i = 0; i < tracks.size(); ++i) {
895 GridTrack& track = tracks[i]; 904 GridTrack& track = tracks[i];
896 GridTrackSize trackSize = 905 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData);
897 gridTrackSize(direction, i, sizingData.sizingOperation);
898 906
899 track.setBaseSize(computeUsedBreadthOfMinLength(trackSize, maxSize)); 907 track.setBaseSize(computeUsedBreadthOfMinLength(trackSize, maxSize));
900 track.setGrowthLimit( 908 track.setGrowthLimit(
901 computeUsedBreadthOfMaxLength(trackSize, track.baseSize(), maxSize)); 909 computeUsedBreadthOfMaxLength(trackSize, track.baseSize(), maxSize));
902 track.setInfinitelyGrowable(false); 910 track.setInfinitelyGrowable(false);
903 911
904 if (trackSize.isFitContent()) { 912 if (trackSize.isFitContent()) {
905 GridLength gridLength = trackSize.fitContentTrackBreadth(); 913 GridLength gridLength = trackSize.fitContentTrackBreadth();
906 if (!gridLength.hasPercentage() || hasDefiniteFreeSpace) 914 if (!gridLength.hasPercentage() || hasDefiniteFreeSpace)
907 track.setGrowthLimitCap(valueForLength(gridLength.length(), maxSize)); 915 track.setGrowthLimitCap(valueForLength(gridLength.length(), maxSize));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 } 962 }
955 963
956 if (flexibleSizedTracksIndex.isEmpty()) 964 if (flexibleSizedTracksIndex.isEmpty())
957 return; 965 return;
958 966
959 // 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction. 967 // 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction.
960 double flexFraction = 0; 968 double flexFraction = 0;
961 if (hasDefiniteFreeSpace) { 969 if (hasDefiniteFreeSpace) {
962 flexFraction = findFlexFactorUnitSize( 970 flexFraction = findFlexFactorUnitSize(
963 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), 971 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()),
964 direction, initialFreeSpace); 972 direction, initialFreeSpace, sizingData);
965 } else { 973 } else {
966 for (const auto& trackIndex : flexibleSizedTracksIndex) 974 for (const auto& trackIndex : flexibleSizedTracksIndex) {
967 flexFraction = std::max( 975 flexFraction = std::max(
968 flexFraction, 976 flexFraction, normalizedFlexFraction(
969 normalizedFlexFraction( 977 tracks[trackIndex],
970 tracks[trackIndex], 978 gridTrackSize(direction, trackIndex, sizingData)
971 gridTrackSize(direction, trackIndex).maxTrackBreadth().flex())); 979 .maxTrackBreadth()
980 .flex()));
981 }
972 982
973 if (m_grid.hasGridItems()) { 983 Grid& grid = sizingData.grid();
jfernandez 2016/12/14 10:41:55 const Grid& grid ?
svillar 2016/12/14 14:23:31 Acknowledged.
984 if (grid.hasGridItems()) {
974 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { 985 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) {
975 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]); 986 GridIterator iterator(grid, direction, flexibleSizedTracksIndex[i]);
976 while (LayoutBox* gridItem = iterator.nextGridItem()) { 987 while (LayoutBox* gridItem = iterator.nextGridItem()) {
977 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); 988 const GridSpan& span = grid.gridItemSpan(*gridItem, direction);
978 989
979 // Do not include already processed items. 990 // Do not include already processed items.
980 if (i > 0 && span.startLine() <= flexibleSizedTracksIndex[i - 1]) 991 if (i > 0 && span.startLine() <= flexibleSizedTracksIndex[i - 1])
981 continue; 992 continue;
982 993
983 flexFraction = std::max( 994 flexFraction =
984 flexFraction, 995 std::max(flexFraction,
985 findFlexFactorUnitSize( 996 findFlexFactorUnitSize(
986 tracks, span, direction, 997 tracks, span, direction,
987 maxContentForChild(*gridItem, direction, sizingData))); 998 maxContentForChild(*gridItem, direction, sizingData),
999 sizingData));
988 } 1000 }
989 } 1001 }
990 } 1002 }
991 } 1003 }
992 1004
993 LayoutUnit totalGrowth; 1005 LayoutUnit totalGrowth;
994 Vector<LayoutUnit> increments; 1006 Vector<LayoutUnit> increments;
995 increments.grow(flexibleSizedTracksIndex.size()); 1007 increments.grow(flexibleSizedTracksIndex.size());
996 computeFlexSizedTracksGrowth(direction, tracks, flexibleSizedTracksIndex, 1008 computeFlexSizedTracksGrowth(direction, tracks, flexibleSizedTracksIndex,
997 flexFraction, increments, totalGrowth); 1009 flexFraction, increments, totalGrowth,
1010 sizingData);
998 1011
999 // We only need to redo the flex fraction computation for indefinite heights 1012 // We only need to redo the flex fraction computation for indefinite heights
1000 // (definite sizes are already constrained by min/max sizes). Regarding 1013 // (definite sizes are already constrained by min/max sizes). Regarding
1001 // widths, they are always definite at layout time so we shouldn't ever have 1014 // widths, they are always definite at layout time so we shouldn't ever have
1002 // to do this. 1015 // to do this.
1003 if (!hasDefiniteFreeSpace && direction == ForRows) { 1016 if (!hasDefiniteFreeSpace && direction == ForRows) {
1004 auto minSize = computeContentLogicalHeight( 1017 auto minSize = computeContentLogicalHeight(
1005 MinSize, styleRef().logicalMinHeight(), LayoutUnit(-1)); 1018 MinSize, styleRef().logicalMinHeight(), LayoutUnit(-1));
1006 auto maxSize = computeContentLogicalHeight( 1019 auto maxSize = computeContentLogicalHeight(
1007 MaxSize, styleRef().logicalMaxHeight(), LayoutUnit(-1)); 1020 MaxSize, styleRef().logicalMaxHeight(), LayoutUnit(-1));
1008 1021
1009 // Redo the flex fraction computation using min|max-height as definite 1022 // Redo the flex fraction computation using min|max-height as definite
1010 // available space in case the total height is smaller than min-height or 1023 // available space in case the total height is smaller than min-height or
1011 // larger than max-height. 1024 // larger than max-height.
1012 LayoutUnit rowsSize = 1025 LayoutUnit rowsSize =
1013 totalGrowth + computeTrackBasedLogicalHeight(sizingData); 1026 totalGrowth + computeTrackBasedLogicalHeight(sizingData);
1014 bool checkMinSize = minSize && rowsSize < minSize; 1027 bool checkMinSize = minSize && rowsSize < minSize;
1015 bool checkMaxSize = maxSize != -1 && rowsSize > maxSize; 1028 bool checkMaxSize = maxSize != -1 && rowsSize > maxSize;
1016 if (checkMinSize || checkMaxSize) { 1029 if (checkMinSize || checkMaxSize) {
1017 LayoutUnit freeSpace = checkMaxSize ? maxSize : LayoutUnit(-1); 1030 LayoutUnit freeSpace = checkMaxSize ? maxSize : LayoutUnit(-1);
1018 freeSpace = std::max(freeSpace, minSize) - 1031 freeSpace = std::max(freeSpace, minSize) -
1019 guttersSize(ForRows, 0, m_grid.numTracks(ForRows), 1032 guttersSize(sizingData.grid(), ForRows, 0,
1033 sizingData.grid().numTracks(ForRows),
1020 sizingData.sizingOperation); 1034 sizingData.sizingOperation);
1021 1035
1022 flexFraction = findFlexFactorUnitSize( 1036 flexFraction = findFlexFactorUnitSize(
1023 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()), 1037 tracks, GridSpan::translatedDefiniteGridSpan(0, tracks.size()),
1024 ForRows, freeSpace); 1038 ForRows, freeSpace, sizingData);
1025 1039
1026 totalGrowth = LayoutUnit(0); 1040 totalGrowth = LayoutUnit(0);
1027 computeFlexSizedTracksGrowth(ForRows, tracks, flexibleSizedTracksIndex, 1041 computeFlexSizedTracksGrowth(ForRows, tracks, flexibleSizedTracksIndex,
1028 flexFraction, increments, totalGrowth); 1042 flexFraction, increments, totalGrowth,
1043 sizingData);
1029 } 1044 }
1030 } 1045 }
1031 1046
1032 size_t i = 0; 1047 size_t i = 0;
1033 for (auto trackIndex : flexibleSizedTracksIndex) { 1048 for (auto trackIndex : flexibleSizedTracksIndex) {
1034 auto& track = tracks[trackIndex]; 1049 auto& track = tracks[trackIndex];
1035 if (LayoutUnit increment = increments[i++]) 1050 if (LayoutUnit increment = increments[i++])
1036 track.setBaseSize(track.baseSize() + increment); 1051 track.setBaseSize(track.baseSize() + increment);
1037 } 1052 }
1038 freeSpace -= totalGrowth; 1053 freeSpace -= totalGrowth;
1039 growthLimitsWithoutMaximization += totalGrowth; 1054 growthLimitsWithoutMaximization += totalGrowth;
1040 } 1055 }
1041 1056
1042 void LayoutGrid::computeFlexSizedTracksGrowth( 1057 void LayoutGrid::computeFlexSizedTracksGrowth(
1043 GridTrackSizingDirection direction, 1058 GridTrackSizingDirection direction,
1044 Vector<GridTrack>& tracks, 1059 Vector<GridTrack>& tracks,
1045 const Vector<size_t>& flexibleSizedTracksIndex, 1060 const Vector<size_t>& flexibleSizedTracksIndex,
1046 double flexFraction, 1061 double flexFraction,
1047 Vector<LayoutUnit>& increments, 1062 Vector<LayoutUnit>& increments,
1048 LayoutUnit& totalGrowth) const { 1063 LayoutUnit& totalGrowth,
1064 const GridSizingData& sizingData) const {
1049 size_t numFlexTracks = flexibleSizedTracksIndex.size(); 1065 size_t numFlexTracks = flexibleSizedTracksIndex.size();
1050 DCHECK_EQ(increments.size(), numFlexTracks); 1066 DCHECK_EQ(increments.size(), numFlexTracks);
1051 for (size_t i = 0; i < numFlexTracks; ++i) { 1067 for (size_t i = 0; i < numFlexTracks; ++i) {
1052 size_t trackIndex = flexibleSizedTracksIndex[i]; 1068 size_t trackIndex = flexibleSizedTracksIndex[i];
1053 auto trackSize = gridTrackSize(direction, trackIndex); 1069 auto trackSize = gridTrackSize(direction, trackIndex, sizingData);
1054 DCHECK(trackSize.maxTrackBreadth().isFlex()); 1070 DCHECK(trackSize.maxTrackBreadth().isFlex());
1055 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize(); 1071 LayoutUnit oldBaseSize = tracks[trackIndex].baseSize();
1056 LayoutUnit newBaseSize = 1072 LayoutUnit newBaseSize =
1057 std::max(oldBaseSize, 1073 std::max(oldBaseSize,
1058 LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex())); 1074 LayoutUnit(flexFraction * trackSize.maxTrackBreadth().flex()));
1059 increments[i] = newBaseSize - oldBaseSize; 1075 increments[i] = newBaseSize - oldBaseSize;
1060 totalGrowth += increments[i]; 1076 totalGrowth += increments[i];
1061 } 1077 }
1062 } 1078 }
1063 1079
(...skipping 29 matching lines...) Expand all
1093 trackLength.isMaxContent()); 1109 trackLength.isMaxContent());
1094 return LayoutUnit(infinity); 1110 return LayoutUnit(infinity);
1095 } 1111 }
1096 1112
1097 double LayoutGrid::computeFlexFactorUnitSize( 1113 double LayoutGrid::computeFlexFactorUnitSize(
1098 const Vector<GridTrack>& tracks, 1114 const Vector<GridTrack>& tracks,
1099 GridTrackSizingDirection direction, 1115 GridTrackSizingDirection direction,
1100 double flexFactorSum, 1116 double flexFactorSum,
1101 LayoutUnit& leftOverSpace, 1117 LayoutUnit& leftOverSpace,
1102 const Vector<size_t, 8>& flexibleTracksIndexes, 1118 const Vector<size_t, 8>& flexibleTracksIndexes,
1119 const GridSizingData& sizingData,
1103 std::unique_ptr<TrackIndexSet> tracksToTreatAsInflexible) const { 1120 std::unique_ptr<TrackIndexSet> tracksToTreatAsInflexible) const {
1104 // We want to avoid the effect of flex factors sum below 1 making the factor 1121 // We want to avoid the effect of flex factors sum below 1 making the factor
1105 // unit size to grow exponentially. 1122 // unit size to grow exponentially.
1106 double hypotheticalFactorUnitSize = 1123 double hypotheticalFactorUnitSize =
1107 leftOverSpace / std::max<double>(1, flexFactorSum); 1124 leftOverSpace / std::max<double>(1, flexFactorSum);
1108 1125
1109 // product of the hypothetical "flex factor unit" and any flexible track's 1126 // product of the hypothetical "flex factor unit" and any flexible track's
1110 // "flex factor" must be grater than such track's "base size". 1127 // "flex factor" must be grater than such track's "base size".
1111 std::unique_ptr<TrackIndexSet> additionalTracksToTreatAsInflexible = 1128 std::unique_ptr<TrackIndexSet> additionalTracksToTreatAsInflexible =
1112 std::move(tracksToTreatAsInflexible); 1129 std::move(tracksToTreatAsInflexible);
1113 bool validFlexFactorUnit = true; 1130 bool validFlexFactorUnit = true;
1114 for (auto index : flexibleTracksIndexes) { 1131 for (auto index : flexibleTracksIndexes) {
1115 if (additionalTracksToTreatAsInflexible && 1132 if (additionalTracksToTreatAsInflexible &&
1116 additionalTracksToTreatAsInflexible->contains(index)) 1133 additionalTracksToTreatAsInflexible->contains(index))
1117 continue; 1134 continue;
1118 LayoutUnit baseSize = tracks[index].baseSize(); 1135 LayoutUnit baseSize = tracks[index].baseSize();
1119 double flexFactor = 1136 double flexFactor =
1120 gridTrackSize(direction, index).maxTrackBreadth().flex(); 1137 gridTrackSize(direction, index, sizingData).maxTrackBreadth().flex();
1121 // treating all such tracks as inflexible. 1138 // treating all such tracks as inflexible.
1122 if (baseSize > hypotheticalFactorUnitSize * flexFactor) { 1139 if (baseSize > hypotheticalFactorUnitSize * flexFactor) {
1123 leftOverSpace -= baseSize; 1140 leftOverSpace -= baseSize;
1124 flexFactorSum -= flexFactor; 1141 flexFactorSum -= flexFactor;
1125 if (!additionalTracksToTreatAsInflexible) 1142 if (!additionalTracksToTreatAsInflexible)
1126 additionalTracksToTreatAsInflexible = makeUnique<TrackIndexSet>(); 1143 additionalTracksToTreatAsInflexible = makeUnique<TrackIndexSet>();
1127 additionalTracksToTreatAsInflexible->add(index); 1144 additionalTracksToTreatAsInflexible->add(index);
1128 validFlexFactorUnit = false; 1145 validFlexFactorUnit = false;
1129 } 1146 }
1130 } 1147 }
1131 if (!validFlexFactorUnit) 1148 if (!validFlexFactorUnit) {
1132 return computeFlexFactorUnitSize( 1149 return computeFlexFactorUnitSize(
1133 tracks, direction, flexFactorSum, leftOverSpace, flexibleTracksIndexes, 1150 tracks, direction, flexFactorSum, leftOverSpace, flexibleTracksIndexes,
1134 std::move(additionalTracksToTreatAsInflexible)); 1151 sizingData, std::move(additionalTracksToTreatAsInflexible));
1152 }
1135 return hypotheticalFactorUnitSize; 1153 return hypotheticalFactorUnitSize;
1136 } 1154 }
1137 1155
1138 double LayoutGrid::findFlexFactorUnitSize(const Vector<GridTrack>& tracks, 1156 double LayoutGrid::findFlexFactorUnitSize(
1139 const GridSpan& tracksSpan, 1157 const Vector<GridTrack>& tracks,
1140 GridTrackSizingDirection direction, 1158 const GridSpan& tracksSpan,
1141 LayoutUnit leftOverSpace) const { 1159 GridTrackSizingDirection direction,
1160 LayoutUnit leftOverSpace,
1161 const GridSizingData& sizingData) const {
1142 if (leftOverSpace <= 0) 1162 if (leftOverSpace <= 0)
1143 return 0; 1163 return 0;
1144 1164
1145 double flexFactorSum = 0; 1165 double flexFactorSum = 0;
1146 Vector<size_t, 8> flexibleTracksIndexes; 1166 Vector<size_t, 8> flexibleTracksIndexes;
1147 for (const auto& trackIndex : tracksSpan) { 1167 for (const auto& trackIndex : tracksSpan) {
1148 GridTrackSize trackSize = gridTrackSize(direction, trackIndex); 1168 GridTrackSize trackSize = gridTrackSize(direction, trackIndex, sizingData);
1149 if (!trackSize.maxTrackBreadth().isFlex()) { 1169 if (!trackSize.maxTrackBreadth().isFlex()) {
1150 leftOverSpace -= tracks[trackIndex].baseSize(); 1170 leftOverSpace -= tracks[trackIndex].baseSize();
1151 } else { 1171 } else {
1152 flexibleTracksIndexes.append(trackIndex); 1172 flexibleTracksIndexes.append(trackIndex);
1153 flexFactorSum += trackSize.maxTrackBreadth().flex(); 1173 flexFactorSum += trackSize.maxTrackBreadth().flex();
1154 } 1174 }
1155 } 1175 }
1156 1176
1157 // The function is not called if we don't have <flex> grid tracks 1177 // The function is not called if we don't have <flex> grid tracks
1158 ASSERT(!flexibleTracksIndexes.isEmpty()); 1178 ASSERT(!flexibleTracksIndexes.isEmpty());
1159 1179
1160 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum, 1180 return computeFlexFactorUnitSize(tracks, direction, flexFactorSum,
1161 leftOverSpace, flexibleTracksIndexes); 1181 leftOverSpace, flexibleTracksIndexes,
1182 sizingData);
1162 } 1183 }
1163 1184
1164 static bool hasOverrideContainingBlockContentSizeForChild( 1185 static bool hasOverrideContainingBlockContentSizeForChild(
1165 const LayoutBox& child, 1186 const LayoutBox& child,
1166 GridTrackSizingDirection direction) { 1187 GridTrackSizingDirection direction) {
1167 return direction == ForColumns 1188 return direction == ForColumns
1168 ? child.hasOverrideContainingBlockLogicalWidth() 1189 ? child.hasOverrideContainingBlockLogicalWidth()
1169 : child.hasOverrideContainingBlockLogicalHeight(); 1190 : child.hasOverrideContainingBlockLogicalHeight();
1170 } 1191 }
1171 1192
(...skipping 20 matching lines...) Expand all
1192 GridTrackSizingDirection direction) { 1213 GridTrackSizingDirection direction) {
1193 if (direction == ForColumns) 1214 if (direction == ForColumns)
1194 return child.hasRelativeLogicalWidth() || 1215 return child.hasRelativeLogicalWidth() ||
1195 child.styleRef().logicalWidth().isIntrinsicOrAuto(); 1216 child.styleRef().logicalWidth().isIntrinsicOrAuto();
1196 return child.hasRelativeLogicalHeight() || 1217 return child.hasRelativeLogicalHeight() ||
1197 child.styleRef().logicalHeight().isIntrinsicOrAuto(); 1218 child.styleRef().logicalHeight().isIntrinsicOrAuto();
1198 } 1219 }
1199 1220
1200 const GridTrackSize& LayoutGrid::rawGridTrackSize( 1221 const GridTrackSize& LayoutGrid::rawGridTrackSize(
1201 GridTrackSizingDirection direction, 1222 GridTrackSizingDirection direction,
1202 size_t translatedIndex) const { 1223 size_t translatedIndex,
1224 const GridSizingData& sizingData) const {
1203 bool isRowAxis = direction == ForColumns; 1225 bool isRowAxis = direction == ForColumns;
1204 const Vector<GridTrackSize>& trackStyles = 1226 const Vector<GridTrackSize>& trackStyles =
1205 isRowAxis ? styleRef().gridTemplateColumns() 1227 isRowAxis ? styleRef().gridTemplateColumns()
1206 : styleRef().gridTemplateRows(); 1228 : styleRef().gridTemplateRows();
1207 const Vector<GridTrackSize>& autoRepeatTrackStyles = 1229 const Vector<GridTrackSize>& autoRepeatTrackStyles =
1208 isRowAxis ? styleRef().gridAutoRepeatColumns() 1230 isRowAxis ? styleRef().gridAutoRepeatColumns()
1209 : styleRef().gridAutoRepeatRows(); 1231 : styleRef().gridAutoRepeatRows();
1210 const Vector<GridTrackSize>& autoTrackStyles = 1232 const Vector<GridTrackSize>& autoTrackStyles =
1211 isRowAxis ? styleRef().gridAutoColumns() : styleRef().gridAutoRows(); 1233 isRowAxis ? styleRef().gridAutoColumns() : styleRef().gridAutoRows();
1212 size_t insertionPoint = isRowAxis 1234 size_t insertionPoint = isRowAxis
1213 ? styleRef().gridAutoRepeatColumnsInsertionPoint() 1235 ? styleRef().gridAutoRepeatColumnsInsertionPoint()
1214 : styleRef().gridAutoRepeatRowsInsertionPoint(); 1236 : styleRef().gridAutoRepeatRowsInsertionPoint();
1215 size_t autoRepeatTracksCount = autoRepeatCountForDirection(direction); 1237 size_t autoRepeatTracksCount = sizingData.grid().autoRepeatTracks(direction);
1216 1238
1217 // We should not use GridPositionsResolver::explicitGridXXXCount() for this 1239 // We should not use GridPositionsResolver::explicitGridXXXCount() for this
1218 // because the explicit grid might be larger than the number of tracks in 1240 // because the explicit grid might be larger than the number of tracks in
1219 // grid-template-rows|columns (if grid-template-areas is specified for 1241 // grid-template-rows|columns (if grid-template-areas is specified for
1220 // example). 1242 // example).
1221 size_t explicitTracksCount = trackStyles.size() + autoRepeatTracksCount; 1243 size_t explicitTracksCount = trackStyles.size() + autoRepeatTracksCount;
1222 1244
1223 int untranslatedIndexAsInt = 1245 int untranslatedIndexAsInt =
1224 translatedIndex + m_grid.smallestTrackStart(direction); 1246 translatedIndex + sizingData.grid().smallestTrackStart(direction);
1225 size_t autoTrackStylesSize = autoTrackStyles.size(); 1247 size_t autoTrackStylesSize = autoTrackStyles.size();
1226 if (untranslatedIndexAsInt < 0) { 1248 if (untranslatedIndexAsInt < 0) {
1227 int index = untranslatedIndexAsInt % static_cast<int>(autoTrackStylesSize); 1249 int index = untranslatedIndexAsInt % static_cast<int>(autoTrackStylesSize);
1228 // We need to traspose the index because the first negative implicit line 1250 // We need to traspose the index because the first negative implicit line
1229 // will get the last defined auto track and so on. 1251 // will get the last defined auto track and so on.
1230 index += index ? autoTrackStylesSize : 0; 1252 index += index ? autoTrackStylesSize : 0;
1231 return autoTrackStyles[index]; 1253 return autoTrackStyles[index];
1232 } 1254 }
1233 1255
1234 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt); 1256 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt);
1235 if (untranslatedIndex >= explicitTracksCount) 1257 if (untranslatedIndex >= explicitTracksCount)
1236 return autoTrackStyles[(untranslatedIndex - explicitTracksCount) % 1258 return autoTrackStyles[(untranslatedIndex - explicitTracksCount) %
1237 autoTrackStylesSize]; 1259 autoTrackStylesSize];
1238 1260
1239 if (LIKELY(!autoRepeatTracksCount) || untranslatedIndex < insertionPoint) 1261 if (LIKELY(!autoRepeatTracksCount) || untranslatedIndex < insertionPoint)
1240 return trackStyles[untranslatedIndex]; 1262 return trackStyles[untranslatedIndex];
1241 1263
1242 if (untranslatedIndex < (insertionPoint + autoRepeatTracksCount)) { 1264 if (untranslatedIndex < (insertionPoint + autoRepeatTracksCount)) {
1243 size_t autoRepeatLocalIndex = untranslatedIndexAsInt - insertionPoint; 1265 size_t autoRepeatLocalIndex = untranslatedIndexAsInt - insertionPoint;
1244 return autoRepeatTrackStyles[autoRepeatLocalIndex % 1266 return autoRepeatTrackStyles[autoRepeatLocalIndex %
1245 autoRepeatTrackStyles.size()]; 1267 autoRepeatTrackStyles.size()];
1246 } 1268 }
1247 1269
1248 return trackStyles[untranslatedIndex - autoRepeatTracksCount]; 1270 return trackStyles[untranslatedIndex - autoRepeatTracksCount];
1249 } 1271 }
1250 1272
1251 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, 1273 GridTrackSize LayoutGrid::gridTrackSize(
1252 size_t translatedIndex, 1274 GridTrackSizingDirection direction,
1253 SizingOperation sizingOperation) const { 1275 size_t translatedIndex,
1276 const GridSizingData& sizingData) const {
1254 // Collapse empty auto repeat tracks if auto-fit. 1277 // Collapse empty auto repeat tracks if auto-fit.
1255 if (m_grid.hasAutoRepeatEmptyTracks(direction) && 1278 if (sizingData.grid().hasAutoRepeatEmptyTracks(direction) &&
1256 m_grid.isEmptyAutoRepeatTrack(direction, translatedIndex)) 1279 sizingData.grid().isEmptyAutoRepeatTrack(direction, translatedIndex))
1257 return {Length(Fixed), LengthTrackSizing}; 1280 return {Length(Fixed), LengthTrackSizing};
1258 1281
1259 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex); 1282 const GridTrackSize& trackSize =
1283 rawGridTrackSize(direction, translatedIndex, sizingData);
1260 if (trackSize.isFitContent()) 1284 if (trackSize.isFitContent())
1261 return trackSize; 1285 return trackSize;
1262 1286
1263 GridLength minTrackBreadth = trackSize.minTrackBreadth(); 1287 GridLength minTrackBreadth = trackSize.minTrackBreadth();
1264 GridLength maxTrackBreadth = trackSize.maxTrackBreadth(); 1288 GridLength maxTrackBreadth = trackSize.maxTrackBreadth();
1265 // If the logical width/height of the grid container is indefinite, percentage 1289 // If the logical width/height of the grid container is indefinite, percentage
1266 // values are treated as <auto>. 1290 // values are treated as <auto>.
1267 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) { 1291 if (minTrackBreadth.hasPercentage() || maxTrackBreadth.hasPercentage()) {
1268 // For the inline axis this only happens when we're computing the intrinsic 1292 // For the inline axis this only happens when we're computing the intrinsic
1269 // sizes (AvailableSpaceIndefinite). 1293 // sizes (AvailableSpaceIndefinite).
1270 if ((sizingOperation == IntrinsicSizeComputation) || 1294 if ((sizingData.sizingOperation == IntrinsicSizeComputation) ||
1271 (direction == ForRows && !cachedHasDefiniteLogicalHeight())) { 1295 (direction == ForRows && !cachedHasDefiniteLogicalHeight())) {
1272 if (minTrackBreadth.hasPercentage()) 1296 if (minTrackBreadth.hasPercentage())
1273 minTrackBreadth = Length(Auto); 1297 minTrackBreadth = Length(Auto);
1274 if (maxTrackBreadth.hasPercentage()) 1298 if (maxTrackBreadth.hasPercentage())
1275 maxTrackBreadth = Length(Auto); 1299 maxTrackBreadth = Length(Auto);
1276 } 1300 }
1277 } 1301 }
1278 1302
1279 // Flex sizes are invalid as a min sizing function. However we still can have 1303 // Flex sizes are invalid as a min sizing function. However we still can have
1280 // a flexible |minTrackBreadth| if the track had a flex size directly (e.g. 1304 // a flexible |minTrackBreadth| if the track had a flex size directly (e.g.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 } 1505 }
1482 1506
1483 private: 1507 private:
1484 LayoutBox* m_gridItem; 1508 LayoutBox* m_gridItem;
1485 GridSpan m_gridSpan; 1509 GridSpan m_gridSpan;
1486 }; 1510 };
1487 1511
1488 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks( 1512 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(
1489 const GridSpan& span, 1513 const GridSpan& span,
1490 GridTrackSizingDirection direction, 1514 GridTrackSizingDirection direction,
1491 SizingOperation sizingOperation) const { 1515 const GridSizingData& sizingData) const {
1492 for (const auto& trackPosition : span) { 1516 for (const auto& trackPosition : span) {
1493 const GridTrackSize& trackSize = 1517 const GridTrackSize& trackSize =
1494 gridTrackSize(direction, trackPosition, sizingOperation); 1518 gridTrackSize(direction, trackPosition, sizingData);
1495 if (trackSize.minTrackBreadth().isFlex() || 1519 if (trackSize.minTrackBreadth().isFlex() ||
1496 trackSize.maxTrackBreadth().isFlex()) 1520 trackSize.maxTrackBreadth().isFlex())
1497 return true; 1521 return true;
1498 } 1522 }
1499 1523
1500 return false; 1524 return false;
1501 } 1525 }
1502 1526
1503 void LayoutGrid::resolveContentBasedTrackSizingFunctions( 1527 void LayoutGrid::resolveContentBasedTrackSizingFunctions(
1504 GridTrackSizingDirection direction, 1528 GridTrackSizingDirection direction,
1505 GridSizingData& sizingData) const { 1529 GridSizingData& sizingData) const {
1506 sizingData.itemsSortedByIncreasingSpan.shrink(0); 1530 sizingData.itemsSortedByIncreasingSpan.shrink(0);
1507 if (m_grid.hasGridItems()) { 1531 Grid& grid = sizingData.grid();
jfernandez 2016/12/14 10:41:55 const ?
svillar 2016/12/14 14:23:32 Acknowledged.
1532 if (grid.hasGridItems()) {
1508 HashSet<LayoutBox*> itemsSet; 1533 HashSet<LayoutBox*> itemsSet;
1509 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) { 1534 for (const auto& trackIndex : sizingData.contentSizedTracksIndex) {
1510 GridIterator iterator(m_grid, direction, trackIndex); 1535 GridIterator iterator(grid, direction, trackIndex);
1511 GridTrack& track = (direction == ForColumns) 1536 GridTrack& track = (direction == ForColumns)
1512 ? sizingData.columnTracks[trackIndex] 1537 ? sizingData.columnTracks[trackIndex]
1513 : sizingData.rowTracks[trackIndex]; 1538 : sizingData.rowTracks[trackIndex];
1514 while (LayoutBox* gridItem = iterator.nextGridItem()) { 1539 while (LayoutBox* gridItem = iterator.nextGridItem()) {
1515 if (itemsSet.add(gridItem).isNewEntry) { 1540 if (itemsSet.add(gridItem).isNewEntry) {
1516 const GridSpan& span = m_grid.gridItemSpan(*gridItem, direction); 1541 const GridSpan& span = grid.gridItemSpan(*gridItem, direction);
1517 if (span.integerSpan() == 1) { 1542 if (span.integerSpan() == 1) {
1518 resolveContentBasedTrackSizingFunctionsForNonSpanningItems( 1543 resolveContentBasedTrackSizingFunctionsForNonSpanningItems(
1519 direction, span, *gridItem, track, sizingData); 1544 direction, span, *gridItem, track, sizingData);
1520 } else if (!spanningItemCrossesFlexibleSizedTracks( 1545 } else if (!spanningItemCrossesFlexibleSizedTracks(span, direction,
1521 span, direction, sizingData.sizingOperation)) { 1546 sizingData)) {
1522 sizingData.itemsSortedByIncreasingSpan.append( 1547 sizingData.itemsSortedByIncreasingSpan.append(
1523 GridItemWithSpan(*gridItem, span)); 1548 GridItemWithSpan(*gridItem, span));
1524 } 1549 }
1525 } 1550 }
1526 } 1551 }
1527 } 1552 }
1528 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(), 1553 std::sort(sizingData.itemsSortedByIncreasingSpan.begin(),
1529 sizingData.itemsSortedByIncreasingSpan.end()); 1554 sizingData.itemsSortedByIncreasingSpan.end());
1530 } 1555 }
1531 1556
(...skipping 24 matching lines...) Expand all
1556 } 1581 }
1557 } 1582 }
1558 1583
1559 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems( 1584 void LayoutGrid::resolveContentBasedTrackSizingFunctionsForNonSpanningItems(
1560 GridTrackSizingDirection direction, 1585 GridTrackSizingDirection direction,
1561 const GridSpan& span, 1586 const GridSpan& span,
1562 LayoutBox& gridItem, 1587 LayoutBox& gridItem,
1563 GridTrack& track, 1588 GridTrack& track,
1564 GridSizingData& sizingData) const { 1589 GridSizingData& sizingData) const {
1565 const size_t trackPosition = span.startLine(); 1590 const size_t trackPosition = span.startLine();
1566 GridTrackSize trackSize = 1591 GridTrackSize trackSize = gridTrackSize(direction, trackPosition, sizingData);
1567 gridTrackSize(direction, trackPosition, sizingData.sizingOperation);
1568 1592
1569 if (trackSize.hasMinContentMinTrackBreadth()) 1593 if (trackSize.hasMinContentMinTrackBreadth())
1570 track.setBaseSize(std::max( 1594 track.setBaseSize(std::max(
1571 track.baseSize(), minContentForChild(gridItem, direction, sizingData))); 1595 track.baseSize(), minContentForChild(gridItem, direction, sizingData)));
1572 else if (trackSize.hasMaxContentMinTrackBreadth()) 1596 else if (trackSize.hasMaxContentMinTrackBreadth())
1573 track.setBaseSize(std::max( 1597 track.setBaseSize(std::max(
1574 track.baseSize(), maxContentForChild(gridItem, direction, sizingData))); 1598 track.baseSize(), maxContentForChild(gridItem, direction, sizingData)));
1575 else if (trackSize.hasAutoMinTrackBreadth()) 1599 else if (trackSize.hasAutoMinTrackBreadth())
1576 track.setBaseSize(std::max( 1600 track.setBaseSize(std::max(
1577 track.baseSize(), minSizeForChild(gridItem, direction, sizingData))); 1601 track.baseSize(), minSizeForChild(gridItem, direction, sizingData)));
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEnd; 1771 for (auto it = gridItemsWithSpan.rangeStart; it != gridItemsWithSpan.rangeEnd;
1748 ++it) { 1772 ++it) {
1749 GridItemWithSpan& gridItemWithSpan = *it; 1773 GridItemWithSpan& gridItemWithSpan = *it;
1750 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1); 1774 ASSERT(gridItemWithSpan.getGridSpan().integerSpan() > 1);
1751 const GridSpan& itemSpan = gridItemWithSpan.getGridSpan(); 1775 const GridSpan& itemSpan = gridItemWithSpan.getGridSpan();
1752 1776
1753 sizingData.growBeyondGrowthLimitsTracks.shrink(0); 1777 sizingData.growBeyondGrowthLimitsTracks.shrink(0);
1754 sizingData.filteredTracks.shrink(0); 1778 sizingData.filteredTracks.shrink(0);
1755 LayoutUnit spanningTracksSize; 1779 LayoutUnit spanningTracksSize;
1756 for (const auto& trackPosition : itemSpan) { 1780 for (const auto& trackPosition : itemSpan) {
1757 GridTrackSize trackSize = gridTrackSize(direction, trackPosition); 1781 GridTrackSize trackSize =
1782 gridTrackSize(direction, trackPosition, sizingData);
1758 GridTrack& track = (direction == ForColumns) 1783 GridTrack& track = (direction == ForColumns)
1759 ? sizingData.columnTracks[trackPosition] 1784 ? sizingData.columnTracks[trackPosition]
1760 : sizingData.rowTracks[trackPosition]; 1785 : sizingData.rowTracks[trackPosition];
1761 spanningTracksSize += 1786 spanningTracksSize +=
1762 trackSizeForTrackSizeComputationPhase(phase, track, ForbidInfinity); 1787 trackSizeForTrackSizeComputationPhase(phase, track, ForbidInfinity);
1763 if (!shouldProcessTrackForTrackSizeComputationPhase(phase, trackSize)) 1788 if (!shouldProcessTrackForTrackSizeComputationPhase(phase, trackSize))
1764 continue; 1789 continue;
1765 1790
1766 sizingData.filteredTracks.append(&track); 1791 sizingData.filteredTracks.append(&track);
1767 1792
1768 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase( 1793 if (trackShouldGrowBeyondGrowthLimitsForTrackSizeComputationPhase(
1769 phase, trackSize)) 1794 phase, trackSize))
1770 sizingData.growBeyondGrowthLimitsTracks.append(&track); 1795 sizingData.growBeyondGrowthLimitsTracks.append(&track);
1771 } 1796 }
1772 1797
1773 if (sizingData.filteredTracks.isEmpty()) 1798 if (sizingData.filteredTracks.isEmpty())
1774 continue; 1799 continue;
1775 1800
1776 spanningTracksSize += 1801 spanningTracksSize +=
1777 guttersSize(direction, itemSpan.startLine(), itemSpan.integerSpan(), 1802 guttersSize(sizingData.grid(), direction, itemSpan.startLine(),
1778 sizingData.sizingOperation); 1803 itemSpan.integerSpan(), sizingData.sizingOperation);
1779 1804
1780 LayoutUnit extraSpace = 1805 LayoutUnit extraSpace =
1781 currentItemSizeForTrackSizeComputationPhase( 1806 currentItemSizeForTrackSizeComputationPhase(
1782 phase, gridItemWithSpan.gridItem(), direction, sizingData) - 1807 phase, gridItemWithSpan.gridItem(), direction, sizingData) -
1783 spanningTracksSize; 1808 spanningTracksSize;
1784 extraSpace = extraSpace.clampNegativeToZero(); 1809 extraSpace = extraSpace.clampNegativeToZero();
1785 auto& tracksToGrowBeyondGrowthLimits = 1810 auto& tracksToGrowBeyondGrowthLimits =
1786 sizingData.growBeyondGrowthLimitsTracks.isEmpty() 1811 sizingData.growBeyondGrowthLimitsTracks.isEmpty()
1787 ? sizingData.filteredTracks 1812 ? sizingData.filteredTracks
1788 : sizingData.growBeyondGrowthLimitsTracks; 1813 : sizingData.growBeyondGrowthLimitsTracks;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 1931
1907 #if ENABLE(ASSERT) 1932 #if ENABLE(ASSERT)
1908 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth( 1933 bool LayoutGrid::tracksAreWiderThanMinTrackBreadth(
1909 GridTrackSizingDirection direction, 1934 GridTrackSizingDirection direction,
1910 GridSizingData& sizingData) const { 1935 GridSizingData& sizingData) const {
1911 const Vector<GridTrack>& tracks = (direction == ForColumns) 1936 const Vector<GridTrack>& tracks = (direction == ForColumns)
1912 ? sizingData.columnTracks 1937 ? sizingData.columnTracks
1913 : sizingData.rowTracks; 1938 : sizingData.rowTracks;
1914 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero(); 1939 LayoutUnit maxSize = sizingData.availableSpace().clampNegativeToZero();
1915 for (size_t i = 0; i < tracks.size(); ++i) { 1940 for (size_t i = 0; i < tracks.size(); ++i) {
1916 GridTrackSize trackSize = 1941 GridTrackSize trackSize = gridTrackSize(direction, i, sizingData);
1917 gridTrackSize(direction, i, sizingData.sizingOperation);
1918 if (computeUsedBreadthOfMinLength(trackSize, maxSize) > 1942 if (computeUsedBreadthOfMinLength(trackSize, maxSize) >
1919 tracks[i].baseSize()) 1943 tracks[i].baseSize())
1920 return false; 1944 return false;
1921 } 1945 }
1922 return true; 1946 return true;
1923 } 1947 }
1924 #endif 1948 #endif
1925 1949
1926 size_t LayoutGrid::computeAutoRepeatTracksCount( 1950 size_t LayoutGrid::computeAutoRepeatTracksCount(
1927 GridTrackSizingDirection direction, 1951 GridTrackSizingDirection direction,
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 bool isRowAxis = direction == ForColumns; 2431 bool isRowAxis = direction == ForColumns;
2408 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; 2432 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions;
2409 size_t numPositions = positions.size(); 2433 size_t numPositions = positions.size();
2410 LayoutUnit offsetBetweenTracks = 2434 LayoutUnit offsetBetweenTracks =
2411 isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows; 2435 isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
2412 2436
2413 Vector<LayoutUnit> tracks; 2437 Vector<LayoutUnit> tracks;
2414 if (numPositions < 2) 2438 if (numPositions < 2)
2415 return tracks; 2439 return tracks;
2416 2440
2441 DCHECK(!m_grid.needsItemsPlacement());
jfernandez 2016/12/14 10:41:55 Perhaps too late for this suggestion, and not very
svillar 2016/12/14 14:23:31 OK we could change it later if needed.
2417 bool hasCollapsedTracks = m_grid.hasAutoRepeatEmptyTracks(direction); 2442 bool hasCollapsedTracks = m_grid.hasAutoRepeatEmptyTracks(direction);
2418 LayoutUnit gap = !hasCollapsedTracks 2443 LayoutUnit gap = !hasCollapsedTracks
2419 ? gridGapForDirection(direction, TrackSizing) 2444 ? gridGapForDirection(direction, TrackSizing)
2420 : LayoutUnit(); 2445 : LayoutUnit();
2421 tracks.reserveCapacity(numPositions - 1); 2446 tracks.reserveCapacity(numPositions - 1);
2422 for (size_t i = 0; i < numPositions - 2; ++i) 2447 for (size_t i = 0; i < numPositions - 2; ++i)
2423 tracks.append(positions[i + 1] - positions[i] - offsetBetweenTracks - gap); 2448 tracks.append(positions[i + 1] - positions[i] - offsetBetweenTracks - gap);
2424 tracks.append(positions[numPositions - 1] - positions[numPositions - 2]); 2449 tracks.append(positions[numPositions - 1] - positions[numPositions - 2]);
2425 2450
2426 if (!hasCollapsedTracks) 2451 if (!hasCollapsedTracks)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 contentAlignmentNormalBehavior()) != ContentDistributionStretch)) 2490 contentAlignmentNormalBehavior()) != ContentDistributionStretch))
2466 return; 2491 return;
2467 2492
2468 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing 2493 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing
2469 // function. 2494 // function.
2470 Vector<GridTrack>& tracks = (direction == ForColumns) 2495 Vector<GridTrack>& tracks = (direction == ForColumns)
2471 ? sizingData.columnTracks 2496 ? sizingData.columnTracks
2472 : sizingData.rowTracks; 2497 : sizingData.rowTracks;
2473 Vector<unsigned> autoSizedTracksIndex; 2498 Vector<unsigned> autoSizedTracksIndex;
2474 for (unsigned i = 0; i < tracks.size(); ++i) { 2499 for (unsigned i = 0; i < tracks.size(); ++i) {
2475 const GridTrackSize& trackSize = gridTrackSize(direction, i); 2500 const GridTrackSize& trackSize = gridTrackSize(direction, i, sizingData);
2476 if (trackSize.hasAutoMaxTrackBreadth()) 2501 if (trackSize.hasAutoMaxTrackBreadth())
2477 autoSizedTracksIndex.append(i); 2502 autoSizedTracksIndex.append(i);
2478 } 2503 }
2479 2504
2480 unsigned numberOfAutoSizedTracks = autoSizedTracksIndex.size(); 2505 unsigned numberOfAutoSizedTracks = autoSizedTracksIndex.size();
2481 if (numberOfAutoSizedTracks < 1) 2506 if (numberOfAutoSizedTracks < 1)
2482 return; 2507 return;
2483 2508
2484 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks; 2509 LayoutUnit sizeToIncrease = availableSpace / numberOfAutoSizedTracks;
2485 for (const auto& trackIndex : autoSizedTracksIndex) { 2510 for (const auto& trackIndex : autoSizedTracksIndex) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 // before stretching, are not set yet. 2564 // before stretching, are not set yet.
2540 applyStretchAlignmentToChildIfNeeded(*child); 2565 applyStretchAlignmentToChildIfNeeded(*child);
2541 2566
2542 child->layoutIfNeeded(); 2567 child->layoutIfNeeded();
2543 2568
2544 // We need pending layouts to be done in order to compute auto-margins 2569 // We need pending layouts to be done in order to compute auto-margins
2545 // properly. 2570 // properly.
2546 updateAutoMarginsInColumnAxisIfNeeded(*child); 2571 updateAutoMarginsInColumnAxisIfNeeded(*child);
2547 updateAutoMarginsInRowAxisIfNeeded(*child); 2572 updateAutoMarginsInRowAxisIfNeeded(*child);
2548 2573
2549 const GridArea& area = m_grid.gridItemArea(*child); 2574 const GridArea& area = sizingData.grid().gridItemArea(*child);
2550 #if ENABLE(ASSERT) 2575 #if ENABLE(ASSERT)
2551 ASSERT(area.columns.startLine() < sizingData.columnTracks.size()); 2576 ASSERT(area.columns.startLine() < sizingData.columnTracks.size());
2552 ASSERT(area.rows.startLine() < sizingData.rowTracks.size()); 2577 ASSERT(area.rows.startLine() < sizingData.rowTracks.size());
2553 #endif 2578 #endif
2554 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); 2579 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData));
2555 2580
2556 // Keep track of children overflowing their grid area as we might need to 2581 // Keep track of children overflowing their grid area as we might need to
2557 // paint them even if the grid-area is not visible. Using physical 2582 // paint them even if the grid-area is not visible. Using physical
2558 // dimensions for simplicity, so we can forget about orthogonalty. 2583 // dimensions for simplicity, so we can forget about orthogonalty.
2559 LayoutUnit childGridAreaHeight = 2584 LayoutUnit childGridAreaHeight =
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 end = logicalWidth() - 2708 end = logicalWidth() -
2684 translateRTLCoordinate(m_columnPositions[endLine]) - 2709 translateRTLCoordinate(m_columnPositions[endLine]) -
2685 borderLogicalRight(); 2710 borderLogicalRight();
2686 } else { 2711 } else {
2687 end = m_rowPositions[endLine] - borderBefore(); 2712 end = m_rowPositions[endLine] - borderBefore();
2688 } 2713 }
2689 2714
2690 // These vectors store line positions including gaps, but we shouldn't 2715 // These vectors store line positions including gaps, but we shouldn't
2691 // consider them for the edges of the grid. 2716 // consider them for the edges of the grid.
2692 if (endLine > 0 && endLine < lastLine) { 2717 if (endLine > 0 && endLine < lastLine) {
2693 end -= guttersSize(direction, endLine - 1, 2, TrackSizing); 2718 DCHECK(!m_grid.needsItemsPlacement());
jfernandez 2016/12/14 10:41:55 ditto
2719 end -= guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing);
2694 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; 2720 end -= isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows;
2695 } 2721 }
2696 } 2722 }
2697 2723
2698 breadth = std::max(end - start, LayoutUnit()); 2724 breadth = std::max(end - start, LayoutUnit());
2699 offset = start; 2725 offset = start;
2700 2726
2701 if (isForColumns && !styleRef().isLeftToRightDirection() && 2727 if (isForColumns && !styleRef().isLeftToRightDirection() &&
2702 !child.styleRef().hasStaticInlinePosition( 2728 !child.styleRef().hasStaticInlinePosition(
2703 child.isHorizontalWritingMode())) { 2729 child.isHorizontalWritingMode())) {
2704 // If the child doesn't have a static inline position (i.e. "left" and/or 2730 // If the child doesn't have a static inline position (i.e. "left" and/or
2705 // "right" aren't "auto", we need to calculate the offset from the left 2731 // "right" aren't "auto", we need to calculate the offset from the left
2706 // (even if we're in RTL). 2732 // (even if we're in RTL).
2707 if (endIsAuto) { 2733 if (endIsAuto) {
2708 offset = LayoutUnit(); 2734 offset = LayoutUnit();
2709 } else { 2735 } else {
2710 offset = translateRTLCoordinate(m_columnPositions[endLine]) - 2736 offset = translateRTLCoordinate(m_columnPositions[endLine]) -
2711 borderLogicalLeft(); 2737 borderLogicalLeft();
2712 2738
2713 if (endLine > 0 && endLine < lastLine) { 2739 if (endLine > 0 && endLine < lastLine) {
2714 offset += guttersSize(direction, endLine - 1, 2, TrackSizing); 2740 DCHECK(!m_grid.needsItemsPlacement());
2741 offset += guttersSize(m_grid, direction, endLine - 1, 2, TrackSizing);
2715 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows; 2742 offset += isForColumns ? m_offsetBetweenColumns : m_offsetBetweenRows;
2716 } 2743 }
2717 } 2744 }
2718 } 2745 }
2719 } 2746 }
2720 2747
2721 LayoutUnit LayoutGrid::assumedRowsSizeForOrthogonalChild( 2748 LayoutUnit LayoutGrid::assumedRowsSizeForOrthogonalChild(
2722 const LayoutBox& child, 2749 const LayoutBox& child,
2723 SizingOperation sizingOperation) const { 2750 const GridSizingData& sizingData) const {
2724 DCHECK(isOrthogonalChild(child)); 2751 DCHECK(isOrthogonalChild(child));
2725 const GridSpan& span = m_grid.gridItemSpan(child, ForRows); 2752 const Grid& grid = sizingData.grid();
2753 const GridSpan& span = grid.gridItemSpan(child, ForRows);
2726 LayoutUnit gridAreaSize; 2754 LayoutUnit gridAreaSize;
2727 bool gridAreaIsIndefinite = false; 2755 bool gridAreaIsIndefinite = false;
2728 LayoutUnit containingBlockAvailableSize = 2756 LayoutUnit containingBlockAvailableSize =
2729 containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding); 2757 containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
2730 for (auto trackPosition : span) { 2758 for (auto trackPosition : span) {
2731 GridLength maxTrackSize = 2759 GridLength maxTrackSize =
2732 gridTrackSize(ForRows, trackPosition, sizingOperation) 2760 gridTrackSize(ForRows, trackPosition, sizingData).maxTrackBreadth();
2733 .maxTrackBreadth();
2734 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex()) 2761 if (maxTrackSize.isContentSized() || maxTrackSize.isFlex())
2735 gridAreaIsIndefinite = true; 2762 gridAreaIsIndefinite = true;
2736 else 2763 else
2737 gridAreaSize += 2764 gridAreaSize +=
2738 valueForLength(maxTrackSize.length(), containingBlockAvailableSize); 2765 valueForLength(maxTrackSize.length(), containingBlockAvailableSize);
2739 } 2766 }
2740 2767
2741 gridAreaSize += guttersSize(ForRows, span.startLine(), span.integerSpan(), 2768 gridAreaSize += guttersSize(grid, ForRows, span.startLine(),
2742 sizingOperation); 2769 span.integerSpan(), sizingData.sizingOperation);
2743 2770
2744 return gridAreaIsIndefinite 2771 return gridAreaIsIndefinite
2745 ? std::max(child.maxPreferredLogicalWidth(), gridAreaSize) 2772 ? std::max(child.maxPreferredLogicalWidth(), gridAreaSize)
2746 : gridAreaSize; 2773 : gridAreaSize;
2747 } 2774 }
2748 2775
2749 LayoutUnit LayoutGrid::gridAreaBreadthForChild( 2776 LayoutUnit LayoutGrid::gridAreaBreadthForChild(
2750 const LayoutBox& child, 2777 const LayoutBox& child,
2751 GridTrackSizingDirection direction, 2778 GridTrackSizingDirection direction,
2752 const GridSizingData& sizingData) const { 2779 const GridSizingData& sizingData) const {
2753 // To determine the column track's size based on an orthogonal grid item we 2780 // To determine the column track's size based on an orthogonal grid item we
2754 // need it's logical height, which may depend on the row track's size. It's 2781 // need it's logical height, which may depend on the row track's size. It's
2755 // possible that the row tracks sizing logic has not been performed yet, so we 2782 // possible that the row tracks sizing logic has not been performed yet, so we
2756 // will need to do an estimation. 2783 // will need to do an estimation.
2757 if (direction == ForRows && 2784 if (direction == ForRows &&
2758 sizingData.sizingState == GridSizingData::ColumnSizingFirstIteration) 2785 sizingData.sizingState == GridSizingData::ColumnSizingFirstIteration)
2759 return assumedRowsSizeForOrthogonalChild(child, sizingData.sizingOperation); 2786 return assumedRowsSizeForOrthogonalChild(child, sizingData);
2760 2787
2761 const Vector<GridTrack>& tracks = 2788 const Vector<GridTrack>& tracks =
2762 direction == ForColumns ? sizingData.columnTracks : sizingData.rowTracks; 2789 direction == ForColumns ? sizingData.columnTracks : sizingData.rowTracks;
2763 const GridSpan& span = m_grid.gridItemSpan(child, direction); 2790 const GridSpan& span = sizingData.grid().gridItemSpan(child, direction);
2764 LayoutUnit gridAreaBreadth; 2791 LayoutUnit gridAreaBreadth;
2765 for (const auto& trackPosition : span) 2792 for (const auto& trackPosition : span)
2766 gridAreaBreadth += tracks[trackPosition].baseSize(); 2793 gridAreaBreadth += tracks[trackPosition].baseSize();
2767 2794
2768 gridAreaBreadth += 2795 gridAreaBreadth +=
2769 guttersSize(direction, span.startLine(), span.integerSpan(), 2796 guttersSize(sizingData.grid(), direction, span.startLine(),
2770 sizingData.sizingOperation); 2797 span.integerSpan(), sizingData.sizingOperation);
2771 2798
2772 return gridAreaBreadth; 2799 return gridAreaBreadth;
2773 } 2800 }
2774 2801
2775 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets( 2802 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(
2776 const LayoutBox& child, 2803 const LayoutBox& child,
2777 GridTrackSizingDirection direction, 2804 GridTrackSizingDirection direction,
2778 const GridSizingData& sizingData) const { 2805 const GridSizingData& sizingData) const {
2779 // We need the cached value when available because Content Distribution 2806 // We need the cached value when available because Content Distribution
2780 // alignment properties may have some influence in the final grid area 2807 // alignment properties may have some influence in the final grid area
2781 // breadth. 2808 // breadth.
2782 const Vector<GridTrack>& tracks = (direction == ForColumns) 2809 const Vector<GridTrack>& tracks = (direction == ForColumns)
2783 ? sizingData.columnTracks 2810 ? sizingData.columnTracks
2784 : sizingData.rowTracks; 2811 : sizingData.rowTracks;
2785 const GridSpan& span = m_grid.gridItemSpan(child, direction); 2812 const GridSpan& span = sizingData.grid().gridItemSpan(child, direction);
2786 const Vector<LayoutUnit>& linePositions = 2813 const Vector<LayoutUnit>& linePositions =
2787 (direction == ForColumns) ? m_columnPositions : m_rowPositions; 2814 (direction == ForColumns) ? m_columnPositions : m_rowPositions;
2788 LayoutUnit initialTrackPosition = linePositions[span.startLine()]; 2815 LayoutUnit initialTrackPosition = linePositions[span.startLine()];
2789 LayoutUnit finalTrackPosition = linePositions[span.endLine() - 1]; 2816 LayoutUnit finalTrackPosition = linePositions[span.endLine() - 1];
2790 // Track Positions vector stores the 'start' grid line of each track, so we 2817 // Track Positions vector stores the 'start' grid line of each track, so we
2791 // have to add last track's baseSize. 2818 // have to add last track's baseSize.
2792 return finalTrackPosition - initialTrackPosition + 2819 return finalTrackPosition - initialTrackPosition +
2793 tracks[span.endLine() - 1].baseSize(); 2820 tracks[span.endLine() - 1].baseSize();
2794 } 2821 }
2795 2822
(...skipping 15 matching lines...) Expand all
2811 size_t numberOfTracks = tracks.size(); 2838 size_t numberOfTracks = tracks.size();
2812 size_t numberOfLines = numberOfTracks + 1; 2839 size_t numberOfLines = numberOfTracks + 1;
2813 size_t lastLine = numberOfLines - 1; 2840 size_t lastLine = numberOfLines - 1;
2814 ContentAlignmentData offset = computeContentPositionAndDistributionOffset( 2841 ContentAlignmentData offset = computeContentPositionAndDistributionOffset(
2815 direction, sizingData.freeSpace(direction), numberOfTracks); 2842 direction, sizingData.freeSpace(direction), numberOfTracks);
2816 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions; 2843 auto& positions = isRowAxis ? m_columnPositions : m_rowPositions;
2817 positions.resize(numberOfLines); 2844 positions.resize(numberOfLines);
2818 auto borderAndPadding = 2845 auto borderAndPadding =
2819 isRowAxis ? borderAndPaddingLogicalLeft() : borderAndPaddingBefore(); 2846 isRowAxis ? borderAndPaddingLogicalLeft() : borderAndPaddingBefore();
2820 positions[0] = borderAndPadding + offset.positionOffset; 2847 positions[0] = borderAndPadding + offset.positionOffset;
2848 Grid& grid = sizingData.grid();
jfernandez 2016/12/14 10:41:55 const ?
svillar 2016/12/14 14:23:31 Acknowledged.
2821 if (numberOfLines > 1) { 2849 if (numberOfLines > 1) {
2822 // If we have collapsed tracks we just ignore gaps here and add them later 2850 // If we have collapsed tracks we just ignore gaps here and add them later
2823 // as we might not compute the gap between two consecutive tracks without 2851 // as we might not compute the gap between two consecutive tracks without
2824 // examining the surrounding ones. 2852 // examining the surrounding ones.
2825 bool hasCollapsedTracks = m_grid.hasAutoRepeatEmptyTracks(direction); 2853 bool hasCollapsedTracks = grid.hasAutoRepeatEmptyTracks(direction);
2826 LayoutUnit gap = 2854 LayoutUnit gap =
2827 !hasCollapsedTracks 2855 !hasCollapsedTracks
2828 ? gridGapForDirection(direction, sizingData.sizingOperation) 2856 ? gridGapForDirection(direction, sizingData.sizingOperation)
2829 : LayoutUnit(); 2857 : LayoutUnit();
2830 size_t nextToLastLine = numberOfLines - 2; 2858 size_t nextToLastLine = numberOfLines - 2;
2831 for (size_t i = 0; i < nextToLastLine; ++i) 2859 for (size_t i = 0; i < nextToLastLine; ++i)
2832 positions[i + 1] = 2860 positions[i + 1] =
2833 positions[i] + offset.distributionOffset + tracks[i].baseSize() + gap; 2861 positions[i] + offset.distributionOffset + tracks[i].baseSize() + gap;
2834 positions[lastLine] = 2862 positions[lastLine] =
2835 positions[nextToLastLine] + tracks[nextToLastLine].baseSize(); 2863 positions[nextToLastLine] + tracks[nextToLastLine].baseSize();
2836 2864
2837 // Adjust collapsed gaps. Collapsed tracks cause the surrounding gutters to 2865 // Adjust collapsed gaps. Collapsed tracks cause the surrounding gutters to
2838 // collapse (they coincide exactly) except on the edges of the grid where 2866 // collapse (they coincide exactly) except on the edges of the grid where
2839 // they become 0. 2867 // they become 0.
2840 if (hasCollapsedTracks) { 2868 if (hasCollapsedTracks) {
2841 gap = gridGapForDirection(direction, sizingData.sizingOperation); 2869 gap = gridGapForDirection(direction, sizingData.sizingOperation);
2842 size_t remainingEmptyTracks = 2870 size_t remainingEmptyTracks =
2843 m_grid.autoRepeatEmptyTracks(direction)->size(); 2871 grid.autoRepeatEmptyTracks(direction)->size();
2844 LayoutUnit gapAccumulator; 2872 LayoutUnit gapAccumulator;
2845 for (size_t i = 1; i < lastLine; ++i) { 2873 for (size_t i = 1; i < lastLine; ++i) {
2846 if (m_grid.isEmptyAutoRepeatTrack(direction, i - 1)) { 2874 if (grid.isEmptyAutoRepeatTrack(direction, i - 1)) {
2847 --remainingEmptyTracks; 2875 --remainingEmptyTracks;
2848 } else { 2876 } else {
2849 // Add gap between consecutive non empty tracks. Add it also just once 2877 // Add gap between consecutive non empty tracks. Add it also just once
2850 // for an arbitrary number of empty tracks between two non empty ones. 2878 // for an arbitrary number of empty tracks between two non empty ones.
2851 bool allRemainingTracksAreEmpty = 2879 bool allRemainingTracksAreEmpty =
2852 remainingEmptyTracks == (lastLine - i); 2880 remainingEmptyTracks == (lastLine - i);
2853 if (!allRemainingTracksAreEmpty || 2881 if (!allRemainingTracksAreEmpty ||
2854 !m_grid.isEmptyAutoRepeatTrack(direction, i)) 2882 !grid.isEmptyAutoRepeatTrack(direction, i))
2855 gapAccumulator += gap; 2883 gapAccumulator += gap;
2856 } 2884 }
2857 positions[i] += gapAccumulator; 2885 positions[i] += gapAccumulator;
2858 } 2886 }
2859 positions[lastLine] += gapAccumulator; 2887 positions[lastLine] += gapAccumulator;
2860 } 2888 }
2861 } 2889 }
2862 auto& offsetBetweenTracks = 2890 auto& offsetBetweenTracks =
2863 isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows; 2891 isRowAxis ? m_offsetBetweenColumns : m_offsetBetweenRows;
2864 offsetBetweenTracks = offset.distributionOffset; 2892 offsetBetweenTracks = offset.distributionOffset;
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
3311 break; 3339 break;
3312 } 3340 }
3313 3341
3314 ASSERT_NOT_REACHED(); 3342 ASSERT_NOT_REACHED();
3315 return GridAxisStart; 3343 return GridAxisStart;
3316 } 3344 }
3317 3345
3318 LayoutUnit LayoutGrid::columnAxisOffsetForChild( 3346 LayoutUnit LayoutGrid::columnAxisOffsetForChild(
3319 const LayoutBox& child, 3347 const LayoutBox& child,
3320 GridSizingData& sizingData) const { 3348 GridSizingData& sizingData) const {
3321 const GridSpan& rowsSpan = m_grid.gridItemSpan(child, ForRows); 3349 const GridSpan& rowsSpan = sizingData.grid().gridItemSpan(child, ForRows);
3322 size_t childStartLine = rowsSpan.startLine(); 3350 size_t childStartLine = rowsSpan.startLine();
3323 LayoutUnit startOfRow = m_rowPositions[childStartLine]; 3351 LayoutUnit startOfRow = m_rowPositions[childStartLine];
3324 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); 3352 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child);
3325 if (hasAutoMarginsInColumnAxis(child)) 3353 if (hasAutoMarginsInColumnAxis(child))
3326 return startPosition; 3354 return startPosition;
3327 GridAxisPosition axisPosition = columnAxisPositionForChild(child); 3355 GridAxisPosition axisPosition = columnAxisPositionForChild(child);
3328 switch (axisPosition) { 3356 switch (axisPosition) {
3329 case GridAxisStart: 3357 case GridAxisStart:
3330 return startPosition; 3358 return startPosition;
3331 case GridAxisEnd: 3359 case GridAxisEnd:
(...skipping 22 matching lines...) Expand all
3354 : offsetFromStartPosition / 2); 3382 : offsetFromStartPosition / 2);
3355 } 3383 }
3356 } 3384 }
3357 3385
3358 ASSERT_NOT_REACHED(); 3386 ASSERT_NOT_REACHED();
3359 return LayoutUnit(); 3387 return LayoutUnit();
3360 } 3388 }
3361 3389
3362 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, 3390 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child,
3363 GridSizingData& sizingData) const { 3391 GridSizingData& sizingData) const {
3364 const GridSpan& columnsSpan = m_grid.gridItemSpan(child, ForColumns); 3392 const GridSpan& columnsSpan =
3393 sizingData.grid().gridItemSpan(child, ForColumns);
3365 size_t childStartLine = columnsSpan.startLine(); 3394 size_t childStartLine = columnsSpan.startLine();
3366 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; 3395 LayoutUnit startOfColumn = m_columnPositions[childStartLine];
3367 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); 3396 LayoutUnit startPosition = startOfColumn + marginStartForChild(child);
3368 if (hasAutoMarginsInRowAxis(child)) 3397 if (hasAutoMarginsInRowAxis(child))
3369 return startPosition; 3398 return startPosition;
3370 GridAxisPosition axisPosition = rowAxisPositionForChild(child); 3399 GridAxisPosition axisPosition = rowAxisPositionForChild(child);
3371 switch (axisPosition) { 3400 switch (axisPosition) {
3372 case GridAxisStart: 3401 case GridAxisStart:
3373 return startPosition; 3402 return startPosition;
3374 case GridAxisEnd: 3403 case GridAxisEnd:
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3571 // See comment in findChildLogicalPosition() about why we need sometimes to 3600 // See comment in findChildLogicalPosition() about why we need sometimes to
3572 // translate from RTL to LTR the rowAxisOffset coordinate. 3601 // translate from RTL to LTR the rowAxisOffset coordinate.
3573 return LayoutPoint(style()->isLeftToRightDirection() 3602 return LayoutPoint(style()->isLeftToRightDirection()
3574 ? rowAxisOffset 3603 ? rowAxisOffset
3575 : translateRTLCoordinate(rowAxisOffset), 3604 : translateRTLCoordinate(rowAxisOffset),
3576 columnAxisOffset); 3605 columnAxisOffset);
3577 } 3606 }
3578 3607
3579 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, 3608 void LayoutGrid::paintChildren(const PaintInfo& paintInfo,
3580 const LayoutPoint& paintOffset) const { 3609 const LayoutPoint& paintOffset) const {
3610 DCHECK(!m_grid.needsItemsPlacement());
jfernandez 2016/12/14 10:41:55 ditto.
3581 if (m_grid.hasGridItems()) 3611 if (m_grid.hasGridItems())
3582 GridPainter(*this).paintChildren(paintInfo, paintOffset); 3612 GridPainter(*this).paintChildren(paintInfo, paintOffset);
3583 } 3613 }
3584 3614
3585 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { 3615 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const {
3586 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); 3616 SECURITY_DCHECK(m_hasDefiniteLogicalHeight);
3587 return m_hasDefiniteLogicalHeight.value(); 3617 return m_hasDefiniteLogicalHeight.value();
3588 } 3618 }
3589 3619
3590 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction, 3620 size_t LayoutGrid::numTracks(GridTrackSizingDirection direction,
3591 const Grid& grid) const { 3621 const Grid& grid) const {
3592 // Due to limitations in our internal representation, we cannot know the 3622 // Due to limitations in our internal representation, we cannot know the
3593 // number of columns from m_grid *if* there is no row (because m_grid would be 3623 // number of columns from m_grid *if* there is no row (because m_grid would be
3594 // empty). That's why in that case we need to get it from the style. Note that 3624 // empty). That's why in that case we need to get it from the style. Note that
3595 // we know for sure that there are't any implicit tracks, because not having 3625 // we know for sure that there are't any implicit tracks, because not having
3596 // rows implies that there are no "normal" children (out-of-flow children are 3626 // rows implies that there are no "normal" children (out-of-flow children are
3597 // not stored in m_grid). 3627 // not stored in m_grid).
3628 DCHECK(!grid.needsItemsPlacement());
jfernandez 2016/12/14 10:41:55 Ditto.
3598 if (direction == ForRows) 3629 if (direction == ForRows)
3599 return grid.numTracks(ForRows); 3630 return grid.numTracks(ForRows);
3600 3631
3601 return grid.numTracks(ForRows) 3632 return grid.numTracks(ForRows)
3602 ? grid.numTracks(ForColumns) 3633 ? grid.numTracks(ForColumns)
3603 : GridPositionsResolver::explicitGridColumnCount( 3634 : GridPositionsResolver::explicitGridColumnCount(
3604 styleRef(), grid.autoRepeatTracks(ForColumns)); 3635 styleRef(), grid.autoRepeatTracks(ForColumns));
3605 } 3636 }
3606 3637
3607 } // namespace blink 3638 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698