OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "GridPositionsResolver.h" | 5 #include "GridPositionsResolver.h" |
6 | 6 |
7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
8 #include "core/style/GridArea.h" | 8 #include "core/style/GridArea.h" |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Negative positions are not allowed per the specification and should have
been handled during parsing. | 143 // Negative positions are not allowed per the specification and should have
been handled during parsing. |
144 ASSERT(position.spanPosition() > 0); | 144 ASSERT(position.spanPosition() > 0); |
145 | 145 |
146 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); | 146 const NamedGridLinesMap& gridLinesNames = gridLinesForSide(gridContainerStyl
e, side); |
147 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); | 147 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); |
148 const Vector<size_t>* gridLines = it == gridLinesNames.end() ? nullptr : &it
->value; | 148 const Vector<size_t>* gridLines = it == gridLinesNames.end() ? nullptr : &it
->value; |
149 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); | 149 size_t lastLine = explicitGridSizeForSide(gridContainerStyle, side); |
150 return definiteGridSpanWithNamedSpanAgainstOpposite(oppositeLine, position,
side, gridLines, lastLine); | 150 return definiteGridSpanWithNamedSpanAgainstOpposite(oppositeLine, position,
side, gridLines, lastLine); |
151 } | 151 } |
152 | 152 |
153 static GridSpan definiteGridSpanWithSpanAgainstOpposite(size_t oppositeLine, con
st GridPosition& position, GridPositionSide side) | 153 static GridSpan definiteGridSpanWithSpanAgainstOpposite(int oppositeLine, const
GridPosition& position, GridPositionSide side) |
154 { | 154 { |
155 size_t positionOffset = position.spanPosition(); | 155 size_t positionOffset = position.spanPosition(); |
156 if (side == ColumnStartSide || side == RowStartSide) | 156 if (side == ColumnStartSide || side == RowStartSide) |
157 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - positionOff
set, oppositeLine); | 157 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine - positionOff
set, oppositeLine); |
158 | 158 |
159 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, oppositeLine + p
ositionOffset); | 159 return GridSpan::untranslatedDefiniteGridSpan(oppositeLine, oppositeLine + p
ositionOffset); |
160 } | 160 } |
161 | 161 |
162 static GridSpan resolveGridPositionAgainstOppositePosition(const ComputedStyle&
gridContainerStyle, int oppositeLine, const GridPosition& position, GridPosition
Side side) | 162 static GridSpan resolveGridPositionAgainstOppositePosition(const ComputedStyle&
gridContainerStyle, int oppositeLine, const GridPosition& position, GridPosition
Side side) |
163 { | 163 { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 if (endLine < startLine) | 292 if (endLine < startLine) |
293 std::swap(endLine, startLine); | 293 std::swap(endLine, startLine); |
294 else if (endLine == startLine) | 294 else if (endLine == startLine) |
295 endLine = startLine + 1; | 295 endLine = startLine + 1; |
296 | 296 |
297 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine); | 297 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine); |
298 } | 298 } |
299 | 299 |
300 } // namespace blink | 300 } // namespace blink |
OLD | NEW |