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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 , rowTracks(gridRowCount) | 241 , rowTracks(gridRowCount) |
242 { | 242 { |
243 } | 243 } |
244 | 244 |
245 Vector<GridTrack> columnTracks; | 245 Vector<GridTrack> columnTracks; |
246 Vector<GridTrack> rowTracks; | 246 Vector<GridTrack> rowTracks; |
247 Vector<size_t> contentSizedTracksIndex; | 247 Vector<size_t> contentSizedTracksIndex; |
248 | 248 |
249 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. | 249 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. |
250 Vector<GridTrack*> filteredTracks; | 250 Vector<GridTrack*> filteredTracks; |
251 WillBeHeapVector<GridItemWithSpan> itemsSortedByIncreasingSpan; | 251 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; |
252 Vector<GridTrack*> growBeyondGrowthLimitsTracks; | 252 Vector<GridTrack*> growBeyondGrowthLimitsTracks; |
253 }; | 253 }; |
254 | 254 |
255 RenderGrid::RenderGrid(Element* element) | 255 RenderGrid::RenderGrid(Element* element) |
256 : RenderBlock(element) | 256 : RenderBlock(element) |
257 , m_gridIsDirty(true) | 257 , m_gridIsDirty(true) |
258 , m_orderIterator(this) | 258 , m_orderIterator(this) |
259 { | 259 { |
260 ASSERT(!childrenInline()); | 260 ASSERT(!childrenInline()); |
261 } | 261 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 | 659 |
660 return logicalHeightForChild(child, columnTracks); | 660 return logicalHeightForChild(child, columnTracks); |
661 } | 661 } |
662 | 662 |
663 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or | 663 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or |
664 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class | 664 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class |
665 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a | 665 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a |
666 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an | 666 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an |
667 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). | 667 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). |
668 class GridItemWithSpan { | 668 class GridItemWithSpan { |
669 ALLOW_ONLY_INLINE_ALLOCATION(); | 669 ALLOW_ONLY_INLINE_ALLOCATION(); |
haraken
2015/02/04 05:48:56
You can drop ALLOW_ONLY_INLINE_ALLOCATION().
sof
2015/02/04 08:44:31
Done.
| |
670 public: | 670 public: |
671 GridItemWithSpan(RenderBox& gridItem, const GridCoordinate& coordinate, Grid TrackSizingDirection direction) | 671 GridItemWithSpan(RenderBox& gridItem, const GridCoordinate& coordinate, Grid TrackSizingDirection direction) |
672 : m_gridItem(gridItem) | 672 : m_gridItem(&gridItem) |
673 , m_coordinate(coordinate) | 673 , m_coordinate(coordinate) |
674 { | 674 { |
675 const GridSpan& span = (direction == ForRows) ? coordinate.rows : coordi nate.columns; | 675 const GridSpan& span = (direction == ForRows) ? coordinate.rows : coordi nate.columns; |
676 m_span = span.resolvedFinalPosition.toInt() - span.resolvedInitialPositi on.toInt() + 1; | 676 m_span = span.resolvedFinalPosition.toInt() - span.resolvedInitialPositi on.toInt() + 1; |
677 } | 677 } |
678 | 678 |
679 RenderBox& gridItem() const { return *m_gridItem; } | 679 RenderBox& gridItem() const { return *m_gridItem; } |
680 GridCoordinate coordinate() const { return m_coordinate; } | 680 GridCoordinate coordinate() const { return m_coordinate; } |
681 #if ENABLE(ASSERT) | 681 #if ENABLE(ASSERT) |
682 size_t span() const { return m_span; } | 682 size_t span() const { return m_span; } |
683 #endif | 683 #endif |
684 | 684 |
685 bool operator<(const GridItemWithSpan other) const { return m_span < other.m _span; } | 685 bool operator<(const GridItemWithSpan other) const { return m_span < other.m _span; } |
686 | 686 |
687 void trace(Visitor* visitor) | |
688 { | |
689 visitor->trace(m_gridItem); | |
690 } | |
691 | |
692 private: | 687 private: |
693 RawPtrWillBeMember<RenderBox> m_gridItem; | 688 RenderBox* m_gridItem; |
694 GridCoordinate m_coordinate; | 689 GridCoordinate m_coordinate; |
695 size_t m_span; | 690 size_t m_span; |
696 }; | 691 }; |
697 | 692 |
698 bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridCoordinate& co ordinate, GridTrackSizingDirection direction) const | 693 bool RenderGrid::spanningItemCrossesFlexibleSizedTracks(const GridCoordinate& co ordinate, GridTrackSizingDirection direction) const |
699 { | 694 { |
700 const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo sition; | 695 const GridResolvedPosition initialTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedInitialPosition : coordinate.rows.resolvedInitialPo sition; |
701 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition ; | 696 const GridResolvedPosition finalTrackPosition = (direction == ForColumns) ? coordinate.columns.resolvedFinalPosition : coordinate.rows.resolvedFinalPosition ; |
702 | 697 |
703 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n <= finalTrackPosition; ++trackPosition) { | 698 for (GridResolvedPosition trackPosition = initialTrackPosition; trackPositio n <= finalTrackPosition; ++trackPosition) { |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1736 if (isOutOfFlowPositioned()) | 1731 if (isOutOfFlowPositioned()) |
1737 return "RenderGrid (positioned)"; | 1732 return "RenderGrid (positioned)"; |
1738 if (isAnonymous()) | 1733 if (isAnonymous()) |
1739 return "RenderGrid (generated)"; | 1734 return "RenderGrid (generated)"; |
1740 if (isRelPositioned()) | 1735 if (isRelPositioned()) |
1741 return "RenderGrid (relative positioned)"; | 1736 return "RenderGrid (relative positioned)"; |
1742 return "RenderGrid"; | 1737 return "RenderGrid"; |
1743 } | 1738 } |
1744 | 1739 |
1745 } // namespace blink | 1740 } // namespace blink |
OLD | NEW |