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

Side by Side Diff: Source/core/rendering/RenderGrid.cpp

Issue 314993002: [CSS Grid Layout] Fix auto-placement algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 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
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 // This will happen when we have "span <custom-indent>", which has a different resolution based on the position. 925 // This will happen when we have "span <custom-indent>", which has a different resolution based on the position.
926 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPosit ionsFromAutoPlacementPosition(*style(), *gridItem, autoPlacementMajorAxisDirecti on(), majorAxisIndex); 926 GridSpan majorAxisPositions = GridResolvedPosition::resolveGridPosit ionsFromAutoPlacementPosition(*style(), *gridItem, autoPlacementMajorAxisDirecti on(), majorAxisIndex);
927 emptyGridArea = findEmptyGridAreaAtSpecifiedPositionsInsideGrid(grid Item, autoPlacementMajorAxisDirection(), majorAxisPositions); 927 emptyGridArea = findEmptyGridAreaAtSpecifiedPositionsInsideGrid(grid Item, autoPlacementMajorAxisDirection(), majorAxisPositions);
928 928
929 if (emptyGridArea) { 929 if (emptyGridArea) {
930 // Check that it fits in the minor axis direction, as we shouldn 't grow in that direction here (it was already managed in populateExplicitGridAn dOrderIterator()). 930 // Check that it fits in the minor axis direction, as we shouldn 't grow in that direction here (it was already managed in populateExplicitGridAn dOrderIterator()).
931 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio n : emptyGridArea->rows.resolvedFinalPosition; 931 GridResolvedPosition minorAxisFinalPositionIndex = autoPlacement MinorAxisDirection() == ForColumns ? emptyGridArea->columns.resolvedFinalPositio n : emptyGridArea->rows.resolvedFinalPosition;
932 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection() == ForColumns ? gridColumnCount() : gridRowCount(); 932 const size_t endOfMinorAxis = autoPlacementMinorAxisDirection() == ForColumns ? gridColumnCount() : gridRowCount();
933 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis) 933 if (minorAxisFinalPositionIndex.toInt() < endOfMinorAxis)
934 break; 934 break;
935
936 // Discard empty grid area as it does not fit in the minor axis direction.
937 // We don't need to create a new empty grid area yet as we might find a valid one in the next iteration.
938 emptyGridArea = nullptr;
935 } 939 }
936 } 940 }
937 941
938 if (!emptyGridArea) { 942 if (!emptyGridArea) {
939 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPosit ionsFromAutoPlacementPosition(*style(), *gridItem, autoPlacementMinorAxisDirecti on(), GridResolvedPosition(0)); 943 GridSpan minorAxisPositions = GridResolvedPosition::resolveGridPosit ionsFromAutoPlacementPosition(*style(), *gridItem, autoPlacementMinorAxisDirecti on(), GridResolvedPosition(0));
940 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g ridItem, autoPlacementMinorAxisDirection(), minorAxisPositions); 944 emptyGridArea = createEmptyGridAreaAtSpecifiedPositionsOutsideGrid(g ridItem, autoPlacementMinorAxisDirection(), minorAxisPositions);
941 } 945 }
942 } 946 }
943 947
944 insertItemIntoGrid(gridItem, *emptyGridArea); 948 insertItemIntoGrid(gridItem, *emptyGridArea);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 if (isOutOfFlowPositioned()) 1263 if (isOutOfFlowPositioned())
1260 return "RenderGrid (positioned)"; 1264 return "RenderGrid (positioned)";
1261 if (isAnonymous()) 1265 if (isAnonymous())
1262 return "RenderGrid (generated)"; 1266 return "RenderGrid (generated)";
1263 if (isRelPositioned()) 1267 if (isRelPositioned())
1264 return "RenderGrid (relative positioned)"; 1268 return "RenderGrid (relative positioned)";
1265 return "RenderGrid"; 1269 return "RenderGrid";
1266 } 1270 }
1267 1271
1268 } // namespace WebCore 1272 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-item-auto-placement-automatic-span-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698