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

Side by Side Diff: Source/core/rendering/RenderGrid.h

Issue 21205004: [CSS Grid Layout] Store m_grid across layout (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Ojan's review Created 7 years, 4 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/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderGrid.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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 RenderGrid(Element*); 47 RenderGrid(Element*);
48 virtual ~RenderGrid(); 48 virtual ~RenderGrid();
49 49
50 virtual const char* renderName() const OVERRIDE; 50 virtual const char* renderName() const OVERRIDE;
51 51
52 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE; 52 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
53 53
54 virtual bool avoidsFloats() const OVERRIDE { return true; } 54 virtual bool avoidsFloats() const OVERRIDE { return true; }
55 virtual bool canCollapseAnonymousBlockChild() const OVERRIDE { return false; } 55 virtual bool canCollapseAnonymousBlockChild() const OVERRIDE { return false; }
56 56
57 void dirtyGrid();
58
57 private: 59 private:
58 virtual bool isRenderGrid() const OVERRIDE { return true; } 60 virtual bool isRenderGrid() const OVERRIDE { return true; }
59 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const OVERRIDE; 61 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const OVERRIDE;
60 virtual void computePreferredLogicalWidths() OVERRIDE; 62 virtual void computePreferredLogicalWidths() OVERRIDE;
61 63
64 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
65 virtual void removeChild(RenderObject*) OVERRIDE;
66
67 virtual void styleDidChange(StyleDifference, const RenderStyle*) OVERRIDE;
68
69 bool explicitGridDidResize(const RenderStyle*) const;
70 bool namedGridLinesDefinitionDidChange(const RenderStyle*) const;
71
62 LayoutUnit computePreferredTrackWidth(const GridLength&, size_t) const; 72 LayoutUnit computePreferredTrackWidth(const GridLength&, size_t) const;
63 73
64 class GridIterator; 74 class GridIterator;
65 enum TrackSizingDirection { ForColumns, ForRows }; 75 enum TrackSizingDirection { ForColumns, ForRows };
66 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack> & columnTracks, Vector<GridTrack>& rowTracks); 76 void computedUsedBreadthOfGridTracks(TrackSizingDirection, Vector<GridTrack> & columnTracks, Vector<GridTrack>& rowTracks);
67 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen gth&) const; 77 LayoutUnit computeUsedBreadthOfMinLength(TrackSizingDirection, const GridLen gth&) const;
68 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen gth&, LayoutUnit usedBreadth) const; 78 LayoutUnit computeUsedBreadthOfMaxLength(TrackSizingDirection, const GridLen gth&, LayoutUnit usedBreadth) const;
69 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L ength&) const; 79 LayoutUnit computeUsedBreadthOfSpecifiedLength(TrackSizingDirection, const L ength&) const;
70 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic alSpace); 80 void resolveContentBasedTrackSizingFunctions(TrackSizingDirection, Vector<Gr idTrack>& columnTracks, Vector<GridTrack>& rowTracks, LayoutUnit& availableLogic alSpace);
71 81
72 void growGrid(TrackSizingDirection); 82 void growGrid(TrackSizingDirection);
73 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack); 83 void insertItemIntoGrid(RenderBox*, size_t rowTrack, size_t columnTrack);
74 void insertItemIntoGrid(RenderBox*, const GridCoordinate&); 84 void insertItemIntoGrid(RenderBox*, const GridCoordinate&);
75 void placeItemsOnGrid(); 85 void placeItemsOnGrid();
76 void populateExplicitGridAndOrderIterator(); 86 void populateExplicitGridAndOrderIterator();
77 void placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*>); 87 void placeSpecifiedMajorAxisItemsOnGrid(Vector<RenderBox*>);
78 void placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*>); 88 void placeAutoMajorAxisItemsOnGrid(Vector<RenderBox*>);
79 void placeAutoMajorAxisItemOnGrid(RenderBox*); 89 void placeAutoMajorAxisItemOnGrid(RenderBox*);
80 TrackSizingDirection autoPlacementMajorAxisDirection() const; 90 TrackSizingDirection autoPlacementMajorAxisDirection() const;
81 TrackSizingDirection autoPlacementMinorAxisDirection() const; 91 TrackSizingDirection autoPlacementMinorAxisDirection() const;
82 92
83 void layoutGridItems(); 93 void layoutGridItems();
84 void clearGrid();
85 94
86 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox*, TrackSizingDir ection, Vector<GridTrack>&); 95 typedef LayoutUnit (RenderGrid::* SizingFunction)(RenderBox*, TrackSizingDir ection, Vector<GridTrack>&);
87 typedef LayoutUnit (GridTrack::* AccumulatorGetter)() const; 96 typedef LayoutUnit (GridTrack::* AccumulatorGetter)() const;
88 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit); 97 typedef void (GridTrack::* AccumulatorGrowFunction)(LayoutUnit);
89 typedef bool (GridTrackSize::* FilterFunction)() const; 98 typedef bool (GridTrackSize::* FilterFunction)() const;
90 void resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection, V ector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, RenderBox*, Filter Function, SizingFunction, AccumulatorGetter, AccumulatorGrowFunction); 99 void resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection, V ector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, RenderBox*, Filter Function, SizingFunction, AccumulatorGetter, AccumulatorGrowFunction);
91 void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracks ForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, LayoutUnit & availableLogicalSpace); 100 void distributeSpaceToTracks(Vector<GridTrack*>&, Vector<GridTrack*>* tracks ForGrowthAboveMaxBreadth, AccumulatorGetter, AccumulatorGrowFunction, LayoutUnit & availableLogicalSpace);
92 101
93 double computeNormalizedFractionBreadth(Vector<GridTrack>&, TrackSizingDirec tion, LayoutUnit availableLogicalSpace) const; 102 double computeNormalizedFractionBreadth(Vector<GridTrack>&, TrackSizingDirec tion, LayoutUnit availableLogicalSpace) const;
94 103
(...skipping 14 matching lines...) Expand all
109 size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) c onst; 118 size_t resolveGridPositionFromStyle(const GridPosition&, GridPositionSide) c onst;
110 PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(size_t resol vedOppositePosition, const GridPosition&, GridPositionSide) const; 119 PassOwnPtr<GridSpan> resolveGridPositionAgainstOppositePosition(size_t resol vedOppositePosition, const GridPosition&, GridPositionSide) const;
111 PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosition(siz e_t resolvedOppositePosition, const GridPosition&, GridPositionSide) const; 120 PassOwnPtr<GridSpan> resolveNamedGridLinePositionAgainstOppositePosition(siz e_t resolvedOppositePosition, const GridPosition&, GridPositionSide) const;
112 PassOwnPtr<GridSpan> resolveBeforeStartNamedGridLinePositionAgainstOppositeP osition(size_t resolvedOppositePosition, const GridPosition&, const Vector<size_ t>&) const; 121 PassOwnPtr<GridSpan> resolveBeforeStartNamedGridLinePositionAgainstOppositeP osition(size_t resolvedOppositePosition, const GridPosition&, const Vector<size_ t>&) const;
113 PassOwnPtr<GridSpan> resolveAfterEndNamedGridLinePositionAgainstOppositePosi tion(size_t resolvedOppositePosition, const GridPosition&, const Vector<size_t>& ) const; 122 PassOwnPtr<GridSpan> resolveAfterEndNamedGridLinePositionAgainstOppositePosi tion(size_t resolvedOppositePosition, const GridPosition&, const Vector<size_t>& ) const;
114 123
115 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirect ion, const Vector<GridTrack>&) const; 124 LayoutUnit gridAreaBreadthForChild(const RenderBox* child, TrackSizingDirect ion, const Vector<GridTrack>&) const;
116 125
117 virtual void paintChildren(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL; 126 virtual void paintChildren(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL;
118 127
128 bool gridIsDirty() const { return m_gridIsDirty; }
129
119 #ifndef NDEBUG 130 #ifndef NDEBUG
120 bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<Gr idTrack>&); 131 bool tracksAreWiderThanMinTrackBreadth(TrackSizingDirection, const Vector<Gr idTrack>&);
121 bool gridWasPopulated() const { return !m_grid.isEmpty() && !m_grid[0].isEmp ty(); }
122 #endif 132 #endif
123 133
124 size_t gridColumnCount() const 134 size_t gridColumnCount() const
125 { 135 {
126 ASSERT(gridWasPopulated()); 136 ASSERT(!gridIsDirty());
127 return m_grid[0].size(); 137 return m_grid[0].size();
128 } 138 }
129 size_t gridRowCount() const 139 size_t gridRowCount() const
130 { 140 {
131 ASSERT(gridWasPopulated()); 141 ASSERT(!gridIsDirty());
132 return m_grid.size(); 142 return m_grid.size();
133 } 143 }
134 144
135 Vector<Vector<Vector<RenderBox*, 1> > > m_grid; 145 Vector<Vector<Vector<RenderBox*, 1> > > m_grid;
146 bool m_gridIsDirty;
136 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate; 147 HashMap<const RenderBox*, GridCoordinate> m_gridItemCoordinate;
137 OrderIterator m_orderIterator; 148 OrderIterator m_orderIterator;
138 }; 149 };
139 150
151 inline RenderGrid* toRenderGrid(RenderObject* object)
152 {
153 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderGrid());
154 return static_cast<RenderGrid*>(object);
155 }
156
157 inline const RenderGrid* toRenderGrid(const RenderObject* object)
158 {
159 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderGrid());
160 return static_cast<const RenderGrid*>(object);
161 }
162
163 // Catch unneeded cast.
164 void toRenderGrid(const RenderGrid*);
165
140 } // namespace WebCore 166 } // namespace WebCore
141 167
142 #endif // RenderGrid_h 168 #endif // RenderGrid_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.cpp ('k') | Source/core/rendering/RenderGrid.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698