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

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

Issue 18532004: Implement 'grid-template' parsing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined and updated after Ojan's and Elliott's comments 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/page/UseCounter.cpp ('k') | Source/core/rendering/style/RenderStyle.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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 "wtf/HashMap.h"
34 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PassOwnPtr.h"
36 #include "wtf/text/WTFString.h"
35 37
36 namespace WebCore { 38 namespace WebCore {
37 39
38 // A span in a single direction (either rows or columns). Note that |initialPosi tionIndex| 40 // A span in a single direction (either rows or columns). Note that |initialPosi tionIndex|
39 // and |finalPositionIndex| are grid areas' indexes, NOT grid lines'. Iterating over the 41 // and |finalPositionIndex| are grid areas' indexes, NOT grid lines'. Iterating over the
40 // span should include both |initialPositionIndex| and |finalPositionIndex| to b e correct. 42 // span should include both |initialPositionIndex| and |finalPositionIndex| to b e correct.
41 struct GridSpan { 43 struct GridSpan {
42 static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalPosit ion) 44 static PassOwnPtr<GridSpan> create(size_t initialPosition, size_t finalPosit ion)
43 { 45 {
44 return adoptPtr(new GridSpan(initialPosition, finalPosition)); 46 return adoptPtr(new GridSpan(initialPosition, finalPosition));
45 } 47 }
46 48
47 GridSpan(size_t initialPosition, size_t finalPosition) 49 GridSpan(size_t initialPosition, size_t finalPosition)
48 : initialPositionIndex(initialPosition) 50 : initialPositionIndex(initialPosition)
49 , finalPositionIndex(finalPosition) 51 , finalPositionIndex(finalPosition)
50 { 52 {
51 ASSERT(initialPositionIndex <= finalPositionIndex); 53 ASSERT(initialPositionIndex <= finalPositionIndex);
52 } 54 }
53 55
56 bool operator==(const GridSpan& o) const
57 {
58 return initialPositionIndex == o.initialPositionIndex && finalPositionIn dex == o.finalPositionIndex;
59 }
60
54 size_t initialPositionIndex; 61 size_t initialPositionIndex;
55 size_t finalPositionIndex; 62 size_t finalPositionIndex;
56 }; 63 };
57 64
58 // This represents a grid area that spans in both rows' and columns' direction. 65 // This represents a grid area that spans in both rows' and columns' direction.
59 struct GridCoordinate { 66 struct GridCoordinate {
60 // HashMap requires a default constuctor. 67 // HashMap requires a default constuctor.
61 GridCoordinate() 68 GridCoordinate()
62 : columns(0, 0) 69 : columns(0, 0)
63 , rows(0, 0) 70 , rows(0, 0)
64 { 71 {
65 } 72 }
66 73
67 GridCoordinate(const GridSpan& r, const GridSpan& c) 74 GridCoordinate(const GridSpan& r, const GridSpan& c)
68 : columns(c) 75 : columns(c)
69 , rows(r) 76 , rows(r)
70 { 77 {
71 } 78 }
72 79
80 bool operator==(const GridCoordinate& o) const
81 {
82 return columns == o.columns && rows == o.rows;
83 }
84
85 bool operator!=(const GridCoordinate& o) const
86 {
87 return !(*this == o);
88 }
89
73 GridSpan columns; 90 GridSpan columns;
74 GridSpan rows; 91 GridSpan rows;
75 }; 92 };
76 93
94 typedef HashMap<String, GridCoordinate> NamedGridAreaMap;
95
77 } // namespace WebCore 96 } // namespace WebCore
78 97
79 #endif // GridCoordinate_h 98 #endif // GridCoordinate_h
OLDNEW
« no previous file with comments | « Source/core/page/UseCounter.cpp ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698