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

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

Issue 2080643002: [css-grid] Implement repeat(auto-fit) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build (debug) fix Created 4 years, 6 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 // 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 16 matching lines...) Expand all
27 bool isRowAxis = direction == ForColumns; 27 bool isRowAxis = direction == ForColumns;
28 const NamedGridLinesMap& gridLineNames = isRowAxis ? gridContainerStyle.name dGridColumnLines() : gridContainerStyle.namedGridRowLines(); 28 const NamedGridLinesMap& gridLineNames = isRowAxis ? gridContainerStyle.name dGridColumnLines() : gridContainerStyle.namedGridRowLines();
29 const NamedGridLinesMap& autoRepeatGridLineNames = isRowAxis ? gridContainer Style.autoRepeatNamedGridColumnLines() : gridContainerStyle.autoRepeatNamedGridR owLines(); 29 const NamedGridLinesMap& autoRepeatGridLineNames = isRowAxis ? gridContainer Style.autoRepeatNamedGridColumnLines() : gridContainerStyle.autoRepeatNamedGridR owLines();
30 30
31 if (!gridLineNames.isEmpty()) { 31 if (!gridLineNames.isEmpty()) {
32 auto it = gridLineNames.find(namedLine); 32 auto it = gridLineNames.find(namedLine);
33 m_namedLinesIndexes = it == gridLineNames.end() ? nullptr : &it->value; 33 m_namedLinesIndexes = it == gridLineNames.end() ? nullptr : &it->value;
34 } 34 }
35 35
36 if (!autoRepeatGridLineNames.isEmpty()) { 36 if (!autoRepeatGridLineNames.isEmpty()) {
37 auto it = autoRepeatGridLineNames.find(namedLine); 37 auto it = m_repetitions ? autoRepeatGridLineNames.find(namedLine) : auto RepeatGridLineNames.end();
38 m_autoRepeatNamedLinesIndexes = it == autoRepeatGridLineNames.end() ? nu llptr : &it->value; 38 m_autoRepeatNamedLinesIndexes = it == autoRepeatGridLineNames.end() ? nu llptr : &it->value;
39 } 39 }
40 40
41 m_insertionPoint = isRowAxis ? gridContainerStyle.gridAutoRepeatColumnsInser tionPoint() : gridContainerStyle.gridAutoRepeatRowsInsertionPoint(); 41 m_insertionPoint = isRowAxis ? gridContainerStyle.gridAutoRepeatColumnsInser tionPoint() : gridContainerStyle.gridAutoRepeatRowsInsertionPoint();
42 } 42 }
43 43
44 bool NamedLineCollection::isValidNamedLineOrArea(const String& namedLine, const ComputedStyle& gridContainerStyle, GridPositionSide side) 44 bool NamedLineCollection::isValidNamedLineOrArea(const String& namedLine, const ComputedStyle& gridContainerStyle, GridPositionSide side)
45 { 45 {
46 bool isRowAxis = directionFromSide(side) == ForColumns; 46 bool isRowAxis = directionFromSide(side) == ForColumns;
47 const NamedGridLinesMap& gridLineNames = isRowAxis ? gridContainerStyle.name dGridColumnLines() : gridContainerStyle.namedGridRowLines(); 47 const NamedGridLinesMap& gridLineNames = isRowAxis ? gridContainerStyle.name dGridColumnLines() : gridContainerStyle.namedGridRowLines();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 NamedLineCollection implicitLines(gridContainerStyle, implicitNamedGridL ineForSide(namedGridLine, side), directionFromSide(side), lastLine, autoRepeatTr acksCount); 320 NamedLineCollection implicitLines(gridContainerStyle, implicitNamedGridL ineForSide(namedGridLine, side), directionFromSide(side), lastLine, autoRepeatTr acksCount);
321 if (implicitLines.hasNamedLines()) 321 if (implicitLines.hasNamedLines())
322 return implicitLines.firstPosition(); 322 return implicitLines.firstPosition();
323 323
324 // Otherwise, if there is a named line with the specified name, contribu tes the first such line to the grid 324 // Otherwise, if there is a named line with the specified name, contribu tes the first such line to the grid
325 // item's placement. 325 // item's placement.
326 NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, dir ectionFromSide(side), lastLine, autoRepeatTracksCount); 326 NamedLineCollection explicitLines(gridContainerStyle, namedGridLine, dir ectionFromSide(side), lastLine, autoRepeatTracksCount);
327 if (explicitLines.hasNamedLines()) 327 if (explicitLines.hasNamedLines())
328 return explicitLines.firstPosition(); 328 return explicitLines.firstPosition();
329 329
330 ASSERT(!NamedLineCollection::isValidNamedLineOrArea(namedGridLine, gridC ontainerStyle, side)); 330 DCHECK(!NamedLineCollection::isValidNamedLineOrArea(namedGridLine, gridC ontainerStyle, side) || !autoRepeatTracksCount);
331 // If none of the above works specs mandate to assume that all the lines in the implicit grid have this name. 331 // If none of the above works specs mandate to assume that all the lines in the implicit grid have this name.
332 return lastLine + 1; 332 return lastLine + 1;
333 } 333 }
334 case AutoPosition: 334 case AutoPosition:
335 case SpanPosition: 335 case SpanPosition:
336 // 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader"). 336 // 'auto' and span depend on the opposite position for resolution (e.g. grid-row: auto / 1 or grid-column: span 3 / "myHeader").
337 ASSERT_NOT_REACHED(); 337 ASSERT_NOT_REACHED();
338 return 0; 338 return 0;
339 } 339 }
340 ASSERT_NOT_REACHED(); 340 ASSERT_NOT_REACHED();
(...skipping 30 matching lines...) Expand all
371 371
372 if (endLine < startLine) 372 if (endLine < startLine)
373 std::swap(endLine, startLine); 373 std::swap(endLine, startLine);
374 else if (endLine == startLine) 374 else if (endLine == startLine)
375 endLine = startLine + 1; 375 endLine = startLine + 1;
376 376
377 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine); 377 return GridSpan::untranslatedDefiniteGridSpan(startLine, endLine);
378 } 378 }
379 379
380 } // namespace blink 380 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698