| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef RenderGrid_h | 26 #ifndef RenderGrid_h |
| 27 #define RenderGrid_h | 27 #define RenderGrid_h |
| 28 | 28 |
| 29 #include "core/rendering/OrderIterator.h" |
| 29 #include "core/rendering/RenderBlock.h" | 30 #include "core/rendering/RenderBlock.h" |
| 30 | 31 |
| 31 namespace WebCore { | 32 namespace WebCore { |
| 32 | 33 |
| 33 class GridCoordinate; | 34 class GridCoordinate; |
| 34 class GridSpan; | 35 class GridSpan; |
| 35 class GridTrack; | 36 class GridTrack; |
| 36 | 37 |
| 37 enum GridPositionSide { | 38 enum GridPositionSide { |
| 38 ColumnStartSide, | 39 ColumnStartSide, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 65 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack>
& columnTracks, Vector<GridTrack>& rowTracks); | 66 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack>
& columnTracks, Vector<GridTrack>& rowTracks); |
| 66 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen
gth&) const; | 67 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen
gth&) const; |
| 67 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen
gth&, LayoutUnit usedBreadth) const; | 68 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen
gth&, LayoutUnit usedBreadth) const; |
| 68 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L
ength&) const; | 69 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L
ength&) const; |
| 69 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr
idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic
alSpace); | 70 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr
idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic
alSpace); |
| 70 | 71 |
| 71 void growGrid(TrackSizingDirection); | 72 void growGrid(TrackSizingDirection); |
| 72 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack); | 73 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack); |
| 73 void insertItemIntoGrid(RenderBox*, const GridCoordinate&); | 74 void insertItemIntoGrid(RenderBox*, const GridCoordinate&); |
| 74 void placeItemsOnGrid(); | 75 void placeItemsOnGrid(); |
| 76 void populateExplicitGridAndOrderIterator(); |
| 75 void placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*>); | 77 void placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*>); |
| 76 void placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*>); | 78 void placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*>); |
| 77 void placeAutoMajorAxisItemOnGrid(RenderBox*); | 79 void placeAutoMajorAxisItemOnGrid(RenderBox*); |
| 78 TrackSizingDirection autoPlacementMajorAxisDirection() const; | 80 TrackSizingDirection autoPlacementMajorAxisDirection() const; |
| 79 TrackSizingDirection autoPlacementMinorAxisDirection() const; | 81 TrackSizingDirection autoPlacementMinorAxisDirection() const; |
| 80 | 82 |
| 81 void layoutGridItems(); | 83 void layoutGridItems(); |
| 82 void clearGrid(); | 84 void clearGrid(); |
| 83 | 85 |
| 84 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox*, TrackSizingDir
ection, Vector<GridTrack>&); | 86 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox*, TrackSizingDir
ection, Vector<GridTrack>&); |
| 85 typedef LayoutUnit (GridTrack::* AccumulatorGetter)() const; | 87 typedef LayoutUnit (GridTrack::* AccumulatorGetter)() const; |
| 86 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); | 88 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); |
| 87 typedef bool (GridTrackSize::* FilterFunction)() const; | 89 typedef bool (GridTrackSize::* FilterFunction)() const; |
| 88 void resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection, V
ector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, RenderBox*, Filter
Function, SizingFunction, AccumulatorGetter, AccumulatorGrowFunction); | 90 void resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection, V
ector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, RenderBox*, Filter
Function, SizingFunction, AccumulatorGetter, AccumulatorGrowFunction); |
| 89 void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracks
ForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, LayoutUnit
& availableLogicalSpace); | 91 void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracks
ForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, LayoutUnit
& availableLogicalSpace); |
| 90 | 92 |
| 91 double computeNormalizedFractionBreadth(Vector<GridTrack>&, TrackSizingDirec
tion, LayoutUnit availableLogicalSpace) const; | 93 double computeNormalizedFractionBreadth(Vector<GridTrack>&, TrackSizingDirec
tion, LayoutUnit availableLogicalSpace) const; |
| 92 | 94 |
| 93 const GridTrackSize& gridTrackSize(TrackSizingDirection, size_t) const; | 95 const GridTrackSize& gridTrackSize(TrackSizingDirection, size_t) const; |
| 94 size_t explicitGridColumnCount() const; | 96 size_t explicitGridColumnCount() const; |
| 95 size_t explicitGridRowCount() const; | 97 size_t explicitGridRowCount() const; |
| 96 size_t explicitGridSizeForSide(GridPositionSide) const; | 98 size_t explicitGridSizeForSide(GridPositionSide) const; |
| 97 size_t maximumIndexInDirection(TrackSizingDirection) const; | |
| 98 | 99 |
| 99 LayoutUnit logicalContentHeightForChild(RenderBox*, Vector<GridTrack>&); | 100 LayoutUnit logicalContentHeightForChild(RenderBox*, Vector<GridTrack>&); |
| 100 LayoutUnit minContentForChild(RenderBox*, TrackSizingDirection, Vector<GridT
rack>& columnTracks); | 101 LayoutUnit minContentForChild(RenderBox*, TrackSizingDirection, Vector<GridT
rack>& columnTracks); |
| 101 LayoutUnit maxContentForChild(RenderBox*, TrackSizingDirection, Vector<GridT
rack>& columnTracks); | 102 LayoutUnit maxContentForChild(RenderBox*, TrackSizingDirection, Vector<GridT
rack>& columnTracks); |
| 102 LayoutPoint findChildLogicalPosition(RenderBox*, const Vector<GridTrack>& co
lumnTracks, const Vector<GridTrack>& rowTracks); | 103 LayoutPoint findChildLogicalPosition(RenderBox*, const Vector<GridTrack>& co
lumnTracks, const Vector<GridTrack>& rowTracks); |
| 103 GridCoordinate cachedGridCoordinate(const RenderBox*) const; | 104 GridCoordinate cachedGridCoordinate(const RenderBox*) const; |
| 104 | 105 |
| 105 GridSpan resolveGridPositionsFromAutoPlacementPosition(const RenderBox*, Tra
ckSizingDirection, size_t) const; | 106 GridSpan resolveGridPositionsFromAutoPlacementPosition(const RenderBox*, Tra
ckSizingDirection, size_t) const; |
| 106 PassOwnPtr<GridSpan> resolveGridPositionsFromStyle(const RenderBox*, TrackSi
zingDirection) const; | 107 PassOwnPtr<GridSpan> resolveGridPositionsFromStyle(const RenderBox*, TrackSi
zingDirection) const; |
| 107 size_t resolveNamedGridLinePositionFromStyle(const GridPosition&, GridPositi
onSide) const; | 108 size_t resolveNamedGridLinePositionFromStyle(const GridPosition&, GridPositi
onSide) const; |
| 108 size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) c
onst; | 109 size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) c
onst; |
| 109 PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(size_t resol
vedOppositePosition, const GridPosition&, GridPositionSide) const; | 110 PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(size_t resol
vedOppositePosition, const GridPosition&, GridPositionSide) const; |
| 110 | 111 |
| 111 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirect
ion, const Vector<GridTrack>&) const; | 112 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirect
ion, const Vector<GridTrack>&) const; |
| 112 | 113 |
| 114 virtual void paintChildren(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL; |
| 115 |
| 113 #ifndef NDEBUG | 116 #ifndef NDEBUG |
| 114 bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<Gr
idTrack>&); | 117 bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<Gr
idTrack>&); |
| 115 bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmp
ty(); } | 118 bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmp
ty(); } |
| 116 #endif | 119 #endif |
| 117 | 120 |
| 118 size_t gridColumnCount() const | 121 size_t gridColumnCount() const |
| 119 { | 122 { |
| 120 ASSERT(gridWasPopulated()); | 123 ASSERT(gridWasPopulated()); |
| 121 return m_grid[0].size(); | 124 return m_grid[0].size(); |
| 122 } | 125 } |
| 123 size_t gridRowCount() const | 126 size_t gridRowCount() const |
| 124 { | 127 { |
| 125 ASSERT(gridWasPopulated()); | 128 ASSERT(gridWasPopulated()); |
| 126 return m_grid.size(); | 129 return m_grid.size(); |
| 127 } | 130 } |
| 128 | 131 |
| 129 Vector<Vector<Vector<RenderBox*, 1> > > m_grid; | 132 Vector<Vector<Vector<RenderBox*, 1> > > m_grid; |
| 130 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; | 133 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; |
| 134 OrderIterator m_orderIterator; |
| 131 }; | 135 }; |
| 132 | 136 |
| 133 } // namespace WebCore | 137 } // namespace WebCore |
| 134 | 138 |
| 135 #endif // RenderGrid_h | 139 #endif // RenderGrid_h |
| OLD | NEW |