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 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2187 | 2187 |
2188 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. | 2188 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. |
2189 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) | 2189 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) |
2190 { | 2190 { |
2191 // We clear height override values because we will decide now whether it's a llowed or | 2191 // We clear height override values because we will decide now whether it's a llowed or |
2192 // not, evaluating the conditions which might have changed since the old val ues were set. | 2192 // not, evaluating the conditions which might have changed since the old val ues were set. |
2193 child.clearOverrideLogicalContentHeight(); | 2193 child.clearOverrideLogicalContentHeight(); |
2194 | 2194 |
2195 auto& childStyle = child.styleRef(); | 2195 auto& childStyle = child.styleRef(); |
2196 bool isHorizontalMode = isHorizontalWritingMode(); | 2196 bool isHorizontalMode = isHorizontalWritingMode(); |
2197 bool hasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().isAuto () : childStyle.width().isAuto(); | 2197 bool childHasAutoSizeInColumnAxis = isHorizontalMode ? childStyle.height().i sAuto() : childStyle.width().isAuto(); |
2198 bool allowedToStretchChildAlongColumnAxis = hasAutoSizeInColumnAxis && !chil dStyle.marginBeforeUsing(style()).isAuto() && !childStyle.marginAfterUsing(style ()).isAuto(); | 2198 bool childHasAutoSizeInRowAxis = isHorizontalMode ? childStyle.width().isAut o() : childStyle.height().isAuto(); |
2199 if (allowedToStretchChildAlongColumnAxis && ComputedStyle::resolveAlignment( styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch) { | 2199 bool allowedToStretchChildAlongColumnAxis = childHasAutoSizeInColumnAxis && !hasAutoMarginsInColumnAxis(child); |
2200 // TODO (lajava): If the child has orthogonal flow, then it already has an override height set, so use it. | 2200 bool allowedToStretchChildAlongRowAxis = childHasAutoSizeInRowAxis && !hasAu toMarginsInRowAxis(child); |
2201 // TODO (lajava): grid track sizing and positioning do not support ortho gonal modes yet. | 2201 bool stretchingAlongRowAxis = ComputedStyle::resolveJustification(styleRef() , childStyle, ItemPositionStretch) == ItemPositionStretch; |
2202 if (child.isHorizontalWritingMode() == isHorizontalMode) { | 2202 bool stretchingAlognColumnAxis = ComputedStyle::resolveAlignment(styleRef(), childStyle, ItemPositionStretch) == ItemPositionStretch; |
cbiesinger
2016/07/22 16:44:00
Alogn -> Along
| |
2203 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildB eforeStretching(child.overrideContainingBlockContentLogicalHeight(), child); | 2203 |
2204 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinM ax(stretchedLogicalHeight, LayoutUnit(-1)); | 2204 GridTrackSizingDirection childBlockDirection = flowAwareDirectionForChild(ch ild, ForRows); |
2205 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight()); | 2205 bool allowedToStretchChildBlockSize = childBlockDirection == ForRows ? allow edToStretchChildAlongColumnAxis && stretchingAlognColumnAxis : allowedToStretchC hildAlongRowAxis && stretchingAlongRowAxis; |
2206 if (desiredLogicalHeight != child.logicalHeight()) { | 2206 if (allowedToStretchChildBlockSize) { |
2207 // TODO (lajava): Can avoid laying out here in some cases. See h ttps://webkit.org/b/87905. | 2207 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBefor eStretching(overrideContainingBlockContentSizeForChild(child, childBlockDirectio n), child); |
2208 child.setLogicalHeight(LayoutUnit()); | 2208 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(s tretchedLogicalHeight, LayoutUnit(-1)); |
2209 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 2209 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borde rAndPaddingLogicalHeight()); |
2210 } | 2210 if (desiredLogicalHeight != child.logicalHeight()) { |
2211 // TODO (lajava): Can avoid laying out here in some cases. See https ://webkit.org/b/87905. | |
2212 child.setLogicalHeight(LayoutUnit()); | |
2213 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | |
2211 } | 2214 } |
2212 } | 2215 } |
2213 } | 2216 } |
2214 | 2217 |
2215 // TODO(lajava): This logic is shared by LayoutFlexibleBox, so it should be move d to LayoutBox. | 2218 // TODO(lajava): This logic is shared by LayoutFlexibleBox, so it should be move d to LayoutBox. |
2216 bool LayoutGrid::hasAutoMarginsInColumnAxis(const LayoutBox& child) const | 2219 bool LayoutGrid::hasAutoMarginsInColumnAxis(const LayoutBox& child) const |
2217 { | 2220 { |
2218 if (isHorizontalWritingMode()) | 2221 if (isHorizontalWritingMode()) |
2219 return child.style()->marginTop().isAuto() || child.style()->marginBotto m().isAuto(); | 2222 return child.style()->marginTop().isAuto() || child.style()->marginBotto m().isAuto(); |
2220 return child.style()->marginLeft().isAuto() || child.style()->marginRight(). isAuto(); | 2223 return child.style()->marginLeft().isAuto() || child.style()->marginRight(). isAuto(); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2596 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; | 2599 return isOrthogonalChild(child) ? childLocation.transposedPoint() : childLoc ation; |
2597 } | 2600 } |
2598 | 2601 |
2599 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2602 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2600 { | 2603 { |
2601 if (!m_gridItemArea.isEmpty()) | 2604 if (!m_gridItemArea.isEmpty()) |
2602 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2605 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2603 } | 2606 } |
2604 | 2607 |
2605 } // namespace blink | 2608 } // namespace blink |
OLD | NEW |