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

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

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 | « no previous file | Source/core/layout/LayoutGrid.cpp » ('j') | Source/core/layout/LayoutGrid.cpp » ('J')
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 17 matching lines...) Expand all
28 28
29 #include "core/layout/LayoutBlock.h" 29 #include "core/layout/LayoutBlock.h"
30 #include "core/layout/OrderIterator.h" 30 #include "core/layout/OrderIterator.h"
31 #include "core/style/GridResolvedPosition.h" 31 #include "core/style/GridResolvedPosition.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 struct GridCoordinate; 35 struct GridCoordinate;
36 struct GridSpan; 36 struct GridSpan;
37 class GridTrack; 37 class GridTrack;
38 class GridItemWithSpan;
39 38
40 class LayoutGrid final : public LayoutBlock { 39 class LayoutGrid final : public LayoutBlock {
41 public: 40 public:
42 LayoutGrid(Element*); 41 explicit LayoutGrid(Element*);
43 virtual ~LayoutGrid(); 42 virtual ~LayoutGrid();
44 43
45 virtual const char* name() const override { return "LayoutGrid"; } 44 virtual const char* name() const override { return "LayoutGrid"; }
46 45
47 virtual void layoutBlock(bool relayoutChildren) override; 46 virtual void layoutBlock(bool relayoutChildren) override;
48 47
49 virtual bool canCollapseAnonymousBlockChild() const override { return false; } 48 virtual bool canCollapseAnonymousBlockChild() const override { return false; }
50 49
51 void dirtyGrid(); 50 void dirtyGrid();
52 51
53 const Vector<LayoutUnit>& columnPositions() const { return m_columnPositions ; } 52 const Vector<LayoutUnit>& columnPositions() const
54 const Vector<LayoutUnit>& rowPositions() const { return m_rowPositions; } 53 {
54 ASSERT(!m_gridIsDirty);
55 return m_columnPositions;
56 }
57
58 const Vector<LayoutUnit>& rowPositions() const
59 {
60 ASSERT(!m_gridIsDirty);
61 return m_rowPositions;
62 }
55 63
56 typedef Vector<LayoutBox*, 1> GridCell; 64 typedef Vector<LayoutBox*, 1> GridCell;
57 const GridCell& gridCell(int row, int column) { return m_grid[row][column]; } 65 const GridCell& gridCell(int row, int column)
58 const Vector<LayoutBox*>& itemsOverflowingGridArea() { return m_gridItemsOve rflowingGridArea; } 66 {
59 int paintIndexForGridItem(const LayoutBox* layoutBox) { return m_gridItemsIn dexesMap.get(layoutBox); } 67 ASSERT_WITH_SECURITY_IMPLICATION(!m_gridIsDirty);
68 return m_grid[row][column];
69 }
60 70
61 bool gridIsDirty() const { return m_gridIsDirty; } 71 const Vector<LayoutBox*>& itemsOverflowingGridArea()
72 {
73 ASSERT_WITH_SECURITY_IMPLICATION(!m_gridIsDirty);
74 return m_gridItemsOverflowingGridArea;
75 }
62 76
77 int paintIndexForGridItem(const LayoutBox* layoutBox)
78 {
79 ASSERT_WITH_SECURITY_IMPLICATION(!m_gridIsDirty);
80 return m_gridItemsIndexesMap.get(layoutBox);
81 }
82
83 private:
63 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); 84 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit);
64 private: 85
65 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectLayoutGrid || LayoutBlock::isOfType(type); } 86 virtual bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectLayoutGrid || LayoutBlock::isOfType(type); }
66 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const override; 87 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const override;
67 virtual void computePreferredLogicalWidths() override; 88 virtual void computePreferredLogicalWidths() override;
68 89
69 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override; 90 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = 0) override;
70 virtual void removeChild(LayoutObject*) override; 91 virtual void removeChild(LayoutObject*) override;
71 92
72 virtual void styleDidChange(StyleDifference, const ComputedStyle*) override; 93 virtual void styleDidChange(StyleDifference, const ComputedStyle*) override;
73 94
74 bool explicitGridDidResize(const ComputedStyle&) const; 95 bool explicitGridDidResize(const ComputedStyle&) const;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 165
145 #if ENABLE(ASSERT) 166 #if ENABLE(ASSERT)
146 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto r<GridTrack>&); 167 bool tracksAreWiderThanMinTrackBreadth(GridTrackSizingDirection, const Vecto r<GridTrack>&);
147 #endif 168 #endif
148 169
149 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection); 170 size_t gridItemSpan(const LayoutBox&, GridTrackSizingDirection);
150 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack SizingDirection) const; 171 bool spanningItemCrossesFlexibleSizedTracks(const GridCoordinate&, GridTrack SizingDirection) const;
151 172
152 size_t gridColumnCount() const 173 size_t gridColumnCount() const
153 { 174 {
154 ASSERT(!gridIsDirty()); 175 ASSERT(!m_gridIsDirty);
155 return m_grid[0].size(); 176 return m_grid[0].size();
156 } 177 }
157 size_t gridRowCount() const 178 size_t gridRowCount() const
158 { 179 {
159 ASSERT(!gridIsDirty()); 180 ASSERT(!m_gridIsDirty);
160 return m_grid.size(); 181 return m_grid.size();
161 } 182 }
162 183
163 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const; 184 bool hasDefiniteLogicalSize(GridTrackSizingDirection) const;
164 185
165 typedef Vector<Vector<GridCell>> GridRepresentation; 186 typedef Vector<Vector<GridCell>> GridRepresentation;
166 GridRepresentation m_grid; 187 GridRepresentation m_grid;
167 bool m_gridIsDirty; 188 bool m_gridIsDirty;
168 Vector<LayoutUnit> m_rowPositions; 189 Vector<LayoutUnit> m_rowPositions;
169 Vector<LayoutUnit> m_columnPositions; 190 Vector<LayoutUnit> m_columnPositions;
170 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate; 191 HashMap<const LayoutBox*, GridCoordinate> m_gridItemCoordinate;
171 OrderIterator m_orderIterator; 192 OrderIterator m_orderIterator;
172 Vector<LayoutBox*> m_gridItemsOverflowingGridArea; 193 Vector<LayoutBox*> m_gridItemsOverflowingGridArea;
173 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap; 194 HashMap<const LayoutBox*, size_t> m_gridItemsIndexesMap;
174 }; 195 };
175 196
176 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid()); 197 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutGrid, isLayoutGrid());
177 198
178 } // namespace blink 199 } // namespace blink
179 200
180 #endif // LayoutGrid_h 201 #endif // LayoutGrid_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/layout/LayoutGrid.cpp » ('j') | Source/core/layout/LayoutGrid.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698