Changeset 173620 in webkit for trunk/Source/WebCore/rendering/RenderGrid.cpp
- Timestamp:
- Sep 15, 2014, 7:20:46 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/Source/WebCore/rendering/RenderGrid.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/rendering/RenderGrid.cpp
r173427 r173620 532 532 } 533 533 534 class GridItemWithSpan { 535 public: 536 GridItemWithSpan(RenderBox& gridItem, GridCoordinate coordinate, GridTrackSizingDirection direction) 537 : m_gridItem(gridItem) 538 , m_coordinate(coordinate) 539 { 540 const GridSpan& span = (direction == ForRows) ? coordinate.rows : coordinate.columns; 541 m_span = span.resolvedFinalPosition.toInt() - span.resolvedInitialPosition.toInt() + 1; 542 } 543 544 RenderBox& gridItem() const { return m_gridItem; } 545 GridCoordinate coordinate() const { return m_coordinate; } 546 547 bool operator<(const GridItemWithSpan other) const 548 { 549 return m_span < other.m_span; 550 } 551 552 private: 553 std::reference_wrapper<RenderBox> m_gridItem; 554 GridCoordinate m_coordinate; 555 size_t m_span; 556 }; 557 534 558 void RenderGrid::resolveContentBasedTrackSizingFunctions(GridTrackSizingDirection direction, GridSizingData& sizingData) 535 559 { … … 538 562 for (size_t i = 0; i < sizingData.contentSizedTracksIndex.size(); ++i) { 539 563 GridIterator iterator(m_grid, direction, sizingData.contentSizedTracksIndex[i]); 564 HashSet<RenderBox*> itemsSet; 565 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; 566 540 567 while (RenderBox* gridItem = iterator.nextGridItem()) { 541 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, *gridItem, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); 542 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, *gridItem, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); 543 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, *gridItem, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); 544 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, *gridItem, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); 568 if (itemsSet.add(gridItem).isNewEntry) 569 itemsSortedByIncreasingSpan.append(GridItemWithSpan(*gridItem, cachedGridCoordinate(*gridItem), direction)); 570 } 571 std::stable_sort(itemsSortedByIncreasingSpan.begin(), itemsSortedByIncreasingSpan.end()); 572 573 for (auto& itemWithSpan : itemsSortedByIncreasingSpan) { 574 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, itemWithSpan, &GridTrackSize::hasMinOrMaxContentMinTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); 575 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, itemWithSpan, &GridTrackSize::hasMaxContentMinTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::usedBreadth, &GridTrack::growUsedBreadth); 576 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, itemWithSpan, &GridTrackSize::hasMinOrMaxContentMaxTrackBreadth, &RenderGrid::minContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); 577 resolveContentBasedTrackSizingFunctionsForItems(direction, sizingData, itemWithSpan, &GridTrackSize::hasMaxContentMaxTrackBreadth, &RenderGrid::maxContentForChild, &GridTrack::maxBreadthIfNotInfinite, &GridTrack::growMaxBreadth); 545 578 } 546 579 … … 551 584 } 552 585 553 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirection direction, GridSizingData& sizingData, RenderBox& gridItem, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction)554 { 555 const GridCoordinate coordinate = cachedGridCoordinate(gridItem);586 void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(GridTrackSizingDirection direction, GridSizingData& sizingData, GridItemWithSpan& gridItemWithSpan, FilterFunction filterFunction, SizingFunction sizingFunction, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction) 587 { 588 const GridCoordinate& coordinate = gridItemWithSpan.coordinate(); 556 589 const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPosition; 557 590 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition; … … 570 603 return; 571 604 572 LayoutUnit additionalBreadthSpace = (this->*sizingFunction)(gridItem , direction, sizingData.columnTracks);605 LayoutUnit additionalBreadthSpace = (this->*sizingFunction)(gridItemWithSpan.gridItem(), direction, sizingData.columnTracks); 573 606 for (GridResolvedPosition trackPositionForSpace = initialTrackPosition; trackPositionForSpace <= finalTrackPosition; ++trackPositionForSpace) { 574 607 GridTrack& track = (direction == ForColumns) ? sizingData.columnTracks[trackPositionForSpace.toInt()] : sizingData.rowTracks[trackPositionForSpace.toInt()];
Note:
See TracChangeset
for help on using the changeset viewer.