Changeset 190633 in webkit
- Timestamp:
- Oct 6, 2015 12:23:52 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r190629 r190633 1 2015-10-06 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] Don't need to reset auto-margins during grid items layout 4 https://bugs.webkit.org/show_bug.cgi?id=149764 5 6 Reviewed by Darin Adler. 7 8 Removed a duplicated layout tests. 9 10 * fast/css-grid-layout/grid-item-should-not-be-stretched-when-height-or-margin-change-expected.txt: Removed. 11 * fast/css-grid-layout/grid-item-should-not-be-stretched-when-height-or-margin-change.html: Removed. 12 1 13 2015-10-02 Jon Honeycutt <jhoneycutt@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r190628 r190633 1 2015-10-06 Javier Fernandez <jfernandez@igalia.com> 2 3 [CSS Grid Layout] Don't need to reset auto-margins during grid items layout 4 https://bugs.webkit.org/show_bug.cgi?id=149764 5 6 Reviewed by Darin Adler. 7 8 This patch implements a refactoring of the auto-margin alignment code for grid 9 items so it uses start/end and before/after margin logic terms. 10 11 I addition, it avoids resetting the auto-margin values, which requires an extra 12 layout, before applying the alignment logic. 13 14 No new tests because there is no behavior change. 15 16 * rendering/RenderGrid.cpp: 17 (WebCore::RenderGrid::computeMarginLogicalHeightForChild): Computing margins if child needs layout. 18 (WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching): 19 (WebCore::RenderGrid::updateAutoMarginsInRowAxisIfNeeded): Using start/end logical margins. 20 (WebCore::RenderGrid::updateAutoMarginsInColumnAxisIfNeeded): Using before/after logical margins. 21 (WebCore::RenderGrid::columnAxisOffsetForChild): Just added comment. 22 (WebCore::RenderGrid::rowAxisOffsetForChild): Just added comment. 23 1 24 2015-10-06 Tim Horton <timothy_horton@apple.com> 2 25 -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r190484 r190633 1271 1271 && child->hasRelativeLogicalHeight())) 1272 1272 child->setNeedsLayout(MarkOnlyThis); 1273 else1274 resetAutoMarginsAndLogicalTopInColumnAxis(*child);1275 1273 1276 1274 child->setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth); … … 1413 1411 } 1414 1412 1413 LayoutUnit RenderGrid::computeMarginLogicalHeightForChild(const RenderBox& child) const 1414 { 1415 if (!child.style().hasMargin()) 1416 return 0; 1417 1418 LayoutUnit marginBefore; 1419 LayoutUnit marginAfter; 1420 child.computeBlockDirectionMargins(this, marginBefore, marginAfter); 1421 1422 return marginBefore + marginAfter; 1423 } 1424 1415 1425 LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox& child) const 1416 1426 { 1417 return gridAreaBreadthForChild - marginLogicalHeightForChild(child); 1427 // Because we want to avoid multiple layouts, stretching logic might be performed before 1428 // children are laid out, so we can't use the child cached values. Hence, we need to 1429 // compute margins in order to determine the available height before stretching. 1430 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalHeightForChild(child) : marginLogicalHeightForChild(child)); 1418 1431 } 1419 1432 … … 1482 1495 1483 1496 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox. 1484 void RenderGrid::resetAutoMarginsAndLogicalTopInColumnAxis(RenderBox& child)1485 {1486 if (hasAutoMarginsInColumnAxis(child) || child.needsLayout()) {1487 child.clearOverrideLogicalContentHeight();1488 child.updateLogicalHeight();1489 if (isHorizontalWritingMode()) {1490 if (child.style().marginTop().isAuto())1491 child.setMarginTop(0);1492 if (child.style().marginBottom().isAuto())1493 child.setMarginBottom(0);1494 } else {1495 if (child.style().marginLeft().isAuto())1496 child.setMarginLeft(0);1497 if (child.style().marginRight().isAuto())1498 child.setMarginRight(0);1499 }1500 1501 }1502 }1503 1504 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox.1505 1497 void RenderGrid::updateAutoMarginsInRowAxisIfNeeded(RenderBox& child) 1506 1498 { 1507 1499 ASSERT(!child.isOutOfFlowPositioned()); 1508 ASSERT(child.overrideContainingBlockContentLogicalWidth());1509 1500 1510 1501 LayoutUnit availableAlignmentSpace = child.overrideContainingBlockContentLogicalWidth().value() - child.logicalWidth(); … … 1512 1503 return; 1513 1504 1514 bool isHorizontal = isHorizontalWritingMode(); 1515 Length topOrLeft = isHorizontal ? child.style().marginLeft() : child.style().marginTop(); 1516 Length bottomOrRight = isHorizontal ? child.style().marginRight() : child.style().marginBottom(); 1517 if (topOrLeft.isAuto() && bottomOrRight.isAuto()) { 1518 if (isHorizontal) { 1519 child.setMarginLeft(availableAlignmentSpace / 2); 1520 child.setMarginRight(availableAlignmentSpace / 2); 1521 } else { 1522 child.setMarginTop(availableAlignmentSpace / 2); 1523 child.setMarginBottom(availableAlignmentSpace / 2); 1524 } 1525 } else if (topOrLeft.isAuto()) { 1526 if (isHorizontal) 1527 child.setMarginLeft(availableAlignmentSpace); 1528 else 1529 child.setMarginTop(availableAlignmentSpace); 1530 } else if (bottomOrRight.isAuto()) { 1531 if (isHorizontal) 1532 child.setMarginRight(availableAlignmentSpace); 1533 else 1534 child.setMarginBottom(availableAlignmentSpace); 1505 const RenderStyle& parentStyle = style(); 1506 Length marginStart = child.style().marginStartUsing(&parentStyle); 1507 Length marginEnd = child.style().marginEndUsing(&parentStyle); 1508 if (marginStart.isAuto() && marginEnd.isAuto()) { 1509 child.setMarginStart(availableAlignmentSpace / 2, &parentStyle); 1510 child.setMarginEnd(availableAlignmentSpace / 2, &parentStyle); 1511 } else if (marginStart.isAuto()) { 1512 child.setMarginStart(availableAlignmentSpace, &parentStyle); 1513 } else if (marginEnd.isAuto()) { 1514 child.setMarginEnd(availableAlignmentSpace, &parentStyle); 1535 1515 } 1536 1516 } … … 1540 1520 { 1541 1521 ASSERT(!child.isOutOfFlowPositioned()); 1542 ASSERT(child.overrideContainingBlockContentLogicalHeight());1543 1522 1544 1523 LayoutUnit availableAlignmentSpace = child.overrideContainingBlockContentLogicalHeight().value() - child.logicalHeight(); … … 1546 1525 return; 1547 1526 1548 bool isHorizontal = isHorizontalWritingMode(); 1549 Length topOrLeft = isHorizontal ? child.style().marginTop() : child.style().marginLeft(); 1550 Length bottomOrRight = isHorizontal ? child.style().marginBottom() : child.style().marginRight(); 1551 if (topOrLeft.isAuto() && bottomOrRight.isAuto()) { 1552 if (isHorizontal) { 1553 child.setMarginTop(availableAlignmentSpace / 2); 1554 child.setMarginBottom(availableAlignmentSpace / 2); 1555 } else { 1556 child.setMarginLeft(availableAlignmentSpace / 2); 1557 child.setMarginRight(availableAlignmentSpace / 2); 1558 } 1559 } else if (topOrLeft.isAuto()) { 1560 if (isHorizontal) 1561 child.setMarginTop(availableAlignmentSpace); 1562 else 1563 child.setMarginLeft(availableAlignmentSpace); 1564 } else if (bottomOrRight.isAuto()) { 1565 if (isHorizontal) 1566 child.setMarginBottom(availableAlignmentSpace); 1567 else 1568 child.setMarginRight(availableAlignmentSpace); 1527 const RenderStyle& parentStyle = style(); 1528 Length marginBefore = child.style().marginBeforeUsing(&parentStyle); 1529 Length marginAfter = child.style().marginAfterUsing(&parentStyle); 1530 if (marginBefore.isAuto() && marginAfter.isAuto()) { 1531 child.setMarginBefore(availableAlignmentSpace / 2, &parentStyle); 1532 child.setMarginAfter(availableAlignmentSpace / 2, &parentStyle); 1533 } else if (marginBefore.isAuto()) { 1534 child.setMarginBefore(availableAlignmentSpace, &parentStyle); 1535 } else if (marginAfter.isAuto()) { 1536 child.setMarginAfter(availableAlignmentSpace, &parentStyle); 1569 1537 } 1570 1538 } … … 1682 1650 LayoutUnit endOfRow = m_rowPositions[childEndLine]; 1683 1651 LayoutUnit childBreadth = child.logicalHeight() + child.marginLogicalHeight(); 1652 // In order to properly adjust the Self Alignment values we need to consider the offset between tracks. 1684 1653 if (childEndLine - childStartLine > 1 && childEndLine < m_rowPositions.size() - 1) 1685 1654 endOfRow -= offsetBetweenTracks(style().resolvedAlignContentDistribution(), m_rowPositions, childBreadth); … … 1711 1680 LayoutUnit endOfColumn = m_columnPositions[childEndLine]; 1712 1681 LayoutUnit childBreadth = child.logicalWidth() + child.marginLogicalWidth(); 1682 // In order to properly adjust the Self Alignment values we need to consider the offset between tracks. 1713 1683 if (childEndLine - childStartLine > 1 && childEndLine < m_columnPositions.size() - 1) 1714 1684 endOfColumn -= offsetBetweenTracks(style().resolvedJustifyContentDistribution(), m_columnPositions, childBreadth);
Note: See TracChangeset
for help on using the changeset viewer.