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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2334133002: [css-grid] Cache definite height detection (Closed)
Patch Set: New version using m_hasDefiniteLogicalHeight class member Created 4 years, 3 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 /* 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 SubtreeLayoutScope layoutScope(*this); 446 SubtreeLayoutScope layoutScope(*this);
447 447
448 { 448 {
449 // LayoutState needs this deliberate scope to pop before updating scroll information (which 449 // LayoutState needs this deliberate scope to pop before updating scroll information (which
450 // may trigger relayout). 450 // may trigger relayout).
451 LayoutState state(*this, locationOffset()); 451 LayoutState state(*this, locationOffset());
452 452
453 LayoutSize previousSize = size(); 453 LayoutSize previousSize = size();
454 454
455 updateLogicalWidth(); 455 updateLogicalWidth();
456 bool logicalHeightWasIndefinite = !hasDefiniteLogicalHeight(); 456 m_hasDefiniteLogicalHeight = LayoutBlock::hasDefiniteLogicalHeight();
jfernandez 2016/09/15 07:27:11 As commented before, we shouldn't need to specify
svillar 2016/09/15 08:02:22 I would not initialize it this way, see my comment
457 457
458 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope); 458 TextAutosizer::LayoutScope textAutosizerLayoutScope(this, &layoutScope);
459 459
460 // TODO(svillar): we won't need to do this once the intrinsic width comp utation is isolated 460 // TODO(svillar): we won't need to do this once the intrinsic width comp utation is isolated
461 // from the LayoutGrid object state (it should not touch any attribute) (see crbug.com/627812) 461 // from the LayoutGrid object state (it should not touch any attribute) (see crbug.com/627812)
462 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack sCount(ForColumns, TrackSizing)) 462 if (m_autoRepeatColumns && m_autoRepeatColumns != computeAutoRepeatTrack sCount(ForColumns, TrackSizing))
463 dirtyGrid(); 463 dirtyGrid();
464 placeItemsOnGrid(TrackSizing); 464 placeItemsOnGrid(TrackSizing);
465 465
466 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 466 GridSizingData sizingData(gridColumnCount(), gridRowCount());
467 467
468 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns. 468 // 1- First, the track sizing algorithm is used to resolve the sizes of the grid columns.
469 // At this point the logical width is always definite as the above call to updateLogicalWidth() 469 // At this point the logical width is always definite as the above call to updateLogicalWidth()
470 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code 470 // properly resolves intrinsic sizes. We cannot do the same for heights though because many code
471 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve 471 // paths inside updateLogicalHeight() require a previous call to setLogi calHeight() to resolve
472 // heights properly (like for positioned items for example). 472 // heights properly (like for positioned items for example).
473 LayoutUnit availableSpaceForColumns = availableLogicalWidth(); 473 LayoutUnit availableSpaceForColumns = availableLogicalWidth();
474 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC olumns); 474 computeTrackSizesForDirection(ForColumns, sizingData, availableSpaceForC olumns);
475 475
476 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro ws, using the 476 // 2- Next, the track sizing algorithm resolves the sizes of the grid ro ws, using the
477 // grid column sizes calculated in the previous step. 477 // grid column sizes calculated in the previous step.
478 if (logicalHeightWasIndefinite) 478 if (hasDefiniteLogicalHeight())
479 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH eight(ExcludeMarginBorderPadding));
480 else
479 computeIntrinsicLogicalHeight(sizingData); 481 computeIntrinsicLogicalHeight(sizingData);
480 else
481 computeTrackSizesForDirection(ForRows, sizingData, availableLogicalH eight(ExcludeMarginBorderPadding));
482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight() + scrollbarLogicalHeight()); 482 setLogicalHeight(computeTrackBasedLogicalHeight(sizingData) + borderAndP addingLogicalHeight() + scrollbarLogicalHeight());
483 483
484 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 484 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
485 updateLogicalHeight(); 485 updateLogicalHeight();
486 486
487 // The above call might have changed the grid's logical height depending on min|max height restrictions. 487 // The above call might have changed the grid's logical height depending on min|max height restrictions.
488 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes). 488 // Update the sizes of the rows whose size depends on the logical height (also on definite|indefinite sizes).
489 LayoutUnit availableSpaceForRows = contentLogicalHeight(); 489 LayoutUnit availableSpaceForRows = contentLogicalHeight();
490 if (logicalHeightWasIndefinite) 490 if (!hasDefiniteLogicalHeight())
491 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor Rows); 491 computeTrackSizesForDirection(ForRows, sizingData, availableSpaceFor Rows);
492 492
493 // 3- If the min-content contribution of any grid items have changed bas ed on the row 493 // 3- If the min-content contribution of any grid items have changed bas ed on the row
494 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m in-content 494 // sizes calculated in step 2, steps 1 and 2 are repeated with the new m in-content
495 // contribution (once only). 495 // contribution (once only).
496 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, availab leSpaceForRows); 496 repeatTracksSizingIfNeeded(sizingData, availableSpaceForColumns, availab leSpaceForRows);
497 497
498 // Grid container should have the minimum height of a line if it's edita ble. That doesn't affect track sizing though. 498 // Grid container should have the minimum height of a line if it's edita ble. That doesn't affect track sizing though.
499 if (hasLineIfEmpty()) 499 if (hasLineIfEmpty())
500 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm ptyLine())); 500 setLogicalHeight(std::max(logicalHeight(), minimumLogicalHeightForEm ptyLine()));
(...skipping 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; 2661 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation;
2662 } 2662 }
2663 2663
2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2664 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2665 { 2665 {
2666 if (!m_gridItemArea.isEmpty()) 2666 if (!m_gridItemArea.isEmpty())
2667 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2667 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2668 } 2668 }
2669 2669
2670 } // namespace blink 2670 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698