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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 } | 216 } |
217 | 217 |
218 void RenderGrid::removeChild(RenderObject* child) | 218 void RenderGrid::removeChild(RenderObject* child) |
219 { | 219 { |
220 RenderBlock::removeChild(child); | 220 RenderBlock::removeChild(child); |
221 | 221 |
222 if (gridIsDirty()) | 222 if (gridIsDirty()) |
223 return; | 223 return; |
224 | 224 |
225 ASSERT(child->isBox()); | 225 ASSERT(child->isBox()); |
226 // FIXME: We could avoid dirtying the grid in some cases (e.g. if it's an ex plicitly positioned element). | 226 |
227 dirtyGrid(); | 227 if (style()->gridAutoFlow() != AutoFlowNone) { |
Julien - ping for review
2014/03/31 18:36:51
Note that if you don't have any grid item that are
| |
228 // The grid needs to be recomputed as it might contain auto-placed items that will change their position. | |
229 dirtyGrid(); | |
230 return; | |
231 } | |
232 | |
233 const RenderBox* childBox = toRenderBox(child); | |
234 GridCoordinate coordinate = m_gridItemCoordinate.get(childBox); | |
Julien - ping for review
2014/03/31 18:36:51
You could avoid the 2 hash lookup by using m_gridI
| |
235 | |
236 for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.ro ws.finalPositionIndex; ++row) { | |
237 for (size_t column = coordinate.columns.initialPositionIndex; column <= coordinate.columns.finalPositionIndex; ++column) { | |
238 GridCell& cell = m_grid[row][column]; | |
239 cell.remove(cell.find(childBox)); | |
240 } | |
241 } | |
242 | |
243 m_gridItemCoordinate.remove(childBox); | |
228 } | 244 } |
229 | 245 |
230 void RenderGrid::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl e) | 246 void RenderGrid::styleDidChange(StyleDifference diff, const RenderStyle* oldStyl e) |
231 { | 247 { |
232 RenderBlock::styleDidChange(diff, oldStyle); | 248 RenderBlock::styleDidChange(diff, oldStyle); |
233 if (!oldStyle) | 249 if (!oldStyle) |
234 return; | 250 return; |
235 | 251 |
236 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have: | 252 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have: |
237 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items. | 253 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items. |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 if (isOutOfFlowPositioned()) | 1407 if (isOutOfFlowPositioned()) |
1392 return "RenderGrid (positioned)"; | 1408 return "RenderGrid (positioned)"; |
1393 if (isAnonymous()) | 1409 if (isAnonymous()) |
1394 return "RenderGrid (generated)"; | 1410 return "RenderGrid (generated)"; |
1395 if (isRelPositioned()) | 1411 if (isRelPositioned()) |
1396 return "RenderGrid (relative positioned)"; | 1412 return "RenderGrid (relative positioned)"; |
1397 return "RenderGrid"; | 1413 return "RenderGrid"; |
1398 } | 1414 } |
1399 | 1415 |
1400 } // namespace WebCore | 1416 } // namespace WebCore |
OLD | NEW |