| OLD | NEW |
| 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } | 678 } |
| 679 | 679 |
| 680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); | 680 return GridTrackSize(minTrackBreadth, maxTrackBreadth); |
| 681 } | 681 } |
| 682 | 682 |
| 683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack>
& columnTracks) | 683 LayoutUnit LayoutGrid::logicalHeightForChild(LayoutBox& child, Vector<GridTrack>
& columnTracks) |
| 684 { | 684 { |
| 685 SubtreeLayoutScope layoutScope(child); | 685 SubtreeLayoutScope layoutScope(child); |
| 686 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride
ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth
() : LayoutUnit(); | 686 LayoutUnit oldOverrideContainingBlockContentLogicalWidth = child.hasOverride
ContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth
() : LayoutUnit(); |
| 687 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh
ild(child, ForColumns, columnTracks); | 687 LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForCh
ild(child, ForColumns, columnTracks); |
| 688 if (child.hasRelativeLogicalHeight() || oldOverrideContainingBlockContentLog
icalWidth != overrideContainingBlockContentLogicalWidth) { | 688 bool shouldClearContainingBlockLogicalHeight = child.hasRelativeLogicalHeigh
t() || child.styleRef().logicalHeight().isIntrinsicOrAuto(); |
| 689 if (shouldClearContainingBlockLogicalHeight || oldOverrideContainingBlockCon
tentLogicalWidth != overrideContainingBlockContentLogicalWidth) |
| 689 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged
); | 690 layoutScope.setNeedsLayout(&child, LayoutInvalidationReason::GridChanged
); |
| 690 } | |
| 691 | 691 |
| 692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); | 692 bool hasOverrideHeight = child.hasOverrideLogicalContentHeight(); |
| 693 // We need to clear the stretched height to properly compute logical height
during layout. | 693 // We need to clear the stretched height to properly compute logical height
during layout. |
| 694 if (hasOverrideHeight && child.needsLayout()) | 694 if (hasOverrideHeight && child.needsLayout()) |
| 695 child.clearOverrideLogicalContentHeight(); | 695 child.clearOverrideLogicalContentHeight(); |
| 696 | 696 |
| 697 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockC
ontentLogicalWidth); | 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 | 698 // 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). | 699 // what we are interested in here. Thus we need to set the override logical
height to -1 (no possible resolution). |
| 700 if (child.hasRelativeLogicalHeight()) | 700 if (shouldClearContainingBlockLogicalHeight) |
| 701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); | 701 child.setOverrideContainingBlockContentLogicalHeight(LayoutUnit(-1)); |
| 702 child.layoutIfNeeded(); | 702 child.layoutIfNeeded(); |
| 703 // If the child was stretched we should use its intrinsic height. | 703 // If the child was stretched we should use its intrinsic height. |
| 704 return (hasOverrideHeight ? childIntrinsicHeight(child) : child.logicalHeigh
t()) + child.marginLogicalHeight(); | 704 return child.logicalHeight() + child.marginLogicalHeight(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio
n direction, Vector<GridTrack>& columnTracks) | 707 LayoutUnit LayoutGrid::minSizeForChild(LayoutBox& child, GridTrackSizingDirectio
n direction, Vector<GridTrack>& columnTracks) |
| 708 { | 708 { |
| 709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 709 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 710 // TODO(svillar): Properly support orthogonal writing mode. | 710 // TODO(svillar): Properly support orthogonal writing mode. |
| 711 if (hasOrthogonalWritingMode) | 711 if (hasOrthogonalWritingMode) |
| 712 return LayoutUnit(); | 712 return LayoutUnit(); |
| 713 | 713 |
| 714 bool isRowAxis = direction == ForColumns; | 714 bool isRowAxis = direction == ForColumns; |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 // If we overflow our alignment container and overflow is 'true' (defaul
t), we | 1635 // If we overflow our alignment container and overflow is 'true' (defaul
t), we |
| 1636 // ignore the overflow and just return the value regardless (which may c
ause data | 1636 // ignore the overflow and just return the value regardless (which may c
ause data |
| 1637 // loss as we overflow the 'start' edge). | 1637 // loss as we overflow the 'start' edge). |
| 1638 return offset; | 1638 return offset; |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 ASSERT_NOT_REACHED(); | 1641 ASSERT_NOT_REACHED(); |
| 1642 return LayoutUnit(); | 1642 return LayoutUnit(); |
| 1643 } | 1643 } |
| 1644 | 1644 |
| 1645 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) | |
| 1646 { | |
| 1647 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); | |
| 1648 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); | |
| 1649 } | |
| 1650 | |
| 1651 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | |
| 1652 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const | |
| 1653 { | |
| 1654 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi
onStretch) != ItemPositionStretch) | |
| 1655 return false; | |
| 1656 | |
| 1657 return isHorizontalWritingMode() && child.style()->height().isAuto(); | |
| 1658 } | |
| 1659 | |
| 1660 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | |
| 1661 LayoutUnit LayoutGrid::childIntrinsicHeight(const LayoutBox& child) const | |
| 1662 { | |
| 1663 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child
)) | |
| 1664 return constrainedChildIntrinsicContentLogicalHeight(child); | |
| 1665 return child.size().height(); | |
| 1666 } | |
| 1667 | |
| 1668 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | |
| 1669 LayoutUnit LayoutGrid::childIntrinsicWidth(const LayoutBox& child) const | |
| 1670 { | |
| 1671 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(chil
d)) | |
| 1672 return constrainedChildIntrinsicContentLogicalHeight(child); | |
| 1673 return child.size().width(); | |
| 1674 } | |
| 1675 | |
| 1676 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | |
| 1677 LayoutUnit LayoutGrid::intrinsicLogicalHeightForChild(const LayoutBox& child) co
nst | |
| 1678 { | |
| 1679 return isHorizontalWritingMode() ? childIntrinsicHeight(child) : childIntrin
sicWidth(child); | |
| 1680 } | |
| 1681 | |
| 1682 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. | 1645 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La
youtBox. |
| 1683 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const | 1646 LayoutUnit LayoutGrid::marginLogicalHeightForChild(const LayoutBox& child) const |
| 1684 { | 1647 { |
| 1685 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); | 1648 return isHorizontalWritingMode() ? child.marginHeight() : child.marginWidth(
); |
| 1686 } | 1649 } |
| 1687 | 1650 |
| 1688 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child
) const | 1651 LayoutUnit LayoutGrid::computeMarginLogicalHeightForChild(const LayoutBox& child
) const |
| 1689 { | 1652 { |
| 1690 if (!child.styleRef().hasMargin()) | 1653 if (!child.styleRef().hasMargin()) |
| 1691 return LayoutUnit(); | 1654 return LayoutUnit(); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 | 2040 |
| 2078 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); | 2041 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child, sizingData
)); |
| 2079 } | 2042 } |
| 2080 | 2043 |
| 2081 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2044 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
| 2082 { | 2045 { |
| 2083 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2046 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 2084 } | 2047 } |
| 2085 | 2048 |
| 2086 } // namespace blink | 2049 } // namespace blink |
| OLD | NEW |