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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 SubtreeLayoutScope layoutScope(*child); | 1268 SubtreeLayoutScope layoutScope(*child); |
1269 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) | 1269 if (oldOverrideContainingBlockContentLogicalWidth != overrideContainingB lockContentLogicalWidth || (oldOverrideContainingBlockContentLogicalHeight != ov errideContainingBlockContentLogicalHeight && child->hasRelativeLogicalHeight())) |
1270 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged); | 1270 layoutScope.setNeedsLayout(child, LayoutInvalidationReason::GridChan ged); |
1271 | 1271 |
1272 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); | 1272 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingB lockContentLogicalWidth); |
1273 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); | 1273 child->setOverrideContainingBlockContentLogicalHeight(overrideContaining BlockContentLogicalHeight); |
1274 | 1274 |
1275 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded | 1275 // Stretching logic might force a child layout, so we need to run it bef ore the layoutIfNeeded |
1276 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly | 1276 // call to avoid unnecessary relayouts. This might imply that child marg ins, needed to correctly |
1277 // determine the available space before stretching, are not set yet. | 1277 // determine the available space before stretching, are not set yet. |
1278 applyStretchAlignmentToChildIfNeeded(*child, overrideContainingBlockCont entLogicalHeight); | 1278 applyStretchAlignmentToChildIfNeeded(*child); |
1279 | 1279 |
1280 child->layoutIfNeeded(); | 1280 child->layoutIfNeeded(); |
1281 | 1281 |
1282 #if ENABLE(ASSERT) | 1282 #if ENABLE(ASSERT) |
1283 const GridCoordinate& coordinate = cachedGridCoordinate(*child); | 1283 const GridCoordinate& coordinate = cachedGridCoordinate(*child); |
1284 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); | 1284 ASSERT(coordinate.columns.resolvedInitialPosition.toInt() < sizingData.c olumnTracks.size()); |
1285 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); | 1285 ASSERT(coordinate.rows.resolvedInitialPosition.toInt() < sizingData.rowT racks.size()); |
1286 #endif | 1286 #endif |
1287 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); | 1287 child->setLogicalLocation(findChildLogicalPosition(*child, sizingData)); |
1288 | 1288 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 ASSERT_NOT_REACHED(); | 1446 ASSERT_NOT_REACHED(); |
1447 return 0; | 1447 return 0; |
1448 } | 1448 } |
1449 | 1449 |
1450 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay outBox& child) | 1450 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay outBox& child) |
1451 { | 1451 { |
1452 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight(); | 1452 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica lHeight(); |
1453 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); | 1453 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
1454 } | 1454 } |
1455 | 1455 |
1456 bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c onst | 1456 bool LayoutGrid::hasAutoSizeInColumnAxisForChild(const LayoutBox& child) const |
1457 { | 1457 { |
1458 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); | 1458 return isHorizontalWritingMode() ? child.style()->height().isAuto() : child. style()->width().isAuto(); |
1459 } | |
1460 | |
1461 bool LayoutGrid::hasAutoSizeInRowAxisForChild(const LayoutBox& child) const | |
1462 { | |
1463 return isHorizontalWritingMode() ? child.style()->width().isAuto() : child.s tyle()->height().isAuto(); | |
1464 } | |
1465 | |
1466 bool LayoutGrid::allowedToStretchChildAlongColumnAxis(const LayoutBox& child) co nst | |
1467 { | |
1468 return hasAutoSizeInColumnAxisForChild(child) && !child.style()->marginBefor eUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); | |
1469 } | |
1470 | |
1471 bool LayoutGrid::allowedToStretchChildAlongRowAxis(const LayoutBox& child) const | |
1472 { | |
1473 return hasAutoSizeInRowAxisForChild(child) && !child.style()->marginStartUsi ng(style()).isAuto() && !child.style()->marginEndUsing(style()).isAuto(); | |
1459 } | 1474 } |
1460 | 1475 |
1461 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. | 1476 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. |
1462 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const | 1477 bool LayoutGrid::needToStretchChildLogicalHeight(const LayoutBox& child) const |
1463 { | 1478 { |
1464 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch) | 1479 if (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPositi onStretch) != ItemPositionStretch) |
1465 return false; | 1480 return false; |
1466 | 1481 |
1467 return isHorizontalWritingMode() && child.style()->height().isAuto(); | 1482 return isHorizontalWritingMode() && child.style()->height().isAuto(); |
1468 } | 1483 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1516 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before | 1531 // Because we want to avoid multiple layouts, stretching logic might be perf ormed before |
1517 // children are laid out, so we can't use the child cached values. Hence, we need to | 1532 // children are laid out, so we can't use the child cached values. Hence, we need to |
1518 // compute margins in order to determine the available height before stretch ing. | 1533 // compute margins in order to determine the available height before stretch ing. |
1519 if (childMarginLogicalHeight == 0) | 1534 if (childMarginLogicalHeight == 0) |
1520 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); | 1535 childMarginLogicalHeight = computeMarginLogicalHeightForChild(child); |
1521 | 1536 |
1522 return gridAreaBreadthForChild - childMarginLogicalHeight; | 1537 return gridAreaBreadthForChild - childMarginLogicalHeight; |
1523 } | 1538 } |
1524 | 1539 |
1525 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. | 1540 // FIXME: This logic is shared by LayoutFlexibleBox, so it should be moved to La youtBox. |
1526 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child, LayoutUn it gridAreaBreadthForChild) | 1541 void LayoutGrid::applyStretchAlignmentToChildIfNeeded(LayoutBox& child) |
1527 { | 1542 { |
1528 if (!allowedToStretchLogicalHeightForChild(child) || ComputedStyle::resolveA lignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStret ch) { | 1543 child.clearOverrideSize(); |
1529 child.clearOverrideLogicalContentHeight(); | 1544 |
1545 if (!allowedToStretchChildAlongRowAxis(child) || ComputedStyle::resolveJusti fication(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStret ch) { | |
1546 if (hasAutoSizeInRowAxisForChild(child)) { | |
1547 LayoutUnit childPreferredWidth = std::min(child.maxPreferredLogicalW idth(), child.overrideContainingBlockContentLogicalWidth() - child.marginLogica lWidth()); | |
Manuel Rego
2015/07/13 12:40:07
This is what's breaking "min-width: auto;".
From
jfernandez
2015/07/14 13:36:08
That's correct, thanks for pointing it out.
| |
1548 child.setOverrideLogicalContentWidth(childPreferredWidth - child.bor derAndPaddingLogicalWidth()); | |
1549 if (childPreferredWidth != child.logicalWidth()) | |
1550 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | |
1551 } | |
1552 } | |
1553 | |
1554 if (!allowedToStretchChildAlongColumnAxis(child) || ComputedStyle::resolveAl ignment(styleRef(), child.styleRef(), ItemPositionStretch) != ItemPositionStretc h) | |
1530 return; | 1555 return; |
1531 } | |
1532 | 1556 |
1533 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); | 1557 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon talWritingMode(); |
1534 // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it. | 1558 // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it. |
1535 // FIXME: grid track sizing and positioning do not support orthogonal modes yet. | 1559 // FIXME: grid track sizing and positioning do not support orthogonal modes yet. |
1536 if (!hasOrthogonalWritingMode) { | 1560 if (!hasOrthogonalWritingMode) { |
1537 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBefor eStretching(gridAreaBreadthForChild, child); | 1561 LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBefor eStretching(child.overrideContainingBlockContentLogicalHeight(), child); |
1538 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(s tretchedLogicalHeight, -1); | 1562 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(s tretchedLogicalHeight, -1); |
1539 | 1563 |
1540 // FIXME: Can avoid laying out here in some cases. See https://webkit.or g/b/87905. | 1564 // FIXME: Can avoid laying out here in some cases. See https://webkit.or g/b/87905. |
1541 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeight(); | 1565 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeight(); |
1542 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight()) | 1566 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight()) |
1543 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight()); | 1567 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b orderAndPaddingLogicalHeight()); |
1544 if (childNeedsRelayout) { | 1568 if (childNeedsRelayout) { |
1545 child.setLogicalHeight(0); | 1569 child.setLogicalHeight(0); |
1546 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1570 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
1547 } | 1571 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1855 | 1879 |
1856 return LayoutPoint(columnPosition, rowPositionForChild(child)); | 1880 return LayoutPoint(columnPosition, rowPositionForChild(child)); |
1857 } | 1881 } |
1858 | 1882 |
1859 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) | 1883 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) |
1860 { | 1884 { |
1861 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1885 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
1862 } | 1886 } |
1863 | 1887 |
1864 } // namespace blink | 1888 } // namespace blink |
OLD | NEW |