| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 RenderBlock::addChild(newChild, beforeChild); | 204 RenderBlock::addChild(newChild, beforeChild); |
| 205 | 205 |
| 206 if (gridIsDirty()) | 206 if (gridIsDirty()) |
| 207 return; | 207 return; |
| 208 | 208 |
| 209 if (!newChild->isBox()) { | 209 if (!newChild->isBox()) { |
| 210 dirtyGrid(); | 210 dirtyGrid(); |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 | 213 |
| 214 if (style()->gridAutoFlow() != AutoFlowNone) { | 214 // FIXME: Implement properly "stack" value in auto-placement algorithm. |
| 215 if (!style()->isGridAutoFlowAlgorithmStack()) { |
| 215 // The grid needs to be recomputed as it might contain auto-placed items
that will change their position. | 216 // The grid needs to be recomputed as it might contain auto-placed items
that will change their position. |
| 216 dirtyGrid(); | 217 dirtyGrid(); |
| 217 return; | 218 return; |
| 218 } | 219 } |
| 219 | 220 |
| 220 RenderBox* newChildBox = toRenderBox(newChild); | 221 RenderBox* newChildBox = toRenderBox(newChild); |
| 221 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr
omStyle(*style(), *newChildBox, ForRows); | 222 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr
omStyle(*style(), *newChildBox, ForRows); |
| 222 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition
sFromStyle(*style(), *newChildBox, ForColumns); | 223 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition
sFromStyle(*style(), *newChildBox, ForColumns); |
| 223 if (!rowPositions || !columnPositions) { | 224 if (!rowPositions || !columnPositions) { |
| 224 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. | 225 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 253 | 254 |
| 254 void RenderGrid::removeChild(RenderObject* child) | 255 void RenderGrid::removeChild(RenderObject* child) |
| 255 { | 256 { |
| 256 RenderBlock::removeChild(child); | 257 RenderBlock::removeChild(child); |
| 257 | 258 |
| 258 if (gridIsDirty()) | 259 if (gridIsDirty()) |
| 259 return; | 260 return; |
| 260 | 261 |
| 261 ASSERT(child->isBox()); | 262 ASSERT(child->isBox()); |
| 262 | 263 |
| 263 if (style()->gridAutoFlow() != AutoFlowNone) { | 264 // FIXME: Implement properly "stack" value in auto-placement algorithm. |
| 265 if (!style()->isGridAutoFlowAlgorithmStack()) { |
| 264 // The grid needs to be recomputed as it might contain auto-placed items
that will change their position. | 266 // The grid needs to be recomputed as it might contain auto-placed items
that will change their position. |
| 265 dirtyGrid(); | 267 dirtyGrid(); |
| 266 return; | 268 return; |
| 267 } | 269 } |
| 268 | 270 |
| 269 const RenderBox* childBox = toRenderBox(child); | 271 const RenderBox* childBox = toRenderBox(child); |
| 270 GridCoordinate coordinate = m_gridItemCoordinate.take(childBox); | 272 GridCoordinate coordinate = m_gridItemCoordinate.take(childBox); |
| 271 | 273 |
| 272 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { | 274 for (GridSpan::iterator row = coordinate.rows.begin(); row != coordinate.row
s.end(); ++row) { |
| 273 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) { | 275 for (GridSpan::iterator column = coordinate.columns.begin(); column != c
oordinate.columns.end(); ++column) { |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 ASSERT(m_gridItemCoordinate.isEmpty()); | 785 ASSERT(m_gridItemCoordinate.isEmpty()); |
| 784 | 786 |
| 785 populateExplicitGridAndOrderIterator(); | 787 populateExplicitGridAndOrderIterator(); |
| 786 | 788 |
| 787 // We clear the dirty bit here as the grid sizes have been updated, this mea
ns | 789 // We clear the dirty bit here as the grid sizes have been updated, this mea
ns |
| 788 // that we can safely call gridRowCount() / gridColumnCount(). | 790 // that we can safely call gridRowCount() / gridColumnCount(). |
| 789 m_gridIsDirty = false; | 791 m_gridIsDirty = false; |
| 790 | 792 |
| 791 Vector<RenderBox*> autoMajorAxisAutoGridItems; | 793 Vector<RenderBox*> autoMajorAxisAutoGridItems; |
| 792 Vector<RenderBox*> specifiedMajorAxisAutoGridItems; | 794 Vector<RenderBox*> specifiedMajorAxisAutoGridItems; |
| 793 GridAutoFlow autoFlow = style()->gridAutoFlow(); | |
| 794 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { | 795 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderItera
tor.next()) { |
| 795 // FIXME: We never re-resolve positions if the grid is grown during auto
-placement which may lead auto / <integer> | 796 // FIXME: We never re-resolve positions if the grid is grown during auto
-placement which may lead auto / <integer> |
| 796 // positions to not match the author's intent. The specification is uncl
ear on what should be done in this case. | 797 // positions to not match the author's intent. The specification is uncl
ear on what should be done in this case. |
| 797 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); | 798 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio
nsFromStyle(*style(), *child, ForRows); |
| 798 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); | 799 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi
tionsFromStyle(*style(), *child, ForColumns); |
| 799 if (!rowPositions || !columnPositions) { | 800 if (!rowPositions || !columnPositions) { |
| 800 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); | 801 GridSpan* majorAxisPositions = (autoPlacementMajorAxisDirection() ==
ForColumns) ? columnPositions.get() : rowPositions.get(); |
| 801 if (!majorAxisPositions) | 802 if (!majorAxisPositions) |
| 802 autoMajorAxisAutoGridItems.append(child); | 803 autoMajorAxisAutoGridItems.append(child); |
| 803 else | 804 else |
| 804 specifiedMajorAxisAutoGridItems.append(child); | 805 specifiedMajorAxisAutoGridItems.append(child); |
| 805 continue; | 806 continue; |
| 806 } | 807 } |
| 807 insertItemIntoGrid(child, GridCoordinate(*rowPositions, *columnPositions
)); | 808 insertItemIntoGrid(child, GridCoordinate(*rowPositions, *columnPositions
)); |
| 808 } | 809 } |
| 809 | 810 |
| 810 ASSERT(gridRowCount() >= style()->gridTemplateRows().size()); | 811 ASSERT(gridRowCount() >= style()->gridTemplateRows().size()); |
| 811 ASSERT(gridColumnCount() >= style()->gridTemplateColumns().size()); | 812 ASSERT(gridColumnCount() >= style()->gridTemplateColumns().size()); |
| 812 | 813 |
| 813 if (autoFlow == AutoFlowNone) { | 814 // FIXME: Implement properly "stack" value in auto-placement algorithm. |
| 815 if (style()->isGridAutoFlowAlgorithmStack()) { |
| 814 // If we did collect some grid items, they won't be placed thus never la
id out. | 816 // If we did collect some grid items, they won't be placed thus never la
id out. |
| 815 ASSERT(!autoMajorAxisAutoGridItems.size()); | 817 ASSERT(!autoMajorAxisAutoGridItems.size()); |
| 816 ASSERT(!specifiedMajorAxisAutoGridItems.size()); | 818 ASSERT(!specifiedMajorAxisAutoGridItems.size()); |
| 817 return; | 819 return; |
| 818 } | 820 } |
| 819 | 821 |
| 820 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); | 822 placeSpecifiedMajorAxisItemsOnGrid(specifiedMajorAxisAutoGridItems); |
| 821 placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); | 823 placeAutoMajorAxisItemsOnGrid(autoMajorAxisAutoGridItems); |
| 822 | 824 |
| 823 m_grid.shrinkToFit(); | 825 m_grid.shrinkToFit(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 | 927 |
| 926 if (!emptyGridArea) | 928 if (!emptyGridArea) |
| 927 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g
ridItem, autoPlacementMinorAxisDirection(), minorAxisPositions); | 929 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g
ridItem, autoPlacementMinorAxisDirection(), minorAxisPositions); |
| 928 } | 930 } |
| 929 | 931 |
| 930 insertItemIntoGrid(gridItem, *emptyGridArea); | 932 insertItemIntoGrid(gridItem, *emptyGridArea); |
| 931 } | 933 } |
| 932 | 934 |
| 933 GridTrackSizingDirection RenderGrid::autoPlacementMajorAxisDirection() const | 935 GridTrackSizingDirection RenderGrid::autoPlacementMajorAxisDirection() const |
| 934 { | 936 { |
| 935 GridAutoFlow flow = style()->gridAutoFlow(); | 937 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows; |
| 936 ASSERT(flow != AutoFlowNone); | |
| 937 return (flow == AutoFlowColumn) ? ForColumns : ForRows; | |
| 938 } | 938 } |
| 939 | 939 |
| 940 GridTrackSizingDirection RenderGrid::autoPlacementMinorAxisDirection() const | 940 GridTrackSizingDirection RenderGrid::autoPlacementMinorAxisDirection() const |
| 941 { | 941 { |
| 942 GridAutoFlow flow = style()->gridAutoFlow(); | 942 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns; |
| 943 ASSERT(flow != AutoFlowNone); | |
| 944 return (flow == AutoFlowColumn) ? ForRows : ForColumns; | |
| 945 } | 943 } |
| 946 | 944 |
| 947 void RenderGrid::dirtyGrid() | 945 void RenderGrid::dirtyGrid() |
| 948 { | 946 { |
| 949 m_grid.resize(0); | 947 m_grid.resize(0); |
| 950 m_gridItemCoordinate.clear(); | 948 m_gridItemCoordinate.clear(); |
| 951 m_gridIsDirty = true; | 949 m_gridIsDirty = true; |
| 952 m_gridItemsOverflowingGridArea.resize(0); | 950 m_gridItemsOverflowingGridArea.resize(0); |
| 953 m_gridItemsIndexesMap.clear(); | 951 m_gridItemsIndexesMap.clear(); |
| 954 } | 952 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 if (isOutOfFlowPositioned()) | 1235 if (isOutOfFlowPositioned()) |
| 1238 return "RenderGrid (positioned)"; | 1236 return "RenderGrid (positioned)"; |
| 1239 if (isAnonymous()) | 1237 if (isAnonymous()) |
| 1240 return "RenderGrid (generated)"; | 1238 return "RenderGrid (generated)"; |
| 1241 if (isRelPositioned()) | 1239 if (isRelPositioned()) |
| 1242 return "RenderGrid (relative positioned)"; | 1240 return "RenderGrid (relative positioned)"; |
| 1243 return "RenderGrid"; | 1241 return "RenderGrid"; |
| 1244 } | 1242 } |
| 1245 | 1243 |
| 1246 } // namespace WebCore | 1244 } // namespace WebCore |
| OLD | NEW |