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

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

Issue 752723004: Use references in RenderBlock and RenderBlockFlow methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cover RenderBlockFlow class as well Created 6 years 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/RenderFlexibleBox.cpp ('k') | Source/core/rendering/RenderTable.h » ('j') | 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 644 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks)
645 { 645 {
646 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 646 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
647 // FIXME: Properly support orthogonal writing mode. 647 // FIXME: Properly support orthogonal writing mode.
648 if (hasOrthogonalWritingMode) 648 if (hasOrthogonalWritingMode)
649 return 0; 649 return 0;
650 650
651 if (direction == ForColumns) { 651 if (direction == ForColumns) {
652 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 652 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
653 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 653 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
654 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(&child); 654 return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
655 } 655 }
656 656
657 return logicalHeightForChild(child, columnTracks); 657 return logicalHeightForChild(child, columnTracks);
658 } 658 }
659 659
660 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks) 660 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirec tion direction, Vector<GridTrack>& columnTracks)
661 { 661 {
662 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 662 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
663 // FIXME: Properly support orthogonal writing mode. 663 // FIXME: Properly support orthogonal writing mode.
664 if (hasOrthogonalWritingMode) 664 if (hasOrthogonalWritingMode)
665 return LayoutUnit(); 665 return LayoutUnit();
666 666
667 if (direction == ForColumns) { 667 if (direction == ForColumns) {
668 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width. 668 // FIXME: It's unclear if we should return the intrinsic width or the pr eferred width.
669 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 669 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
670 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(&child); 670 return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthFor Child(child);
671 } 671 }
672 672
673 return logicalHeightForChild(child, columnTracks); 673 return logicalHeightForChild(child, columnTracks);
674 } 674 }
675 675
676 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or 676 // We're basically using a class instead of a std::pair for two reasons. First o f all, accessing gridItem() or
677 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class 677 // coordinate() is much more self-explanatory that using .first or .second membe rs in the pair. Secondly the class
678 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a 678 // allows us to precompute the value of the span, something which is quite conve nient for the sorting. Having a
679 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an 679 // std::pair<RenderBox*, size_t> does not work either because we still need the GridCoordinate so we'd have to add an
680 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems(). 680 // extra hash lookup for each item at the beginning of RenderGrid::resolveConten tBasedTrackSizingFunctionsForItems().
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 // ignore the overflow and just return the value regardless (which may cause data 1200 // ignore the overflow and just return the value regardless (which may cause data
1201 // loss as we overflow the 'start' edge). 1201 // loss as we overflow the 'start' edge).
1202 return offset; 1202 return offset;
1203 } 1203 }
1204 1204
1205 LayoutUnit RenderGrid::startOfColumnForChild(const RenderBox& child) const 1205 LayoutUnit RenderGrid::startOfColumnForChild(const RenderBox& child) const
1206 { 1206 {
1207 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1207 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1208 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()]; 1208 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()];
1209 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1209 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1210 return startOfColumn + marginStartForChild(&child); 1210 return startOfColumn + marginStartForChild(child);
1211 } 1211 }
1212 1212
1213 LayoutUnit RenderGrid::endOfColumnForChild(const RenderBox& child) const 1213 LayoutUnit RenderGrid::endOfColumnForChild(const RenderBox& child) const
1214 { 1214 {
1215 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1215 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1216 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()]; 1216 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()];
1217 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1217 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1218 LayoutUnit columnPosition = startOfColumn + marginStartForChild(&child); 1218 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child);
1219 1219
1220 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP osition.next().toInt()]; 1220 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP osition.next().toInt()];
1221 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth()); 1221 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth());
1222 1222
1223 return columnPosition + offsetFromColumnPosition; 1223 return columnPosition + offsetFromColumnPosition;
1224 } 1224 }
1225 1225
1226 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerStart(const RenderB ox& child) const 1226 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerStart(const RenderB ox& child) const
1227 { 1227 {
1228 if (style()->isLeftToRightDirection()) 1228 if (style()->isLeftToRightDirection())
1229 return startOfColumnForChild(child); 1229 return startOfColumnForChild(child);
1230 1230
1231 return endOfColumnForChild(child); 1231 return endOfColumnForChild(child);
1232 } 1232 }
1233 1233
1234 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerEnd(const RenderBox & child) const 1234 LayoutUnit RenderGrid::columnPositionAlignedWithGridContainerEnd(const RenderBox & child) const
1235 { 1235 {
1236 if (!style()->isLeftToRightDirection()) 1236 if (!style()->isLeftToRightDirection())
1237 return startOfColumnForChild(child); 1237 return startOfColumnForChild(child);
1238 1238
1239 return endOfColumnForChild(child); 1239 return endOfColumnForChild(child);
1240 } 1240 }
1241 1241
1242 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox& child) co nst 1242 LayoutUnit RenderGrid::centeredColumnPositionForChild(const RenderBox& child) co nst
1243 { 1243 {
1244 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1244 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1245 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()]; 1245 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit ialPosition.toInt()];
1246 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP osition.next().toInt()]; 1246 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP osition.next().toInt()];
1247 LayoutUnit columnPosition = startOfColumn + marginStartForChild(&child); 1247 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child);
1248 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth()); 1248 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica lWidth());
1249 1249
1250 return columnPosition + offsetFromColumnPosition / 2; 1250 return columnPosition + offsetFromColumnPosition / 2;
1251 } 1251 }
1252 1252
1253 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox& child) const 1253 LayoutUnit RenderGrid::columnPositionForChild(const RenderBox& child) const
1254 { 1254 {
1255 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1255 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1256 1256
1257 switch (RenderStyle::resolveJustification(style(), child.style(), ItemPositi onStretch)) { 1257 switch (RenderStyle::resolveJustification(style(), child.style(), ItemPositi onStretch)) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 ASSERT_NOT_REACHED(); 1324 ASSERT_NOT_REACHED();
1325 return 0; 1325 return 0;
1326 } 1326 }
1327 1327
1328 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox& child) const 1328 LayoutUnit RenderGrid::endOfRowForChild(const RenderBox& child) const
1329 { 1329 {
1330 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1330 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1331 1331
1332 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; 1332 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()];
1333 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1333 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1334 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(&child); 1334 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
1335 1335
1336 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; 1336 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1337 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight()); 1337 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight());
1338 1338
1339 return rowPosition + offsetFromRowPosition; 1339 return rowPosition + offsetFromRowPosition;
1340 } 1340 }
1341 1341
1342 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox& child) const 1342 LayoutUnit RenderGrid::startOfRowForChild(const RenderBox& child) const
1343 { 1343 {
1344 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1344 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1345 1345
1346 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()]; 1346 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()];
1347 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1347 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1348 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(&child); 1348 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
1349 1349
1350 return rowPosition; 1350 return rowPosition;
1351 } 1351 }
1352 1352
1353 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox& child) const 1353 LayoutUnit RenderGrid::centeredRowPositionForChild(const RenderBox& child) const
1354 { 1354 {
1355 const GridCoordinate& coordinate = cachedGridCoordinate(child); 1355 const GridCoordinate& coordinate = cachedGridCoordinate(child);
1356 1356
1357 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted. 1357 // The grid items should be inside the grid container's border box, that's w hy they need to be shifted.
1358 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(&child); 1358 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi on.toInt()] + marginBeforeForChild(child);
1359 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()]; 1359 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n ext().toInt()];
1360 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(&child); 1360 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child);
1361 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight()); 1361 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight());
1362 1362
1363 return rowPosition + offsetFromRowPosition / 2; 1363 return rowPosition + offsetFromRowPosition / 2;
1364 } 1364 }
1365 1365
1366 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Ren derBox& child) 1366 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Ren derBox& child)
1367 { 1367 {
1368 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight(); 1368 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight();
1369 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); 1369 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight);
1370 } 1370 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 if (isOutOfFlowPositioned()) 1600 if (isOutOfFlowPositioned())
1601 return "RenderGrid (positioned)"; 1601 return "RenderGrid (positioned)";
1602 if (isAnonymous()) 1602 if (isAnonymous())
1603 return "RenderGrid (generated)"; 1603 return "RenderGrid (generated)";
1604 if (isRelPositioned()) 1604 if (isRelPositioned())
1605 return "RenderGrid (relative positioned)"; 1605 return "RenderGrid (relative positioned)";
1606 return "RenderGrid"; 1606 return "RenderGrid";
1607 } 1607 }
1608 1608
1609 } // namespace blink 1609 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderFlexibleBox.cpp ('k') | Source/core/rendering/RenderTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698