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

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

Issue 1145183003: [CSS Grid Layout] Clear stretched height when conditions don't allow it. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Applied suggested changes. Created 5 years, 6 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 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 // compute margins in order to determine the available height before stretch ing. 1558 // compute margins in order to determine the available height before stretch ing.
1559 if (childMarginLogicalHeight == 0) 1559 if (childMarginLogicalHeight == 0)
1560 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); 1560 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child);
1561 1561
1562 return gridAreaBreadthForChild - childMarginLogicalHeight; 1562 return gridAreaBreadthForChild - childMarginLogicalHeight;
1563 } 1563 }
1564 1564
1565 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. 1565 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox.
1566 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn it gridAreaBreadthForChild) 1566 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn it gridAreaBreadthForChild)
1567 { 1567 {
1568 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch) 1568 if (!allowedToStretchLogicalHeightForChild(child) || ComputedStyle::resolveA lignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStret ch) {
1569 child.clearOverrideLogicalContentHeight();
1569 return; 1570 return;
1571 }
1570 1572
1571 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1573 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1572 if (allowedToStretchLogicalHeightForChild(child)) { 1574 // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it.
1573 // FIXME: If the child has orthogonal flow, then it already has an overr ide height set, so use it. 1575 // FIXME: grid track sizing and positioning do not support orthogonal modes yet.
1574 // FIXME: grid track sizing and positioning do not support orthogonal mo des yet. 1576 if (!hasOrthogonalWritingMode) {
1575 if (!hasOrthogonalWritingMode) { 1577 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBefor eStretching(gridAreaBreadthForChild, child);
1576 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(gridAreaBreadthForChild, child); 1578 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(s tretchedLogicalHeight, -1);
1577 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, -1);
1578 1579
1579 // FIXME: Can avoid laying out here in some cases. See https://webki t.org/b/87905. 1580 // FIXME: Can avoid laying out here in some cases. See https://webkit.or g/b/87905.
1580 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeigh t(); 1581 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeight();
1581 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight()) 1582 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight())
1582 child.setOverrideLogicalContentHeight(desiredLogicalHeight - chi ld.borderAndPaddingLogicalHeight()); 1583 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight());
1583 if (childNeedsRelayout) { 1584 if (childNeedsRelayout) {
1584 child.setLogicalHeight(0); 1585 child.setLogicalHeight(0);
1585 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); 1586 child.setNeedsLayout(LayoutInvalidationReason::GridChanged);
1586 }
1587 } 1587 }
1588 } 1588 }
1589 } 1589 }
1590 1590
1591 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const 1591 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const
1592 { 1592 {
1593 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); 1593 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode();
1594 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) { 1594 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo sitionStretch)) {
1595 case ItemPositionSelfStart: 1595 case ItemPositionSelfStart:
1596 // If orthogonal writing-modes, this computes to 'start'. 1596 // If orthogonal writing-modes, this computes to 'start'.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 1829
1830 return LayoutPoint(columnPosition, rowPositionForChild(child)); 1830 return LayoutPoint(columnPosition, rowPositionForChild(child));
1831 } 1831 }
1832 1832
1833 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) 1833 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset)
1834 { 1834 {
1835 GridPainter(*this).paintChildren(paintInfo, paintOffset); 1835 GridPainter(*this).paintChildren(paintInfo, paintOffset);
1836 } 1836 }
1837 1837
1838 } // namespace blink 1838 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/css-grid-layout/grid-items-should-not-be-stretched-when-height-or-margin-change-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698