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

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

Issue 2543193002: [css-grid] Use child's marginLogicalWidth to compute content-sized track (Closed)
Patch Set: Compute margins if child needs layout. Created 4 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
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 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 // intrinsic width, which is what we are interested in here. Thus we need to 1374 // intrinsic width, which is what we are interested in here. Thus we need to
1375 // set the inline-axis override size to -1 (no possible resolution). 1375 // set the inline-axis override size to -1 (no possible resolution).
1376 if (shouldClearOverrideContainingBlockContentSizeForChild(child, 1376 if (shouldClearOverrideContainingBlockContentSizeForChild(child,
1377 ForColumns)) 1377 ForColumns))
1378 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection, 1378 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection,
1379 LayoutUnit(-1)); 1379 LayoutUnit(-1));
1380 1380
1381 // FIXME: It's unclear if we should return the intrinsic width or the 1381 // FIXME: It's unclear if we should return the intrinsic width or the
1382 // preferred width. 1382 // preferred width.
1383 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 1383 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
1384 return child.minPreferredLogicalWidth() + 1384 LayoutUnit marginLogicalWidth =
1385 marginIntrinsicLogicalWidthForChild(child); 1385 child.needsLayout()
1386 ? computeMarginLogicalSizeForChild(InlineDirection, child)
1387 : child.marginLogicalWidth();
1388 return child.minPreferredLogicalWidth() + marginLogicalWidth;
1386 } 1389 }
1387 1390
1388 // All orthogonal flow boxes were already laid out during an early layout 1391 // All orthogonal flow boxes were already laid out during an early layout
1389 // phase performed in FrameView::performLayout. 1392 // phase performed in FrameView::performLayout.
1390 // It's true that grid track sizing was not completed at that time and it may 1393 // It's true that grid track sizing was not completed at that time and it may
1391 // afffect the final height of a grid item, but since it's forbidden to 1394 // afffect the final height of a grid item, but since it's forbidden to
1392 // perform a layout during intrinsic width computation, we have to use that 1395 // perform a layout during intrinsic width computation, we have to use that
1393 // computed height for now. 1396 // computed height for now.
1394 if (direction == ForColumns && 1397 if (direction == ForColumns &&
1395 sizingData.sizingOperation == IntrinsicSizeComputation) { 1398 sizingData.sizingOperation == IntrinsicSizeComputation) {
(...skipping 18 matching lines...) Expand all
1414 // intrinsic width, which is what we are interested in here. Thus we need to 1417 // intrinsic width, which is what we are interested in here. Thus we need to
1415 // set the inline-axis override size to -1 (no possible resolution). 1418 // set the inline-axis override size to -1 (no possible resolution).
1416 if (shouldClearOverrideContainingBlockContentSizeForChild(child, 1419 if (shouldClearOverrideContainingBlockContentSizeForChild(child,
1417 ForColumns)) 1420 ForColumns))
1418 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection, 1421 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection,
1419 LayoutUnit(-1)); 1422 LayoutUnit(-1));
1420 1423
1421 // FIXME: It's unclear if we should return the intrinsic width or the 1424 // FIXME: It's unclear if we should return the intrinsic width or the
1422 // preferred width. 1425 // preferred width.
1423 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html 1426 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html
1424 return child.maxPreferredLogicalWidth() + 1427 LayoutUnit marginLogicalWidth =
1425 marginIntrinsicLogicalWidthForChild(child); 1428 child.needsLayout()
1429 ? computeMarginLogicalSizeForChild(InlineDirection, child)
1430 : child.marginLogicalWidth();
1431 return child.maxPreferredLogicalWidth() + marginLogicalWidth;
1426 } 1432 }
1427 1433
1428 // All orthogonal flow boxes were already laid out during an early layout 1434 // All orthogonal flow boxes were already laid out during an early layout
1429 // phase performed in FrameView::performLayout. 1435 // phase performed in FrameView::performLayout.
1430 // It's true that grid track sizing was not completed at that time and it may 1436 // It's true that grid track sizing was not completed at that time and it may
1431 // afffect the final height of a grid item, but since it's forbidden to 1437 // afffect the final height of a grid item, but since it's forbidden to
1432 // perform a layout during intrinsic width computation, we have to use that 1438 // perform a layout during intrinsic width computation, we have to use that
1433 // computed height for now. 1439 // computed height for now.
1434 if (direction == ForColumns && 1440 if (direction == ForColumns &&
1435 sizingData.sizingOperation == IntrinsicSizeComputation) { 1441 sizingData.sizingOperation == IntrinsicSizeComputation) {
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 MarginDirection forDirection, 2876 MarginDirection forDirection,
2871 const LayoutBox& child) const { 2877 const LayoutBox& child) const {
2872 if (!child.styleRef().hasMargin()) 2878 if (!child.styleRef().hasMargin())
2873 return LayoutUnit(); 2879 return LayoutUnit();
2874 2880
2875 bool isRowAxis = forDirection == InlineDirection; 2881 bool isRowAxis = forDirection == InlineDirection;
2876 LayoutUnit marginStart; 2882 LayoutUnit marginStart;
2877 LayoutUnit marginEnd; 2883 LayoutUnit marginEnd;
2878 LayoutUnit logicalSize = 2884 LayoutUnit logicalSize =
2879 isRowAxis ? child.logicalWidth() : child.logicalHeight(); 2885 isRowAxis ? child.logicalWidth() : child.logicalHeight();
2880 Length marginStartLength = isRowAxis 2886 Length marginStartLength = isRowAxis ? child.styleRef().marginStart()
2881 ? child.styleRef().marginStart() 2887 : child.styleRef().marginBefore();
2882 : child.styleRef().marginBeforeUsing(style()); 2888 Length marginEndLength =
2883 Length marginEndLength = isRowAxis 2889 isRowAxis ? child.styleRef().marginEnd() : child.styleRef().marginAfter();
2884 ? child.styleRef().marginEnd()
2885 : child.styleRef().marginAfterUsing(style());
2886 child.computeMarginsForDirection( 2890 child.computeMarginsForDirection(
2887 forDirection, this, child.containingBlockLogicalWidthForContent(), 2891 forDirection, this, child.containingBlockLogicalWidthForContent(),
2888 logicalSize, marginStart, marginEnd, marginStartLength, marginEndLength); 2892 logicalSize, marginStart, marginEnd, marginStartLength, marginEndLength);
2889 2893
2890 return marginStart + marginEnd; 2894 return marginStart + marginEnd;
2891 } 2895 }
2892 2896
2893 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching( 2897 LayoutUnit LayoutGrid::availableAlignmentSpaceForChildBeforeStretching(
2894 LayoutUnit gridAreaBreadthForChild, 2898 LayoutUnit gridAreaBreadthForChild,
2895 const LayoutBox& child) const { 2899 const LayoutBox& child) const {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3572 if (direction == ForRows) 3576 if (direction == ForRows)
3573 return m_grid.numTracks(ForRows); 3577 return m_grid.numTracks(ForRows);
3574 3578
3575 return m_grid.numTracks(ForRows) 3579 return m_grid.numTracks(ForRows)
3576 ? m_grid.numTracks(ForColumns) 3580 ? m_grid.numTracks(ForColumns)
3577 : GridPositionsResolver::explicitGridColumnCount( 3581 : GridPositionsResolver::explicitGridColumnCount(
3578 styleRef(), m_grid.autoRepeatTracks(ForColumns)); 3582 styleRef(), m_grid.autoRepeatTracks(ForColumns));
3579 } 3583 }
3580 3584
3581 } // namespace blink 3585 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css-grid-layout/grid-track-sizing-with-margins-and-orthogonal-flows.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698