| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 434 |
| 435 LayoutSize previousSize = size(); | 435 LayoutSize previousSize = size(); |
| 436 | 436 |
| 437 updateLogicalWidth(); | 437 updateLogicalWidth(); |
| 438 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref
erredSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1); | 438 bool logicalHeightWasIndefinite = computeContentLogicalHeight(MainOrPref
erredSize, style()->logicalHeight(), LayoutUnit(-1)) == LayoutUnit(-1); |
| 439 | 439 |
| 440 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); | 440 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); |
| 441 | 441 |
| 442 // TODO(svillar): we won't need to do this once the intrinsic width comp
utation is isolated | 442 // TODO(svillar): we won't need to do this once the intrinsic width comp
utation is isolated |
| 443 // from the LayoutGrid object state (it should not touch any attribute)
(see crbug.com/627812) | 443 // from the LayoutGrid object state (it should not touch any attribute)
(see crbug.com/627812) |
| 444 size_t autoRepeatColumnsCount = computeAutoRepeatTracksCount(ForColumns)
; | 444 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack
sCount(ForColumns, TrackSizing)) |
| 445 if (m_autoRepeatColumns && m_autoRepeatColumns != autoRepeatColumnsCount
) | |
| 446 dirtyGrid(); | 445 dirtyGrid(); |
| 447 placeItemsOnGrid(autoRepeatColumnsCount); | 446 placeItemsOnGrid(TrackSizing); |
| 448 | 447 |
| 449 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 448 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 450 | 449 |
| 451 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. | 450 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. |
| 452 // At this point the logical width is always definite as the above call
to updateLogicalWidth() | 451 // At this point the logical width is always definite as the above call
to updateLogicalWidth() |
| 453 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code | 452 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code |
| 454 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve | 453 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve |
| 455 // heights properly (like for positioned items for example). | 454 // heights properly (like for positioned items for example). |
| 456 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 455 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); |
| 457 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); | 456 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 567 } |
| 569 if (nonEmptyTracksAfterEndLine) | 568 if (nonEmptyTracksAfterEndLine) |
| 570 gapAccumulator += gap; | 569 gapAccumulator += gap; |
| 571 } | 570 } |
| 572 | 571 |
| 573 return gapAccumulator; | 572 return gapAccumulator; |
| 574 } | 573 } |
| 575 | 574 |
| 576 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const | 575 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const |
| 577 { | 576 { |
| 578 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(styleRef().gridAutoRepeatCol
umns().size()); | 577 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); |
| 579 | 578 |
| 580 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 579 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
| 581 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 580 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); |
| 582 sizingData.sizingOperation = IntrinsicSizeComputation; | 581 sizingData.sizingOperation = IntrinsicSizeComputation; |
| 583 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL
ogicalWidth); | 582 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL
ogicalWidth); |
| 584 | 583 |
| 585 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr
acks.size()); | 584 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr
acks.size()); |
| 586 minLogicalWidth += totalGuttersSize; | 585 minLogicalWidth += totalGuttersSize; |
| 587 maxLogicalWidth += totalGuttersSize; | 586 maxLogicalWidth += totalGuttersSize; |
| 588 | 587 |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 { | 1376 { |
| 1378 RELEASE_ASSERT(area.rows.isTranslatedDefinite() && area.columns.isTranslated
Definite()); | 1377 RELEASE_ASSERT(area.rows.isTranslatedDefinite() && area.columns.isTranslated
Definite()); |
| 1379 ensureGridSize(area.rows.endLine(), area.columns.endLine()); | 1378 ensureGridSize(area.rows.endLine(), area.columns.endLine()); |
| 1380 | 1379 |
| 1381 for (const auto& row : area.rows) { | 1380 for (const auto& row : area.rows) { |
| 1382 for (const auto& column: area.columns) | 1381 for (const auto& column: area.columns) |
| 1383 m_grid[row][column].append(&child); | 1382 m_grid[row][column].append(&child); |
| 1384 } | 1383 } |
| 1385 } | 1384 } |
| 1386 | 1385 |
| 1387 size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection directi
on) const | 1386 size_t LayoutGrid::computeAutoRepeatTracksCount(GridTrackSizingDirection directi
on, SizingOperation sizingOperation) const |
| 1388 { | 1387 { |
| 1389 bool isRowAxis = direction == ForColumns; | 1388 bool isRowAxis = direction == ForColumns; |
| 1390 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns(
) : styleRef().gridAutoRepeatRows(); | 1389 const auto& autoRepeatTracks = isRowAxis ? styleRef().gridAutoRepeatColumns(
) : styleRef().gridAutoRepeatRows(); |
| 1391 size_t autoRepeatTrackListLength = autoRepeatTracks.size(); | 1390 size_t autoRepeatTrackListLength = autoRepeatTracks.size(); |
| 1392 | 1391 |
| 1393 if (!autoRepeatTrackListLength) | 1392 if (!autoRepeatTrackListLength) |
| 1394 return 0; | 1393 return 0; |
| 1395 | 1394 |
| 1396 LayoutUnit availableSize = isRowAxis ? availableLogicalWidth() : computeCont
entLogicalHeight(MainOrPreferredSize, styleRef().logicalHeight(), LayoutUnit(-1)
); | 1395 LayoutUnit availableSize; |
| 1397 if (availableSize == -1) { | 1396 if (isRowAxis) { |
| 1398 const Length& maxLength = isRowAxis ? styleRef().logicalMaxWidth() : sty
leRef().logicalMaxHeight(); | 1397 availableSize = sizingOperation == IntrinsicSizeComputation ? LayoutUnit
(-1) : availableLogicalWidth(); |
| 1399 if (!maxLength.isMaxSizeNone()) { | 1398 } else { |
| 1400 availableSize = isRowAxis | 1399 availableSize = computeContentLogicalHeight(MainOrPreferredSize, styleRe
f().logicalHeight(), LayoutUnit(-1)); |
| 1401 ? computeLogicalWidthUsing(MaxSize, maxLength, containingBlockLo
gicalWidthForContent(), containingBlock()) | 1400 if (availableSize == -1) { |
| 1402 : computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1)
); | 1401 const Length& maxLength = styleRef().logicalMaxHeight(); |
| 1402 if (!maxLength.isMaxSizeNone()) |
| 1403 availableSize = computeContentLogicalHeight(MaxSize, maxLength,
LayoutUnit(-1)); |
| 1404 } else { |
| 1405 availableSize = constrainLogicalHeightByMinMax(availableSize, Layout
Unit(-1)); |
| 1403 } | 1406 } |
| 1404 } else { | |
| 1405 availableSize = isRowAxis | |
| 1406 ? constrainLogicalWidthByMinMax(availableSize, availableLogicalWidth
(), containingBlock()) | |
| 1407 : constrainLogicalHeightByMinMax(availableSize, LayoutUnit(-1)); | |
| 1408 } | 1407 } |
| 1409 | 1408 |
| 1410 bool needsToFulfillMinimumSize = false; | 1409 bool needsToFulfillMinimumSize = false; |
| 1411 bool indefiniteMainAndMaxSizes = availableSize == LayoutUnit(-1); | 1410 bool indefiniteMainAndMaxSizes = availableSize == LayoutUnit(-1); |
| 1412 if (indefiniteMainAndMaxSizes) { | 1411 if (indefiniteMainAndMaxSizes) { |
| 1413 const Length& minSize = isRowAxis ? styleRef().logicalMinWidth() : style
Ref().logicalMinHeight(); | 1412 const Length& minSize = isRowAxis ? styleRef().logicalMinWidth() : style
Ref().logicalMinHeight(); |
| 1414 if (!minSize.isSpecified()) | 1413 if (!minSize.isSpecified()) |
| 1415 return autoRepeatTrackListLength; | 1414 return autoRepeatTrackListLength; |
| 1416 | 1415 |
| 1417 LayoutUnit containingBlockAvailableSize = isRowAxis ? containingBlockLog
icalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBord
erPadding); | 1416 LayoutUnit containingBlockAvailableSize = isRowAxis ? containingBlockLog
icalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBord
erPadding); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 if (!iterator.nextGridItem()) { | 1483 if (!iterator.nextGridItem()) { |
| 1485 if (!emptyTrackIndexes) | 1484 if (!emptyTrackIndexes) |
| 1486 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 1485 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
| 1487 emptyTrackIndexes->add(trackIndex); | 1486 emptyTrackIndexes->add(trackIndex); |
| 1488 } | 1487 } |
| 1489 } | 1488 } |
| 1490 } | 1489 } |
| 1491 return emptyTrackIndexes; | 1490 return emptyTrackIndexes; |
| 1492 } | 1491 } |
| 1493 | 1492 |
| 1494 void LayoutGrid::placeItemsOnGrid(size_t autoRepeatColumnsCount) | 1493 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) |
| 1495 { | 1494 { |
| 1496 if (!m_gridIsDirty) | 1495 if (!m_gridIsDirty) |
| 1497 return; | 1496 return; |
| 1498 | 1497 |
| 1499 ASSERT(m_gridItemArea.isEmpty()); | 1498 DCHECK(m_gridItemArea.isEmpty()); |
| 1499 DCHECK(m_gridItemsIndexesMap.isEmpty()); |
| 1500 | 1500 |
| 1501 m_autoRepeatColumns = autoRepeatColumnsCount; | 1501 if (sizingOperation == IntrinsicSizeComputation) |
| 1502 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows); | 1502 m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); |
| 1503 else |
| 1504 m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOpe
ration); |
| 1505 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); |
| 1503 | 1506 |
| 1504 populateExplicitGridAndOrderIterator(); | 1507 populateExplicitGridAndOrderIterator(); |
| 1505 | 1508 |
| 1506 // We clear the dirty bit here as the grid sizes have been updated. | 1509 // We clear the dirty bit here as the grid sizes have been updated. |
| 1507 m_gridIsDirty = false; | 1510 m_gridIsDirty = false; |
| 1508 | 1511 |
| 1509 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1512 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 1510 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1513 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 1511 m_hasAnyOrthogonalChild = false; | 1514 m_hasAnyOrthogonalChild = false; |
| 1512 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { | 1515 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; | 2610 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; |
| 2608 } | 2611 } |
| 2609 | 2612 |
| 2610 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2613 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2611 { | 2614 { |
| 2612 if (!m_gridItemArea.isEmpty()) | 2615 if (!m_gridItemArea.isEmpty()) |
| 2613 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2616 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2614 } | 2617 } |
| 2615 | 2618 |
| 2616 } // namespace blink | 2619 } // namespace blink |
| OLD | NEW |