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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 { | 559 { |
560 return (side == ColumnStartSide || side == ColumnEndSide) ? explicitGridColu mnCount() : explicitGridRowCount(); | 560 return (side == ColumnStartSide || side == ColumnEndSide) ? explicitGridColu mnCount() : explicitGridRowCount(); |
561 } | 561 } |
562 | 562 |
563 LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox* child, Vector<Gri dTrack>& columnTracks) | 563 LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox* child, Vector<Gri dTrack>& columnTracks) |
564 { | 564 { |
565 SubtreeLayoutScope layoutScope(child); | 565 SubtreeLayoutScope layoutScope(child); |
566 if (child->style()->logicalHeight().isPercent()) | 566 if (child->style()->logicalHeight().isPercent()) |
567 layoutScope.setNeedsLayout(child); | 567 layoutScope.setNeedsLayout(child); |
568 | 568 |
569 child->setOverrideContainingBlockContentLogicalWidth(gridAreaBreadthForChild (child, ForColumns, columnTracks)); | |
570 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is | 569 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is |
571 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). | 570 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). |
572 child->setOverrideContainingBlockContentLogicalHeight(-1); | 571 child->setOverrideContainingBlockContentLogicalHeight(-1); |
573 child->layoutIfNeeded(); | 572 child->layoutIfNeeded(); |
574 return child->logicalHeight(); | 573 return child->logicalHeight(); |
575 } | 574 } |
576 | 575 |
577 LayoutUnit RenderGrid::minContentForChild(RenderBox* child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) | 576 LayoutUnit RenderGrid::minContentForChild(RenderBox* child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) |
578 { | 577 { |
579 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode(); | 578 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizo ntalWritingMode(); |
(...skipping 28 matching lines...) Expand all Loading... | |
608 | 607 |
609 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) | 608 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirectio n direction, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) |
610 { | 609 { |
611 // FIXME: Split the grid tracks into groups that doesn't overlap a <flex> gr id track (crbug.com/235258). | 610 // FIXME: Split the grid tracks into groups that doesn't overlap a <flex> gr id track (crbug.com/235258). |
612 | 611 |
613 // FIXME: Per step 2 of the specification, we should order the grid items by increasing span. | 612 // FIXME: Per step 2 of the specification, we should order the grid items by increasing span. |
614 | 613 |
615 for (size_t i = 0; i < sizingData.contentSizedTracksIndex.size(); ++i) { | 614 for (size_t i = 0; i < sizingData.contentSizedTracksIndex.size(); ++i) { |
616 GridIterator iterator(m_grid, direction, sizingData.contentSizedTracksIn dex[i]); | 615 GridIterator iterator(m_grid, direction, sizingData.contentSizedTracksIn dex[i]); |
617 while (RenderBox* gridItem = iterator.nextGridItem()) { | 616 while (RenderBox* gridItem = iterator.nextGridItem()) { |
617 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = gridItem- >hasOverrideContainingBlockLogicalWidth() ? gridItem->overrideContainingBlockCon tentLogicalWidth() : LayoutUnit(); | |
618 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBrea dthForChild(gridItem, ForColumns, sizingData.columnTracks); | |
619 | |
620 SubtreeLayoutScope layoutScope(gridItem); | |
621 if ((oldOverrideContainingBlockContentLogicalWidth != overrideContai ningBlockContentLogicalWidth) && breathIsFlexOrContentSizedForChild(gridItem, Fo rColumns)) | |
622 layoutScope.setNeedsLayout(gridItem); | |
623 | |
624 gridItem->setOverrideContainingBlockContentLogicalWidth(overrideCont ainingBlockContentLogicalWidth); | |
625 gridItem->layoutIfNeeded(); | |
Julien - ping for review
2014/02/07 00:13:57
I think I understand the problem now. The original
| |
626 | |
618 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); | 627 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); |
619 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); | 628 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); |
620 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth ); | 629 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::min ContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth ); |
621 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); | 630 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingDat a, gridItem, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxConte ntForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); |
622 } | 631 } |
623 | 632 |
624 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[i ] : sizingData.rowTracks[i]; | 633 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[i ] : sizingData.rowTracks[i]; |
625 if (track.m_maxBreadth == infinity) | 634 if (track.m_maxBreadth == infinity) |
626 track.m_maxBreadth = track.m_usedBreadth; | 635 track.m_maxBreadth = track.m_usedBreadth; |
627 } | 636 } |
628 } | 637 } |
629 | 638 |
639 bool RenderGrid::breathIsFlexOrContentSizedForChild(RenderBox* child, GridTrackS izingDirection direction) const | |
Julien - ping for review
2014/02/07 00:13:57
If you think of it, this check is unneeded as we o
| |
640 { | |
641 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
642 const size_t initial = (direction == ForColumns) ? coordinate.columns.initia lPositionIndex : coordinate.rows.initialPositionIndex; | |
643 const size_t final = (direction == ForColumns) ? coordinate.columns.finalPos itionIndex : coordinate.rows.finalPositionIndex; | |
644 for (size_t i = initial; i <= final; i++) { | |
645 const GridTrackSize& trackSize = gridTrackSize(direction, i); | |
646 if (trackSize.maxTrackBreadth().isFlex() || trackSize.maxTrackBreadth(). isContentSized()) | |
647 return true; | |
648 } | |
649 return false; | |
650 } | |
651 | |
630 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, RenderBox* gridItem, FilterFunc tion filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGette r, AccumulatorGrowFunction trackGrowthFunction) | 652 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizing Direction direction, GridSizingData& sizingData, RenderBox* gridItem, FilterFunc tion filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGette r, AccumulatorGrowFunction trackGrowthFunction) |
631 { | 653 { |
632 const GridCoordinate coordinate = cachedGridCoordinate(gridItem); | 654 const GridCoordinate coordinate = cachedGridCoordinate(gridItem); |
633 const size_t initialTrackIndex = (direction == ForColumns) ? coordinate.colu mns.initialPositionIndex : coordinate.rows.initialPositionIndex; | 655 const size_t initialTrackIndex = (direction == ForColumns) ? coordinate.colu mns.initialPositionIndex : coordinate.rows.initialPositionIndex; |
634 const size_t finalTrackIndex = (direction == ForColumns) ? coordinate.column s.finalPositionIndex : coordinate.rows.finalPositionIndex; | 656 const size_t finalTrackIndex = (direction == ForColumns) ? coordinate.column s.finalPositionIndex : coordinate.rows.finalPositionIndex; |
635 | 657 |
636 sizingData.filteredTracks.shrink(0); | 658 sizingData.filteredTracks.shrink(0); |
637 for (size_t trackIndex = initialTrackIndex; trackIndex <= finalTrackIndex; + +trackIndex) { | 659 for (size_t trackIndex = initialTrackIndex; trackIndex <= finalTrackIndex; + +trackIndex) { |
638 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex); | 660 const GridTrackSize& trackSize = gridTrackSize(direction, trackIndex); |
639 if (!(trackSize.*filterFunction)()) | 661 if (!(trackSize.*filterFunction)()) |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1315 if (isOutOfFlowPositioned()) | 1337 if (isOutOfFlowPositioned()) |
1316 return "RenderGrid (positioned)"; | 1338 return "RenderGrid (positioned)"; |
1317 if (isAnonymous()) | 1339 if (isAnonymous()) |
1318 return "RenderGrid (generated)"; | 1340 return "RenderGrid (generated)"; |
1319 if (isRelPositioned()) | 1341 if (isRelPositioned()) |
1320 return "RenderGrid (relative positioned)"; | 1342 return "RenderGrid (relative positioned)"; |
1321 return "RenderGrid"; | 1343 return "RenderGrid"; |
1322 } | 1344 } |
1323 | 1345 |
1324 } // namespace WebCore | 1346 } // namespace WebCore |
OLD | NEW |