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

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

Issue 1144203009: Strengthen the LayoutGrid dirtiness asserts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/LayoutGrid.h ('k') | Source/core/paint/GridPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 #include "core/style/GridCoordinate.h" 31 #include "core/style/GridCoordinate.h"
32 #include "core/style/ComputedStyle.h" 32 #include "core/style/ComputedStyle.h"
33 #include "core/paint/DeprecatedPaintLayer.h" 33 #include "core/paint/DeprecatedPaintLayer.h"
34 #include "core/paint/GridPainter.h" 34 #include "core/paint/GridPainter.h"
35 #include "platform/LengthFunctions.h" 35 #include "platform/LengthFunctions.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 static const int infinity = -1; 39 static const int infinity = -1;
40 40
41 class GridItemWithSpan;
svillar 2015/06/03 09:27:33 Why this?
esprehn 2015/06/03 16:39:11 That class doesn't appear to be used or defined ou
42
41 class GridTrack { 43 class GridTrack {
42 public: 44 public:
43 GridTrack() 45 GridTrack()
44 : m_plannedIncrease(0) 46 : m_plannedIncrease(0)
45 , m_increaseDuringDistribution(0) 47 , m_increaseDuringDistribution(0)
46 , m_baseSize(0) 48 , m_baseSize(0)
47 , m_growthLimit(0) 49 , m_growthLimit(0)
48 { 50 {
49 } 51 }
50 52
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 259 }
258 260
259 LayoutGrid::~LayoutGrid() 261 LayoutGrid::~LayoutGrid()
260 { 262 {
261 } 263 }
262 264
263 void LayoutGrid::addChild(LayoutObject* newChild, LayoutObject* beforeChild) 265 void LayoutGrid::addChild(LayoutObject* newChild, LayoutObject* beforeChild)
264 { 266 {
265 LayoutBlock::addChild(newChild, beforeChild); 267 LayoutBlock::addChild(newChild, beforeChild);
266 268
267 if (gridIsDirty())
268 return;
269
270 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position. 269 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position.
271 dirtyGrid(); 270 dirtyGrid();
272 return;
273 } 271 }
274 272
275 void LayoutGrid::removeChild(LayoutObject* child) 273 void LayoutGrid::removeChild(LayoutObject* child)
276 { 274 {
277 LayoutBlock::removeChild(child); 275 LayoutBlock::removeChild(child);
278 276
279 if (gridIsDirty())
280 return;
281
282 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position. 277 // The grid needs to be recomputed as it might contain auto-placed items tha t will change their position.
283 dirtyGrid(); 278 dirtyGrid();
284 return;
285 } 279 }
286 280
287 void LayoutGrid::styleDidChange(StyleDifference diff, const ComputedStyle* oldSt yle) 281 void LayoutGrid::styleDidChange(StyleDifference diff, const ComputedStyle* oldSt yle)
288 { 282 {
289 LayoutBlock::styleDidChange(diff, oldStyle); 283 LayoutBlock::styleDidChange(diff, oldStyle);
290 if (!oldStyle) 284 if (!oldStyle)
291 return; 285 return;
292 286
293 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have: 287 // FIXME: The following checks could be narrowed down if we kept track of wh ich type of grid items we have:
294 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items. 288 // - explicit grid size changes impact negative explicitely positioned and a uto-placed grid items.
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 for (GridSpan::iterator column = coordinate.columns.begin(); column != c oordinate.columns.end(); ++column) 912 for (GridSpan::iterator column = coordinate.columns.begin(); column != c oordinate.columns.end(); ++column)
919 m_grid[row.toInt()][column.toInt()].append(&child); 913 m_grid[row.toInt()][column.toInt()].append(&child);
920 } 914 }
921 915
922 RELEASE_ASSERT(!m_gridItemCoordinate.contains(&child)); 916 RELEASE_ASSERT(!m_gridItemCoordinate.contains(&child));
923 m_gridItemCoordinate.set(&child, coordinate); 917 m_gridItemCoordinate.set(&child, coordinate);
924 } 918 }
925 919
926 void LayoutGrid::placeItemsOnGrid() 920 void LayoutGrid::placeItemsOnGrid()
927 { 921 {
928 if (!gridIsDirty()) 922 if (!m_gridIsDirty)
929 return; 923 return;
930 924
931 ASSERT(m_gridItemCoordinate.isEmpty()); 925 ASSERT(m_gridItemCoordinate.isEmpty());
932 926
933 populateExplicitGridAndOrderIterator(); 927 populateExplicitGridAndOrderIterator();
934 928
935 // We clear the dirty bit here as the grid sizes have been updated, this mea ns 929 // We clear the dirty bit here as the grid sizes have been updated.
936 // that we can safely call gridRowCount() / gridColumnCount().
937 m_gridIsDirty = false; 930 m_gridIsDirty = false;
938 931
939 Vector<LayoutBox*> autoMajorAxisAutoGridItems; 932 Vector<LayoutBox*> autoMajorAxisAutoGridItems;
940 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; 933 Vector<LayoutBox*> specifiedMajorAxisAutoGridItems;
941 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { 934 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) {
942 if (child->isOutOfFlowPositioned()) 935 if (child->isOutOfFlowPositioned())
943 continue; 936 continue;
944 937
945 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio nsFromStyle(*style(), *child, ForRows); 938 OwnPtr<GridSpan> rowPositions = GridResolvedPosition::resolveGridPositio nsFromStyle(*style(), *child, ForRows);
946 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi tionsFromStyle(*style(), *child, ForColumns); 939 OwnPtr<GridSpan> columnPositions = GridResolvedPosition::resolveGridPosi tionsFromStyle(*style(), *child, ForColumns);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows; 1108 return style()->isGridAutoFlowDirectionColumn() ? ForColumns : ForRows;
1116 } 1109 }
1117 1110
1118 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const 1111 GridTrackSizingDirection LayoutGrid::autoPlacementMinorAxisDirection() const
1119 { 1112 {
1120 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns; 1113 return style()->isGridAutoFlowDirectionColumn() ? ForRows : ForColumns;
1121 } 1114 }
1122 1115
1123 void LayoutGrid::dirtyGrid() 1116 void LayoutGrid::dirtyGrid()
1124 { 1117 {
1118 if (m_gridIsDirty)
1119 return;
1120
1125 // Even if this could be redundant, it could be seen as a defensive strategy against 1121 // Even if this could be redundant, it could be seen as a defensive strategy against
1126 // style changes events happening during the layout phase or even while the painting process 1122 // style changes events happening during the layout phase or even while the painting process
1127 // is still ongoing. 1123 // is still ongoing.
1128 // Forcing a new layout for the Grid layout would cancel any ongoing paintin g and ensure 1124 // Forcing a new layout for the Grid layout would cancel any ongoing paintin g and ensure
1129 // the grid and its children are correctly laid out according to the new sty le rules. 1125 // the grid and its children are correctly laid out according to the new sty le rules.
1130 setNeedsLayout(LayoutInvalidationReason::GridChanged); 1126 setNeedsLayout(LayoutInvalidationReason::GridChanged);
1131 1127
1132 m_grid.resize(0); 1128 m_grid.resize(0);
1133 m_gridItemCoordinate.clear(); 1129 m_gridItemCoordinate.clear();
1134 m_gridIsDirty = true;
1135 m_gridItemsOverflowingGridArea.resize(0); 1130 m_gridItemsOverflowingGridArea.resize(0);
1136 m_gridItemsIndexesMap.clear(); 1131 m_gridItemsIndexesMap.clear();
1132 m_gridIsDirty = true;
1137 } 1133 }
1138 1134
1139 void LayoutGrid::layoutGridItems() 1135 void LayoutGrid::layoutGridItems()
1140 { 1136 {
1141 placeItemsOnGrid(); 1137 placeItemsOnGrid();
1142 1138
1143 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); 1139 LayoutUnit availableSpaceForColumns = availableLogicalWidth();
1144 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding); 1140 LayoutUnit availableSpaceForRows = availableLogicalHeight(IncludeMarginBorde rPadding);
1145 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 1141 GridSizingData sizingData(gridColumnCount(), gridRowCount());
1146 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns); 1142 computeUsedBreadthOfGridTracks(ForColumns, sizingData, availableSpaceForColu mns);
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1833 1829
1834 return LayoutPoint(columnPosition, rowPositionForChild(child)); 1830 return LayoutPoint(columnPosition, rowPositionForChild(child));
1835 } 1831 }
1836 1832
1837 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 1833 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
1838 { 1834 {
1839 GridPainter(*this).paintChildren(paintInfo, paintOffset); 1835 GridPainter(*this).paintChildren(paintInfo, paintOffset);
1840 } 1836 }
1841 1837
1842 } // namespace blink 1838 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutGrid.h ('k') | Source/core/paint/GridPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698