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

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

Issue 1854623002: [css-grid] Use the margin box for non auto minimum sizes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 4 years, 8 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 | « third_party/WebKit/Source/core/layout/LayoutGrid.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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Vector<GridTrack> rowTracks; 240 Vector<GridTrack> rowTracks;
241 Vector<size_t> contentSizedTracksIndex; 241 Vector<size_t> contentSizedTracksIndex;
242 242
243 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free. 243 // Performance optimization: hold onto these Vectors until the end of Layout to avoid repeated malloc / free.
244 Vector<GridTrack*> filteredTracks; 244 Vector<GridTrack*> filteredTracks;
245 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan; 245 Vector<GridItemWithSpan> itemsSortedByIncreasingSpan;
246 Vector<GridTrack*> growBeyondGrowthLimitsTracks; 246 Vector<GridTrack*> growBeyondGrowthLimitsTracks;
247 247
248 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; } 248 LayoutUnit& freeSpaceForDirection(GridTrackSizingDirection direction) { retu rn direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; }
249 249
250 enum SizingOperation { TrackSizing, IntrinsicSizeComputation };
251 SizingOperation sizingOperation { TrackSizing };
252
250 private: 253 private:
251 LayoutUnit freeSpaceForColumns { }; 254 LayoutUnit freeSpaceForColumns { };
252 LayoutUnit freeSpaceForRows { }; 255 LayoutUnit freeSpaceForRows { };
253 }; 256 };
254 257
255 struct GridItemsSpanGroupRange { 258 struct GridItemsSpanGroupRange {
256 Vector<GridItemWithSpan>::iterator rangeStart; 259 Vector<GridItemWithSpan>::iterator rangeStart;
257 Vector<GridItemWithSpan>::iterator rangeEnd; 260 Vector<GridItemWithSpan>::iterator rangeEnd;
258 }; 261 };
259 262
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 326
324 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size()); 327 logicalHeight += guttersSize(ForRows, sizingData.rowTracks.size());
325 328
326 return logicalHeight; 329 return logicalHeight;
327 } 330 }
328 331
329 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace) 332 void LayoutGrid::computeTrackSizesForDirection(GridTrackSizingDirection directio n, GridSizingData& sizingData, LayoutUnit freeSpace)
330 { 333 {
331 ASSERT(freeSpace >= 0); 334 ASSERT(freeSpace >= 0);
332 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount()); 335 sizingData.freeSpaceForDirection(direction) = freeSpace - guttersSize(direct ion, direction == ForRows ? gridRowCount() : gridColumnCount());
336 sizingData.sizingOperation = GridSizingData::TrackSizing;
333 337
334 LayoutUnit baseSizes, growthLimits; 338 LayoutUnit baseSizes, growthLimits;
335 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s, AvailableSpaceDefinite); 339 computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimit s, AvailableSpaceDefinite);
336 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData)); 340 ASSERT(tracksAreWiderThanMinTrackBreadth(direction, sizingData));
337 } 341 }
338 342
339 void LayoutGrid::layoutBlock(bool relayoutChildren) 343 void LayoutGrid::layoutBlock(bool relayoutChildren)
340 { 344 {
341 ASSERT(needsLayout()); 345 ASSERT(needsLayout());
342 346
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap(); 416 const Length& trackGap = direction == ForColumns ? styleRef().gridColumnGap( ) : styleRef().gridRowGap();
413 return valueForLength(trackGap, LayoutUnit()) * (span - 1); 417 return valueForLength(trackGap, LayoutUnit()) * (span - 1);
414 } 418 }
415 419
416 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const 420 void LayoutGrid::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const
417 { 421 {
418 const_cast<LayoutGrid*>(this)->placeItemsOnGrid(); 422 const_cast<LayoutGrid*>(this)->placeItemsOnGrid();
419 423
420 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 424 GridSizingData sizingData(gridColumnCount(), gridRowCount());
421 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit(); 425 sizingData.freeSpaceForDirection(ForColumns) = LayoutUnit();
426 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation;
422 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite); 427 const_cast<LayoutGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, si zingData, minLogicalWidth, maxLogicalWidth, AvailableSpaceIndefinite);
423 428
424 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size()); 429 LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTrack s.size());
425 minLogicalWidth += totalGuttersSize; 430 minLogicalWidth += totalGuttersSize;
426 maxLogicalWidth += totalGuttersSize; 431 maxLogicalWidth += totalGuttersSize;
427 432
428 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth()); 433 LayoutUnit scrollbarWidth = LayoutUnit(intrinsicScrollbarLogicalWidth());
429 minLogicalWidth += scrollbarWidth; 434 minLogicalWidth += scrollbarWidth;
430 maxLogicalWidth += scrollbarWidth; 435 maxLogicalWidth += scrollbarWidth;
431 } 436 }
432 437
433 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData) 438 void LayoutGrid::computeIntrinsicLogicalHeight(GridSizingData& sizingData)
434 { 439 {
435 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); 440 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData));
436 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit(); 441 sizingData.freeSpaceForDirection(ForRows) = LayoutUnit();
442 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation;
437 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight, AvailableSpaceIndefinite); 443 computeUsedBreadthOfGridTracks(ForRows, sizingData, m_minContentHeight, m_ma xContentHeight, AvailableSpaceIndefinite);
438 444
439 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount()); 445 LayoutUnit totalGuttersSize = guttersSize(ForRows, gridRowCount());
440 m_minContentHeight += totalGuttersSize; 446 m_minContentHeight += totalGuttersSize;
441 m_maxContentHeight += totalGuttersSize; 447 m_maxContentHeight += totalGuttersSize;
442 448
443 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData)); 449 ASSERT(tracksAreWiderThanMinTrackBreadth(ForRows, sizingData));
444 } 450 }
445 451
446 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const 452 LayoutUnit LayoutGrid::computeIntrinsicLogicalContentHeightUsing(const Length& l ogicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddi ng) const
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 maxTrackBreadth = Length(Auto); 682 maxTrackBreadth = Length(Auto);
677 } 683 }
678 } 684 }
679 685
680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); 686 return GridTrackSize(minTrackBreadth, maxTrackBreadth);
681 } 687 }
682 688
683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData) 689 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, GridSizingData& s izingData)
684 { 690 {
685 SubtreeLayoutScope layoutScope(child); 691 SubtreeLayoutScope layoutScope(child);
686 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth () : LayoutUnit();
687 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh ild(child, ForColumns, sizingData.columnTracks);
688 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh t() || child.styleRef().logicalHeight().isIntrinsicOrAuto(); 692 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh t() || child.styleRef().logicalHeight().isIntrinsicOrAuto();
689 if (shouldClearContainingBlockLogicalHeight || oldOverrideContainingBlockCon tentLogicalWidth != overrideContainingBlockContentLogicalWidth) 693 if (shouldClearContainingBlockLogicalHeight)
690 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged ); 694 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged );
691 695
692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); 696 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight();
693 // We need to clear the stretched height to properly compute logical height during layout. 697 // We need to clear the stretched height to properly compute logical height during layout.
694 if (hasOverrideHeight && child.needsLayout()) 698 if (hasOverrideHeight && child.needsLayout())
695 child.clearOverrideLogicalContentHeight(); 699 child.clearOverrideLogicalContentHeight();
696 700
697 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC ontentLogicalWidth);
698 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is 701 // If |child| has a relative logical height, we shouldn't let it override it s intrinsic height, which is
699 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 702 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution).
700 if (shouldClearContainingBlockLogicalHeight) 703 if (shouldClearContainingBlockLogicalHeight)
701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); 704 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1));
702 child.layoutIfNeeded(); 705 child.layoutIfNeeded();
703 // If the child was stretched we should use its intrinsic height. 706 // If the child was stretched we should use its intrinsic height.
704 return child.logicalHeight() + child.marginLogicalHeight(); 707 return child.logicalHeight() + child.marginLogicalHeight();
705 } 708 }
706 709
707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData) 710 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio n direction, GridSizingData& sizingData)
708 { 711 {
709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 712 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
710 // TODO(svillar): Properly support orthogonal writing mode. 713 // TODO(svillar): Properly support orthogonal writing mode.
711 if (hasOrthogonalWritingMode) 714 if (hasOrthogonalWritingMode)
712 return LayoutUnit(); 715 return LayoutUnit();
713 716
714 bool isRowAxis = direction == ForColumns; 717 bool isRowAxis = direction == ForColumns;
715 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight(); 718 const Length& childSize = isRowAxis ? child.styleRef().logicalWidth() : chil d.styleRef().logicalHeight();
716 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight(); 719 const Length& childMinSize = isRowAxis ? child.styleRef().logicalMinWidth() : child.styleRef().logicalMinHeight();
717 if (!childSize.isAuto() || childMinSize.isAuto()) 720 if (!childSize.isAuto() || childMinSize.isAuto())
718 return minContentForChild(child, direction, sizingData); 721 return minContentForChild(child, direction, sizingData);
719 722
720 if (isRowAxis) 723 bool overrideLogicalWidthHasChanged = updateOverrideContainingBlockContentLo gicalWidthForChild(child, sizingData);
721 return child.computeLogicalWidthUsing(MinSize, childMinSize, contentLogi calWidth(), this); 724 if (isRowAxis) {
725 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizing Data::TrackSizing ? computeMarginLogicalSizeForChild(InlineDirection, child) : m arginIntrinsicLogicalWidthForChild(child);
726 return child.computeLogicalWidthUsing(MinSize, childMinSize, child.overr ideContainingBlockContentLogicalWidth(), this) + marginLogicalWidth;
727 }
722 728
723 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.scrollbarLogicalHeight(); 729 if (overrideLogicalWidthHasChanged)
730 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
731 child.layoutIfNeeded();
732 return child.computeLogicalHeightUsing(MinSize, childMinSize, child.intrinsi cLogicalHeight()) + child.marginLogicalHeight() + child.scrollbarLogicalHeight() ;
733 }
734
735 bool LayoutGrid::updateOverrideContainingBlockContentLogicalWidthForChild(Layout Box& child, GridSizingData& sizingData)
736 {
737 LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizing Data.columnTracks);
738 if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContaini ngBlockContentLogicalWidth() == overrideWidth)
739 return false;
740
741 child.setOverrideContainingBlockContentLogicalWidth(overrideWidth);
742 return true;
724 } 743 }
725 744
726 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) 745 LayoutUnit LayoutGrid::minContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData)
727 { 746 {
728 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 747 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
729 // FIXME: Properly support orthogonal writing mode. 748 // FIXME: Properly support orthogonal writing mode.
730 if (hasOrthogonalWritingMode) 749 if (hasOrthogonalWritingMode)
731 return LayoutUnit(); 750 return LayoutUnit();
732 751
733 if (direction == ForColumns) { 752 if (direction == ForColumns) {
734 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 753 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
735 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). 754 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution).
736 if (child.hasRelativeLogicalWidth()) 755 if (child.hasRelativeLogicalWidth())
737 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); 756 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1));
738 757
739 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 758 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
740 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 759 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
741 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 760 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
742 } 761 }
743 762
763 SubtreeLayoutScope layouter(child);
764 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingDa ta))
765 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
744 return logicalHeightForChild(child, sizingData); 766 return logicalHeightForChild(child, sizingData);
745 } 767 }
746 768
747 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData) 769 LayoutUnit LayoutGrid::maxContentForChild(LayoutBox& child, GridTrackSizingDirec tion direction, GridSizingData& sizingData)
748 { 770 {
749 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 771 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
750 // FIXME: Properly support orthogonal writing mode. 772 // FIXME: Properly support orthogonal writing mode.
751 if (hasOrthogonalWritingMode) 773 if (hasOrthogonalWritingMode)
752 return LayoutUnit(); 774 return LayoutUnit();
753 775
754 if (direction == ForColumns) { 776 if (direction == ForColumns) {
755 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is 777 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is
756 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution). 778 // what we are interested in here. Thus we need to set the override logi cal width to -1 (no possible resolution).
757 if (child.hasRelativeLogicalWidth()) 779 if (child.hasRelativeLogicalWidth())
758 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1)); 780 child.setOverrideContainingBlockContentLogicalWidth(LayoutUnit(-1));
759 781
760 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 782 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
761 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 783 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
762 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 784 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
763 } 785 }
764 786
787 SubtreeLayoutScope layouter(child);
788 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingDa ta))
789 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
765 return logicalHeightForChild(child, sizingData); 790 return logicalHeightForChild(child, sizingData);
766 } 791 }
767 792
768 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more 793 // We're basically using a class instead of a std::pair because of accessing gri dItem() or getGridSpan() is much more
769 // self-explanatory that using .first or .second members in the pair. Having a s td::pair<LayoutBox*, size_t> 794 // self-explanatory that using .first or .second members in the pair. Having a s td::pair<LayoutBox*, size_t>
770 // does not work either because we still need the GridSpan so we'd have to add a n extra hash lookup for each item 795 // does not work either because we still need the GridSpan so we'd have to add a n extra hash lookup for each item
771 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms(). 796 // at the beginning of LayoutGrid::resolveContentBasedTrackSizingFunctionsForIte ms().
772 class GridItemWithSpan { 797 class GridItemWithSpan {
773 public: 798 public:
774 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan) 799 GridItemWithSpan(LayoutBox& gridItem, const GridSpan& gridSpan)
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 ASSERT_NOT_REACHED(); 1666 ASSERT_NOT_REACHED();
1642 return LayoutUnit(); 1667 return LayoutUnit();
1643 } 1668 }
1644 1669
1645 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1670 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1646 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const 1671 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const
1647 { 1672 {
1648 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth( ); 1673 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth( );
1649 } 1674 }
1650 1675
1651 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child ) const 1676 LayoutUnit LayoutGrid::computeMarginLogicalSizeForChild(MarginDirection forDirec tion, const LayoutBox& child) const
1652 { 1677 {
1653 if (!child.styleRef().hasMargin()) 1678 if (!child.styleRef().hasMargin())
1654 return LayoutUnit(); 1679 return LayoutUnit();
1655 1680
1656 LayoutUnit marginBefore; 1681 bool isRowAxis = forDirection == InlineDirection;
1657 LayoutUnit marginAfter; 1682 LayoutUnit marginStart;
1658 child.computeMarginsForDirection(BlockDirection, this, child.containingBlock LogicalWidthForContent(), child.logicalHeight(), marginBefore, marginAfter, 1683 LayoutUnit marginEnd;
1659 child.style()->marginBeforeUsing(style()), 1684 LayoutUnit logicalSize = isRowAxis ? child.logicalWidth() : child.logicalHei ght();
1660 child.style()->marginAfterUsing(style())); 1685 Length marginStartLength = isRowAxis ? child.styleRef().marginStart() : chil d.styleRef().marginBeforeUsing(style());
1686 Length marginEndLength = isRowAxis ? child.styleRef().marginEnd() : child.st yleRef().marginAfterUsing(style());
1687 child.computeMarginsForDirection(forDirection, this, child.containingBlockLo gicalWidthForContent(), logicalSize,
1688 marginStart, marginEnd, marginStartLength, marginEndLength);
1661 1689
1662 return marginBefore + marginAfter; 1690 return marginStart + marginEnd;
1663 } 1691 }
1664 1692
1665 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const 1693 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUni t gridAreaBreadthForChild, const LayoutBox& child) const
1666 { 1694 {
1667 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before 1695 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before
1668 // children are laid out, so we can't use the child cached values. Hence, we need to 1696 // children are laid out, so we can't use the child cached values. Hence, we need to
1669 // compute margins in order to determine the available height before stretch ing. 1697 // compute margins in order to determine the available height before stretch ing.
1670 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical HeightForChild(child) : marginLogicalHeightForChild(child)); 1698 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical SizeForChild(BlockDirection, child) : marginLogicalHeightForChild(child));
1671 } 1699 }
1672 1700
1673 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1701 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1674 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) 1702 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child)
1675 { 1703 {
1676 // We clear height override values because we will decide now whether it's a llowed or 1704 // We clear height override values because we will decide now whether it's a llowed or
1677 // not, evaluating the conditions which might have changed since the old val ues were set. 1705 // not, evaluating the conditions which might have changed since the old val ues were set.
1678 child.clearOverrideLogicalContentHeight(); 1706 child.clearOverrideLogicalContentHeight();
1679 1707
1680 auto& childStyle = child.styleRef(); 1708 auto& childStyle = child.styleRef();
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2068
2041 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData )); 2069 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData ));
2042 } 2070 }
2043 2071
2044 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const 2072 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const
2045 { 2073 {
2046 GridPainter(*this).paintChildren(paintInfo, paintOffset); 2074 GridPainter(*this).paintChildren(paintInfo, paintOffset);
2047 } 2075 }
2048 2076
2049 } // namespace blink 2077 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698