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

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

Issue 2758683002: Replace ASSERT_NOT_REACHED with NOTREACHED in core/layout/ (Closed)
Patch Set: Rebase with latest Created 3 years, 9 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
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 LayoutUnit fillAvailableExtent = 431 LayoutUnit fillAvailableExtent =
432 containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadding); 432 containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadding);
433 return std::min<LayoutUnit>( 433 return std::min<LayoutUnit>(
434 m_maxContentHeight, std::max(m_minContentHeight, fillAvailableExtent)); 434 m_maxContentHeight, std::max(m_minContentHeight, fillAvailableExtent));
435 } 435 }
436 436
437 if (logicalHeightLength.isFillAvailable()) 437 if (logicalHeightLength.isFillAvailable())
438 return containingBlock()->availableLogicalHeight( 438 return containingBlock()->availableLogicalHeight(
439 ExcludeMarginBorderPadding) - 439 ExcludeMarginBorderPadding) -
440 borderAndPadding; 440 borderAndPadding;
441 ASSERT_NOT_REACHED(); 441 NOTREACHED();
442 return LayoutUnit(); 442 return LayoutUnit();
443 } 443 }
444 444
445 static LayoutUnit overrideContainingBlockContentSizeForChild( 445 static LayoutUnit overrideContainingBlockContentSizeForChild(
446 const LayoutBox& child, 446 const LayoutBox& child,
447 GridTrackSizingDirection direction) { 447 GridTrackSizingDirection direction) {
448 return direction == ForColumns 448 return direction == ForColumns
449 ? child.overrideContainingBlockContentLogicalWidth() 449 ? child.overrideContainingBlockContentLogicalWidth()
450 : child.overrideContainingBlockContentLogicalHeight(); 450 : child.overrideContainingBlockContentLogicalHeight();
451 } 451 }
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // unreachable). 1370 // unreachable).
1371 return offset.clampNegativeToZero(); 1371 return offset.clampNegativeToZero();
1372 case OverflowAlignmentUnsafe: 1372 case OverflowAlignmentUnsafe:
1373 case OverflowAlignmentDefault: 1373 case OverflowAlignmentDefault:
1374 // If we overflow our alignment container and overflow is 'true' 1374 // If we overflow our alignment container and overflow is 'true'
1375 // (default), we ignore the overflow and just return the value regardless 1375 // (default), we ignore the overflow and just return the value regardless
1376 // (which may cause data loss as we overflow the 'start' edge). 1376 // (which may cause data loss as we overflow the 'start' edge).
1377 return offset; 1377 return offset;
1378 } 1378 }
1379 1379
1380 ASSERT_NOT_REACHED(); 1380 NOTREACHED();
1381 return LayoutUnit(); 1381 return LayoutUnit();
1382 } 1382 }
1383 1383
1384 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to 1384 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to
1385 // LayoutBox. 1385 // LayoutBox.
1386 LayoutUnit LayoutGrid::marginLogicalHeightForChild( 1386 LayoutUnit LayoutGrid::marginLogicalHeightForChild(
1387 const LayoutBox& child) const { 1387 const LayoutBox& child) const {
1388 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(); 1388 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth();
1389 } 1389 }
1390 1390
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 case ItemPositionBaseline: 1733 case ItemPositionBaseline:
1734 case ItemPositionLastBaseline: 1734 case ItemPositionLastBaseline:
1735 // FIXME: These two require implementing Baseline Alignment. For now, we 1735 // FIXME: These two require implementing Baseline Alignment. For now, we
1736 // always 'start' align the child. crbug.com/234191 1736 // always 'start' align the child. crbug.com/234191
1737 return GridAxisStart; 1737 return GridAxisStart;
1738 case ItemPositionAuto: 1738 case ItemPositionAuto:
1739 case ItemPositionNormal: 1739 case ItemPositionNormal:
1740 break; 1740 break;
1741 } 1741 }
1742 1742
1743 ASSERT_NOT_REACHED(); 1743 NOTREACHED();
1744 return GridAxisStart; 1744 return GridAxisStart;
1745 } 1745 }
1746 1746
1747 GridAxisPosition LayoutGrid::rowAxisPositionForChild( 1747 GridAxisPosition LayoutGrid::rowAxisPositionForChild(
1748 const LayoutBox& child) const { 1748 const LayoutBox& child) const {
1749 bool hasSameDirection = 1749 bool hasSameDirection =
1750 child.styleRef().direction() == styleRef().direction(); 1750 child.styleRef().direction() == styleRef().direction();
1751 bool gridIsLTR = styleRef().isLeftToRightDirection(); 1751 bool gridIsLTR = styleRef().isLeftToRightDirection();
1752 1752
1753 switch (justifySelfForChild(child).position()) { 1753 switch (justifySelfForChild(child).position()) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 case ItemPositionBaseline: 1812 case ItemPositionBaseline:
1813 case ItemPositionLastBaseline: 1813 case ItemPositionLastBaseline:
1814 // FIXME: These two require implementing Baseline Alignment. For now, we 1814 // FIXME: These two require implementing Baseline Alignment. For now, we
1815 // always 'start' align the child. crbug.com/234191 1815 // always 'start' align the child. crbug.com/234191
1816 return GridAxisStart; 1816 return GridAxisStart;
1817 case ItemPositionAuto: 1817 case ItemPositionAuto:
1818 case ItemPositionNormal: 1818 case ItemPositionNormal:
1819 break; 1819 break;
1820 } 1820 }
1821 1821
1822 ASSERT_NOT_REACHED(); 1822 NOTREACHED();
1823 return GridAxisStart; 1823 return GridAxisStart;
1824 } 1824 }
1825 1825
1826 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const { 1826 LayoutUnit LayoutGrid::columnAxisOffsetForChild(const LayoutBox& child) const {
1827 const GridSpan& rowsSpan = 1827 const GridSpan& rowsSpan =
1828 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForRows); 1828 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForRows);
1829 size_t childStartLine = rowsSpan.startLine(); 1829 size_t childStartLine = rowsSpan.startLine();
1830 LayoutUnit startOfRow = m_rowPositions[childStartLine]; 1830 LayoutUnit startOfRow = m_rowPositions[childStartLine];
1831 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); 1831 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child);
1832 if (hasAutoMarginsInColumnAxis(child)) 1832 if (hasAutoMarginsInColumnAxis(child))
(...skipping 21 matching lines...) Expand all
1854 : child.logicalHeight() + child.marginLogicalHeight(); 1854 : child.logicalHeight() + child.marginLogicalHeight();
1855 OverflowAlignment overflow = alignSelfForChild(child).overflow(); 1855 OverflowAlignment overflow = alignSelfForChild(child).overflow();
1856 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( 1856 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(
1857 overflow, endOfRow - startOfRow, columnAxisChildSize); 1857 overflow, endOfRow - startOfRow, columnAxisChildSize);
1858 return startPosition + (axisPosition == GridAxisEnd 1858 return startPosition + (axisPosition == GridAxisEnd
1859 ? offsetFromStartPosition 1859 ? offsetFromStartPosition
1860 : offsetFromStartPosition / 2); 1860 : offsetFromStartPosition / 2);
1861 } 1861 }
1862 } 1862 }
1863 1863
1864 ASSERT_NOT_REACHED(); 1864 NOTREACHED();
1865 return LayoutUnit(); 1865 return LayoutUnit();
1866 } 1866 }
1867 1867
1868 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const { 1868 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const {
1869 const GridSpan& columnsSpan = 1869 const GridSpan& columnsSpan =
1870 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForColumns); 1870 m_trackSizingAlgorithm.grid().gridItemSpan(child, ForColumns);
1871 size_t childStartLine = columnsSpan.startLine(); 1871 size_t childStartLine = columnsSpan.startLine();
1872 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; 1872 LayoutUnit startOfColumn = m_columnPositions[childStartLine];
1873 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); 1873 LayoutUnit startPosition = startOfColumn + marginStartForChild(child);
1874 if (hasAutoMarginsInRowAxis(child)) 1874 if (hasAutoMarginsInRowAxis(child))
(...skipping 21 matching lines...) Expand all
1896 : child.logicalWidth() + child.marginLogicalWidth(); 1896 : child.logicalWidth() + child.marginLogicalWidth();
1897 OverflowAlignment overflow = justifySelfForChild(child).overflow(); 1897 OverflowAlignment overflow = justifySelfForChild(child).overflow();
1898 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset( 1898 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(
1899 overflow, endOfColumn - startOfColumn, rowAxisChildSize); 1899 overflow, endOfColumn - startOfColumn, rowAxisChildSize);
1900 return startPosition + (axisPosition == GridAxisEnd 1900 return startPosition + (axisPosition == GridAxisEnd
1901 ? offsetFromStartPosition 1901 ? offsetFromStartPosition
1902 : offsetFromStartPosition / 2); 1902 : offsetFromStartPosition / 2);
1903 } 1903 }
1904 } 1904 }
1905 1905
1906 ASSERT_NOT_REACHED(); 1906 NOTREACHED();
1907 return LayoutUnit(); 1907 return LayoutUnit();
1908 } 1908 }
1909 1909
1910 ContentPosition static resolveContentDistributionFallback( 1910 ContentPosition static resolveContentDistributionFallback(
1911 ContentDistributionType distribution) { 1911 ContentDistributionType distribution) {
1912 switch (distribution) { 1912 switch (distribution) {
1913 case ContentDistributionSpaceBetween: 1913 case ContentDistributionSpaceBetween:
1914 return ContentPositionStart; 1914 return ContentPositionStart;
1915 case ContentDistributionSpaceAround: 1915 case ContentDistributionSpaceAround:
1916 return ContentPositionCenter; 1916 return ContentPositionCenter;
1917 case ContentDistributionSpaceEvenly: 1917 case ContentDistributionSpaceEvenly:
1918 return ContentPositionCenter; 1918 return ContentPositionCenter;
1919 case ContentDistributionStretch: 1919 case ContentDistributionStretch:
1920 return ContentPositionStart; 1920 return ContentPositionStart;
1921 case ContentDistributionDefault: 1921 case ContentDistributionDefault:
1922 return ContentPositionNormal; 1922 return ContentPositionNormal;
1923 } 1923 }
1924 1924
1925 ASSERT_NOT_REACHED(); 1925 NOTREACHED();
1926 return ContentPositionNormal; 1926 return ContentPositionNormal;
1927 } 1927 }
1928 1928
1929 static ContentAlignmentData contentDistributionOffset( 1929 static ContentAlignmentData contentDistributionOffset(
1930 const LayoutUnit& availableFreeSpace, 1930 const LayoutUnit& availableFreeSpace,
1931 ContentPosition& fallbackPosition, 1931 ContentPosition& fallbackPosition,
1932 ContentDistributionType distribution, 1932 ContentDistributionType distribution,
1933 unsigned numberOfGridTracks) { 1933 unsigned numberOfGridTracks) {
1934 if (distribution != ContentDistributionDefault && 1934 if (distribution != ContentDistributionDefault &&
1935 fallbackPosition == ContentPositionNormal) 1935 fallbackPosition == ContentPositionNormal)
(...skipping 14 matching lines...) Expand all
1950 distributionOffset = availableFreeSpace / numberOfGridTracks; 1950 distributionOffset = availableFreeSpace / numberOfGridTracks;
1951 return {distributionOffset / 2, distributionOffset}; 1951 return {distributionOffset / 2, distributionOffset};
1952 case ContentDistributionSpaceEvenly: 1952 case ContentDistributionSpaceEvenly:
1953 distributionOffset = availableFreeSpace / (numberOfGridTracks + 1); 1953 distributionOffset = availableFreeSpace / (numberOfGridTracks + 1);
1954 return {distributionOffset, distributionOffset}; 1954 return {distributionOffset, distributionOffset};
1955 case ContentDistributionStretch: 1955 case ContentDistributionStretch:
1956 case ContentDistributionDefault: 1956 case ContentDistributionDefault:
1957 return {}; 1957 return {};
1958 } 1958 }
1959 1959
1960 ASSERT_NOT_REACHED(); 1960 NOTREACHED();
1961 return {}; 1961 return {};
1962 } 1962 }
1963 1963
1964 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset( 1964 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(
1965 GridTrackSizingDirection direction, 1965 GridTrackSizingDirection direction,
1966 const LayoutUnit& availableFreeSpace, 1966 const LayoutUnit& availableFreeSpace,
1967 unsigned numberOfGridTracks) const { 1967 unsigned numberOfGridTracks) const {
1968 bool isRowAxis = direction == ForColumns; 1968 bool isRowAxis = direction == ForColumns;
1969 ContentPosition position = isRowAxis 1969 ContentPosition position = isRowAxis
1970 ? styleRef().resolvedJustifyContentPosition( 1970 ? styleRef().resolvedJustifyContentPosition(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 // always 'start' align the child. crbug.com/234191 2026 // always 'start' align the child. crbug.com/234191
2027 if (isRowAxis) 2027 if (isRowAxis)
2028 return {styleRef().isLeftToRightDirection() ? LayoutUnit() 2028 return {styleRef().isLeftToRightDirection() ? LayoutUnit()
2029 : availableFreeSpace, 2029 : availableFreeSpace,
2030 LayoutUnit()}; 2030 LayoutUnit()};
2031 return {LayoutUnit(), LayoutUnit()}; 2031 return {LayoutUnit(), LayoutUnit()};
2032 case ContentPositionNormal: 2032 case ContentPositionNormal:
2033 break; 2033 break;
2034 } 2034 }
2035 2035
2036 ASSERT_NOT_REACHED(); 2036 NOTREACHED();
2037 return {LayoutUnit(), LayoutUnit()}; 2037 return {LayoutUnit(), LayoutUnit()};
2038 } 2038 }
2039 2039
2040 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const { 2040 LayoutUnit LayoutGrid::translateRTLCoordinate(LayoutUnit coordinate) const {
2041 ASSERT(!styleRef().isLeftToRightDirection()); 2041 ASSERT(!styleRef().isLeftToRightDirection());
2042 2042
2043 LayoutUnit alignmentOffset = m_columnPositions[0]; 2043 LayoutUnit alignmentOffset = m_columnPositions[0];
2044 LayoutUnit rightGridEdgePosition = 2044 LayoutUnit rightGridEdgePosition =
2045 m_columnPositions[m_columnPositions.size() - 1]; 2045 m_columnPositions[m_columnPositions.size() - 1];
2046 return rightGridEdgePosition + alignmentOffset - coordinate; 2046 return rightGridEdgePosition + alignmentOffset - coordinate;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 if (direction == ForRows) 2103 if (direction == ForRows)
2104 return grid.numTracks(ForRows); 2104 return grid.numTracks(ForRows);
2105 2105
2106 return grid.numTracks(ForRows) 2106 return grid.numTracks(ForRows)
2107 ? grid.numTracks(ForColumns) 2107 ? grid.numTracks(ForColumns)
2108 : GridPositionsResolver::explicitGridColumnCount( 2108 : GridPositionsResolver::explicitGridColumnCount(
2109 styleRef(), grid.autoRepeatTracks(ForColumns)); 2109 styleRef(), grid.autoRepeatTracks(ForColumns));
2110 } 2110 }
2111 2111
2112 } // namespace blink 2112 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutDetailsMarker.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutInline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698