Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2748983003: [css-grid] Fix crash removing positioned grid item (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 LayoutGrid* LayoutGrid::createAnonymous(Document* document) { 65 LayoutGrid* LayoutGrid::createAnonymous(Document* document) {
66 LayoutGrid* layoutGrid = new LayoutGrid(nullptr); 66 LayoutGrid* layoutGrid = new LayoutGrid(nullptr);
67 layoutGrid->setDocumentForAnonymous(document); 67 layoutGrid->setDocumentForAnonymous(document);
68 return layoutGrid; 68 return layoutGrid;
69 } 69 }
70 70
71 void LayoutGrid::addChild(LayoutObject* newChild, LayoutObject* beforeChild) { 71 void LayoutGrid::addChild(LayoutObject* newChild, LayoutObject* beforeChild) {
72 LayoutBlock::addChild(newChild, beforeChild); 72 LayoutBlock::addChild(newChild, beforeChild);
73 73
74 // The grid needs to be recomputed as it might contain auto-placed items that 74 if (!newChild->isOutOfFlowPositioned()) {
jfernandez 2017/03/15 09:26:36 I think it'd be useful to add comment explaining w
Manuel Rego 2017/03/15 10:59:26 Done.
75 // will change their position. 75 // The grid needs to be recomputed as it might contain auto-placed items
76 dirtyGrid(); 76 // that will change their position.
77 dirtyGrid();
78 }
svillar 2017/03/15 10:03:54 Better to early return if (newChild->isOutOfFlowP
Manuel Rego 2017/03/15 10:59:26 Acknowledged.
77 } 79 }
78 80
79 void LayoutGrid::removeChild(LayoutObject* child) { 81 void LayoutGrid::removeChild(LayoutObject* child) {
80 LayoutBlock::removeChild(child); 82 LayoutBlock::removeChild(child);
81 83
82 // The grid needs to be recomputed as it might contain auto-placed items that 84 if (!child->isOutOfFlowPositioned()) {
83 // will change their position. 85 // The grid needs to be recomputed as it might contain auto-placed items
84 dirtyGrid(); 86 // that will change their position.
87 dirtyGrid();
88 }
svillar 2017/03/15 10:03:54 Ditto.
Manuel Rego 2017/03/15 10:59:26 Acknowledged.
85 } 89 }
86 90
87 void LayoutGrid::styleDidChange(StyleDifference diff, 91 void LayoutGrid::styleDidChange(StyleDifference diff,
88 const ComputedStyle* oldStyle) { 92 const ComputedStyle* oldStyle) {
89 LayoutBlock::styleDidChange(diff, oldStyle); 93 LayoutBlock::styleDidChange(diff, oldStyle);
90 if (!oldStyle) 94 if (!oldStyle)
91 return; 95 return;
92 96
93 // FIXME: The following checks could be narrowed down if we kept track of 97 // FIXME: The following checks could be narrowed down if we kept track of
94 // which type of grid items we have: 98 // which type of grid items we have:
(...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 if (direction == ForRows) 2095 if (direction == ForRows)
2092 return grid.numTracks(ForRows); 2096 return grid.numTracks(ForRows);
2093 2097
2094 return grid.numTracks(ForRows) 2098 return grid.numTracks(ForRows)
2095 ? grid.numTracks(ForColumns) 2099 ? grid.numTracks(ForColumns)
2096 : GridPositionsResolver::explicitGridColumnCount( 2100 : GridPositionsResolver::explicitGridColumnCount(
2097 styleRef(), grid.autoRepeatTracks(ForColumns)); 2101 styleRef(), grid.autoRepeatTracks(ForColumns));
2098 } 2102 }
2099 2103
2100 } // namespace blink 2104 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698