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

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

Issue 181333003: [CSS Grid Layout] Use Render methods, rather than style, to determine shrink-to-fit behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | « Source/core/rendering/RenderGrid.h ('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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 clearPreferredLogicalWidthsDirty(); 335 clearPreferredLogicalWidthsDirty();
336 } 336 }
337 337
338 void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData) 338 void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData)
339 { 339 {
340 LayoutUnit availableLogicalSpace = (direction == ForColumns) ? availableLogi calWidth() : availableLogicalHeight(IncludeMarginBorderPadding); 340 LayoutUnit availableLogicalSpace = (direction == ForColumns) ? availableLogi calWidth() : availableLogicalHeight(IncludeMarginBorderPadding);
341 computeUsedBreadthOfGridTracks(direction, sizingData, availableLogicalSpace) ; 341 computeUsedBreadthOfGridTracks(direction, sizingData, availableLogicalSpace) ;
342 } 342 }
343 343
344 static bool gridElementIsShrinkToFit(const RenderStyle& style) 344 bool RenderGrid::gridElementIsShrinkToFit()
345 { 345 {
346 return style.isFloating() || style.position() == AbsolutePosition; 346 return isFloatingOrOutOfFlowPositioned();
Julien - ping for review 2014/02/26 22:43:43 Are fixed elements also shrink-to-fit? (this will
347 } 347 }
348 348
349 void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace) 349 void RenderGrid::computeUsedBreadthOfGridTracks(GridTrackSizingDirection directi on, GridSizingData& sizingData, LayoutUnit& availableLogicalSpace)
350 { 350 {
351 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks; 351 Vector<GridTrack>& tracks = (direction == ForColumns) ? sizingData.columnTra cks : sizingData.rowTracks;
352 Vector<size_t> flexibleSizedTracksIndex; 352 Vector<size_t> flexibleSizedTracksIndex;
353 sizingData.contentSizedTracksIndex.shrink(0); 353 sizingData.contentSizedTracksIndex.shrink(0);
354 354
355 // 1. Initialize per Grid track variables. 355 // 1. Initialize per Grid track variables.
356 for (size_t i = 0; i < tracks.size(); ++i) { 356 for (size_t i = 0; i < tracks.size(); ++i) {
(...skipping 15 matching lines...) Expand all
372 372
373 // 2. Resolve content-based TrackSizingFunctions. 373 // 2. Resolve content-based TrackSizingFunctions.
374 if (!sizingData.contentSizedTracksIndex.isEmpty()) 374 if (!sizingData.contentSizedTracksIndex.isEmpty())
375 resolveContentBasedTrackSizingFunctions(direction, sizingData, available LogicalSpace); 375 resolveContentBasedTrackSizingFunctions(direction, sizingData, available LogicalSpace);
376 376
377 for (size_t i = 0; i < tracks.size(); ++i) { 377 for (size_t i = 0; i < tracks.size(); ++i) {
378 ASSERT(tracks[i].m_maxBreadth != infinity); 378 ASSERT(tracks[i].m_maxBreadth != infinity);
379 availableLogicalSpace -= tracks[i].m_usedBreadth; 379 availableLogicalSpace -= tracks[i].m_usedBreadth;
380 } 380 }
381 381
382 const bool hasUndefinedRemainingSpace = (direction == ForRows) ? style()->lo gicalHeight().isAuto() : gridElementIsShrinkToFit(*style()); 382 const bool hasUndefinedRemainingSpace = (direction == ForRows) ? style()->lo gicalHeight().isAuto() : gridElementIsShrinkToFit();
383 383
384 if (!hasUndefinedRemainingSpace && availableLogicalSpace <= 0) 384 if (!hasUndefinedRemainingSpace && availableLogicalSpace <= 0)
385 return; 385 return;
386 386
387 // 3. Grow all Grid tracks in GridTracks from their UsedBreadth up to their MaxBreadth value until 387 // 3. Grow all Grid tracks in GridTracks from their UsedBreadth up to their MaxBreadth value until
388 // availableLogicalSpace (RemainingSpace in the specs) is exhausted. 388 // availableLogicalSpace (RemainingSpace in the specs) is exhausted.
389 const size_t tracksSize = tracks.size(); 389 const size_t tracksSize = tracks.size();
390 if (!hasUndefinedRemainingSpace) { 390 if (!hasUndefinedRemainingSpace) {
391 Vector<GridTrack*> tracksForDistribution(tracksSize); 391 Vector<GridTrack*> tracksForDistribution(tracksSize);
392 for (size_t i = 0; i < tracksSize; ++i) 392 for (size_t i = 0; i < tracksSize; ++i)
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 if (isOutOfFlowPositioned()) 1374 if (isOutOfFlowPositioned())
1375 return "RenderGrid (positioned)"; 1375 return "RenderGrid (positioned)";
1376 if (isAnonymous()) 1376 if (isAnonymous())
1377 return "RenderGrid (generated)"; 1377 return "RenderGrid (generated)";
1378 if (isRelPositioned()) 1378 if (isRelPositioned())
1379 return "RenderGrid (relative positioned)"; 1379 return "RenderGrid (relative positioned)";
1380 return "RenderGrid"; 1380 return "RenderGrid";
1381 } 1381 }
1382 1382
1383 } // namespace WebCore 1383 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698