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

Side by Side Diff: third_party/WebKit/Source/core/style/GridArea.h

Issue 2751653003: Replace ASSERT and ASSERT_NOT_REACHED in core/style/ (Closed)
Patch Set: Replace ASSERT and ASSERT_NOT_REACHED in core/style/ Created 3 years, 9 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
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 static GridSpan indefiniteGridSpan() { return GridSpan(0, 1, Indefinite); } 65 static GridSpan indefiniteGridSpan() { return GridSpan(0, 1, Indefinite); }
66 66
67 bool operator==(const GridSpan& o) const { 67 bool operator==(const GridSpan& o) const {
68 return m_type == o.m_type && m_startLine == o.m_startLine && 68 return m_type == o.m_type && m_startLine == o.m_startLine &&
69 m_endLine == o.m_endLine; 69 m_endLine == o.m_endLine;
70 } 70 }
71 71
72 size_t integerSpan() const { 72 size_t integerSpan() const {
73 ASSERT(isTranslatedDefinite()); 73 DCHECK(isTranslatedDefinite());
74 ASSERT(m_endLine > m_startLine); 74 DCHECK_GT(m_endLine, m_startLine);
75 return m_endLine - m_startLine; 75 return m_endLine - m_startLine;
76 } 76 }
77 77
78 int untranslatedStartLine() const { 78 int untranslatedStartLine() const {
79 ASSERT(m_type == UntranslatedDefinite); 79 DCHECK_EQ(m_type, UntranslatedDefinite);
80 return m_startLine; 80 return m_startLine;
81 } 81 }
82 82
83 int untranslatedEndLine() const { 83 int untranslatedEndLine() const {
84 ASSERT(m_type == UntranslatedDefinite); 84 DCHECK_EQ(m_type, UntranslatedDefinite);
85 return m_endLine; 85 return m_endLine;
86 } 86 }
87 87
88 size_t startLine() const { 88 size_t startLine() const {
89 ASSERT(isTranslatedDefinite()); 89 DCHECK(isTranslatedDefinite());
90 ASSERT(m_startLine >= 0); 90 DCHECK_GE(m_startLine, 0);
91 return m_startLine; 91 return m_startLine;
92 } 92 }
93 93
94 size_t endLine() const { 94 size_t endLine() const {
95 ASSERT(isTranslatedDefinite()); 95 DCHECK(isTranslatedDefinite());
96 ASSERT(m_endLine > 0); 96 DCHECK_GT(m_endLine, 0);
97 return m_endLine; 97 return m_endLine;
98 } 98 }
99 99
100 struct GridSpanIterator { 100 struct GridSpanIterator {
101 GridSpanIterator(size_t v) : value(v) {} 101 GridSpanIterator(size_t v) : value(v) {}
102 102
103 size_t operator*() const { return value; } 103 size_t operator*() const { return value; }
104 size_t operator++() { return value++; } 104 size_t operator++() { return value++; }
105 bool operator!=(GridSpanIterator other) const { 105 bool operator!=(GridSpanIterator other) const {
106 return value != other.value; 106 return value != other.value;
107 } 107 }
108 108
109 size_t value; 109 size_t value;
110 }; 110 };
111 111
112 GridSpanIterator begin() const { 112 GridSpanIterator begin() const {
113 ASSERT(isTranslatedDefinite()); 113 DCHECK(isTranslatedDefinite());
114 return m_startLine; 114 return m_startLine;
115 } 115 }
116 116
117 GridSpanIterator end() const { 117 GridSpanIterator end() const {
118 ASSERT(isTranslatedDefinite()); 118 DCHECK(isTranslatedDefinite());
119 return m_endLine; 119 return m_endLine;
120 } 120 }
121 121
122 bool isTranslatedDefinite() const { return m_type == TranslatedDefinite; } 122 bool isTranslatedDefinite() const { return m_type == TranslatedDefinite; }
123 123
124 bool isIndefinite() const { return m_type == Indefinite; } 124 bool isIndefinite() const { return m_type == Indefinite; }
125 125
126 void translate(size_t offset) { 126 void translate(size_t offset) {
127 ASSERT(m_type == UntranslatedDefinite); 127 DCHECK_EQ(m_type, UntranslatedDefinite);
128 128
129 m_type = TranslatedDefinite; 129 m_type = TranslatedDefinite;
130 m_startLine += offset; 130 m_startLine += offset;
131 m_endLine += offset; 131 m_endLine += offset;
132 132
133 ASSERT(m_startLine >= 0); 133 DCHECK_GE(m_startLine, 0);
134 ASSERT(m_endLine > 0); 134 DCHECK_GT(m_endLine, 0);
135 } 135 }
136 136
137 private: 137 private:
138 enum GridSpanType { UntranslatedDefinite, TranslatedDefinite, Indefinite }; 138 enum GridSpanType { UntranslatedDefinite, TranslatedDefinite, Indefinite };
139 139
140 GridSpan(int startLine, int endLine, GridSpanType type) : m_type(type) { 140 GridSpan(int startLine, int endLine, GridSpanType type) : m_type(type) {
141 #if DCHECK_IS_ON() 141 #if DCHECK_IS_ON()
142 ASSERT(startLine < endLine); 142 DCHECK_LT(startLine, endLine);
143 if (type == TranslatedDefinite) { 143 if (type == TranslatedDefinite) {
144 ASSERT(startLine >= 0); 144 DCHECK_GE(startLine, 0);
145 ASSERT(endLine > 0); 145 DCHECK_GT(endLine, 0);
146 } 146 }
147 #endif 147 #endif
148 148
149 m_startLine = clampTo<int>(startLine, -kGridMaxTracks, kGridMaxTracks - 1); 149 m_startLine = clampTo<int>(startLine, -kGridMaxTracks, kGridMaxTracks - 1);
150 m_endLine = clampTo<int>(endLine, -kGridMaxTracks + 1, kGridMaxTracks); 150 m_endLine = clampTo<int>(endLine, -kGridMaxTracks + 1, kGridMaxTracks);
151 } 151 }
152 152
153 int m_startLine; 153 int m_startLine;
154 int m_endLine; 154 int m_endLine;
155 GridSpanType m_type; 155 GridSpanType m_type;
(...skipping 19 matching lines...) Expand all
175 175
176 GridSpan columns; 176 GridSpan columns;
177 GridSpan rows; 177 GridSpan rows;
178 }; 178 };
179 179
180 typedef HashMap<String, GridArea> NamedGridAreaMap; 180 typedef HashMap<String, GridArea> NamedGridAreaMap;
181 181
182 } // namespace blink 182 } // namespace blink
183 183
184 #endif // GridArea_h 184 #endif // GridArea_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/FillLayer.h ('k') | third_party/WebKit/Source/core/style/GridLength.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698