| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 child->clearContainingBlockOverrideSize(); | 503 child->clearContainingBlockOverrideSize(); |
| 504 child->forceLayout(); | 504 child->forceLayout(); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 | 507 |
| 508 updateLogicalWidth(); | 508 updateLogicalWidth(); |
| 509 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); | 509 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
| 510 | 510 |
| 511 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 511 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
| 512 | 512 |
| 513 updateAutoRepeatTracksAndSetDirtyIfNeeded(TrackSizing); | 513 // TODO(svillar): we won't need to do this once the intrinsic width |
| 514 placeItemsOnGrid(); | 514 // computation is isolated from the LayoutGrid object state (it should not |
| 515 // touch any attribute) (see crbug.com/627812) |
| 516 if (m_autoRepeatColumns && |
| 517 m_autoRepeatColumns != |
| 518 computeAutoRepeatTracksCount(ForColumns, TrackSizing)) |
| 519 dirtyGrid(); |
| 520 placeItemsOnGrid(TrackSizing); |
| 515 | 521 |
| 516 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 522 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 517 | 523 |
| 518 // 1- First, the track sizing algorithm is used to resolve the sizes of the | 524 // 1- First, the track sizing algorithm is used to resolve the sizes of the |
| 519 // grid columns. | 525 // grid columns. |
| 520 // At this point the logical width is always definite as the above call to | 526 // At this point the logical width is always definite as the above call to |
| 521 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the | 527 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the |
| 522 // same for heights though because many code paths inside | 528 // same for heights though because many code paths inside |
| 523 // updateLogicalHeight() require a previous call to setLogicalHeight() to | 529 // updateLogicalHeight() require a previous call to setLogicalHeight() to |
| 524 // resolve heights properly (like for positioned items for example). | 530 // resolve heights properly (like for positioned items for example). |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 if (nonEmptyTracksAfterEndLine) | 686 if (nonEmptyTracksAfterEndLine) |
| 681 gapAccumulator += gap; | 687 gapAccumulator += gap; |
| 682 } | 688 } |
| 683 | 689 |
| 684 return gapAccumulator; | 690 return gapAccumulator; |
| 685 } | 691 } |
| 686 | 692 |
| 687 void LayoutGrid::computeIntrinsicLogicalWidths( | 693 void LayoutGrid::computeIntrinsicLogicalWidths( |
| 688 LayoutUnit& minLogicalWidth, | 694 LayoutUnit& minLogicalWidth, |
| 689 LayoutUnit& maxLogicalWidth) const { | 695 LayoutUnit& maxLogicalWidth) const { |
| 690 const_cast<LayoutGrid*>(this)->updateAutoRepeatTracksAndSetDirtyIfNeeded( | 696 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); |
| 691 IntrinsicSizeComputation); | |
| 692 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); | |
| 693 | 697 |
| 694 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 698 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 695 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, | 699 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, |
| 696 maxLogicalWidth); | 700 maxLogicalWidth); |
| 697 | 701 |
| 698 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); | 702 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); |
| 699 minLogicalWidth += scrollbarWidth; | 703 minLogicalWidth += scrollbarWidth; |
| 700 maxLogicalWidth += scrollbarWidth; | 704 maxLogicalWidth += scrollbarWidth; |
| 701 } | 705 } |
| 702 | 706 |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 RELEASE_ASSERT(area.rows.isTranslatedDefinite() && | 1824 RELEASE_ASSERT(area.rows.isTranslatedDefinite() && |
| 1821 area.columns.isTranslatedDefinite()); | 1825 area.columns.isTranslatedDefinite()); |
| 1822 ensureGridSize(area.rows.endLine(), area.columns.endLine()); | 1826 ensureGridSize(area.rows.endLine(), area.columns.endLine()); |
| 1823 | 1827 |
| 1824 for (const auto& row : area.rows) { | 1828 for (const auto& row : area.rows) { |
| 1825 for (const auto& column : area.columns) | 1829 for (const auto& column : area.columns) |
| 1826 m_grid[row][column].append(&child); | 1830 m_grid[row][column].append(&child); |
| 1827 } | 1831 } |
| 1828 } | 1832 } |
| 1829 | 1833 |
| 1830 void LayoutGrid::updateAutoRepeatTracksAndSetDirtyIfNeeded( | |
| 1831 SizingOperation sizingOperation) { | |
| 1832 size_t newAutoRepeatColumns = | |
| 1833 computeAutoRepeatTracksCount(ForColumns, sizingOperation); | |
| 1834 size_t newAutoRepeatRows = | |
| 1835 computeAutoRepeatTracksCount(ForRows, sizingOperation); | |
| 1836 | |
| 1837 if (m_autoRepeatColumns != newAutoRepeatColumns || | |
| 1838 m_autoRepeatRows != newAutoRepeatRows) | |
| 1839 dirtyGrid(); | |
| 1840 | |
| 1841 m_autoRepeatColumns = newAutoRepeatColumns; | |
| 1842 m_autoRepeatRows = newAutoRepeatRows; | |
| 1843 } | |
| 1844 | |
| 1845 size_t LayoutGrid::computeAutoRepeatTracksCount( | 1834 size_t LayoutGrid::computeAutoRepeatTracksCount( |
| 1846 GridTrackSizingDirection direction, | 1835 GridTrackSizingDirection direction, |
| 1847 SizingOperation sizingOperation) const { | 1836 SizingOperation sizingOperation) const { |
| 1848 bool isRowAxis = direction == ForColumns; | 1837 bool isRowAxis = direction == ForColumns; |
| 1849 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns() | 1838 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns() |
| 1850 : styleRef().gridAutoRepeatRows(); | 1839 : styleRef().gridAutoRepeatRows(); |
| 1851 size_t autoRepeatTrackListLength = autoRepeatTracks.size(); | 1840 size_t autoRepeatTrackListLength = autoRepeatTracks.size(); |
| 1852 | 1841 |
| 1853 if (!autoRepeatTrackListLength) | 1842 if (!autoRepeatTrackListLength) |
| 1854 return 0; | 1843 return 0; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 if (!iterator.nextGridItem()) { | 1964 if (!iterator.nextGridItem()) { |
| 1976 if (!emptyTrackIndexes) | 1965 if (!emptyTrackIndexes) |
| 1977 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 1966 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
| 1978 emptyTrackIndexes->add(trackIndex); | 1967 emptyTrackIndexes->add(trackIndex); |
| 1979 } | 1968 } |
| 1980 } | 1969 } |
| 1981 } | 1970 } |
| 1982 return emptyTrackIndexes; | 1971 return emptyTrackIndexes; |
| 1983 } | 1972 } |
| 1984 | 1973 |
| 1985 void LayoutGrid::placeItemsOnGrid() { | 1974 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) { |
| 1986 if (!m_gridIsDirty) | 1975 if (!m_gridIsDirty) |
| 1987 return; | 1976 return; |
| 1988 | 1977 |
| 1989 DCHECK(m_gridItemArea.isEmpty()); | 1978 DCHECK(m_gridItemArea.isEmpty()); |
| 1990 | 1979 |
| 1980 if (sizingOperation == IntrinsicSizeComputation) { |
| 1981 m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); |
| 1982 } else { |
| 1983 m_autoRepeatColumns = |
| 1984 computeAutoRepeatTracksCount(ForColumns, sizingOperation); |
| 1985 } |
| 1986 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); |
| 1987 |
| 1991 populateExplicitGridAndOrderIterator(); | 1988 populateExplicitGridAndOrderIterator(); |
| 1992 | 1989 |
| 1993 // We clear the dirty bit here as the grid sizes have been updated. | 1990 // We clear the dirty bit here as the grid sizes have been updated. |
| 1994 m_gridIsDirty = false; | 1991 m_gridIsDirty = false; |
| 1995 | 1992 |
| 1996 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1993 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 1997 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1994 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 1998 DCHECK(m_gridItemsIndexesMap.isEmpty()); | 1995 DCHECK(m_gridItemsIndexesMap.isEmpty()); |
| 1999 size_t childIndex = 0; | 1996 size_t childIndex = 0; |
| 2000 m_hasAnyOrthogonalChildren = false; | 1997 m_hasAnyOrthogonalChildren = false; |
| (...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3495 if (!m_gridItemArea.isEmpty()) | 3492 if (!m_gridItemArea.isEmpty()) |
| 3496 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 3493 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 3497 } | 3494 } |
| 3498 | 3495 |
| 3499 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { | 3496 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { |
| 3500 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); | 3497 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); |
| 3501 return m_hasDefiniteLogicalHeight.value(); | 3498 return m_hasDefiniteLogicalHeight.value(); |
| 3502 } | 3499 } |
| 3503 | 3500 |
| 3504 } // namespace blink | 3501 } // namespace blink |
| OLD | NEW |