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

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

Issue 815833005: [css-grid] Handle min-content/max-content with orthogonal flows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Solving positioning issues. Created 5 years, 11 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/resources/grid.css ('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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is 643 // If |child| has a percentage logical height, we shouldn't let it override its intrinsic height, which is
644 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution). 644 // what we are interested in here. Thus we need to set the override logical height to -1 (no possible resolution).
645 child.setOverrideContainingBlockContentLogicalHeight(-1); 645 child.setOverrideContainingBlockContentLogicalHeight(-1);
646 child.layoutIfNeeded(); 646 child.layoutIfNeeded();
647 return child.logicalHeight() + child.marginLogicalHeight(); 647 return child.logicalHeight() + child.marginLogicalHeight();
648 } 648 }
649 649
650 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 650 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks)
651 { 651 {
652 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 652 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
653 // FIXME: Properly support orthogonal writing mode.
654 if (hasOrthogonalWritingMode) 653 if (hasOrthogonalWritingMode)
655 return 0; 654 direction = direction == ForColumns ? ForRows : ForColumns;
svillar 2015/01/12 08:27:51 As a side note, we have a lot of direction==ForCol
656 655
657 if (direction == ForColumns) { 656 if (direction == ForColumns) {
658 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 657 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
659 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 658 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
660 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 659 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
661 } 660 }
662 661
663 return logicalHeightForChild(child, columnTracks); 662 return logicalHeightForChild(child, columnTracks);
664 } 663 }
665 664
666 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 665 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks)
667 { 666 {
668 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 667 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
669 // FIXME: Properly support orthogonal writing mode.
670 if (hasOrthogonalWritingMode) 668 if (hasOrthogonalWritingMode)
671 return LayoutUnit(); 669 direction = direction == ForColumns ? ForRows : ForColumns;
672 670
673 if (direction == ForColumns) { 671 if (direction == ForColumns) {
674 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 672 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
675 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 673 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
676 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child); 674 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
677 } 675 }
678 676
679 return logicalHeightForChild(child, columnTracks); 677 return logicalHeightForChild(child, columnTracks);
680 } 678 }
681 679
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 } 1121 }
1124 1122
1125 // Because the grid area cannot be styled, we don't need to adjust 1123 // Because the grid area cannot be styled, we don't need to adjust
1126 // the grid breadth to account for 'box-sizing'. 1124 // the grid breadth to account for 'box-sizing'.
1127 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit(); 1125 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child->hasOve rrideContainingBlockLogicalWidth() ? child->overrideContainingBlockContentLogica lWidth() : LayoutUnit();
1128 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit(); 1126 LayoutUnit oldOverrideContainingBlockContentLogicalHeight = child->hasOv errideContainingBlockLogicalHeight() ? child->overrideContainingBlockContentLogi calHeight() : LayoutUnit();
1129 1127
1130 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks); 1128 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthF orChild(*child, ForColumns, sizingData.columnTracks);
1131 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks); 1129 LayoutUnit overrideContainingBlockContentLogicalHeight = gridAreaBreadth ForChild(*child, ForRows, sizingData.rowTracks);
1132 1130
1131 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHo rizontalWritingMode();
Julien - ping for review 2015/01/21 09:32:10 Why do we need to _always_ force a layout in the o
1132
1133 SubtreeLayoutScope layoutScope(*child); 1133 SubtreeLayoutScope layoutScope(*child);
1134 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) 1134 if (hasOrthogonalWritingMode || oldOverrideContainingBlockContentLogical Width != overrideContainingBlockContentLogicalWidth || (oldOverrideContainingBlo ckContentLogicalHeight != overrideContainingBlockContentLogicalHeight && child-> hasRelativeLogicalHeight()))
1135 layoutScope.setNeedsLayout(child); 1135 layoutScope.setNeedsLayout(child);
1136 1136
1137 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); 1137 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth);
1138 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); 1138 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight);
1139 1139
1140 applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockCont entLogicalHeight); 1140 applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockCont entLogicalHeight);
1141 1141
1142 child->layoutIfNeeded(); 1142 child->layoutIfNeeded();
1143 1143
1144 #if ENABLE(ASSERT) 1144 #if ENABLE(ASSERT)
1145 const GridCoordinate& coordinate = cachedGridCoordinate(*child); 1145 const GridCoordinate& coordinate = cachedGridCoordinate(*child);
1146 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); 1146 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size());
1147 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); 1147 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size());
1148 #endif 1148 #endif
1149 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset)); 1149 child->setLogicalLocation(findChildLogicalPosition(*child, contentPositi onOffset));
1150 1150
1151 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is 1151 // Keep track of children overflowing their grid area as we might need t o paint them even if the grid-area is
1152 // not visible 1152 // not visible
1153 if (child->logicalHeight() > overrideContainingBlockContentLogicalHeight 1153 bool overflowingContainingBlockHeight = hasOrthogonalWritingMode ? child ->logicalWidth() > overrideContainingBlockContentLogicalHeight : child->logicalH eight() > overrideContainingBlockContentLogicalHeight;
1154 || child->logicalWidth() > overrideContainingBlockContentLogicalWidt h) 1154 bool overflowingContainingBlockWidth = hasOrthogonalWritingMode ? child- >logicalHeight() > overrideContainingBlockContentLogicalWidth : child->logicalHe ight() > overrideContainingBlockContentLogicalWidth;
1155 if (overflowingContainingBlockHeight || overflowingContainingBlockWidth)
1155 m_gridItemsOverflowingGridArea.append(child); 1156 m_gridItemsOverflowingGridArea.append(child);
1156 } 1157 }
1157 1158
1158 for (const auto& row : sizingData.rowTracks) 1159 for (const auto& row : sizingData.rowTracks)
1159 setLogicalHeight(logicalHeight() + row.m_usedBreadth); 1160 setLogicalHeight(logicalHeight() + row.m_usedBreadth);
1160 1161
1161 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock. 1162 // Min / max logical height is handled by the call to updateLogicalHeight in layoutBlock.
1162 1163
1163 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight()); 1164 setLogicalHeight(logicalHeight() + borderAndPaddingLogicalHeight());
1164 } 1165 }
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 case ContentPositionAuto: 1647 case ContentPositionAuto:
1647 break; 1648 break;
1648 } 1649 }
1649 1650
1650 ASSERT_NOT_REACHED(); 1651 ASSERT_NOT_REACHED();
1651 return 0; 1652 return 0;
1652 } 1653 }
1653 1654
1654 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child, LayoutS ize contentAlignmentOffset) const 1655 LayoutPoint RenderGrid::findChildLogicalPosition(const RenderBox& child, LayoutS ize contentAlignmentOffset) const
1655 { 1656 {
1657 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1658 LayoutUnit rowPosition = rowPositionForChild(child);
1656 LayoutUnit columnPosition = columnPositionForChild(child); 1659 LayoutUnit columnPosition = columnPositionForChild(child);
1657 // We stored m_columnPositions's data ignoring the direction, hence we might need now 1660 // We stored m_columnPositions's data ignoring the direction, hence we might need now
1658 // to translate positions from RTL to LTR, as it's more convenient for paint ing. 1661 // to translate positions from RTL to LTR, as it's more convenient for paint ing.
1659 if (!style()->isLeftToRightDirection()) 1662 if (!style()->isLeftToRightDirection())
1660 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth(); 1663 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord erAndPaddingLogicalLeft()) - columnPosition - child.logicalWidth();
1661 1664
1665 // We stored column's and row's positions without considering orthogonal flo ws, so now we
1666 // need to flip the final LayoutPoint coordinates if that's the case.
1667 LayoutPoint childLocation = hasOrthogonalWritingMode ? LayoutPoint(rowPositi on, columnPosition) : LayoutPoint(columnPosition, rowPosition);
Julien - ping for review 2015/01/21 09:32:10 I really don't understand this line. All the offse
1668
1662 // The Content Alignment offset accounts for the RTL to LTR flip. 1669 // The Content Alignment offset accounts for the RTL to LTR flip.
1663 LayoutPoint childLocation(columnPosition, rowPositionForChild(child));
1664 childLocation.move(contentAlignmentOffset); 1670 childLocation.move(contentAlignmentOffset);
Julien - ping for review 2015/01/21 09:32:10 This is also incoherent with flipping coordinates
1665 1671
1666 return childLocation; 1672 return childLocation;
1667 } 1673 }
1668 1674
1669 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 1675 void RenderGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
1670 { 1676 {
1671 GridPainter(*this).paintChildren(paintInfo, paintOffset); 1677 GridPainter(*this).paintChildren(paintInfo, paintOffset);
1672 } 1678 }
1673 1679
1674 const char* RenderGrid::renderName() const 1680 const char* RenderGrid::renderName() const
1675 { 1681 {
1676 if (isFloating()) 1682 if (isFloating())
1677 return "RenderGrid (floating)"; 1683 return "RenderGrid (floating)";
1678 if (isOutOfFlowPositioned()) 1684 if (isOutOfFlowPositioned())
1679 return "RenderGrid (positioned)"; 1685 return "RenderGrid (positioned)";
1680 if (isAnonymous()) 1686 if (isAnonymous())
1681 return "RenderGrid (generated)"; 1687 return "RenderGrid (generated)";
1682 if (isRelPositioned()) 1688 if (isRelPositioned())
1683 return "RenderGrid (relative positioned)"; 1689 return "RenderGrid (relative positioned)";
1684 return "RenderGrid"; 1690 return "RenderGrid";
1685 } 1691 }
1686 1692
1687 } // namespace blink 1693 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css-grid-layout/resources/grid.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698