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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 const GridResolvedPosition initialTrackPosition = span.resolvedInitialPositi on; |
791 const GridResolvedPosition finalTrackPosition = span.resolvedFinalPosition; | 791 const GridResolvedPosition finalTrackPosition = span.resolvedFinalPosition; |
792 | 792 |
793 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n <= finalTrackPosition; ++trackPosition) { | 793 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n < finalTrackPosition; ++trackPosition) { |
svillar
2015/11/17 11:37:05
Hmm I think GridSpan already has iterator support,
Manuel Rego
2015/11/17 14:30:49
Yes, this is unrelated to the change but we can do
| |
794 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition. toInt()); | 794 const GridTrackSize& trackSize = gridTrackSize(direction, trackPosition. toInt()); |
795 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex()) | 795 if (trackSize.minTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isFlex()) |
796 return true; | 796 return true; |
797 } | 797 } |
798 | 798 |
799 return false; | 799 return false; |
800 } | 800 } |
801 | 801 |
802 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) | 802 void LayoutGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData) |
803 { | 803 { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1087 for (size_t i = 0; i < tracks.size(); ++i) { | 1087 for (size_t i = 0; i < tracks.size(); ++i) { |
1088 GridTrackSize trackSize = gridTrackSize(direction, i); | 1088 GridTrackSize trackSize = gridTrackSize(direction, i); |
1089 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); | 1089 const GridLength& minTrackBreadth = trackSize.minTrackBreadth(); |
1090 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i]. baseSize()) | 1090 if (computeUsedBreadthOfMinLength(minTrackBreadth, maxSize) > tracks[i]. baseSize()) |
1091 return false; | 1091 return false; |
1092 } | 1092 } |
1093 return true; | 1093 return true; |
1094 } | 1094 } |
1095 #endif | 1095 #endif |
1096 | 1096 |
1097 void LayoutGrid::ensureGridSize(size_t maximumRowIndex, size_t maximumColumnInde x) | 1097 void LayoutGrid::ensureGridSize(size_t maximumRowSize, size_t maximumColumnSize) |
1098 { | 1098 { |
1099 const size_t oldRowSize = gridRowCount(); | 1099 const size_t oldRowSize = gridRowCount(); |
1100 if (maximumRowIndex >= oldRowSize) { | 1100 if (maximumRowSize > oldRowSize) { |
1101 m_grid.grow(maximumRowIndex + 1); | 1101 m_grid.grow(maximumRowSize); |
1102 for (size_t row = oldRowSize; row < gridRowCount(); ++row) | 1102 for (size_t row = oldRowSize; row < gridRowCount(); ++row) |
1103 m_grid[row].grow(gridColumnCount()); | 1103 m_grid[row].grow(gridColumnCount()); |
1104 } | 1104 } |
1105 | 1105 |
1106 if (maximumColumnIndex >= gridColumnCount()) { | 1106 if (maximumColumnSize > gridColumnCount()) { |
1107 for (size_t row = 0; row < gridRowCount(); ++row) | 1107 for (size_t row = 0; row < gridRowCount(); ++row) |
1108 m_grid[row].grow(maximumColumnIndex + 1); | 1108 m_grid[row].grow(maximumColumnSize); |
1109 } | 1109 } |
1110 } | 1110 } |
1111 | 1111 |
1112 void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridCoordinate& coor dinate) | 1112 void LayoutGrid::insertItemIntoGrid(LayoutBox& child, const GridCoordinate& coor dinate) |
1113 { | 1113 { |
1114 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col umns.resolvedFinalPosition.toInt()); | 1114 ensureGridSize(coordinate.rows.resolvedFinalPosition.toInt(), coordinate.col umns.resolvedFinalPosition.toInt()); |
1115 | 1115 |
1116 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row s.end(); ++row) { | 1116 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) | 1117 for (GridSpan::iterator column = coordinate.columns.begin(); column != c oordinate.columns.end(); ++column) |
1118 m_grid[row.toInt()][column.toInt()].append(&child); | 1118 m_grid[row.toInt()][column.toInt()].append(&child); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1177 | 1177 |
1178 populator.collectChild(child); | 1178 populator.collectChild(child); |
1179 m_gridItemsIndexesMap.set(child, childIndex++); | 1179 m_gridItemsIndexesMap.set(child, childIndex++); |
1180 | 1180 |
1181 // This function bypasses the cache (cachedGridCoordinate()) as it is us ed to build it. | 1181 // This function bypasses the cache (cachedGridCoordinate()) as it is us ed to build it. |
1182 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio nsFromStyle(*style(), *child, ForRows); | 1182 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio nsFromStyle(*style(), *child, ForRows); |
1183 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi tionsFromStyle(*style(), *child, ForColumns); | 1183 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi tionsFromStyle(*style(), *child, ForColumns); |
1184 | 1184 |
1185 // |positions| is 0 if we need to run the auto-placement algorithm. | 1185 // |positions| is 0 if we need to run the auto-placement algorithm. |
1186 if (rowPositions) { | 1186 if (rowPositions) { |
1187 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re solvedFinalPosition.next().toInt()); | 1187 maximumRowIndex = std::max<size_t>(maximumRowIndex, rowPositions->re solvedFinalPosition.toInt()); |
1188 } else { | 1188 } else { |
1189 // Grow the grid for items with a definite row span, getting the lar gest such span. | 1189 // 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)); | 1190 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA utoPlacementPosition(*style(), *child, ForRows, GridResolvedPosition(0)); |
1191 maximumRowIndex = std::max<size_t>(maximumRowIndex, positions.resolv edFinalPosition.next().toInt()); | 1191 maximumRowIndex = std::max<size_t>(maximumRowIndex, positions.resolv edFinalPosition.toInt()); |
1192 } | 1192 } |
1193 | 1193 |
1194 if (columnPositions) { | 1194 if (columnPositions) { |
1195 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, columnPosi tions->resolvedFinalPosition.next().toInt()); | 1195 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, columnPosi tions->resolvedFinalPosition.toInt()); |
1196 } else { | 1196 } else { |
1197 // Grow the grid for items with a definite column span, getting the largest such span. | 1197 // 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)); | 1198 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromA utoPlacementPosition(*style(), *child, ForColumns, GridResolvedPosition(0)); |
1199 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions. resolvedFinalPosition.next().toInt()); | 1199 maximumColumnIndex = std::max<size_t>(maximumColumnIndex, positions. resolvedFinalPosition.toInt()); |
1200 } | 1200 } |
1201 } | 1201 } |
1202 | 1202 |
1203 m_grid.grow(maximumRowIndex); | 1203 m_grid.grow(maximumRowIndex); |
1204 for (auto& column : m_grid) | 1204 for (auto& column : m_grid) |
1205 column.grow(maximumColumnIndex); | 1205 column.grow(maximumColumnIndex); |
1206 } | 1206 } |
1207 | 1207 |
1208 PassOwnPtr<GridCoordinate> LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOu tsideGrid(const LayoutBox& gridItem, GridTrackSizingDirection specifiedDirection , const GridSpan& specifiedPositions) const | 1208 PassOwnPtr<GridCoordinate> LayoutGrid::createEmptyGridAreaAtSpecifiedPositionsOu tsideGrid(const LayoutBox& gridItem, GridTrackSizingDirection specifiedDirection , const GridSpan& specifiedPositions) const |
1209 { | 1209 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1282 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions FromAutoPlacementPosition(*style(), gridItem, autoPlacementMinorAxisDirection(), GridResolvedPosition(0)); | 1282 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPositions FromAutoPlacementPosition(*style(), gridItem, autoPlacementMinorAxisDirection(), GridResolvedPosition(0)); |
1283 | 1283 |
1284 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde x < endOfMajorAxis; ++majorAxisIndex) { | 1284 for (size_t majorAxisIndex = majorAxisAutoPlacementCursor; majorAxisInde x < endOfMajorAxis; ++majorAxisIndex) { |
1285 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj orAxisIndex, minorAxisAutoPlacementCursor); | 1285 GridIterator iterator(m_grid, autoPlacementMajorAxisDirection(), maj orAxisIndex, minorAxisAutoPlacementCursor); |
1286 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege rSpan(), minorAxisPositions.integerSpan()); | 1286 emptyGridArea = iterator.nextEmptyGridArea(majorAxisPositions.intege rSpan(), minorAxisPositions.integerSpan()); |
1287 | 1287 |
1288 if (emptyGridArea) { | 1288 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()). | 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()). |
1290 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio n : emptyGridArea->rows.resolvedFinalPosition; | 1290 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio n : emptyGridArea->rows.resolvedFinalPosition; |
1291 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection() == ForColumns ? gridColumnCount() : gridRowCount(); | 1291 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection() == ForColumns ? gridColumnCount() : gridRowCount(); |
1292 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis) | 1292 if (minorAxisFinalPositionIndex.toInt() <= endOfMinorAxis) |
1293 break; | 1293 break; |
1294 | 1294 |
1295 // Discard empty grid area as it does not fit in the minor axis direction. | 1295 // 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. | 1296 // 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; | 1297 emptyGridArea = nullptr; |
1298 } | 1298 } |
1299 | 1299 |
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. | 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. |
1301 minorAxisAutoPlacementCursor = 0; | 1301 minorAxisAutoPlacementCursor = 0; |
1302 } | 1302 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1477 | 1477 |
1478 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid ColumnStart() : child.style()->gridRowStart(); | 1478 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid ColumnStart() : child.style()->gridRowStart(); |
1479 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo lumnEnd() : child.style()->gridRowEnd(); | 1479 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo lumnEnd() : child.style()->gridRowEnd(); |
1480 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR owCount()) - 1; | 1480 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR owCount()) - 1; |
1481 | 1481 |
1482 bool startIsAuto = startPosition.isAuto() | 1482 bool startIsAuto = startPosition.isAuto() |
1483 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in itialPositionSide(direction))) | 1483 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in itialPositionSide(direction))) |
1484 || (positions->resolvedInitialPosition.toInt() > lastTrackIndex); | 1484 || (positions->resolvedInitialPosition.toInt() > lastTrackIndex); |
1485 bool endIsAuto = endPosition.isAuto() | 1485 bool endIsAuto = endPosition.isAuto() |
1486 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP ositionSide(direction))) | 1486 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP ositionSide(direction))) |
1487 || (positions->resolvedFinalPosition.toInt() > lastTrackIndex); | 1487 || (positions->resolvedFinalPosition.prev().toInt() > lastTrackIndex); |
svillar
2015/11/17 11:37:05
could we write this as
resolvedFinalPosition.toIn
Manuel Rego
2015/11/17 14:30:49
I don't think so, otherwise this will be TRUE in m
| |
1488 | 1488 |
1489 GridResolvedPosition firstPosition = GridResolvedPosition(0); | 1489 GridResolvedPosition firstPosition = GridResolvedPosition(0); |
1490 GridResolvedPosition initialPosition = startIsAuto ? firstPosition : positio ns->resolvedInitialPosition; | 1490 GridResolvedPosition initialPosition = startIsAuto ? firstPosition : positio ns->resolvedInitialPosition; |
1491 GridResolvedPosition lastPosition = GridResolvedPosition(lastTrackIndex); | 1491 GridResolvedPosition lastPosition = GridResolvedPosition(lastTrackIndex); |
1492 GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions->r esolvedFinalPosition; | 1492 GridResolvedPosition finalPosition = endIsAuto ? lastPosition : positions->r esolvedFinalPosition.prev(); |
1493 | 1493 |
1494 // Positioned children do not grow the grid, so we need to clamp the positio ns to avoid ending up outside of it. | 1494 // 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); | 1495 initialPosition = std::min<GridResolvedPosition>(initialPosition, lastPositi on); |
1496 finalPosition = std::min<GridResolvedPosition>(finalPosition, lastPosition); | 1496 finalPosition = std::min<GridResolvedPosition>(finalPosition, lastPosition); |
1497 | 1497 |
1498 LayoutUnit start = startIsAuto ? LayoutUnit() : (direction == ForColumns) ? m_columnPositions[initialPosition.toInt()] : m_rowPositions[initialPosition.toI nt()]; | 1498 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()]; | 1499 LayoutUnit end = endIsAuto ? (direction == ForColumns) ? logicalWidth() : lo gicalHeight() : (direction == ForColumns) ? m_columnPositions[finalPosition.nex t().toInt()] : m_rowPositions[finalPosition.next().toInt()]; |
1500 | 1500 |
1501 breadth = end - start; | 1501 breadth = end - start; |
1502 | 1502 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1547 } | 1547 } |
1548 | 1548 |
1549 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const | 1549 LayoutUnit LayoutGrid::gridAreaBreadthForChildIncludingAlignmentOffsets(const La youtBox& child, GridTrackSizingDirection direction, const GridSizingData& sizing Data) const |
1550 { | 1550 { |
1551 // We need the cached value when available because Content Distribution alig nment properties | 1551 // We need the cached value when available because Content Distribution alig nment properties |
1552 // may have some influence in the final grid area breadth. | 1552 // may have some influence in the final grid area breadth. |
1553 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; | 1553 const Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.col umnTracks : sizingData.rowTracks; |
1554 const GridSpan& span = cachedGridSpan(child, direction); | 1554 const GridSpan& span = cachedGridSpan(child, direction); |
1555 const Vector<LayoutUnit>& linePositions = (direction == ForColumns) ? m_colu mnPositions : m_rowPositions; | 1555 const Vector<LayoutUnit>& linePositions = (direction == ForColumns) ? m_colu mnPositions : m_rowPositions; |
1556 LayoutUnit initialTrackPosition = linePositions[span.resolvedInitialPosition .toInt()]; | 1556 LayoutUnit initialTrackPosition = linePositions[span.resolvedInitialPosition .toInt()]; |
1557 LayoutUnit finalTrackPosition = linePositions[span.resolvedFinalPosition.toI nt()]; | 1557 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. | 1558 // 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(); | 1559 return finalTrackPosition - initialTrackPosition + tracks[span.resolvedFinal Position.prev().toInt()].baseSize(); |
1560 } | 1560 } |
1561 | 1561 |
1562 void LayoutGrid::populateGridPositions(GridSizingData& sizingData) | 1562 void LayoutGrid::populateGridPositions(GridSizingData& sizingData) |
1563 { | 1563 { |
1564 // Since we add alignment offsets and track gutters, grid lines are not alwa ys adjacent. Hence we will have to | 1564 // 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, | 1565 // 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. | 1566 // 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 | 1567 // FIXME: This will affect the computed style value of grid tracks size, sin ce we are |
1568 // using these positions to compute them. | 1568 // using these positions to compute them. |
1569 | 1569 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1867 LayoutUnit startOfRow = m_rowPositions[childStartLine]; | 1867 LayoutUnit startOfRow = m_rowPositions[childStartLine]; |
1868 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); | 1868 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); |
1869 if (hasAutoMarginsInColumnAxis(child)) | 1869 if (hasAutoMarginsInColumnAxis(child)) |
1870 return startPosition; | 1870 return startPosition; |
1871 GridAxisPosition axisPosition = columnAxisPositionForChild(child); | 1871 GridAxisPosition axisPosition = columnAxisPositionForChild(child); |
1872 switch (axisPosition) { | 1872 switch (axisPosition) { |
1873 case GridAxisStart: | 1873 case GridAxisStart: |
1874 return startPosition; | 1874 return startPosition; |
1875 case GridAxisEnd: | 1875 case GridAxisEnd: |
1876 case GridAxisCenter: { | 1876 case GridAxisCenter: { |
1877 size_t childEndLine = rowsSpan.resolvedFinalPosition.next().toInt(); | 1877 size_t childEndLine = rowsSpan.resolvedFinalPosition.toInt(); |
1878 LayoutUnit endOfRow = m_rowPositions[childEndLine]; | 1878 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 | 1879 // 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) | 1880 // 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) | 1881 if (childEndLine < m_rowPositions.size() - 1) |
1882 endOfRow -= guttersSize(ForRows, 2); | 1882 endOfRow -= guttersSize(ForRows, 2); |
1883 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); | 1883 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHei ght(); |
1884 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s ize() - 1) | 1884 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.s ize() - 1) |
1885 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution( ), m_rowPositions, childBreadth); | 1885 endOfRow -= offsetBetweenTracks(styleRef().alignContentDistribution( ), m_rowPositions, childBreadth); |
1886 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); | 1886 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, childBreadth); |
1887 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 1887 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
(...skipping 11 matching lines...) Expand all Loading... | |
1899 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; | 1899 LayoutUnit startOfColumn = m_columnPositions[childStartLine]; |
1900 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); | 1900 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
1901 if (hasAutoMarginsInRowAxis(child)) | 1901 if (hasAutoMarginsInRowAxis(child)) |
1902 return startPosition; | 1902 return startPosition; |
1903 GridAxisPosition axisPosition = rowAxisPositionForChild(child); | 1903 GridAxisPosition axisPosition = rowAxisPositionForChild(child); |
1904 switch (axisPosition) { | 1904 switch (axisPosition) { |
1905 case GridAxisStart: | 1905 case GridAxisStart: |
1906 return startPosition; | 1906 return startPosition; |
1907 case GridAxisEnd: | 1907 case GridAxisEnd: |
1908 case GridAxisCenter: { | 1908 case GridAxisCenter: { |
1909 size_t childEndLine = columnsSpan.resolvedFinalPosition.next().toInt(); | 1909 size_t childEndLine = columnsSpan.resolvedFinalPosition.toInt(); |
1910 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; | 1910 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 | 1911 // 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) | 1912 // 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) | 1913 if (childEndLine < m_columnPositions.size() - 1) |
1914 endOfColumn -= guttersSize(ForRows, 2); | 1914 endOfColumn -= guttersSize(ForRows, 2); |
1915 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); | 1915 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidt h(); |
1916 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition s.size() - 1) | 1916 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPosition s.size() - 1) |
1917 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu tion(), m_columnPositions, childBreadth); | 1917 endOfColumn -= offsetBetweenTracks(styleRef().justifyContentDistribu tion(), m_columnPositions, childBreadth); |
1918 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); | 1918 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(chil d.styleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, childB readth); |
1919 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); | 1919 return startPosition + (axisPosition == GridAxisEnd ? offsetFromStartPos ition : offsetFromStartPosition / 2); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2050 | 2050 |
2051 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2051 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
2052 } | 2052 } |
2053 | 2053 |
2054 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2054 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2055 { | 2055 { |
2056 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2056 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2057 } | 2057 } |
2058 | 2058 |
2059 } // namespace blink | 2059 } // namespace blink |
OLD | NEW |