Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 ASSERT(m_type == UntranslatedDefinite); | 140 ASSERT(m_type == UntranslatedDefinite); |
| 141 | 141 |
| 142 m_type = TranslatedDefinite; | 142 m_type = TranslatedDefinite; |
| 143 m_startLine += offset; | 143 m_startLine += offset; |
| 144 m_endLine += offset; | 144 m_endLine += offset; |
| 145 | 145 |
| 146 ASSERT(m_startLine >= 0); | 146 ASSERT(m_startLine >= 0); |
| 147 ASSERT(m_endLine > 0); | 147 ASSERT(m_endLine > 0); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void adjustForDroppedTracks(size_t numDroppedTracks); | |
|
Manuel Rego
2016/06/21 21:57:38
Why the implementation is not here like for the re
svillar
2016/06/23 08:09:42
Because it's kind of a non-written rule of the pro
| |
| 151 | |
| 150 private: | 152 private: |
| 151 | 153 |
| 152 enum GridSpanType {UntranslatedDefinite, TranslatedDefinite, Indefinite}; | 154 enum GridSpanType {UntranslatedDefinite, TranslatedDefinite, Indefinite}; |
| 153 | 155 |
| 154 GridSpan(int startLine, int endLine, GridSpanType type) | 156 GridSpan(int startLine, int endLine, GridSpanType type) |
| 155 : m_type(type) | 157 : m_type(type) |
| 156 { | 158 { |
| 157 #if ENABLE(ASSERT) | 159 #if ENABLE(ASSERT) |
| 158 ASSERT(startLine < endLine); | 160 ASSERT(startLine < endLine); |
| 159 if (type == TranslatedDefinite) { | 161 if (type == TranslatedDefinite) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 171 m_endLine = std::min(endLine, kGridMaxTracks); | 173 m_endLine = std::min(endLine, kGridMaxTracks); |
| 172 else | 174 else |
| 173 m_endLine = std::max(endLine, -kGridMaxTracks + 1); | 175 m_endLine = std::max(endLine, -kGridMaxTracks + 1); |
| 174 } | 176 } |
| 175 | 177 |
| 176 int m_startLine; | 178 int m_startLine; |
| 177 int m_endLine; | 179 int m_endLine; |
| 178 GridSpanType m_type; | 180 GridSpanType m_type; |
| 179 }; | 181 }; |
| 180 | 182 |
| 183 void inline GridSpan::adjustForDroppedTracks(size_t numDroppedTracks) | |
| 184 { | |
| 185 DCHECK(isTranslatedDefinite()); | |
| 186 DCHECK_GE(static_cast<size_t>(m_startLine), numDroppedTracks); | |
|
Manuel Rego
2016/06/21 21:57:38
You can use startLine() to avoid the manual cast h
svillar
2016/06/23 08:09:43
awesome
| |
| 187 DCHECK_GE(static_cast<size_t>(m_endLine), numDroppedTracks); | |
|
Manuel Rego
2016/06/21 21:57:38
m_endLine is always greater than m_startLine,
so t
svillar
2016/06/23 08:09:43
Acknowledged.
| |
| 188 m_startLine -= numDroppedTracks; | |
| 189 m_endLine -= numDroppedTracks; | |
| 190 } | |
| 191 | |
| 181 // This represents a grid area that spans in both rows' and columns' direction. | 192 // This represents a grid area that spans in both rows' and columns' direction. |
| 182 struct GridArea { | 193 struct GridArea { |
| 183 USING_FAST_MALLOC(GridArea); | 194 USING_FAST_MALLOC(GridArea); |
| 184 public: | 195 public: |
| 185 // HashMap requires a default constuctor. | 196 // HashMap requires a default constuctor. |
| 186 GridArea() | 197 GridArea() |
| 187 : columns(GridSpan::indefiniteGridSpan()) | 198 : columns(GridSpan::indefiniteGridSpan()) |
| 188 , rows(GridSpan::indefiniteGridSpan()) | 199 , rows(GridSpan::indefiniteGridSpan()) |
| 189 { | 200 { |
| 190 } | 201 } |
| 191 | 202 |
| 192 GridArea(const GridSpan& r, const GridSpan& c) | 203 GridArea(const GridSpan& r, const GridSpan& c) |
| 193 : columns(c) | 204 : columns(c) |
| 194 , rows(r) | 205 , rows(r) |
| 195 { | 206 { |
| 196 } | 207 } |
| 197 | 208 |
| 198 bool operator==(const GridArea& o) const | 209 bool operator==(const GridArea& o) const |
| 199 { | 210 { |
| 200 return columns == o.columns && rows == o.rows; | 211 return columns == o.columns && rows == o.rows; |
| 201 } | 212 } |
| 202 | 213 |
| 203 bool operator!=(const GridArea& o) const | 214 bool operator!=(const GridArea& o) const |
| 204 { | 215 { |
| 205 return !(*this == o); | 216 return !(*this == o); |
| 206 } | 217 } |
| 207 | 218 |
| 219 void adjustForDroppedTracks(size_t numDroppedColumns, size_t numDroppedRows) ; | |
|
Manuel Rego
2016/06/21 21:57:38
Ditto.
| |
| 220 | |
| 208 GridSpan columns; | 221 GridSpan columns; |
| 209 GridSpan rows; | 222 GridSpan rows; |
| 210 }; | 223 }; |
| 211 | 224 |
| 225 void inline GridArea::adjustForDroppedTracks(size_t numDroppedColumns, size_t nu mDroppedRows) | |
| 226 { | |
| 227 if (numDroppedColumns) | |
| 228 columns.adjustForDroppedTracks(numDroppedColumns); | |
| 229 if (numDroppedRows) | |
| 230 rows.adjustForDroppedTracks(numDroppedRows); | |
| 231 } | |
| 232 | |
| 212 typedef HashMap<String, GridArea> NamedGridAreaMap; | 233 typedef HashMap<String, GridArea> NamedGridAreaMap; |
| 213 | 234 |
| 214 } // namespace blink | 235 } // namespace blink |
| 215 | 236 |
| 216 #endif // GridArea_h | 237 #endif // GridArea_h |
| OLD | NEW |