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 19 matching lines...) Expand all Loading... |
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 Loading... |
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& contentAlignmentBehavior() |
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(contentAlignmentBehavior()) != ContentDistributionStretch) |
1377 || (direction == ForRows && styleRef().resolvedAlignContentDistribution(
normalValueBehavior()) != ContentDistributionStretch)) | 1378 || (direction == ForRows && styleRef().resolvedAlignContentDistribution(
contentAlignmentBehavior()) != 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 Loading... |
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 Loading... |
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 Loading... |
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().writingMode() == styleRef().writi
ngMode(); | 1799 bool hasSameWritingMode = child.styleRef().writingMode() == styleRef().writi
ngMode(); |
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 Loading... |
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(), ItemPositionStretch
).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<LayoutUnit>& trackPositions, const LayoutUnit& childBreadth) | 1890 static inline LayoutUnit offsetBetweenTracks(ContentDistributionType distributio
n, const Vector<LayoutUnit>& trackPositions, const LayoutUnit& childBreadth) |
1888 { | 1891 { |
1889 return (distribution == ContentDistributionStretch || ContentDistributionStr
etch == ContentDistributionDefault) ? LayoutUnit() : trackPositions[1] - trackPo
sitions[0] - childBreadth; | 1892 return (distribution == ContentDistributionStretch || ContentDistributionStr
etch == ContentDistributionDefault) ? LayoutUnit() : trackPositions[1] - trackPo
sitions[0] - childBreadth; |
(...skipping 15 matching lines...) Expand all Loading... |
1905 case GridAxisEnd: | 1908 case GridAxisEnd: |
1906 case GridAxisCenter: { | 1909 case GridAxisCenter: { |
1907 size_t childEndLine = rowsSpan.resolvedFinalPosition(); | 1910 size_t childEndLine = rowsSpan.resolvedFinalPosition(); |
1908 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 1911 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
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 if (childEndLine < m_rowPositions.size() - 1) | 1914 if (childEndLine < m_rowPositions.size() - 1) |
1912 endOfRow -= guttersSize(ForRows, 2); | 1915 endOfRow -= guttersSize(ForRows, 2); |
1913 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); | 1916 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); |
1914 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) | 1917 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) |
1915 endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistr
ibution(normalValueBehavior()), m_rowPositions, childBreadth); | 1918 endOfRow -= offsetBetweenTracks(styleRef().resolvedAlignContentDistr
ibution(contentAlignmentBehavior()), m_rowPositions, childBreadth); |
1916 OverflowAlignment overflow = child.styleRef().resolvedAlignment(styleRef
(), ItemPositionStretch).overflow(); | 1919 OverflowAlignment overflow = child.styleRef().resolvedAlignSelf(styleRef
(), selfAlignmentNormalBehavior).overflow(); |
1917 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfRow - startOfRow, childBreadth); | 1920 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfRow - startOfRow, childBreadth); |
1918 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1921 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
1919 } | 1922 } |
1920 } | 1923 } |
1921 | 1924 |
1922 ASSERT_NOT_REACHED(); | 1925 ASSERT_NOT_REACHED(); |
1923 return LayoutUnit(); | 1926 return LayoutUnit(); |
1924 } | 1927 } |
1925 | 1928 |
1926 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const | 1929 LayoutUnit LayoutGrid::rowAxisOffsetForChild(const LayoutBox& child) const |
(...skipping 11 matching lines...) Expand all Loading... |
1938 case GridAxisEnd: | 1941 case GridAxisEnd: |
1939 case GridAxisCenter: { | 1942 case GridAxisCenter: { |
1940 size_t childEndLine = columnsSpan.resolvedFinalPosition(); | 1943 size_t childEndLine = columnsSpan.resolvedFinalPosition(); |
1941 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 1944 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
1942 // m_columnPositions include gutters so we need to subtract them to get
the actual end position for a given | 1945 // m_columnPositions include gutters so we need to subtract them to get
the actual end position for a given |
1943 // column (this does not have to be done for the last track as there are
no more m_columnPositions after it) | 1946 // column (this does not have to be done for the last track as there are
no more m_columnPositions after it) |
1944 if (childEndLine < m_columnPositions.size() - 1) | 1947 if (childEndLine < m_columnPositions.size() - 1) |
1945 endOfColumn -= guttersSize(ForRows, 2); | 1948 endOfColumn -= guttersSize(ForRows, 2); |
1946 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); | 1949 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); |
1947 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) | 1950 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) |
1948 endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContent
Distribution(normalValueBehavior()), m_columnPositions, childBreadth); | 1951 endOfColumn -= offsetBetweenTracks(styleRef().resolvedJustifyContent
Distribution(contentAlignmentBehavior()), m_columnPositions, childBreadth); |
1949 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); | 1952 OverflowAlignment overflow = child.styleRef().resolvedJustifySelf(styleR
ef(), selfAlignmentNormalBehavior).overflow(); |
| 1953 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(over
flow, endOfColumn - startOfColumn, childBreadth); |
1950 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1954 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
1951 } | 1955 } |
1952 } | 1956 } |
1953 | 1957 |
1954 ASSERT_NOT_REACHED(); | 1958 ASSERT_NOT_REACHED(); |
1955 return LayoutUnit(); | 1959 return LayoutUnit(); |
1956 } | 1960 } |
1957 | 1961 |
1958 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) | 1962 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) |
1959 { | 1963 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 return {}; | 2005 return {}; |
2002 } | 2006 } |
2003 | 2007 |
2004 ASSERT_NOT_REACHED(); | 2008 ASSERT_NOT_REACHED(); |
2005 return {}; | 2009 return {}; |
2006 } | 2010 } |
2007 | 2011 |
2008 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const | 2012 ContentAlignmentData LayoutGrid::computeContentPositionAndDistributionOffset(Gri
dTrackSizingDirection direction, const LayoutUnit& availableFreeSpace, unsigned
numberOfGridTracks) const |
2009 { | 2013 { |
2010 bool isRowAxis = direction == ForColumns; | 2014 bool isRowAxis = direction == ForColumns; |
2011 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi
tion(normalValueBehavior()) : styleRef().resolvedAlignContentPosition(normalValu
eBehavior()); | 2015 ContentPosition position = isRowAxis ? styleRef().resolvedJustifyContentPosi
tion(contentAlignmentBehavior()) : styleRef().resolvedAlignContentPosition(conte
ntAlignmentBehavior()); |
2012 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif
yContentDistribution(normalValueBehavior()) : styleRef().resolvedAlignContentDis
tribution(normalValueBehavior()); | 2016 ContentDistributionType distribution = isRowAxis ? styleRef().resolvedJustif
yContentDistribution(contentAlignmentBehavior()) : styleRef().resolvedAlignConte
ntDistribution(contentAlignmentBehavior()); |
2013 // If <content-distribution> value can't be applied, 'position' will become
the associated | 2017 // If <content-distribution> value can't be applied, 'position' will become
the associated |
2014 // <content-position> fallback value. | 2018 // <content-position> fallback value. |
2015 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); | 2019 ContentAlignmentData contentAlignment = contentDistributionOffset(availableF
reeSpace, position, distribution, numberOfGridTracks); |
2016 if (contentAlignment.isValid()) | 2020 if (contentAlignment.isValid()) |
2017 return contentAlignment; | 2021 return contentAlignment; |
2018 | 2022 |
2019 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); | 2023 OverflowAlignment overflow = isRowAxis ? styleRef().justifyContentOverflowAl
ignment() : styleRef().alignContentOverflowAlignment(); |
2020 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) | 2024 if (availableFreeSpace <= 0 && overflow == OverflowAlignmentSafe) |
2021 return {LayoutUnit(), LayoutUnit()}; | 2025 return {LayoutUnit(), LayoutUnit()}; |
2022 | 2026 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 | 2073 |
2070 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2074 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
2071 } | 2075 } |
2072 | 2076 |
2073 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2077 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2074 { | 2078 { |
2075 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2079 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2076 } | 2080 } |
2077 | 2081 |
2078 } // namespace blink | 2082 } // namespace blink |
OLD | NEW |