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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 || oldStyle.gridAutoRepeatColumns().size() != styleRef().gridAutoRepeatC olumns().size() | 356 || oldStyle.gridAutoRepeatColumns().size() != styleRef().gridAutoRepeatC olumns().size() |
357 || oldStyle.gridAutoRepeatRows().size() != styleRef().gridAutoRepeatRows ().size(); | 357 || oldStyle.gridAutoRepeatRows().size() != styleRef().gridAutoRepeatRows ().size(); |
358 } | 358 } |
359 | 359 |
360 bool LayoutGrid::namedGridLinesDefinitionDidChange(const ComputedStyle& oldStyle ) const | 360 bool LayoutGrid::namedGridLinesDefinitionDidChange(const ComputedStyle& oldStyle ) const |
361 { | 361 { |
362 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines() | 362 return oldStyle.namedGridRowLines() != styleRef().namedGridRowLines() |
363 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); | 363 || oldStyle.namedGridColumnLines() != styleRef().namedGridColumnLines(); |
364 } | 364 } |
365 | 365 |
366 size_t LayoutGrid::autoRepeatTracksCount(GridTrackSizingDirection direction) con st | |
367 { | |
368 if (direction == ForColumns) | |
369 return m_autoRepeatColumns * styleRef().gridAutoRepeatColumns().size(); | |
370 return m_autoRepeatRows * styleRef().gridAutoRepeatRows().size(); | |
371 } | |
372 | |
366 size_t LayoutGrid::gridColumnCount() const | 373 size_t LayoutGrid::gridColumnCount() const |
367 { | 374 { |
368 DCHECK(!m_gridIsDirty); | 375 DCHECK(!m_gridIsDirty); |
369 // Due to limitations in our internal representation, we cannot know the num ber of columns from | 376 // Due to limitations in our internal representation, we cannot know the num ber of columns from |
370 // m_grid *if* there is no row (because m_grid would be empty). That's why i n that case we need | 377 // m_grid *if* there is no row (because m_grid would be empty). That's why i n that case we need |
371 // to get it from the style. Note that we know for sure that there are't any implicit tracks, | 378 // to get it from the style. Note that we know for sure that there are't any implicit tracks, |
372 // because not having rows implies that there are no "normal" children (out- of-flow children are | 379 // because not having rows implies that there are no "normal" children (out- of-flow children are |
373 // not stored in m_grid). | 380 // not stored in m_grid). |
374 return m_grid.size() ? m_grid[0].size() : GridPositionsResolver::explicitGri dColumnCount(styleRef(), m_autoRepeatColumns); | 381 return m_grid.size() ? m_grid[0].size() : GridPositionsResolver::explicitGri dColumnCount(styleRef(), autoRepeatTracksCount(ForColumns)); |
375 } | 382 } |
376 | 383 |
377 size_t LayoutGrid::gridRowCount() const | 384 size_t LayoutGrid::gridRowCount() const |
378 { | 385 { |
379 DCHECK(!m_gridIsDirty); | 386 DCHECK(!m_gridIsDirty); |
380 return m_grid.size(); | 387 return m_grid.size(); |
381 } | 388 } |
382 | 389 |
383 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const | 390 LayoutUnit LayoutGrid::computeTrackBasedLogicalHeight(const GridSizingData& sizi ngData) const |
384 { | 391 { |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 return child.hasRelativeLogicalHeight() || child.styleRef().logicalHeight(). isIntrinsicOrAuto(); | 850 return child.hasRelativeLogicalHeight() || child.styleRef().logicalHeight(). isIntrinsicOrAuto(); |
844 } | 851 } |
845 | 852 |
846 const GridTrackSize& LayoutGrid::rawGridTrackSize(GridTrackSizingDirection direc tion, size_t translatedIndex) const | 853 const GridTrackSize& LayoutGrid::rawGridTrackSize(GridTrackSizingDirection direc tion, size_t translatedIndex) const |
847 { | 854 { |
848 bool isRowAxis = direction == ForColumns; | 855 bool isRowAxis = direction == ForColumns; |
849 const Vector<GridTrackSize>& trackStyles = isRowAxis ? styleRef().gridTempla teColumns() : styleRef().gridTemplateRows(); | 856 const Vector<GridTrackSize>& trackStyles = isRowAxis ? styleRef().gridTempla teColumns() : styleRef().gridTemplateRows(); |
850 const Vector<GridTrackSize>& autoRepeatTrackStyles = isRowAxis ? styleRef(). gridAutoRepeatColumns() : styleRef().gridAutoRepeatRows(); | 857 const Vector<GridTrackSize>& autoRepeatTrackStyles = isRowAxis ? styleRef(). gridAutoRepeatColumns() : styleRef().gridAutoRepeatRows(); |
851 const GridTrackSize& autoTrackSize = isRowAxis ? styleRef().gridAutoColumns( ) : styleRef().gridAutoRows(); | 858 const GridTrackSize& autoTrackSize = isRowAxis ? styleRef().gridAutoColumns( ) : styleRef().gridAutoRows(); |
852 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); | 859 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); |
853 size_t repetitions = autoRepeatCountForDirection(direction); | 860 size_t autoRepeatTracksCount = autoRepeatCountForDirection(direction) * auto RepeatTrackStyles.size(); |
854 | 861 |
855 // We should not use GridPositionsResolver::explicitGridXXXCount() for this because the | 862 // We should not use GridPositionsResolver::explicitGridXXXCount() for this because the |
856 // explicit grid might be larger than the number of tracks in grid-template- rows|columns (if | 863 // explicit grid might be larger than the number of tracks in grid-template- rows|columns (if |
857 // grid-template-areas is specified for example). | 864 // grid-template-areas is specified for example). |
858 size_t explicitTracksCount = trackStyles.size() + repetitions; | 865 size_t explicitTracksCount = trackStyles.size() + autoRepeatTracksCount; |
859 | 866 |
860 int untranslatedIndexAsInt = translatedIndex + (isRowAxis ? m_smallestColumn Start : m_smallestRowStart); | 867 int untranslatedIndexAsInt = translatedIndex + (isRowAxis ? m_smallestColumn Start : m_smallestRowStart); |
861 if (untranslatedIndexAsInt < 0) | 868 if (untranslatedIndexAsInt < 0) |
862 return autoTrackSize; | 869 return autoTrackSize; |
863 | 870 |
864 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt); | 871 size_t untranslatedIndex = static_cast<size_t>(untranslatedIndexAsInt); |
865 if (untranslatedIndex >= explicitTracksCount) | 872 if (untranslatedIndex >= explicitTracksCount) |
866 return autoTrackSize; | 873 return autoTrackSize; |
867 | 874 |
868 if (LIKELY(!repetitions) || untranslatedIndex < insertionPoint) | 875 if (LIKELY(!autoRepeatTracksCount) || untranslatedIndex < insertionPoint) |
869 return trackStyles[untranslatedIndex]; | 876 return trackStyles[untranslatedIndex]; |
870 | 877 |
871 if (untranslatedIndex < (insertionPoint + repetitions)) | 878 if (untranslatedIndex < (insertionPoint + autoRepeatTracksCount)) { |
872 return autoRepeatTrackStyles[0]; | 879 size_t autoRepeatLocalIndex = untranslatedIndexAsInt - insertionPoint; |
880 return autoRepeatTrackStyles[autoRepeatLocalIndex % autoRepeatTrackStyle s.size()]; | |
881 } | |
873 | 882 |
874 return trackStyles[untranslatedIndex - repetitions]; | 883 return trackStyles[untranslatedIndex - autoRepeatTracksCount]; |
jfernandez
2016/07/19 14:43:18
Are you sure this can't lead to a negative value a
eae
2016/07/19 20:59:48
Please add a DCHECK here to ensure it cannot go ne
svillar
2016/07/20 07:22:30
Replying to both, I am not changing the code here,
jfernandez
2016/07/20 08:51:50
Yes, you're right.
| |
875 } | 884 } |
876 | 885 |
877 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t translatedIndex, SizingOperation sizingOperation) const | 886 GridTrackSize LayoutGrid::gridTrackSize(GridTrackSizingDirection direction, size _t translatedIndex, SizingOperation sizingOperation) const |
878 { | 887 { |
879 // Collapse empty auto repeat tracks if auto-fit. | 888 // Collapse empty auto repeat tracks if auto-fit. |
880 if (hasAutoRepeatEmptyTracks(direction) && isEmptyAutoRepeatTrack(direction, translatedIndex)) | 889 if (hasAutoRepeatEmptyTracks(direction) && isEmptyAutoRepeatTrack(direction, translatedIndex)) |
881 return { Length(Fixed), Length(Fixed) }; | 890 return { Length(Fixed), Length(Fixed) }; |
882 | 891 |
883 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex ); | 892 const GridTrackSize& trackSize = rawGridTrackSize(direction, translatedIndex ); |
884 | 893 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1381 } | 1390 } |
1382 | 1391 |
1383 size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection directi on) const | 1392 size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection directi on) const |
1384 { | 1393 { |
1385 bool isRowAxis = direction == ForColumns; | 1394 bool isRowAxis = direction == ForColumns; |
1386 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns( ) : styleRef().gridAutoRepeatRows(); | 1395 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns( ) : styleRef().gridAutoRepeatRows(); |
1387 | 1396 |
1388 if (!autoRepeatTracks.size()) | 1397 if (!autoRepeatTracks.size()) |
1389 return 0; | 1398 return 0; |
1390 | 1399 |
1391 DCHECK_EQ(autoRepeatTracks.size(), static_cast<size_t>(1)); | |
1392 auto autoTrackSize = autoRepeatTracks.at(0); | |
1393 DCHECK(autoTrackSize.minTrackBreadth().isLength()); | |
1394 DCHECK(!autoTrackSize.minTrackBreadth().isFlex()); | |
1395 | |
1396 LayoutUnit availableSize = isRowAxis ? availableLogicalWidth() : computeCont entLogicalHeight(MainOrPreferredSize, styleRef().logicalHeight(), LayoutUnit(-1) ); | 1400 LayoutUnit availableSize = isRowAxis ? availableLogicalWidth() : computeCont entLogicalHeight(MainOrPreferredSize, styleRef().logicalHeight(), LayoutUnit(-1) ); |
1397 if (availableSize == -1) { | 1401 if (availableSize == -1) { |
1398 const Length& maxLength = isRowAxis ? styleRef().logicalMaxWidth() : sty leRef().logicalMaxHeight(); | 1402 const Length& maxLength = isRowAxis ? styleRef().logicalMaxWidth() : sty leRef().logicalMaxHeight(); |
1399 if (!maxLength.isMaxSizeNone()) { | 1403 if (!maxLength.isMaxSizeNone()) { |
1400 availableSize = isRowAxis | 1404 availableSize = isRowAxis |
1401 ? computeLogicalWidthUsing(MaxSize, maxLength, containingBlockLo gicalWidthForContent(), containingBlock()) | 1405 ? computeLogicalWidthUsing(MaxSize, maxLength, containingBlockLo gicalWidthForContent(), containingBlock()) |
1402 : computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1) ); | 1406 : computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1) ); |
1403 } | 1407 } |
1404 } else { | 1408 } else { |
1405 availableSize = isRowAxis | 1409 availableSize = isRowAxis |
1406 ? constrainLogicalWidthByMinMax(availableSize, availableLogicalWidth (), containingBlock()) | 1410 ? constrainLogicalWidthByMinMax(availableSize, availableLogicalWidth (), containingBlock()) |
1407 : constrainLogicalHeightByMinMax(availableSize, LayoutUnit(-1)); | 1411 : constrainLogicalHeightByMinMax(availableSize, LayoutUnit(-1)); |
1408 } | 1412 } |
1409 | 1413 |
1410 bool needsToFulfillMinimumSize = false; | 1414 bool needsToFulfillMinimumSize = false; |
1411 bool indefiniteMainAndMaxSizes = availableSize == LayoutUnit(-1); | 1415 bool indefiniteMainAndMaxSizes = availableSize == LayoutUnit(-1); |
1412 if (indefiniteMainAndMaxSizes) { | 1416 if (indefiniteMainAndMaxSizes) { |
1413 const Length& minSize = isRowAxis ? styleRef().logicalMinWidth() : style Ref().logicalMinHeight(); | 1417 const Length& minSize = isRowAxis ? styleRef().logicalMinWidth() : style Ref().logicalMinHeight(); |
1414 if (!minSize.isSpecified()) | 1418 if (!minSize.isSpecified()) |
1415 return 1; | 1419 return 1; |
1416 | 1420 |
1417 LayoutUnit containingBlockAvailableSize = isRowAxis ? containingBlockLog icalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBord erPadding); | 1421 LayoutUnit containingBlockAvailableSize = isRowAxis ? containingBlockLog icalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBord erPadding); |
1418 availableSize = valueForLength(minSize, containingBlockAvailableSize); | 1422 availableSize = valueForLength(minSize, containingBlockAvailableSize); |
1419 needsToFulfillMinimumSize = true; | 1423 needsToFulfillMinimumSize = true; |
1420 } | 1424 } |
1421 | 1425 |
1422 bool hasDefiniteMaxTrackSizingFunction = autoTrackSize.maxTrackBreadth().isL ength() && !autoTrackSize.maxTrackBreadth().isContentSized(); | 1426 LayoutUnit autoRepeatTracksSize; |
1423 const Length trackLength = hasDefiniteMaxTrackSizingFunction ? autoTrackSize .maxTrackBreadth().length() : autoTrackSize.minTrackBreadth().length(); | 1427 for (auto autoTrackSize : autoRepeatTracks) { |
1428 DCHECK(autoTrackSize.minTrackBreadth().isLength()); | |
1429 DCHECK(!autoTrackSize.minTrackBreadth().isFlex()); | |
1430 bool hasDefiniteMaxTrackSizingFunction = autoTrackSize.maxTrackBreadth() .isLength() && !autoTrackSize.maxTrackBreadth().isContentSized(); | |
1431 auto trackLength = hasDefiniteMaxTrackSizingFunction ? autoTrackSize.max TrackBreadth().length() : autoTrackSize.minTrackBreadth().length(); | |
1432 autoRepeatTracksSize += valueForLength(trackLength, availableSize); | |
1433 } | |
1424 // For the purpose of finding the number of auto-repeated tracks, the UA mus t floor the track size to a UA-specified | 1434 // For the purpose of finding the number of auto-repeated tracks, the UA mus t floor the track size to a UA-specified |
1425 // value to avoid division by zero. It is suggested that this floor be 1px. | 1435 // value to avoid division by zero. It is suggested that this floor be 1px. |
1426 LayoutUnit autoRepeatTrackSize = std::max<LayoutUnit>(LayoutUnit(1), valueFo rLength(trackLength, availableSize)); | 1436 autoRepeatTracksSize = std::max<LayoutUnit>(LayoutUnit(1), autoRepeatTracksS ize); |
1427 | 1437 |
1428 // There will be always at least 1 auto-repeat track, so take it already int o account when computing the total track size. | 1438 // There will be always at least 1 auto-repeat track, so take it already int o account when computing the total track size. |
1429 LayoutUnit tracksSize = autoRepeatTrackSize; | 1439 LayoutUnit tracksSize = autoRepeatTracksSize; |
1430 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); | 1440 const Vector<GridTrackSize>& trackSizes = isRowAxis ? styleRef().gridTemplat eColumns() : styleRef().gridTemplateRows(); |
1431 | 1441 |
1432 for (const auto& track : trackSizes) { | 1442 for (const auto& track : trackSizes) { |
1433 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); | 1443 bool hasDefiniteMaxTrackBreadth = track.maxTrackBreadth().isLength() && !track.maxTrackBreadth().isContentSized(); |
1434 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); | 1444 DCHECK(hasDefiniteMaxTrackBreadth || (track.minTrackBreadth().isLength() && !track.minTrackBreadth().isContentSized())); |
1435 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); | 1445 tracksSize += valueForLength(hasDefiniteMaxTrackBreadth ? track.maxTrack Breadth().length() : track.minTrackBreadth().length(), availableSize); |
1436 } | 1446 } |
1437 | 1447 |
1438 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when | 1448 // Add gutters as if there where only 1 auto repeat track. Gaps between auto repeat tracks will be added later when |
1439 // computing the repetitions. | 1449 // computing the repetitions. |
1440 LayoutUnit gapSize = gridGapForDirection(direction); | 1450 LayoutUnit gapSize = gridGapForDirection(direction); |
1441 tracksSize += gapSize * trackSizes.size(); | 1451 tracksSize += gapSize * trackSizes.size(); |
1442 | 1452 |
1443 LayoutUnit freeSpace = availableSize - tracksSize; | 1453 LayoutUnit freeSpace = availableSize - tracksSize; |
1444 if (freeSpace <= 0) | 1454 if (freeSpace <= 0) |
1445 return 1; | 1455 return 1; |
1446 | 1456 |
1447 size_t repetitions = 1 + (freeSpace / (autoRepeatTrackSize + gapSize)).toInt (); | 1457 size_t repetitions = 1 + (freeSpace / (autoRepeatTracksSize + gapSize)).toIn t(); |
1448 | 1458 |
1449 // Provided the grid container does not have a definite size or max-size in the relevant axis, | 1459 // Provided the grid container does not have a definite size or max-size in the relevant axis, |
1450 // if the min size is definite then the number of repetitions is the largest possible positive | 1460 // if the min size is definite then the number of repetitions is the largest possible positive |
1451 // integer that fulfills that minimum requirement. | 1461 // integer that fulfills that minimum requirement. |
1452 if (needsToFulfillMinimumSize) | 1462 if (needsToFulfillMinimumSize) |
1453 ++repetitions; | 1463 ++repetitions; |
1454 | 1464 |
1455 return repetitions; | 1465 return repetitions; |
1456 } | 1466 } |
1457 | 1467 |
1458 | 1468 |
1459 std::unique_ptr<LayoutGrid::OrderedTrackIndexSet> LayoutGrid::computeEmptyTracks ForAutoRepeat(GridTrackSizingDirection direction) const | 1469 std::unique_ptr<LayoutGrid::OrderedTrackIndexSet> LayoutGrid::computeEmptyTracks ForAutoRepeat(GridTrackSizingDirection direction) const |
1460 { | 1470 { |
1461 bool isRowAxis = direction == ForColumns; | 1471 bool isRowAxis = direction == ForColumns; |
1462 if ((isRowAxis && styleRef().gridAutoRepeatColumnsType() != AutoFit) | 1472 if ((isRowAxis && styleRef().gridAutoRepeatColumnsType() != AutoFit) |
1463 || (!isRowAxis && styleRef().gridAutoRepeatRowsType() != AutoFit)) | 1473 || (!isRowAxis && styleRef().gridAutoRepeatRowsType() != AutoFit)) |
1464 return nullptr; | 1474 return nullptr; |
1465 | 1475 |
1466 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; | 1476 std::unique_ptr<OrderedTrackIndexSet> emptyTrackIndexes; |
1467 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); | 1477 size_t insertionPoint = isRowAxis ? styleRef().gridAutoRepeatColumnsInsertio nPoint() : styleRef().gridAutoRepeatRowsInsertionPoint(); |
1478 auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns() : st yleRef().gridAutoRepeatRows(); | |
1468 size_t repetitions = autoRepeatCountForDirection(direction); | 1479 size_t repetitions = autoRepeatCountForDirection(direction); |
1469 size_t firstAutoRepeatTrack = insertionPoint + std::abs(isRowAxis ? m_smalle stColumnStart : m_smallestRowStart); | 1480 size_t firstAutoRepeatTrack = insertionPoint + std::abs(isRowAxis ? m_smalle stColumnStart : m_smallestRowStart); |
1470 size_t lastAutoRepeatTrack = firstAutoRepeatTrack + repetitions; | 1481 size_t lastAutoRepeatTrack = firstAutoRepeatTrack + repetitions * autoRepeat Tracks.size(); |
1471 | 1482 |
1472 if (m_gridItemArea.isEmpty()) { | 1483 if (m_gridItemArea.isEmpty()) { |
1473 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 1484 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
1474 for (size_t trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepe atTrack; ++trackIndex) | 1485 for (size_t trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepe atTrack; ++trackIndex) |
1475 emptyTrackIndexes->add(trackIndex); | 1486 emptyTrackIndexes->add(trackIndex); |
1476 } else { | 1487 } else { |
1477 for (size_t trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepe atTrack; ++trackIndex) { | 1488 for (size_t trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepe atTrack; ++trackIndex) { |
1478 GridIterator iterator(m_grid, direction, trackIndex); | 1489 GridIterator iterator(m_grid, direction, trackIndex); |
1479 if (!iterator.nextGridItem()) { | 1490 if (!iterator.nextGridItem()) { |
1480 if (!emptyTrackIndexes) | 1491 if (!emptyTrackIndexes) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1524 GridSpan majorAxisPositions = (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns : area.rows; | 1535 GridSpan majorAxisPositions = (autoPlacementMajorAxisDirection() == ForColumns) ? area.columns : area.rows; |
1525 if (majorAxisPositions.isIndefinite()) | 1536 if (majorAxisPositions.isIndefinite()) |
1526 autoMajorAxisAutoGridItems.append(child); | 1537 autoMajorAxisAutoGridItems.append(child); |
1527 else | 1538 else |
1528 specifiedMajorAxisAutoGridItems.append(child); | 1539 specifiedMajorAxisAutoGridItems.append(child); |
1529 continue; | 1540 continue; |
1530 } | 1541 } |
1531 insertItemIntoGrid(*child, area); | 1542 insertItemIntoGrid(*child, area); |
1532 } | 1543 } |
1533 | 1544 |
1534 DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount(*style (), m_autoRepeatRows)); | 1545 DCHECK_GE(gridRowCount(), GridPositionsResolver::explicitGridRowCount(*style (), autoRepeatTracksCount(ForRows))); |
jfernandez
2016/07/19 14:43:18
It seems that we are using the autoRepeatTracksCou
svillar
2016/07/20 07:22:30
I've been checking where we use m_autoRepeatColumn
| |
1535 DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount( *style(), m_autoRepeatColumns)); | 1546 DCHECK_GE(gridColumnCount(), GridPositionsResolver::explicitGridColumnCount( *style(), autoRepeatTracksCount(ForColumns))); |
1536 | 1547 |
1537 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); | 1548 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); |
1538 placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); | 1549 placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); |
1539 | 1550 |
1540 m_grid.shrinkToFit(); | 1551 m_grid.shrinkToFit(); |
1541 | 1552 |
1542 // Compute collapsable tracks for auto-fit. | 1553 // Compute collapsable tracks for auto-fit. |
1543 m_autoRepeatEmptyColumns = computeEmptyTracksForAutoRepeat(ForColumns); | 1554 m_autoRepeatEmptyColumns = computeEmptyTracksForAutoRepeat(ForColumns); |
1544 m_autoRepeatEmptyRows = computeEmptyTracksForAutoRepeat(ForRows); | 1555 m_autoRepeatEmptyRows = computeEmptyTracksForAutoRepeat(ForRows); |
1545 | 1556 |
1546 #if ENABLE(ASSERT) | 1557 #if ENABLE(ASSERT) |
1547 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { | 1558 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { |
1548 if (child->isOutOfFlowPositioned()) | 1559 if (child->isOutOfFlowPositioned()) |
1549 continue; | 1560 continue; |
1550 | 1561 |
1551 GridArea area = cachedGridArea(*child); | 1562 GridArea area = cachedGridArea(*child); |
1552 ASSERT(area.rows.isTranslatedDefinite() && area.columns.isTranslatedDefi nite()); | 1563 ASSERT(area.rows.isTranslatedDefinite() && area.columns.isTranslatedDefi nite()); |
1553 } | 1564 } |
1554 #endif | 1565 #endif |
1555 } | 1566 } |
1556 | 1567 |
1557 void LayoutGrid::populateExplicitGridAndOrderIterator() | 1568 void LayoutGrid::populateExplicitGridAndOrderIterator() |
1558 { | 1569 { |
1559 OrderIteratorPopulator populator(m_orderIterator); | 1570 OrderIteratorPopulator populator(m_orderIterator); |
1560 | 1571 |
1561 m_smallestRowStart = m_smallestColumnStart = 0; | 1572 m_smallestRowStart = m_smallestColumnStart = 0; |
1562 | 1573 |
1563 size_t maximumRowIndex = GridPositionsResolver::explicitGridRowCount(*style( ), m_autoRepeatRows); | 1574 size_t maximumRowIndex = GridPositionsResolver::explicitGridRowCount(*style( ), autoRepeatTracksCount(ForRows)); |
1564 size_t maximumColumnIndex = GridPositionsResolver::explicitGridColumnCount(* style(), m_autoRepeatColumns); | 1575 size_t maximumColumnIndex = GridPositionsResolver::explicitGridColumnCount(* style(), autoRepeatTracksCount(ForColumns)); |
1565 | 1576 |
1566 ASSERT(m_gridItemsIndexesMap.isEmpty()); | 1577 ASSERT(m_gridItemsIndexesMap.isEmpty()); |
1567 size_t childIndex = 0; | 1578 size_t childIndex = 0; |
1568 for (LayoutBox* child = firstChildBox(); child; child = child->nextInFlowSib lingBox()) { | 1579 for (LayoutBox* child = firstChildBox(); child; child = child->nextInFlowSib lingBox()) { |
1569 if (child->isOutOfFlowPositioned()) | 1580 if (child->isOutOfFlowPositioned()) |
1570 continue; | 1581 continue; |
1571 | 1582 |
1572 populator.collectChild(child); | 1583 populator.collectChild(child); |
1573 m_gridItemsIndexesMap.set(child, childIndex++); | 1584 m_gridItemsIndexesMap.set(child, childIndex++); |
1574 | 1585 |
1575 // This function bypasses the cache (cachedGridArea()) as it is used to build it. | 1586 // This function bypasses the cache (cachedGridArea()) as it is used to build it. |
1576 GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromS tyle(*style(), *child, ForRows, m_autoRepeatRows); | 1587 GridSpan rowPositions = GridPositionsResolver::resolveGridPositionsFromS tyle(*style(), *child, ForRows, autoRepeatTracksCount(ForRows)); |
1577 GridSpan columnPositions = GridPositionsResolver::resolveGridPositionsFr omStyle(*style(), *child, ForColumns, m_autoRepeatColumns); | 1588 GridSpan columnPositions = GridPositionsResolver::resolveGridPositionsFr omStyle(*style(), *child, ForColumns, autoRepeatTracksCount(ForColumns)); |
1578 m_gridItemArea.set(child, GridArea(rowPositions, columnPositions)); | 1589 m_gridItemArea.set(child, GridArea(rowPositions, columnPositions)); |
1579 | 1590 |
1580 // |positions| is 0 if we need to run the auto-placement algorithm. | 1591 // |positions| is 0 if we need to run the auto-placement algorithm. |
1581 if (!rowPositions.isIndefinite()) { | 1592 if (!rowPositions.isIndefinite()) { |
1582 m_smallestRowStart = std::min(m_smallestRowStart, rowPositions.untra nslatedStartLine()); | 1593 m_smallestRowStart = std::min(m_smallestRowStart, rowPositions.untra nslatedStartLine()); |
1583 maximumRowIndex = std::max<int>(maximumRowIndex, rowPositions.untran slatedEndLine()); | 1594 maximumRowIndex = std::max<int>(maximumRowIndex, rowPositions.untran slatedEndLine()); |
1584 } else { | 1595 } else { |
1585 // Grow the grid for items with a definite row span, getting the lar gest such span. | 1596 // Grow the grid for items with a definite row span, getting the lar gest such span. |
1586 size_t spanSize = GridPositionsResolver::spanSizeForAutoPlacedItem(* style(), *child, ForRows); | 1597 size_t spanSize = GridPositionsResolver::spanSizeForAutoPlacedItem(* style(), *child, ForRows); |
1587 maximumRowIndex = std::max(maximumRowIndex, spanSize); | 1598 maximumRowIndex = std::max(maximumRowIndex, spanSize); |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2539 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2550 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
2540 } | 2551 } |
2541 | 2552 |
2542 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2553 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2543 { | 2554 { |
2544 if (!m_gridItemArea.isEmpty()) | 2555 if (!m_gridItemArea.isEmpty()) |
2545 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2556 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2546 } | 2557 } |
2547 | 2558 |
2548 } // namespace blink | 2559 } // namespace blink |
OLD | NEW |