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

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

Issue 2287533002: [css-grid] Remove a duplicated auto repeat computation for intrinsic sizes (Closed)
Patch Set: Rebased patch Created 4 years, 2 months 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 child->clearContainingBlockOverrideSize(); 500 child->clearContainingBlockOverrideSize();
501 child->forceLayout(); 501 child->forceLayout();
502 } 502 }
503 } 503 }
504 504
505 updateLogicalWidth(); 505 updateLogicalWidth();
506 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); 506 m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight();
507 507
508 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); 508 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope);
509 509
510 // TODO(svillar): we won't need to do this once the intrinsic width 510 updateAutoRepeatTracksAndSetDirtyIfNeeded(TrackSizing);
511 // computation is isolated from the LayoutGrid object state (it should not 511 placeItemsOnGrid();
512 // touch any attribute) (see crbug.com/627812)
513 if (m_autoRepeatColumns &&
514 m_autoRepeatColumns !=
515 computeAutoRepeatTracksCount(ForColumns, TrackSizing))
516 dirtyGrid();
517 placeItemsOnGrid(TrackSizing);
518 512
519 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 513 GridSizingData sizingData(gridColumnCount(), gridRowCount());
520 514
521 // 1- First, the track sizing algorithm is used to resolve the sizes of the 515 // 1- First, the track sizing algorithm is used to resolve the sizes of the
522 // grid columns. 516 // grid columns.
523 // At this point the logical width is always definite as the above call to 517 // At this point the logical width is always definite as the above call to
524 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the 518 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the
525 // same for heights though because many code paths inside 519 // same for heights though because many code paths inside
526 // updateLogicalHeight() require a previous call to setLogicalHeight() to 520 // updateLogicalHeight() require a previous call to setLogicalHeight() to
527 // resolve heights properly (like for positioned items for example). 521 // resolve heights properly (like for positioned items for example).
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 if (nonEmptyTracksAfterEndLine) 671 if (nonEmptyTracksAfterEndLine)
678 gapAccumulator += gap; 672 gapAccumulator += gap;
679 } 673 }
680 674
681 return gapAccumulator; 675 return gapAccumulator;
682 } 676 }
683 677
684 void LayoutGrid::computeIntrinsicLogicalWidths( 678 void LayoutGrid::computeIntrinsicLogicalWidths(
685 LayoutUnit& minLogicalWidth, 679 LayoutUnit& minLogicalWidth,
686 LayoutUnit& maxLogicalWidth) const { 680 LayoutUnit& maxLogicalWidth) const {
687 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); 681 const_cast<LayoutGrid*>(this)->updateAutoRepeatTracksAndSetDirtyIfNeeded(
682 IntrinsicSizeComputation);
683 const_cast<LayoutGrid*>(this)->placeItemsOnGrid();
688 684
689 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 685 GridSizingData sizingData(gridColumnCount(), gridRowCount());
690 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth, 686 computeTrackSizesForIndefiniteSize(ForColumns, sizingData, minLogicalWidth,
691 maxLogicalWidth); 687 maxLogicalWidth);
692 688
693 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth()); 689 LayoutUnit scrollbarWidth = LayoutUnit(scrollbarLogicalWidth());
694 minLogicalWidth += scrollbarWidth; 690 minLogicalWidth += scrollbarWidth;
695 maxLogicalWidth += scrollbarWidth; 691 maxLogicalWidth += scrollbarWidth;
696 } 692 }
697 693
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 RELEASE_ASSERT(area.rows.isTranslatedDefinite() && 1755 RELEASE_ASSERT(area.rows.isTranslatedDefinite() &&
1760 area.columns.isTranslatedDefinite()); 1756 area.columns.isTranslatedDefinite());
1761 ensureGridSize(area.rows.endLine(), area.columns.endLine()); 1757 ensureGridSize(area.rows.endLine(), area.columns.endLine());
1762 1758
1763 for (const auto& row : area.rows) { 1759 for (const auto& row : area.rows) {
1764 for (const auto& column : area.columns) 1760 for (const auto& column : area.columns)
1765 m_grid[row][column].append(&child); 1761 m_grid[row][column].append(&child);
1766 } 1762 }
1767 } 1763 }
1768 1764
1765 void LayoutGrid::updateAutoRepeatTracksAndSetDirtyIfNeeded(
1766 SizingOperation sizingOperation) {
1767 size_t newAutoRepeatColumns =
1768 computeAutoRepeatTracksCount(ForColumns, sizingOperation);
1769 size_t newAutoRepeatRows =
1770 computeAutoRepeatTracksCount(ForRows, sizingOperation);
1771
1772 if (m_autoRepeatColumns != newAutoRepeatColumns ||
1773 m_autoRepeatRows != newAutoRepeatRows)
1774 dirtyGrid();
1775
1776 m_autoRepeatColumns = newAutoRepeatColumns;
1777 m_autoRepeatRows = newAutoRepeatRows;
1778 }
1779
1769 size_t LayoutGrid::computeAutoRepeatTracksCount( 1780 size_t LayoutGrid::computeAutoRepeatTracksCount(
1770 GridTrackSizingDirection direction, 1781 GridTrackSizingDirection direction,
1771 SizingOperation sizingOperation) const { 1782 SizingOperation sizingOperation) const {
1772 bool isRowAxis = direction == ForColumns; 1783 bool isRowAxis = direction == ForColumns;
1773 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns() 1784 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns()
1774 : styleRef().gridAutoRepeatRows(); 1785 : styleRef().gridAutoRepeatRows();
1775 size_t autoRepeatTrackListLength = autoRepeatTracks.size(); 1786 size_t autoRepeatTrackListLength = autoRepeatTracks.size();
1776 1787
1777 if (!autoRepeatTrackListLength) 1788 if (!autoRepeatTrackListLength)
1778 return 0; 1789 return 0;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 if (!iterator.nextGridItem()) { 1910 if (!iterator.nextGridItem()) {
1900 if (!emptyTrackIndexes) 1911 if (!emptyTrackIndexes)
1901 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); 1912 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet);
1902 emptyTrackIndexes->add(trackIndex); 1913 emptyTrackIndexes->add(trackIndex);
1903 } 1914 }
1904 } 1915 }
1905 } 1916 }
1906 return emptyTrackIndexes; 1917 return emptyTrackIndexes;
1907 } 1918 }
1908 1919
1909 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) { 1920 void LayoutGrid::placeItemsOnGrid() {
1910 if (!m_gridIsDirty) 1921 if (!m_gridIsDirty)
1911 return; 1922 return;
1912 1923
1913 DCHECK(m_gridItemArea.isEmpty()); 1924 DCHECK(m_gridItemArea.isEmpty());
1914 DCHECK(m_gridItemsIndexesMap.isEmpty()); 1925 DCHECK(m_gridItemsIndexesMap.isEmpty());
1915 1926
1916 if (sizingOperation == IntrinsicSizeComputation)
1917 m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size();
1918 else
1919 m_autoRepeatColumns =
1920 computeAutoRepeatTracksCount(ForColumns, sizingOperation);
1921 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation);
1922
1923 populateExplicitGridAndOrderIterator(); 1927 populateExplicitGridAndOrderIterator();
1924 1928
1925 // We clear the dirty bit here as the grid sizes have been updated. 1929 // We clear the dirty bit here as the grid sizes have been updated.
1926 m_gridIsDirty = false; 1930 m_gridIsDirty = false;
1927 1931
1928 Vector<LayoutBox*> autoMajorAxisAutoGridItems; 1932 Vector<LayoutBox*> autoMajorAxisAutoGridItems;
1929 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; 1933 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems;
1930 m_hasAnyOrthogonalChildren = false; 1934 m_hasAnyOrthogonalChildren = false;
1931 for (LayoutBox* child = m_orderIterator.first(); child; 1935 for (LayoutBox* child = m_orderIterator.first(); child;
1932 child = m_orderIterator.next()) { 1936 child = m_orderIterator.next()) {
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 if (!m_gridItemArea.isEmpty()) 3326 if (!m_gridItemArea.isEmpty())
3323 GridPainter(*this).paintChildren(paintInfo, paintOffset); 3327 GridPainter(*this).paintChildren(paintInfo, paintOffset);
3324 } 3328 }
3325 3329
3326 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const { 3330 bool LayoutGrid::cachedHasDefiniteLogicalHeight() const {
3327 SECURITY_DCHECK(m_hasDefiniteLogicalHeight); 3331 SECURITY_DCHECK(m_hasDefiniteLogicalHeight);
3328 return m_hasDefiniteLogicalHeight.value(); 3332 return m_hasDefiniteLogicalHeight.value();
3329 } 3333 }
3330 3334
3331 } // namespace blink 3335 } // 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