Chromium Code Reviews| 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(-1); |
|
Manuel Rego
2016/08/23 07:43:03
Mmm, this means that for columns during intrinsic
svillar
2016/08/25 09:33:10
There is no intrinsic size computation with fixed
Manuel Rego
2016/08/25 09:59:35
Thanks for the explanations I knew I was missing s
| |
| 1397 if (availableSize == -1) { | 1396 // Widths are always definite except during intrinsic size computation. For heights we need to |
| 1398 const Length& maxLength = isRowAxis ? styleRef().logicalMaxWidth() : sty leRef().logicalMaxHeight(); | 1397 // check whether the computed logical height is -1 or not to determine it. |
| 1399 if (!maxLength.isMaxSizeNone()) { | 1398 if (sizingOperation != IntrinsicSizeComputation || !isRowAxis) { |
| 1400 availableSize = isRowAxis | 1399 if (isRowAxis) { |
|
Manuel Rego
2016/08/23 07:43:03
Just in case I was wrong in my previous comment,
I
svillar
2016/08/25 09:33:10
Acknowledged.
| |
| 1401 ? computeLogicalWidthUsing(MaxSize, maxLength, containingBlockLo gicalWidthForContent(), containingBlock()) | 1400 DCHECK_NE(sizingOperation, IntrinsicSizeComputation); |
|
jfernandez
2016/08/22 14:44:48
Where is this case defined in the new logic ? Is i
svillar
2016/08/22 16:01:52
You can see it defined for rows in the else block
jfernandez
2016/08/22 16:20:20
got it now, thanks.
|
jfernandez
2016/08/22 14:44:48
Wouldn't be clearer if we define the DCHECK like i
svillar
2016/08/22 16:01:52
I really don't get what you mean. Could you rephra
jfernandez
2016/08/22 16:20:20
I was mistaken, forget about this suggestion.
|
| 1402 : computeContentLogicalHeight(MaxSize, maxLength, LayoutUnit(-1) ); | 1401 availableSize = availableLogicalWidth(); |
| 1402 } else { | |
| 1403 availableSize = computeContentLogicalHeight(MainOrPreferredSize, sty leRef().logicalHeight(), LayoutUnit(-1)); | |
| 1404 if (availableSize == -1) { | |
| 1405 const Length& maxLength = styleRef().logicalMaxHeight(); | |
| 1406 if (!maxLength.isMaxSizeNone()) | |
| 1407 availableSize = computeContentLogicalHeight(MaxSize, maxLeng th, LayoutUnit(-1)); | |
| 1408 } else { | |
| 1409 availableSize = constrainLogicalHeightByMinMax(availableSize, La youtUnit(-1)); | |
| 1410 } | |
| 1403 } | 1411 } |
| 1404 } else { | |
| 1405 availableSize = isRowAxis | |
| 1406 ? constrainLogicalWidthByMinMax(availableSize, availableLogicalWidth (), containingBlock()) | |
| 1407 : 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 autoRepeatTrackListLength; | 1419 return autoRepeatTrackListLength; |
| 1416 | 1420 |
| 1417 LayoutUnit containingBlockAvailableSize = isRowAxis ? containingBlockLog icalWidthForContent() : containingBlockLogicalHeightForContent(ExcludeMarginBord erPadding); | 1421 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()) { | 1488 if (!iterator.nextGridItem()) { |
| 1485 if (!emptyTrackIndexes) | 1489 if (!emptyTrackIndexes) |
| 1486 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); | 1490 emptyTrackIndexes = wrapUnique(new OrderedTrackIndexSet); |
| 1487 emptyTrackIndexes->add(trackIndex); | 1491 emptyTrackIndexes->add(trackIndex); |
| 1488 } | 1492 } |
| 1489 } | 1493 } |
| 1490 } | 1494 } |
| 1491 return emptyTrackIndexes; | 1495 return emptyTrackIndexes; |
| 1492 } | 1496 } |
| 1493 | 1497 |
| 1494 void LayoutGrid::placeItemsOnGrid(size_t autoRepeatColumnsCount) | 1498 void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) |
| 1495 { | 1499 { |
| 1496 if (!m_gridIsDirty) | 1500 if (!m_gridIsDirty) |
| 1497 return; | 1501 return; |
| 1498 | 1502 |
| 1499 ASSERT(m_gridItemArea.isEmpty()); | 1503 DCHECK(m_gridItemArea.isEmpty()); |
| 1504 DCHECK(m_gridItemsIndexesMap.isEmpty()); | |
| 1500 | 1505 |
| 1501 m_autoRepeatColumns = autoRepeatColumnsCount; | 1506 if (sizingOperation == IntrinsicSizeComputation) |
| 1502 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows); | 1507 m_autoRepeatColumns = styleRef().gridAutoRepeatColumns().size(); |
| 1508 else | |
| 1509 m_autoRepeatColumns = computeAutoRepeatTracksCount(ForColumns, sizingOpe ration); | |
| 1510 m_autoRepeatRows = computeAutoRepeatTracksCount(ForRows, sizingOperation); | |
| 1503 | 1511 |
| 1504 populateExplicitGridAndOrderIterator(); | 1512 populateExplicitGridAndOrderIterator(); |
| 1505 | 1513 |
| 1506 // We clear the dirty bit here as the grid sizes have been updated. | 1514 // We clear the dirty bit here as the grid sizes have been updated. |
| 1507 m_gridIsDirty = false; | 1515 m_gridIsDirty = false; |
| 1508 | 1516 |
| 1509 Vector<LayoutBox*> autoMajorAxisAutoGridItems; | 1517 Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
| 1510 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; | 1518 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
| 1511 m_hasAnyOrthogonalChild = false; | 1519 m_hasAnyOrthogonalChild = false; |
| 1512 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { | 1520 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; | 2615 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
| 2608 } | 2616 } |
| 2609 | 2617 |
| 2610 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2618 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
| 2611 { | 2619 { |
| 2612 if (!m_gridItemArea.isEmpty()) | 2620 if (!m_gridItemArea.isEmpty()) |
| 2613 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2621 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2614 } | 2622 } |
| 2615 | 2623 |
| 2616 } // namespace blink | 2624 } // namespace blink |
| OLD | NEW |