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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 { | 200 { |
201 } | 201 } |
202 | 202 |
203 void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild) | 203 void RenderGrid::addChild(RenderObject* newChild, RenderObject* beforeChild) |
204 { | 204 { |
205 RenderBlock::addChild(newChild, beforeChild); | 205 RenderBlock::addChild(newChild, beforeChild); |
206 | 206 |
207 if (gridIsDirty()) | 207 if (gridIsDirty()) |
208 return; | 208 return; |
209 | 209 |
210 // If the new requested beforeChild is not one of our children is because it 's wrapped by an anonymous container. In | |
211 // those cases addChild will be called twice for the newChild, one with the initial beforeChild and another one with | |
212 // its parent (the anonymous block container). See RenderBlock::addChildIgno ringAnonymousColumnBlocks() | |
213 if (beforeChild && beforeChild->parent() != this) { | |
214 ASSERT(beforeChild->parent()->isAnonymous()); | |
215 dirtyGrid(); | |
Julien - ping for review
2014/06/25 21:25:08
Do we really need to invalidate the grid in this c
svillar
2014/06/26 09:45:53
Good point, should be safe to just return indeed.
| |
216 return; | |
217 } | |
218 | |
210 if (!newChild->isBox()) { | 219 if (!newChild->isBox()) { |
211 dirtyGrid(); | 220 dirtyGrid(); |
212 return; | 221 return; |
213 } | 222 } |
214 | 223 |
215 if (style()->gridAutoFlow() != AutoFlowNone) { | 224 if (style()->gridAutoFlow() != AutoFlowNone) { |
216 // The grid needs to be recomputed as it might contain auto-placed items that will change their position. | 225 // The grid needs to be recomputed as it might contain auto-placed items that will change their position. |
217 dirtyGrid(); | 226 dirtyGrid(); |
218 return; | 227 return; |
219 } | 228 } |
220 | 229 |
221 RenderBox* newChildBox = toRenderBox(newChild); | 230 RenderBox* newChildBox = toRenderBox(newChild); |
222 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr omStyle(*style(), *newChildBox, ForRows); | 231 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositionsFr omStyle(*style(), *newChildBox, ForRows); |
223 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition sFromStyle(*style(), *newChildBox, ForColumns); | 232 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosition sFromStyle(*style(), *newChildBox, ForColumns); |
224 if (!rowPositions || !columnPositions) { | 233 if (!rowPositions || !columnPositions) { |
225 // The new child requires the auto-placement algorithm to run so we need to recompute the grid fully. | 234 // The new child requires the auto-placement algorithm to run so we need to recompute the grid fully. |
226 dirtyGrid(); | 235 dirtyGrid(); |
227 return; | 236 return; |
228 } else { | 237 } else { |
229 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPos itions)); | 238 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *columnPos itions)); |
230 addChildToIndexesMap(newChildBox); | 239 addChildToIndexesMap(newChildBox); |
Manuel Rego
2014/06/25 20:13:11
Probably we could add an ASSERT here, similar to t
Julien - ping for review
2014/06/25 21:25:08
I would make it a RELEASE_ASSERT as it seems like
| |
231 } | 240 } |
232 } | 241 } |
233 | 242 |
234 void RenderGrid::addChildToIndexesMap(RenderBox* child) | 243 void RenderGrid::addChildToIndexesMap(RenderBox* child) |
235 { | 244 { |
236 ASSERT(!m_gridItemsIndexesMap.contains(child)); | 245 ASSERT(!m_gridItemsIndexesMap.contains(child)); |
237 RenderBox* sibling = child->nextSiblingBox(); | 246 RenderBox* sibling = child->nextSiblingBox(); |
238 bool lastSibling = !sibling; | 247 bool lastSibling = !sibling; |
239 | 248 |
240 if (lastSibling) | 249 if (lastSibling) |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1249 if (isOutOfFlowPositioned()) | 1258 if (isOutOfFlowPositioned()) |
1250 return "RenderGrid (positioned)"; | 1259 return "RenderGrid (positioned)"; |
1251 if (isAnonymous()) | 1260 if (isAnonymous()) |
1252 return "RenderGrid (generated)"; | 1261 return "RenderGrid (generated)"; |
1253 if (isRelPositioned()) | 1262 if (isRelPositioned()) |
1254 return "RenderGrid (relative positioned)"; | 1263 return "RenderGrid (relative positioned)"; |
1255 return "RenderGrid"; | 1264 return "RenderGrid"; |
1256 } | 1265 } |
1257 | 1266 |
1258 } // namespace WebCore | 1267 } // namespace WebCore |
OLD | NEW |