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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 ASSERT(!m_grid.isEmpty()); | 202 ASSERT(!m_grid.isEmpty()); |
203 ASSERT(fixedTrackSpan >= 1 && varyingTrackSpan >= 1); | 203 ASSERT(fixedTrackSpan >= 1 && varyingTrackSpan >= 1); |
204 | 204 |
205 size_t rowSpan = (m_direction == ForColumns) ? varyingTrackSpan : fixedT
rackSpan; | 205 size_t rowSpan = (m_direction == ForColumns) ? varyingTrackSpan : fixedT
rackSpan; |
206 size_t columnSpan = (m_direction == ForColumns) ? fixedTrackSpan : varyi
ngTrackSpan; | 206 size_t columnSpan = (m_direction == ForColumns) ? fixedTrackSpan : varyi
ngTrackSpan; |
207 | 207 |
208 size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m
_columnIndex; | 208 size_t& varyingTrackIndex = (m_direction == ForColumns) ? m_rowIndex : m
_columnIndex; |
209 const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_gr
id.size() : m_grid[0].size(); | 209 const size_t endOfVaryingTrackIndex = (m_direction == ForColumns) ? m_gr
id.size() : m_grid[0].size(); |
210 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex)
{ | 210 for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex)
{ |
211 if (checkEmptyCells(rowSpan, columnSpan)) { | 211 if (checkEmptyCells(rowSpan, columnSpan)) { |
212 OwnPtr<GridCoordinate> result = adoptPtr(new GridCoordinate(Grid
Span(m_rowIndex, m_rowIndex + rowSpan - 1), GridSpan(m_columnIndex, m_columnInde
x + columnSpan - 1))); | 212 OwnPtr<GridCoordinate> result = adoptPtr(new GridCoordinate(Grid
Span(m_rowIndex, m_rowIndex + rowSpan), GridSpan(m_columnIndex, m_columnIndex +
columnSpan))); |
213 // Advance the iterator to avoid an infinite loop where we would
return the same grid area over and over. | 213 // Advance the iterator to avoid an infinite loop where we would
return the same grid area over and over. |
214 ++varyingTrackIndex; | 214 ++varyingTrackIndex; |
215 return result.release(); | 215 return result.release(); |
216 } | 216 } |
217 } | 217 } |
218 return nullptr; | 218 return nullptr; |
219 } | 219 } |
220 | 220 |
221 private: | 221 private: |
222 const GridRepresentation& m_grid; | 222 const GridRepresentation& m_grid; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 for (auto& track : tracks) | 532 for (auto& track : tracks) |
533 track.setBaseSize(track.growthLimit()); | 533 track.setBaseSize(track.growthLimit()); |
534 } | 534 } |
535 | 535 |
536 if (flexibleSizedTracksIndex.isEmpty()) | 536 if (flexibleSizedTracksIndex.isEmpty()) |
537 return; | 537 return; |
538 | 538 |
539 // 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction. | 539 // 4. Grow all Grid tracks having a fraction as the MaxTrackSizingFunction. |
540 double flexFraction = 0; | 540 double flexFraction = 0; |
541 if (hasDefiniteFreeSpace) { | 541 if (hasDefiniteFreeSpace) { |
542 flexFraction = findFlexFactorUnitSize(tracks, GridSpan(0, tracks.size()
- 1), direction, initialFreeSpace); | 542 flexFraction = findFlexFactorUnitSize(tracks, GridSpan(0, tracks.size())
, direction, initialFreeSpace); |
543 } else { | 543 } else { |
544 for (const auto& trackIndex : flexibleSizedTracksIndex) | 544 for (const auto& trackIndex : flexibleSizedTracksIndex) |
545 flexFraction = std::max(flexFraction, normalizedFlexFraction(tracks[
trackIndex], gridTrackSize(direction, trackIndex).maxTrackBreadth().flex())); | 545 flexFraction = std::max(flexFraction, normalizedFlexFraction(tracks[
trackIndex], gridTrackSize(direction, trackIndex).maxTrackBreadth().flex())); |
546 | 546 |
547 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { | 547 for (size_t i = 0; i < flexibleSizedTracksIndex.size(); ++i) { |
548 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); | 548 GridIterator iterator(m_grid, direction, flexibleSizedTracksIndex[i]
); |
549 while (LayoutBox* gridItem = iterator.nextGridItem()) { | 549 while (LayoutBox* gridItem = iterator.nextGridItem()) { |
550 const GridSpan span = cachedGridSpan(*gridItem, direction); | 550 const GridSpan span = cachedGridSpan(*gridItem, direction); |
551 | 551 |
552 // Do not include already processed items. | 552 // Do not include already processed items. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 780 |
781 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ
erSpan() < other.m_gridSpan.integerSpan(); } | 781 bool operator<(const GridItemWithSpan other) const { return m_gridSpan.integ
erSpan() < other.m_gridSpan.integerSpan(); } |
782 | 782 |
783 private: | 783 private: |
784 LayoutBox* m_gridItem; | 784 LayoutBox* m_gridItem; |
785 GridSpan m_gridSpan; | 785 GridSpan m_gridSpan; |
786 }; | 786 }; |
787 | 787 |
788 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr
idTrackSizingDirection direction) const | 788 bool LayoutGrid::spanningItemCrossesFlexibleSizedTracks(const GridSpan& span, Gr
idTrackSizingDirection direction) const |
789 { | 789 { |
790 const GridResolvedPosition initialTrackPosition = span.resolvedInitialPositi
on; | 790 for (const auto& trackPosition : span) { |
791 const GridResolvedPosition finalTrackPosition = span.resolvedFinalPosition; | |
792 | |
793 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio
n <= finalTrackPosition; ++trackPosition) { | |
794 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); | 791 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition.
toInt()); |
795 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) | 792 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth().
isFlex()) |
796 return true; | 793 return true; |
797 } | 794 } |
798 | 795 |
799 return false; | 796 return false; |
800 } | 797 } |
801 | 798 |
802 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData) | 799 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio
n direction, GridSizingData& sizingData) |
803 { | 800 { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 for (size_t i = 0; i < tracks.size(); ++i) { | 1084 for (size_t i = 0; i < tracks.size(); ++i) { |
1088 GridTrackSize trackSize = gridTrackSize(direction, i); | 1085 GridTrackSize trackSize = gridTrackSize(direction, i); |
1089 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 1086 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); |
1090 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].
baseSize()) | 1087 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i].
baseSize()) |
1091 return false; | 1088 return false; |
1092 } | 1089 } |
1093 return true; | 1090 return true; |
1094 } | 1091 } |
1095 #endif | 1092 #endif |
1096 | 1093 |
1097 void LayoutGrid::ensureGridSize(size_t maximumRowIndex, size_t maximumColumnInde
x) | 1094 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) |
1098 { | 1095 { |
1099 const size_t oldRowSize = gridRowCount(); | 1096 const size_t oldRowSize = gridRowCount(); |
1100 if (maximumRowIndex >= oldRowSize) { | 1097 if (maximumRowSize > oldRowSize) { |
1101 m_grid.grow(maximumRowIndex + 1); | 1098 m_grid.grow(maximumRowSize); |
1102 for (size_t row = oldRowSize; row < gridRowCount(); ++row) | 1099 for (size_t row = oldRowSize; row < gridRowCount(); ++row) |
1103 m_grid[row].grow(gridColumnCount()); | 1100 m_grid[row].grow(gridColumnCount()); |
1104 } | 1101 } |
1105 | 1102 |
1106 if (maximumColumnIndex >= gridColumnCount()) { | 1103 if (maximumColumnSize > gridColumnCount()) { |
1107 for (size_t row = 0; row < gridRowCount(); ++row) | 1104 for (size_t row = 0; row < gridRowCount(); ++row) |
1108 m_grid[row].grow(maximumColumnIndex + 1); | 1105 m_grid[row].grow(maximumColumnSize); |
1109 } | 1106 } |
1110 } | 1107 } |
1111 | 1108 |
1112 void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridCoordinate& coor
dinate) | 1109 void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridCoordinate& coor
dinate) |
1113 { | 1110 { |
1114 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); | 1111 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col
umns.resolvedFinalPosition.toInt()); |
1115 | 1112 |
1116 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { | 1113 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { |
1117 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) | 1114 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) |
1118 m_grid[row.toInt()][column.toInt()].append(&child); | 1115 m_grid[row.toInt()][column.toInt()].append(&child); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1174 |
1178 populator.collectChild(child); | 1175 populator.collectChild(child); |
1179 m_gridItemsIndexesMap.set(child, childIndex++); | 1176 m_gridItemsIndexesMap.set(child, childIndex++); |
1180 | 1177 |
1181 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. | 1178 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. |
1182 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); | 1179 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); |
1183 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); | 1180 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); |
1184 | 1181 |
1185 // |positions| is 0 if we need to run the auto-placement algorithm. | 1182 // |positions| is 0 if we need to run the auto-placement algorithm. |
1186 if (rowPositions) { | 1183 if (rowPositions) { |
1187 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re
solvedFinalPosition.next().toInt()); | 1184 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re
solvedFinalPosition.toInt()); |
1188 } else { | 1185 } else { |
1189 // Grow the grid for items with a definite row span, getting the lar
gest such span. | 1186 // Grow the grid for items with a definite row span, getting the lar
gest such span. |
1190 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForRows, GridResolvedPosition(0)); | 1187 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForRows, GridResolvedPosition(0)); |
1191 maximumRowIndex = std::max<size_t>(maximumRowIndex, positions.resolv
edFinalPosition.next().toInt()); | 1188 maximumRowIndex = std::max<size_t>(maximumRowIndex, positions.resolv
edFinalPosition.toInt()); |
1192 } | 1189 } |
1193 | 1190 |
1194 if (columnPositions) { | 1191 if (columnPositions) { |
1195 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, columnPosi
tions->resolvedFinalPosition.next().toInt()); | 1192 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, columnPosi
tions->resolvedFinalPosition.toInt()); |
1196 } else { | 1193 } else { |
1197 // Grow the grid for items with a definite column span, getting the
largest such span. | 1194 // Grow the grid for items with a definite column span, getting the
largest such span. |
1198 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); | 1195 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA
utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); |
1199 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.next().toInt()); | 1196 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions.
resolvedFinalPosition.toInt()); |
1200 } | 1197 } |
1201 } | 1198 } |
1202 | 1199 |
1203 m_grid.grow(maximumRowIndex); | 1200 m_grid.grow(maximumRowIndex); |
1204 for (auto& column : m_grid) | 1201 for (auto& column : m_grid) |
1205 column.grow(maximumColumnIndex); | 1202 column.grow(maximumColumnIndex); |
1206 } | 1203 } |
1207 | 1204 |
1208 PassOwnPtr<GridCoordinate> LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const LayoutBox& gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const | 1205 PassOwnPtr<GridCoordinate> LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOu
tsideGrid(const LayoutBox& gridItem, GridTrackSizingDirection specifiedDirection
, const GridSpan& specifiedPositions) const |
1209 { | 1206 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), gridItem, autoPlacementMinorAxisDirection(),
GridResolvedPosition(0)); | 1279 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions
FromAutoPlacementPosition(*style(), gridItem, autoPlacementMinorAxisDirection(),
GridResolvedPosition(0)); |
1283 | 1280 |
1284 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde
x < endOfMajorAxis; ++majorAxisIndex) { | 1281 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde
x < endOfMajorAxis; ++majorAxisIndex) { |
1285 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj
orAxisIndex, minorAxisAutoPlacementCursor); | 1282 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj
orAxisIndex, minorAxisAutoPlacementCursor); |
1286 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege
rSpan(), minorAxisPositions.integerSpan()); | 1283 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege
rSpan(), minorAxisPositions.integerSpan()); |
1287 | 1284 |
1288 if (emptyGridArea) { | 1285 if (emptyGridArea) { |
1289 // Check that it fits in the minor axis direction, as we shouldn
't grow in that direction here (it was already managed in populateExplicitGridAn
dOrderIterator()). | 1286 // Check that it fits in the minor axis direction, as we shouldn
't grow in that direction here (it was already managed in populateExplicitGridAn
dOrderIterator()). |
1290 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement
MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio
n : emptyGridArea->rows.resolvedFinalPosition; | 1287 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement
MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio
n : emptyGridArea->rows.resolvedFinalPosition; |
1291 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection()
== ForColumns ? gridColumnCount() : gridRowCount(); | 1288 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection()
== ForColumns ? gridColumnCount() : gridRowCount(); |
1292 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis) | 1289 if (minorAxisFinalPositionIndex.toInt() <= endOfMinorAxis) |
1293 break; | 1290 break; |
1294 | 1291 |
1295 // Discard empty grid area as it does not fit in the minor axis
direction. | 1292 // Discard empty grid area as it does not fit in the minor axis
direction. |
1296 // We don't need to create a new empty grid area yet as we might
find a valid one in the next iteration. | 1293 // We don't need to create a new empty grid area yet as we might
find a valid one in the next iteration. |
1297 emptyGridArea = nullptr; | 1294 emptyGridArea = nullptr; |
1298 } | 1295 } |
1299 | 1296 |
1300 // As we're moving to the next track in the major axis we should res
et the auto-placement cursor in the minor axis. | 1297 // As we're moving to the next track in the major axis we should res
et the auto-placement cursor in the minor axis. |
1301 minorAxisAutoPlacementCursor = 0; | 1298 minorAxisAutoPlacementCursor = 0; |
1302 } | 1299 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 | 1474 |
1478 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid
ColumnStart() : child.style()->gridRowStart(); | 1475 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid
ColumnStart() : child.style()->gridRowStart(); |
1479 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo
lumnEnd() : child.style()->gridRowEnd(); | 1476 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo
lumnEnd() : child.style()->gridRowEnd(); |
1480 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR
owCount()) - 1; | 1477 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR
owCount()) - 1; |
1481 | 1478 |
1482 bool startIsAuto = startPosition.isAuto() | 1479 bool startIsAuto = startPosition.isAuto() |
1483 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam
edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in
itialPositionSide(direction))) | 1480 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam
edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in
itialPositionSide(direction))) |
1484 || (positions->resolvedInitialPosition.toInt() > lastTrackIndex); | 1481 || (positions->resolvedInitialPosition.toInt() > lastTrackIndex); |
1485 bool endIsAuto = endPosition.isAuto() | 1482 bool endIsAuto = endPosition.isAuto() |
1486 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed
LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP
ositionSide(direction))) | 1483 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed
LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP
ositionSide(direction))) |
1487 || (positions->resolvedFinalPosition.toInt() > lastTrackIndex); | 1484 || (positions->resolvedFinalPosition.prev().toInt() > lastTrackIndex); |
1488 | 1485 |
1489 GridResolvedPosition firstPosition = GridResolvedPosition(0); | 1486 GridResolvedPosition firstPosition = GridResolvedPosition(0); |
1490 GridResolvedPosition initialPosition = startIsAuto ? firstPosition : positio
ns->resolvedInitialPosition; | 1487 GridResolvedPosition initialPosition = startIsAuto ? firstPosition : positio
ns->resolvedInitialPosition; |
1491 GridResolvedPosition lastPosition = GridResolvedPosition(lastTrackIndex); | 1488 GridResolvedPosition lastPosition = GridResolvedPosition(lastTrackIndex); |
1492 GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions->r
esolvedFinalPosition; | 1489 GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions->r
esolvedFinalPosition.prev(); |
1493 | 1490 |
1494 // Positioned children do not grow the grid, so we need to clamp the positio
ns to avoid ending up outside of it. | 1491 // Positioned children do not grow the grid, so we need to clamp the positio
ns to avoid ending up outside of it. |
1495 initialPosition = std::min<GridResolvedPosition>(initialPosition, lastPositi
on); | 1492 initialPosition = std::min<GridResolvedPosition>(initialPosition, lastPositi
on); |
1496 finalPosition = std::min<GridResolvedPosition>(finalPosition, lastPosition); | 1493 finalPosition = std::min<GridResolvedPosition>(finalPosition, lastPosition); |
1497 | 1494 |
1498 LayoutUnit start = startIsAuto ? LayoutUnit() : (direction == ForColumns) ?
m_columnPositions[initialPosition.toInt()] : m_rowPositions[initialPosition.toI
nt()]; | 1495 LayoutUnit start = startIsAuto ? LayoutUnit() : (direction == ForColumns) ?
m_columnPositions[initialPosition.toInt()] : m_rowPositions[initialPosition.toI
nt()]; |
1499 LayoutUnit end = endIsAuto ? (direction == ForColumns) ? logicalWidth() : lo
gicalHeight() : (direction == ForColumns) ? m_columnPositions[finalPosition.nex
t().toInt()] : m_rowPositions[finalPosition.next().toInt()]; | 1496 LayoutUnit end = endIsAuto ? (direction == ForColumns) ? logicalWidth() : lo
gicalHeight() : (direction == ForColumns) ? m_columnPositions[finalPosition.nex
t().toInt()] : m_rowPositions[finalPosition.next().toInt()]; |
1500 | 1497 |
1501 breadth = end - start; | 1498 breadth = end - start; |
1502 | 1499 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 } | 1544 } |
1548 | 1545 |
1549 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La
youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing
Data) const | 1546 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La
youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing
Data) const |
1550 { | 1547 { |
1551 // We need the cached value when available because Content Distribution alig
nment properties | 1548 // We need the cached value when available because Content Distribution alig
nment properties |
1552 // may have some influence in the final grid area breadth. | 1549 // may have some influence in the final grid area breadth. |
1553 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col
umnTracks : sizingData.rowTracks; | 1550 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col
umnTracks : sizingData.rowTracks; |
1554 const GridSpan& span = cachedGridSpan(child, direction); | 1551 const GridSpan& span = cachedGridSpan(child, direction); |
1555 const Vector<LayoutUnit>& linePositions = (direction == ForColumns) ? m_colu
mnPositions : m_rowPositions; | 1552 const Vector<LayoutUnit>& linePositions = (direction == ForColumns) ? m_colu
mnPositions : m_rowPositions; |
1556 LayoutUnit initialTrackPosition = linePositions[span.resolvedInitialPosition
.toInt()]; | 1553 LayoutUnit initialTrackPosition = linePositions[span.resolvedInitialPosition
.toInt()]; |
1557 LayoutUnit finalTrackPosition = linePositions[span.resolvedFinalPosition.toI
nt()]; | 1554 LayoutUnit finalTrackPosition = linePositions[span.resolvedFinalPosition.pre
v().toInt()]; |
1558 // Track Positions vector stores the 'start' grid line of each track, so w h
ave to add last track's baseSize. | 1555 // Track Positions vector stores the 'start' grid line of each track, so w h
ave to add last track's baseSize. |
1559 return finalTrackPosition - initialTrackPosition + tracks[span.resolvedFinal
Position.toInt()].baseSize(); | 1556 return finalTrackPosition - initialTrackPosition + tracks[span.resolvedFinal
Position.prev().toInt()].baseSize(); |
1560 } | 1557 } |
1561 | 1558 |
1562 void LayoutGrid::populateGridPositions(GridSizingData& sizingData) | 1559 void LayoutGrid::populateGridPositions(GridSizingData& sizingData) |
1563 { | 1560 { |
1564 // Since we add alignment offsets and track gutters, grid lines are not alwa
ys adjacent. Hence we will have to | 1561 // Since we add alignment offsets and track gutters, grid lines are not alwa
ys adjacent. Hence we will have to |
1565 // assume from now on that we just store positions of the initial grid lines
of each track, | 1562 // assume from now on that we just store positions of the initial grid lines
of each track, |
1566 // except the last one, which is the only one considered as a final grid lin
e of a track. | 1563 // except the last one, which is the only one considered as a final grid lin
e of a track. |
1567 // FIXME: This will affect the computed style value of grid tracks size, sin
ce we are | 1564 // FIXME: This will affect the computed style value of grid tracks size, sin
ce we are |
1568 // using these positions to compute them. | 1565 // using these positions to compute them. |
1569 | 1566 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 LayoutUnit startOfRow = m_rowPositions[childStartLine]; | 1864 LayoutUnit startOfRow = m_rowPositions[childStartLine]; |
1868 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); | 1865 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); |
1869 if (hasAutoMarginsInColumnAxis(child)) | 1866 if (hasAutoMarginsInColumnAxis(child)) |
1870 return startPosition; | 1867 return startPosition; |
1871 GridAxisPosition axisPosition = columnAxisPositionForChild(child); | 1868 GridAxisPosition axisPosition = columnAxisPositionForChild(child); |
1872 switch (axisPosition) { | 1869 switch (axisPosition) { |
1873 case GridAxisStart: | 1870 case GridAxisStart: |
1874 return startPosition; | 1871 return startPosition; |
1875 case GridAxisEnd: | 1872 case GridAxisEnd: |
1876 case GridAxisCenter: { | 1873 case GridAxisCenter: { |
1877 size_t childEndLine = rowsSpan.resolvedFinalPosition.next().toInt(); | 1874 size_t childEndLine = rowsSpan.resolvedFinalPosition.toInt(); |
1878 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 1875 LayoutUnit endOfRow = m_rowPositions[childEndLine]; |
1879 // m_rowPositions include gutters so we need to substract them to get th
e actual end position for a given | 1876 // m_rowPositions include gutters so we need to substract them to get th
e actual end position for a given |
1880 // row (this does not have to be done for the last track as there are no
more m_rowPositions after it) | 1877 // row (this does not have to be done for the last track as there are no
more m_rowPositions after it) |
1881 if (childEndLine < m_rowPositions.size() - 1) | 1878 if (childEndLine < m_rowPositions.size() - 1) |
1882 endOfRow -= guttersSize(ForRows, 2); | 1879 endOfRow -= guttersSize(ForRows, 2); |
1883 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); | 1880 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei
ght(); |
1884 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) | 1881 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s
ize() - 1) |
1885 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution(
), m_rowPositions, childBreadth); | 1882 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution(
), m_rowPositions, childBreadth); |
1886 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); | 1883 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); |
1887 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1884 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
(...skipping 11 matching lines...) Expand all Loading... |
1899 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; | 1896 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; |
1900 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); | 1897 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
1901 if (hasAutoMarginsInRowAxis(child)) | 1898 if (hasAutoMarginsInRowAxis(child)) |
1902 return startPosition; | 1899 return startPosition; |
1903 GridAxisPosition axisPosition = rowAxisPositionForChild(child); | 1900 GridAxisPosition axisPosition = rowAxisPositionForChild(child); |
1904 switch (axisPosition) { | 1901 switch (axisPosition) { |
1905 case GridAxisStart: | 1902 case GridAxisStart: |
1906 return startPosition; | 1903 return startPosition; |
1907 case GridAxisEnd: | 1904 case GridAxisEnd: |
1908 case GridAxisCenter: { | 1905 case GridAxisCenter: { |
1909 size_t childEndLine = columnsSpan.resolvedFinalPosition.next().toInt(); | 1906 size_t childEndLine = columnsSpan.resolvedFinalPosition.toInt(); |
1910 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 1907 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; |
1911 // m_columnPositions include gutters so we need to substract them to get
the actual end position for a given | 1908 // m_columnPositions include gutters so we need to substract them to get
the actual end position for a given |
1912 // column (this does not have to be done for the last track as there are
no more m_columnPositions after it) | 1909 // column (this does not have to be done for the last track as there are
no more m_columnPositions after it) |
1913 if (childEndLine < m_columnPositions.size() - 1) | 1910 if (childEndLine < m_columnPositions.size() - 1) |
1914 endOfColumn -= guttersSize(ForRows, 2); | 1911 endOfColumn -= guttersSize(ForRows, 2); |
1915 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); | 1912 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt
h(); |
1916 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) | 1913 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition
s.size() - 1) |
1917 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu
tion(), m_columnPositions, childBreadth); | 1914 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu
tion(), m_columnPositions, childBreadth); |
1918 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); | 1915 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil
d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB
readth); |
1919 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); | 1916 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos
ition : offsetFromStartPosition / 2); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2050 | 2047 |
2051 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2048 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
2052 } | 2049 } |
2053 | 2050 |
2054 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2051 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2055 { | 2052 { |
2056 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2053 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2057 } | 2054 } |
2058 | 2055 |
2059 } // namespace blink | 2056 } // namespace blink |
OLD | NEW |