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

Side by Side Diff: third_party/WebKit/Source/core/style/GridResolvedPosition.cpp

Issue 1496863004: [css-grid] Simplify method to resolve auto-placed items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kill-grid-resolved-position
Patch Set: Created 5 years 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 // 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 "config.h" 5 #include "config.h"
6 #include "core/style/GridResolvedPosition.h" 6 #include "core/style/GridResolvedPosition.h"
7 7
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/style/GridCoordinate.h" 9 #include "core/style/GridCoordinate.h"
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ASSERT(position.spanPosition() > 0); 148 ASSERT(position.spanPosition() > 0);
149 149
150 if (!position.namedGridLine().isNull()) { 150 if (!position.namedGridLine().isNull()) {
151 // span 2 'c' -> we need to find the appropriate grid line before / afte r our opposite position. 151 // span 2 'c' -> we need to find the appropriate grid line before / afte r our opposite position.
152 return resolveNamedGridLinePositionAgainstOppositePosition(gridContainer Style, resolvedOppositePosition, position, side); 152 return resolveNamedGridLinePositionAgainstOppositePosition(gridContainer Style, resolvedOppositePosition, position, side);
153 } 153 }
154 154
155 return definiteGridSpanWithSpanAgainstOpposite(resolvedOppositePosition, pos ition, side); 155 return definiteGridSpanWithSpanAgainstOpposite(resolvedOppositePosition, pos ition, side);
156 } 156 }
157 157
158 GridSpan GridResolvedPosition::resolveGridPositionsFromAutoPlacementPosition(con st ComputedStyle& gridContainerStyle, const LayoutBox& gridItem, GridTrackSizing Direction direction, size_t resolvedInitialPosition) 158 size_t GridResolvedPosition::spanSizeFromAutoPlacementPosition(const ComputedSty le& gridContainerStyle, const LayoutBox& gridItem, GridTrackSizingDirection dire ction)
159 { 159 {
160 GridPosition initialPosition, finalPosition; 160 GridPosition initialPosition, finalPosition;
161 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, i nitialPosition, finalPosition); 161 initialAndFinalPositionsFromStyle(gridContainerStyle, gridItem, direction, i nitialPosition, finalPosition);
162 162
163 GridPositionSide finalSide = finalPositionSide(direction);
164
165 // This method will only be used when both positions need to be resolved aga inst the opposite one. 163 // This method will only be used when both positions need to be resolved aga inst the opposite one.
166 ASSERT(initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPos ition.shouldBeResolvedAgainstOppositePosition()); 164 ASSERT(initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPos ition.shouldBeResolvedAgainstOppositePosition());
167 165
168 size_t resolvedFinalPosition = resolvedInitialPosition + 1; 166 if (initialPosition.isAuto() && finalPosition.isAuto())
167 return 1;
169 168
170 if (initialPosition.isSpan()) 169 GridPosition spanPosition = initialPosition.isSpan() ? initialPosition : fin alPosition;
171 return resolveGridPositionAgainstOppositePosition(gridContainerStyle, re solvedInitialPosition, initialPosition, finalSide); 170 ASSERT(spanPosition.isSpan());
172 if (finalPosition.isSpan()) 171 ASSERT(spanPosition.spanPosition());
173 return resolveGridPositionAgainstOppositePosition(gridContainerStyle, re solvedInitialPosition, finalPosition, finalSide); 172 return spanPosition.spanPosition();
svillar 2015/12/04 13:28:36 This is terribly confusing. We should use some oth
Manuel Rego 2015/12/04 14:49:10 True, I've changed it for "position".
174
175 return GridSpan::definiteGridSpan(resolvedInitialPosition, resolvedFinalPosi tion);
176 } 173 }
177 174
178 size_t GridResolvedPosition::explicitGridColumnCount(const ComputedStyle& gridCo ntainerStyle) 175 size_t GridResolvedPosition::explicitGridColumnCount(const ComputedStyle& gridCo ntainerStyle)
179 { 176 {
180 return std::min(gridContainerStyle.gridTemplateColumns().size(), kGridMaxTra cks); 177 return std::min(gridContainerStyle.gridTemplateColumns().size(), kGridMaxTra cks);
181 } 178 }
182 179
183 size_t GridResolvedPosition::explicitGridRowCount(const ComputedStyle& gridConta inerStyle) 180 size_t GridResolvedPosition::explicitGridRowCount(const ComputedStyle& gridConta inerStyle)
184 { 181 {
185 return std::min(gridContainerStyle.gridTemplateRows().size(), kGridMaxTracks ); 182 return std::min(gridContainerStyle.gridTemplateRows().size(), kGridMaxTracks );
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 295
299 if (resolvedFinalPosition < resolvedInitialPosition) 296 if (resolvedFinalPosition < resolvedInitialPosition)
300 std::swap(resolvedFinalPosition, resolvedInitialPosition); 297 std::swap(resolvedFinalPosition, resolvedInitialPosition);
301 else if (resolvedFinalPosition == resolvedInitialPosition) 298 else if (resolvedFinalPosition == resolvedInitialPosition)
302 resolvedFinalPosition = resolvedInitialPosition + 1; 299 resolvedFinalPosition = resolvedInitialPosition + 1;
303 300
304 return GridSpan::definiteGridSpan(resolvedInitialPosition, resolvedFinalPosi tion); 301 return GridSpan::definiteGridSpan(resolvedInitialPosition, resolvedFinalPosi tion);
305 } 302 }
306 303
307 } // namespace blink 304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698