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

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

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied suggested changes. Created 4 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 19 matching lines...) Expand all
30 #include "core/paint/GridPainter.h" 30 #include "core/paint/GridPainter.h"
31 #include "core/paint/PaintLayer.h" 31 #include "core/paint/PaintLayer.h"
32 #include "core/style/ComputedStyle.h" 32 #include "core/style/ComputedStyle.h"
33 #include "core/style/GridArea.h" 33 #include "core/style/GridArea.h"
34 #include "platform/LengthFunctions.h" 34 #include "platform/LengthFunctions.h"
35 #include <algorithm> 35 #include <algorithm>
36 36
37 namespace blink { 37 namespace blink {
38 38
39 static const int infinity = -1; 39 static const int infinity = -1;
40 static const ItemPosition selfAlignmentNormalBehavior = ItemPositionStretch;
40 41
41 class GridItemWithSpan; 42 class GridItemWithSpan;
42 43
43 class GridTrack { 44 class GridTrack {
44 public: 45 public:
45 GridTrack() 46 GridTrack()
46 : m_baseSize(0) 47 : m_baseSize(0)
47 , m_growthLimit(0) 48 , m_growthLimit(0)
48 , m_plannedSize(0) 49 , m_plannedSize(0)
49 , m_sizeDuringDistribution(0) 50 , m_sizeDuringDistribution(0)
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 // the grid and its children are correctly laid out according to the new sty le rules. 1357 // the grid and its children are correctly laid out according to the new sty le rules.
1357 setNeedsLayout(LayoutInvalidationReason::GridChanged); 1358 setNeedsLayout(LayoutInvalidationReason::GridChanged);
1358 1359
1359 m_grid.resize(0); 1360 m_grid.resize(0);
1360 m_gridItemArea.clear(); 1361 m_gridItemArea.clear();
1361 m_gridItemsOverflowingGridArea.resize(0); 1362 m_gridItemsOverflowingGridArea.resize(0);
1362 m_gridItemsIndexesMap.clear(); 1363 m_gridItemsIndexesMap.clear();
1363 m_gridIsDirty = true; 1364 m_gridIsDirty = true;
1364 } 1365 }
1365 1366
1366 static const StyleContentAlignmentData& normalValueBehavior() 1367 static const StyleContentAlignmentData& contentAlignmentNormalBehavior()
1367 { 1368 {
1368 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm al, ContentDistributionStretch}; 1369 static const StyleContentAlignmentData normalBehavior = {ContentPositionNorm al, ContentDistributionStretch};
1369 return normalBehavior; 1370 return normalBehavior;
1370 } 1371 }
1371 1372
1372 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection direction, GridSizingData& sizingData) 1373 void LayoutGrid::applyStretchAlignmentToTracksIfNeeded(GridTrackSizingDirection direction, GridSizingData& sizingData)
1373 { 1374 {
1374 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction); 1375 LayoutUnit& availableSpace = sizingData.freeSpaceForDirection(direction);
1375 if (availableSpace <= 0 1376 if (availableSpace <= 0
1376 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu tion(normalValueBehavior()) != ContentDistributionStretch) 1377 || (direction == ForColumns && styleRef().resolvedJustifyContentDistribu tion(contentAlignmentNormalBehavior()) != ContentDistributionStretch)
1377 || (direction == ForRows && styleRef().resolvedAlignContentDistribution( normalValueBehavior()) != ContentDistributionStretch)) 1378 || (direction == ForRows && styleRef().resolvedAlignContentDistribution( contentAlignmentNormalBehavior()) != ContentDistributionStretch))
1378 return; 1379 return;
1379 1380
1380 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func tion. 1381 // Spec defines auto-sized tracks as the ones with an 'auto' max-sizing func tion.
1381 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 1382 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
1382 Vector<unsigned> autoSizedTracksIndex; 1383 Vector<unsigned> autoSizedTracksIndex;
1383 for (unsigned i = 0; i < tracks.size(); ++i) { 1384 for (unsigned i = 0; i < tracks.size(); ++i) {
1384 const GridTrackSize& trackSize = gridTrackSize(direction, i); 1385 const GridTrackSize& trackSize = gridTrackSize(direction, i);
1385 if (trackSize.hasAutoMaxTrackBreadth()) 1386 if (trackSize.hasAutoMaxTrackBreadth())
1386 autoSizedTracksIndex.append(i); 1387 autoSizedTracksIndex.append(i);
1387 } 1388 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 1645
1645 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay outBox& child) 1646 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay outBox& child)
1646 { 1647 {
1647 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight(); 1648 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight();
1648 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); 1649 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight);
1649 } 1650 }
1650 1651
1651 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1652 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1652 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const 1653 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const
1653 { 1654 {
1654 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch) 1655 if (child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBehavi or).position() != ItemPositionStretch)
1655 return false; 1656 return false;
1656 1657
1657 return isHorizontalWritingMode() && child.style()->height().isAuto(); 1658 return isHorizontalWritingMode() && child.style()->height().isAuto();
1658 } 1659 }
1659 1660
1660 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1661 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1661 LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const 1662 LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const
1662 { 1663 {
1663 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child )) 1664 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child ))
1664 return constrainedChildIntrinsicContentLogicalHeight(child); 1665 return constrainedChildIntrinsicContentLogicalHeight(child);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) 1712 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child)
1712 { 1713 {
1713 // We clear height override values because we will decide now whether it's a llowed or 1714 // We clear height override values because we will decide now whether it's a llowed or
1714 // not, evaluating the conditions which might have changed since the old val ues were set. 1715 // not, evaluating the conditions which might have changed since the old val ues were set.
1715 child.clearOverrideLogicalContentHeight(); 1716 child.clearOverrideLogicalContentHeight();
1716 1717
1717 auto& childStyle = child.styleRef(); 1718 auto& childStyle = child.styleRef();
1718 bool isHorizontalMode = isHorizontalWritingMode(); 1719 bool isHorizontalMode = isHorizontalWritingMode();
1719 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto () : childStyle.width().isAuto(); 1720 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto () : childStyle.width().isAuto();
1720 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style ()).isAuto(); 1721 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style ()).isAuto();
1721 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment( styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { 1722 if (allowedToStretchChildAlongColumnAxis && childStyle.resolvedAlignSelf(sty leRef(), selfAlignmentNormalBehavior).position() == ItemPositionStretch) {
1722 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it. 1723 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it.
1723 // TODO (lajava): grid track sizing and positioning do not support ortho gonal modes yet. 1724 // TODO (lajava): grid track sizing and positioning do not support ortho gonal modes yet.
1724 if (child.isHorizontalWritingMode() == isHorizontalMode) { 1725 if (child.isHorizontalWritingMode() == isHorizontalMode) {
1725 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); 1726 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child);
1726 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, LayoutUnit(-1)); 1727 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, LayoutUnit(-1));
1727 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight()); 1728 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight());
1728 if (desiredLogicalHeight != child.logicalHeight()) { 1729 if (desiredLogicalHeight != child.logicalHeight()) {
1729 // TODO (lajava): Can avoid laying out here in some cases. See h ttps://webkit.org/b/87905. 1730 // TODO (lajava): Can avoid laying out here in some cases. See h ttps://webkit.org/b/87905.
1730 child.setLogicalHeight(LayoutUnit()); 1731 child.setLogicalHeight(LayoutUnit());
1731 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); 1732 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } else if (marginAfter.isAuto()) { 1791 } else if (marginAfter.isAuto()) {
1791 child.setMarginAfter(availableAlignmentSpace, style()); 1792 child.setMarginAfter(availableAlignmentSpace, style());
1792 } 1793 }
1793 } 1794 }
1794 1795
1795 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const 1796 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child) const
1796 { 1797 {
1797 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1798 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1798 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode(); 1799 bool hasSameWritingMode = child.styleRef().getWritingMode() == styleRef().ge tWritingMode();
1799 1800
1800 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { 1801 switch (child.styleRef().resolvedAlignSelf(styleRef(), selfAlignmentNormalBe havior).position()) {
1801 case ItemPositionSelfStart: 1802 case ItemPositionSelfStart:
1802 // If orthogonal writing-modes, this computes to 'start'. 1803 // If orthogonal writing-modes, this computes to 'start'.
1803 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1804 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1804 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow. 1805 // self-start is based on the child's block axis direction. That's why w e need to check against the grid container's block flow.
1805 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisStart : GridAxisEnd; 1806 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisStart : GridAxisEnd;
1806 case ItemPositionSelfEnd: 1807 case ItemPositionSelfEnd:
1807 // If orthogonal writing-modes, this computes to 'end'. 1808 // If orthogonal writing-modes, this computes to 'end'.
1808 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1809 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1809 // self-end is based on the child's block axis direction. That's why we need to check against the grid container's block flow. 1810 // self-end is based on the child's block axis direction. That's why we need to check against the grid container's block flow.
1810 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisEnd : GridAxisStart; 1811 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisEnd : GridAxisStart;
(...skipping 16 matching lines...) Expand all
1827 case ItemPositionEnd: 1828 case ItemPositionEnd:
1828 return GridAxisEnd; 1829 return GridAxisEnd;
1829 case ItemPositionStretch: 1830 case ItemPositionStretch:
1830 return GridAxisStart; 1831 return GridAxisStart;
1831 case ItemPositionBaseline: 1832 case ItemPositionBaseline:
1832 case ItemPositionLastBaseline: 1833 case ItemPositionLastBaseline:
1833 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. 1834 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child.
1834 // crbug.com/234191 1835 // crbug.com/234191
1835 return GridAxisStart; 1836 return GridAxisStart;
1836 case ItemPositionAuto: 1837 case ItemPositionAuto:
1838 case ItemPositionNormal:
1837 break; 1839 break;
1838 } 1840 }
1839 1841
1840 ASSERT_NOT_REACHED(); 1842 ASSERT_NOT_REACHED();
1841 return GridAxisStart; 1843 return GridAxisStart;
1842 } 1844 }
1843 1845
1844 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st 1846 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con st
1845 { 1847 {
1846 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1848 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1847 bool hasSameDirection = child.styleRef().direction() == styleRef().direction (); 1849 bool hasSameDirection = child.styleRef().direction() == styleRef().direction ();
1848 bool isLTR = styleRef().isLeftToRightDirection(); 1850 bool isLTR = styleRef().isLeftToRightDirection();
1849 1851
1850 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It emPositionStretch)) { 1852 switch (child.styleRef().resolvedJustifySelf(styleRef(), selfAlignmentNormal Behavior).position()) {
1851 case ItemPositionSelfStart: 1853 case ItemPositionSelfStart:
1852 // For orthogonal writing-modes, this computes to 'start' 1854 // For orthogonal writing-modes, this computes to 'start'
1853 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1855 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1854 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction. 1856 // self-start is based on the child's direction. That's why we need to c heck against the grid container's direction.
1855 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisStart : GridAxisEnd; 1857 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisStart : GridAxisEnd;
1856 case ItemPositionSelfEnd: 1858 case ItemPositionSelfEnd:
1857 // For orthogonal writing-modes, this computes to 'start' 1859 // For orthogonal writing-modes, this computes to 'start'
1858 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1860 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet.
1859 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisEnd : Gr idAxisStart; 1861 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisEnd : Gr idAxisStart;
1860 case ItemPositionLeft: 1862 case ItemPositionLeft:
1861 return isLTR ? GridAxisStart : GridAxisEnd; 1863 return isLTR ? GridAxisStart : GridAxisEnd;
1862 case ItemPositionRight: 1864 case ItemPositionRight:
1863 return isLTR ? GridAxisEnd : GridAxisStart; 1865 return isLTR ? GridAxisEnd : GridAxisStart;
1864 case ItemPositionCenter: 1866 case ItemPositionCenter:
1865 return GridAxisCenter; 1867 return GridAxisCenter;
1866 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'. 1868 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen t to 'start'.
1867 case ItemPositionStart: 1869 case ItemPositionStart:
1868 return GridAxisStart; 1870 return GridAxisStart;
1869 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'. 1871 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent to 'end'.
1870 case ItemPositionEnd: 1872 case ItemPositionEnd:
1871 return GridAxisEnd; 1873 return GridAxisEnd;
1872 case ItemPositionStretch: 1874 case ItemPositionStretch:
1873 return GridAxisStart; 1875 return GridAxisStart;
1874 case ItemPositionBaseline: 1876 case ItemPositionBaseline:
1875 case ItemPositionLastBaseline: 1877 case ItemPositionLastBaseline:
1876 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child. 1878 // FIXME: These two require implementing Baseline Alignment. For now, we always 'start' align the child.
1877 // crbug.com/234191 1879 // crbug.com/234191
1878 return GridAxisStart; 1880 return GridAxisStart;
1879 case ItemPositionAuto: 1881 case ItemPositionAuto:
1882 case ItemPositionNormal:
1880 break; 1883 break;
1881 } 1884 }
1882 1885
1883 ASSERT_NOT_REACHED(); 1886 ASSERT_NOT_REACHED();
1884 return GridAxisStart; 1887 return GridAxisStart;
1885 } 1888 }
1886 1889
1887 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distributio n, const Vector<GridTrack>& trackSizes, const Vector<LayoutUnit>& trackPositions , LayoutUnit trackGap) 1890 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distributio n, const Vector<GridTrack>& trackSizes, const Vector<LayoutUnit>& trackPositions , LayoutUnit trackGap)
1888 { 1891 {
1889 // FIXME: Perhaps a good idea to cache the result of this operation, since t he ContentDistribution offset between tracks is always the same, 1892 // FIXME: Perhaps a good idea to cache the result of this operation, since t he ContentDistribution offset between tracks is always the same,
(...skipping 19 matching lines...) Expand all
1909 // m_rowPositions include gutters so we need to subtract them to get the actual end position for a given 1912 // m_rowPositions include gutters so we need to subtract them to get the actual end position for a given
1910 // row (this does not have to be done for the last track as there are no more m_rowPositions after it) 1913 // row (this does not have to be done for the last track as there are no more m_rowPositions after it)
1911 LayoutUnit trackGap = guttersSize(ForRows, 2); 1914 LayoutUnit trackGap = guttersSize(ForRows, 2);
1912 if (childEndLine < m_rowPositions.size() - 1) 1915 if (childEndLine < m_rowPositions.size() - 1)
1913 endOfRow -= trackGap; 1916 endOfRow -= trackGap;
1914 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); 1917 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght();
1915 // The track's start and end lines may be not adjacent because of conten t alignment, so we assume the stored 1918 // The track's start and end lines may be not adjacent because of conten t alignment, so we assume the stored
1916 // lines are all start plus a content-alignment distribution offset. 1919 // lines are all start plus a content-alignment distribution offset.
1917 // We must subtract last line's offset because is not part of the track the items belongs to. 1920 // We must subtract last line's offset because is not part of the track the items belongs to.
1918 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s ize() - 1) 1921 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s ize() - 1)
1919 endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistr ibution(normalValueBehavior()), sizingData.rowTracks, m_rowPositions, trackGap); 1922 endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistr ibution(contentAlignmentNormalBehavior()), sizingData.rowTracks, m_rowPositions, trackGap);
1920 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef (), ItemPositionStretch).overflow(); 1923 OverflowAlignment overflow = child.styleRef().resolvedAlignSelf(styleRef (), selfAlignmentNormalBehavior).overflow();
1921 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth); 1924 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfRow - startOfRow, childBreadth);
1922 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); 1925 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2);
1923 } 1926 }
1924 } 1927 }
1925 1928
1926 ASSERT_NOT_REACHED(); 1929 ASSERT_NOT_REACHED();
1927 return LayoutUnit(); 1930 return LayoutUnit();
1928 } 1931 }
1929 1932
1930 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const 1933 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child, GridSizingD ata& sizingData) const
(...skipping 15 matching lines...) Expand all
1946 // m_columnPositions include gutters so we need to subtract them to get the actual end position for a given 1949 // m_columnPositions include gutters so we need to subtract them to get the actual end position for a given
1947 // column (this does not have to be done for the last track as there are no more m_columnPositions after it) 1950 // column (this does not have to be done for the last track as there are no more m_columnPositions after it)
1948 LayoutUnit trackGap = guttersSize(ForColumns, 2); 1951 LayoutUnit trackGap = guttersSize(ForColumns, 2);
1949 if (childEndLine < m_columnPositions.size() - 1) 1952 if (childEndLine < m_columnPositions.size() - 1)
1950 endOfColumn -= trackGap; 1953 endOfColumn -= trackGap;
1951 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); 1954 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h();
1952 // The track's start and end lines may be not adjacent because of conten t alignment, so we assume the stored 1955 // The track's start and end lines may be not adjacent because of conten t alignment, so we assume the stored
1953 // lines are all start plus a content-alignment distribution offset. 1956 // lines are all start plus a content-alignment distribution offset.
1954 // We must subtract last line's offset because is not part of the track the items belongs to. 1957 // We must subtract last line's offset because is not part of the track the items belongs to.
1955 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition s.size() - 1) 1958 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition s.size() - 1)
1956 endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContent Distribution(normalValueBehavior()), sizingData.columnTracks, m_columnPositions, trackGap); 1959 endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContent Distribution(contentAlignmentNormalBehavior()), sizingData.columnTracks, m_colum nPositions, trackGap);
1957 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); 1960 OverflowAlignment overflow = child.styleRef().resolvedJustifySelf(styleR ef(), selfAlignmentNormalBehavior).overflow();
1961 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over flow, endOfColumn - startOfColumn, childBreadth);
1958 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); 1962 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2);
1959 } 1963 }
1960 } 1964 }
1961 1965
1962 ASSERT_NOT_REACHED(); 1966 ASSERT_NOT_REACHED();
1963 return LayoutUnit(); 1967 return LayoutUnit();
1964 } 1968 }
1965 1969
1966 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution) 1970 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp e distribution)
1967 { 1971 {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2009 return {}; 2013 return {};
2010 } 2014 }
2011 2015
2012 ASSERT_NOT_REACHED(); 2016 ASSERT_NOT_REACHED();
2013 return {}; 2017 return {};
2014 } 2018 }
2015 2019
2016 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const 2020 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned numberOfGridTracks) const
2017 { 2021 {
2018 bool isRowAxis = direction == ForColumns; 2022 bool isRowAxis = direction == ForColumns;
2019 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi tion(normalValueBehavior()) : styleRef().resolvedAlignContentPosition(normalValu eBehavior()); 2023 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi tion(contentAlignmentNormalBehavior()) : styleRef().resolvedAlignContentPosition (contentAlignmentNormalBehavior());
2020 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif yContentDistribution(normalValueBehavior()) : styleRef().resolvedAlignContentDis tribution(normalValueBehavior()); 2024 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif yContentDistribution(contentAlignmentNormalBehavior()) : styleRef().resolvedAlig nContentDistribution(contentAlignmentNormalBehavior());
2021 // If <content-distribution> value can't be applied, 'position' will become the associated 2025 // If <content-distribution> value can't be applied, 'position' will become the associated
2022 // <content-position> fallback value. 2026 // <content-position> fallback value.
2023 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF reeSpace, position, distribution, numberOfGridTracks); 2027 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF reeSpace, position, distribution, numberOfGridTracks);
2024 if (contentAlignment.isValid()) 2028 if (contentAlignment.isValid())
2025 return contentAlignment; 2029 return contentAlignment;
2026 2030
2027 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl ignment() : styleRef().alignContentOverflowAlignment(); 2031 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl ignment() : styleRef().alignContentOverflowAlignment();
2028 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) 2032 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe)
2029 return {LayoutUnit(), LayoutUnit()}; 2033 return {LayoutUnit(), LayoutUnit()};
2030 2034
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 2081
2078 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2082 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2079 } 2083 }
2080 2084
2081 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2085 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2082 { 2086 {
2083 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2087 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2084 } 2088 }
2085 2089
2086 } // namespace blink 2090 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698