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

Side by Side Diff: Source/core/style/GridCoordinate.h

Issue 1308633005: Make classes and structures in core/style, core/plugins and core/streams fast-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « Source/core/style/FillLayer.h ('k') | Source/core/style/GridLength.h » ('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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef GridCoordinate_h 31 #ifndef GridCoordinate_h
32 #define GridCoordinate_h 32 #define GridCoordinate_h
33 33
34 #include "core/style/GridResolvedPosition.h" 34 #include "core/style/GridResolvedPosition.h"
35 #include "wtf/FastAllocBase.h"
35 #include "wtf/HashMap.h" 36 #include "wtf/HashMap.h"
36 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
37 #include "wtf/text/WTFString.h" 38 #include "wtf/text/WTFString.h"
38 #include <algorithm> 39 #include <algorithm>
39 40
40 namespace blink { 41 namespace blink {
41 42
42 // Recommended maximum size for both explicit and implicit grids. 43 // Recommended maximum size for both explicit and implicit grids.
43 const size_t kGridMaxTracks = 1000000; 44 const size_t kGridMaxTracks = 1000000;
44 45
45 // A span in a single direction (either rows or columns). Note that |resolvedIni tialPosition| 46 // A span in a single direction (either rows or columns). Note that |resolvedIni tialPosition|
46 // and |resolvedFinalPosition| are grid areas' indexes, NOT grid lines'. Iterati ng over the 47 // and |resolvedFinalPosition| are grid areas' indexes, NOT grid lines'. Iterati ng over the
47 // span should include both |resolvedInitialPosition| and |resolvedFinalPosition | to be correct. 48 // span should include both |resolvedInitialPosition| and |resolvedFinalPosition | to be correct.
48 struct GridSpan { 49 struct GridSpan {
50 WTF_MAKE_FAST_ALLOCATED(GridSpan);
51 public:
49 static PassOwnPtr<GridSpan> create(const GridResolvedPosition& resolvedIniti alPosition, const GridResolvedPosition& resolvedFinalPosition) 52 static PassOwnPtr<GridSpan> create(const GridResolvedPosition& resolvedIniti alPosition, const GridResolvedPosition& resolvedFinalPosition)
50 { 53 {
51 return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosit ion)); 54 return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosit ion));
52 } 55 }
53 56
54 static PassOwnPtr<GridSpan> createWithSpanAgainstOpposite(const GridResolved Position& resolvedOppositePosition, const GridPosition& position, GridPositionSi de side) 57 static PassOwnPtr<GridSpan> createWithSpanAgainstOpposite(const GridResolved Position& resolvedOppositePosition, const GridPosition& position, GridPositionSi de side)
55 { 58 {
56 // 'span 1' is contained inside a single grid track regardless of the di rection. 59 // 'span 1' is contained inside a single grid track regardless of the di rection.
57 // That's why the CSS span value is one more than the offset we apply. 60 // That's why the CSS span value is one more than the offset we apply.
58 size_t positionOffset = position.spanPosition() - 1; 61 size_t positionOffset = position.spanPosition() - 1;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 137 }
135 138
136 iterator end() const 139 iterator end() const
137 { 140 {
138 return resolvedFinalPosition.next(); 141 return resolvedFinalPosition.next();
139 } 142 }
140 }; 143 };
141 144
142 // This represents a grid area that spans in both rows' and columns' direction. 145 // This represents a grid area that spans in both rows' and columns' direction.
143 struct GridCoordinate { 146 struct GridCoordinate {
147 WTF_MAKE_FAST_ALLOCATED(GridCoordinate);
148 public:
144 // HashMap requires a default constuctor. 149 // HashMap requires a default constuctor.
145 GridCoordinate() 150 GridCoordinate()
146 : columns(0, 0) 151 : columns(0, 0)
147 , rows(0, 0) 152 , rows(0, 0)
148 { 153 {
149 } 154 }
150 155
151 GridCoordinate(const GridSpan& r, const GridSpan& c) 156 GridCoordinate(const GridSpan& r, const GridSpan& c)
152 : columns(c) 157 : columns(c)
153 , rows(r) 158 , rows(r)
(...skipping 28 matching lines...) Expand all
182 187
183 GridSpan columns; 188 GridSpan columns;
184 GridSpan rows; 189 GridSpan rows;
185 }; 190 };
186 191
187 typedef HashMap<String, GridCoordinate> NamedGridAreaMap; 192 typedef HashMap<String, GridCoordinate> NamedGridAreaMap;
188 193
189 } // namespace blink 194 } // namespace blink
190 195
191 #endif // GridCoordinate_h 196 #endif // GridCoordinate_h
OLDNEW
« no previous file with comments | « Source/core/style/FillLayer.h ('k') | Source/core/style/GridLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698