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 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack
sCount(ForColumns)) | 444 size_t autoRepeatColumnsCount = computeAutoRepeatTracksCount(ForColumns)
; |
| 445 if (m_autoRepeatColumns && m_autoRepeatColumns != autoRepeatColumnsCount
) |
445 dirtyGrid(); | 446 dirtyGrid(); |
446 placeItemsOnGrid(TrackSizing); | 447 placeItemsOnGrid(autoRepeatColumnsCount); |
447 | 448 |
448 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 449 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
449 | 450 |
450 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. | 451 // 1- First, the track sizing algorithm is used to resolve the sizes of
the grid columns. |
451 // At this point the logical width is always definite as the above call
to updateLogicalWidth() | 452 // At this point the logical width is always definite as the above call
to updateLogicalWidth() |
452 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code | 453 // properly resolves intrinsic sizes. We cannot do the same for heights
though because many code |
453 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve | 454 // paths inside updateLogicalHeight() require a previous call to setLogi
calHeight() to resolve |
454 // heights properly (like for positioned items for example). | 455 // heights properly (like for positioned items for example). |
455 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); | 456 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); |
456 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); | 457 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC
olumns); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 568 } |
568 if (nonEmptyTracksAfterEndLine) | 569 if (nonEmptyTracksAfterEndLine) |
569 gapAccumulator += gap; | 570 gapAccumulator += gap; |
570 } | 571 } |
571 | 572 |
572 return gapAccumulator; | 573 return gapAccumulator; |
573 } | 574 } |
574 | 575 |
575 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const | 576 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo
utUnit& maxLogicalWidth) const |
576 { | 577 { |
577 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(IntrinsicSizeComputation); | 578 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(styleRef().gridAutoRepeatCol
umns().size()); |
578 | 579 |
579 GridSizingData sizingData(gridColumnCount(), gridRowCount()); | 580 GridSizingData sizingData(gridColumnCount(), gridRowCount()); |
580 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); | 581 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); |
581 sizingData.sizingOperation = IntrinsicSizeComputation; | 582 sizingData.sizingOperation = IntrinsicSizeComputation; |
582 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL
ogicalWidth); | 583 computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxL
ogicalWidth); |
583 | 584 |
584 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr
acks.size()); | 585 LayoutUnit totalGuttersSize = guttersSize(ForColumns, 0, sizingData.columnTr
acks.size()); |
585 minLogicalWidth += totalGuttersSize; | 586 minLogicalWidth += totalGuttersSize; |
586 maxLogicalWidth += totalGuttersSize; | 587 maxLogicalWidth += totalGuttersSize; |
587 | 588 |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 if (!iterator.nextGridItem()) { | 1484 if (!iterator.nextGridItem()) { |
1484 if (!emptyTrackIndexes) | 1485 if (!emptyTrackIndexes) |
1485 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 1486 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
1486 emptyTrackIndexes->add(trackIndex); | 1487 emptyTrackIndexes->add(trackIndex); |
1487 } | 1488 } |
1488 } | 1489 } |
1489 } | 1490 } |
1490 return emptyTrackIndexes; | 1491 return emptyTrackIndexes; |
1491 } | 1492 } |
1492 | 1493 |
1493 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) | 1494 void LayoutGrid::placeItemsOnGrid(size_t autoRepeatColumnsCount) |
1494 { | 1495 { |
1495 if (!m_gridIsDirty) | 1496 if (!m_gridIsDirty) |
1496 return; | 1497 return; |
1497 | 1498 |
1498 ASSERT(m_gridItemArea.isEmpty()); | 1499 ASSERT(m_gridItemArea.isEmpty()); |
1499 | 1500 |
1500 if (sizingOperation == IntrinsicSizeComputation) | 1501 m_autoRepeatColumns = autoRepeatColumnsCount; |
1501 m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); | |
1502 else | |
1503 m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns); | |
1504 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows); | 1502 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows); |
1505 | 1503 |
1506 populateExplicitGridAndOrderIterator(); | 1504 populateExplicitGridAndOrderIterator(); |
1507 | 1505 |
1508 // We clear the dirty bit here as the grid sizes have been updated. | 1506 // We clear the dirty bit here as the grid sizes have been updated. |
1509 m_gridIsDirty = false; | 1507 m_gridIsDirty = false; |
1510 | 1508 |
1511 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1509 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
1512 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1510 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
1513 m_hasAnyOrthogonalChild = false; | 1511 m_hasAnyOrthogonalChild = false; |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; | 2586 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc
ation; |
2589 } | 2587 } |
2590 | 2588 |
2591 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2589 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2592 { | 2590 { |
2593 if (!m_gridItemArea.isEmpty()) | 2591 if (!m_gridItemArea.isEmpty()) |
2594 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2592 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2595 } | 2593 } |
2596 | 2594 |
2597 } // namespace blink | 2595 } // namespace blink |
OLD | NEW |