| 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 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 m_columnPositions[0] = borderAndPaddingStart() + sizingData.columnsPositionO
ffset; | 1420 m_columnPositions[0] = borderAndPaddingStart() + sizingData.columnsPositionO
ffset; |
| 1421 for (unsigned i = 0; i < numberOfColumnTracks; ++i) | 1421 for (unsigned i = 0; i < numberOfColumnTracks; ++i) |
| 1422 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnsDist
ributionOffset + sizingData.columnTracks[i].baseSize(); | 1422 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnsDist
ributionOffset + sizingData.columnTracks[i].baseSize(); |
| 1423 | 1423 |
| 1424 m_rowPositions.resize(numberOfRowTracks + 1); | 1424 m_rowPositions.resize(numberOfRowTracks + 1); |
| 1425 m_rowPositions[0] = borderAndPaddingBefore() + sizingData.rowsPositionOffset
; | 1425 m_rowPositions[0] = borderAndPaddingBefore() + sizingData.rowsPositionOffset
; |
| 1426 for (unsigned i = 0; i < numberOfRowTracks; ++i) | 1426 for (unsigned i = 0; i < numberOfRowTracks; ++i) |
| 1427 m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowsDistributionO
ffset + sizingData.rowTracks[i].baseSize(); | 1427 m_rowPositions[i + 1] = m_rowPositions[i] + sizingData.rowsDistributionO
ffset + sizingData.rowTracks[i].baseSize(); |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay
outUnit startOfTrack, LayoutUnit endOfTrack, LayoutUnit childBreadth) | 1430 static LayoutUnit computeOverflowAlignmentOffset(OverflowAlignment overflow, Lay
outUnit trackBreadth, LayoutUnit childBreadth) |
| 1431 { | 1431 { |
| 1432 LayoutUnit trackBreadth = endOfTrack - startOfTrack; | |
| 1433 LayoutUnit offset = trackBreadth - childBreadth; | 1432 LayoutUnit offset = trackBreadth - childBreadth; |
| 1434 | 1433 switch (overflow) { |
| 1435 // If overflow is 'safe', we have to make sure we don't overflow the 'start' | 1434 case OverflowAlignmentSafe: |
| 1436 // edge (potentially cause some data loss as the overflow is unreachable). | 1435 // If overflow is 'safe', we have to make sure we don't overflow the 'st
art' |
| 1437 if (overflow == OverflowAlignmentSafe) | 1436 // edge (potentially cause some data loss as the overflow is unreachable
). |
| 1438 offset = std::max<LayoutUnit>(0, offset); | 1437 return std::max<LayoutUnit>(0, offset); |
| 1439 | 1438 case OverflowAlignmentTrue: |
| 1440 // If we overflow our alignment container and overflow is 'true' (default),
we | 1439 case OverflowAlignmentDefault: |
| 1441 // ignore the overflow and just return the value regardless (which may cause
data | 1440 // If we overflow our alignment container and overflow is 'true' (defaul
t), we |
| 1442 // loss as we overflow the 'start' edge). | 1441 // ignore the overflow and just return the value regardless (which may c
ause data |
| 1443 return offset; | 1442 // loss as we overflow the 'start' edge). |
| 1444 } | 1443 return offset; |
| 1445 | |
| 1446 LayoutUnit LayoutGrid::startOfColumnForChild(const LayoutBox& child) const | |
| 1447 { | |
| 1448 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1449 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | |
| 1450 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | |
| 1451 return startOfColumn + marginStartForChild(child); | |
| 1452 } | |
| 1453 | |
| 1454 LayoutUnit LayoutGrid::endOfColumnForChild(const LayoutBox& child) const | |
| 1455 { | |
| 1456 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1457 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | |
| 1458 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | |
| 1459 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | |
| 1460 | |
| 1461 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | |
| 1462 // FIXME: This might not work as expected with orthogonal writing-modes. | |
| 1463 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); | |
| 1464 | |
| 1465 return columnPosition + offsetFromColumnPosition; | |
| 1466 } | |
| 1467 | |
| 1468 LayoutUnit LayoutGrid::columnPositionLeft(const LayoutBox& child) const | |
| 1469 { | |
| 1470 if (style()->isLeftToRightDirection()) | |
| 1471 return startOfColumnForChild(child); | |
| 1472 | |
| 1473 return endOfColumnForChild(child); | |
| 1474 } | |
| 1475 | |
| 1476 LayoutUnit LayoutGrid::columnPositionRight(const LayoutBox& child) const | |
| 1477 { | |
| 1478 if (!style()->isLeftToRightDirection()) | |
| 1479 return startOfColumnForChild(child); | |
| 1480 | |
| 1481 return endOfColumnForChild(child); | |
| 1482 } | |
| 1483 | |
| 1484 LayoutUnit LayoutGrid::centeredColumnPositionForChild(const LayoutBox& child) co
nst | |
| 1485 { | |
| 1486 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1487 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; | |
| 1488 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; | |
| 1489 LayoutUnit columnPosition = startOfColumn + marginStartForChild(child); | |
| 1490 // FIXME: This might not work as expected with orthogonal writing-modes. | |
| 1491 LayoutUnit offsetFromColumnPosition = computeOverflowAlignmentOffset(child.s
tyle()->justifySelfOverflowAlignment(), startOfColumn, endOfColumn, child.logica
lWidth() + child.marginLogicalWidth()); | |
| 1492 | |
| 1493 return columnPosition + offsetFromColumnPosition / 2; | |
| 1494 } | |
| 1495 | |
| 1496 LayoutUnit LayoutGrid::columnPositionForChild(const LayoutBox& child) const | |
| 1497 { | |
| 1498 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | |
| 1499 | |
| 1500 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It
emPositionStretch)) { | |
| 1501 case ItemPositionSelfStart: | |
| 1502 // For orthogonal writing-modes, this computes to 'start' | |
| 1503 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | |
| 1504 if (hasOrthogonalWritingMode) | |
| 1505 return startOfColumnForChild(child); | |
| 1506 | |
| 1507 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. | |
| 1508 if (child.style()->direction() != style()->direction()) | |
| 1509 return endOfColumnForChild(child); | |
| 1510 | |
| 1511 return startOfColumnForChild(child); | |
| 1512 case ItemPositionSelfEnd: | |
| 1513 // For orthogonal writing-modes, this computes to 'start' | |
| 1514 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | |
| 1515 if (hasOrthogonalWritingMode) | |
| 1516 return endOfColumnForChild(child); | |
| 1517 | |
| 1518 // self-end is based on the child's direction. That's why we need to che
ck against the grid container's direction. | |
| 1519 if (child.style()->direction() != style()->direction()) | |
| 1520 return startOfColumnForChild(child); | |
| 1521 | |
| 1522 return endOfColumnForChild(child); | |
| 1523 case ItemPositionFlexStart: | |
| 1524 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | |
| 1525 return startOfColumnForChild(child); | |
| 1526 case ItemPositionFlexEnd: | |
| 1527 // Only used in flex layout, for other layout, it's equivalent to 'end'. | |
| 1528 return endOfColumnForChild(child); | |
| 1529 case ItemPositionLeft: | |
| 1530 return columnPositionLeft(child); | |
| 1531 case ItemPositionRight: | |
| 1532 return columnPositionRight(child); | |
| 1533 case ItemPositionCenter: | |
| 1534 return centeredColumnPositionForChild(child); | |
| 1535 case ItemPositionStart: | |
| 1536 return startOfColumnForChild(child); | |
| 1537 case ItemPositionEnd: | |
| 1538 return endOfColumnForChild(child); | |
| 1539 case ItemPositionAuto: | |
| 1540 break; | |
| 1541 case ItemPositionStretch: | |
| 1542 return startOfColumnForChild(child); | |
| 1543 case ItemPositionBaseline: | |
| 1544 case ItemPositionLastBaseline: | |
| 1545 // FIXME: Implement the previous values. For now, we always 'start' alig
n the child. | |
| 1546 return startOfColumnForChild(child); | |
| 1547 } | 1444 } |
| 1548 | 1445 |
| 1549 ASSERT_NOT_REACHED(); | 1446 ASSERT_NOT_REACHED(); |
| 1550 return 0; | 1447 return 0; |
| 1551 } | 1448 } |
| 1552 | 1449 |
| 1553 LayoutUnit LayoutGrid::endOfRowForChild(const LayoutBox& child) const | |
| 1554 { | |
| 1555 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1556 | |
| 1557 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | |
| 1558 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | |
| 1559 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | |
| 1560 | |
| 1561 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | |
| 1562 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); | |
| 1563 | |
| 1564 return rowPosition + offsetFromRowPosition; | |
| 1565 } | |
| 1566 | |
| 1567 LayoutUnit LayoutGrid::startOfRowForChild(const LayoutBox& child) const | |
| 1568 { | |
| 1569 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1570 | |
| 1571 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | |
| 1572 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | |
| 1573 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | |
| 1574 | |
| 1575 return rowPosition; | |
| 1576 } | |
| 1577 | |
| 1578 LayoutUnit LayoutGrid::centeredRowPositionForChild(const LayoutBox& child) const | |
| 1579 { | |
| 1580 const GridCoordinate& coordinate = cachedGridCoordinate(child); | |
| 1581 | |
| 1582 // The grid items should be inside the grid container's border box, that's w
hy they need to be shifted. | |
| 1583 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; | |
| 1584 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; | |
| 1585 LayoutUnit rowPosition = startOfRow + marginBeforeForChild(child); | |
| 1586 LayoutUnit offsetFromRowPosition = computeOverflowAlignmentOffset(child.styl
e()->alignSelfOverflowAlignment(), startOfRow, endOfRow, child.logicalHeight() +
child.marginLogicalHeight()); | |
| 1587 | |
| 1588 return rowPosition + offsetFromRowPosition / 2; | |
| 1589 } | |
| 1590 | |
| 1591 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) | 1450 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(const Lay
outBox& child) |
| 1592 { | 1451 { |
| 1593 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); | 1452 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogica
lHeight(); |
| 1594 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); | 1453 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeig
ht + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight); |
| 1595 } | 1454 } |
| 1596 | 1455 |
| 1597 bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c
onst | 1456 bool LayoutGrid::allowedToStretchLogicalHeightForChild(const LayoutBox& child) c
onst |
| 1598 { | 1457 { |
| 1599 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo
reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); | 1458 return child.style()->logicalHeight().isAuto() && !child.style()->marginBefo
reUsing(style()).isAuto() && !child.style()->marginAfterUsing(style()).isAuto(); |
| 1600 } | 1459 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeight(); | 1541 bool childNeedsRelayout = desiredLogicalHeight != child.logicalHeight(); |
| 1683 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight()) | 1542 if (childNeedsRelayout || !child.hasOverrideLogicalContentHeight()) |
| 1684 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); | 1543 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.b
orderAndPaddingLogicalHeight()); |
| 1685 if (childNeedsRelayout) { | 1544 if (childNeedsRelayout) { |
| 1686 child.setLogicalHeight(0); | 1545 child.setLogicalHeight(0); |
| 1687 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); | 1546 child.setNeedsLayout(LayoutInvalidationReason::GridChanged); |
| 1688 } | 1547 } |
| 1689 } | 1548 } |
| 1690 } | 1549 } |
| 1691 | 1550 |
| 1551 GridAxisPosition LayoutGrid::columnAxisPositionForChild(const LayoutBox& child)
const |
| 1552 { |
| 1553 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 1554 bool hasSameWritingMode = child.styleRef().writingMode() == styleRef().writi
ngMode(); |
| 1555 |
| 1556 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo
sitionStretch)) { |
| 1557 case ItemPositionSelfStart: |
| 1558 // If orthogonal writing-modes, this computes to 'start'. |
| 1559 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1560 // self-start is based on the child's block axis direction. That's why w
e need to check against the grid container's block flow. |
| 1561 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisStart
: GridAxisEnd; |
| 1562 case ItemPositionSelfEnd: |
| 1563 // If orthogonal writing-modes, this computes to 'end'. |
| 1564 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1565 // self-end is based on the child's block axis direction. That's why we
need to check against the grid container's block flow. |
| 1566 return (hasOrthogonalWritingMode || hasSameWritingMode) ? GridAxisEnd :
GridAxisStart; |
| 1567 case ItemPositionLeft: |
| 1568 // The alignment axis (column axis) and the inline axis are parallell in |
| 1569 // orthogonal writing mode. Otherwise this this is equivalent to 'start'
. |
| 1570 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1571 return GridAxisStart; |
| 1572 case ItemPositionRight: |
| 1573 // The alignment axis (column axis) and the inline axis are parallell in |
| 1574 // orthogonal writing mode. Otherwise this this is equivalent to 'start'
. |
| 1575 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1576 return hasOrthogonalWritingMode ? GridAxisEnd : GridAxisStart; |
| 1577 case ItemPositionCenter: |
| 1578 return GridAxisCenter; |
| 1579 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen
t to 'start'. |
| 1580 case ItemPositionStart: |
| 1581 return GridAxisStart; |
| 1582 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent
to 'end'. |
| 1583 case ItemPositionEnd: |
| 1584 return GridAxisEnd; |
| 1585 case ItemPositionStretch: |
| 1586 return GridAxisStart; |
| 1587 case ItemPositionBaseline: |
| 1588 case ItemPositionLastBaseline: |
| 1589 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
| 1590 // crbug.com/234191 |
| 1591 return GridAxisStart; |
| 1592 case ItemPositionAuto: |
| 1593 break; |
| 1594 } |
| 1595 |
| 1596 ASSERT_NOT_REACHED(); |
| 1597 return GridAxisStart; |
| 1598 } |
| 1599 |
| 1600 GridAxisPosition LayoutGrid::rowAxisPositionForChild(const LayoutBox& child) con
st |
| 1601 { |
| 1602 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); |
| 1603 bool hasSameDirection = child.styleRef().direction() == styleRef().direction
(); |
| 1604 bool isLTR = styleRef().isLeftToRightDirection(); |
| 1605 |
| 1606 switch (ComputedStyle::resolveJustification(styleRef(), child.styleRef(), It
emPositionStretch)) { |
| 1607 case ItemPositionSelfStart: |
| 1608 // For orthogonal writing-modes, this computes to 'start' |
| 1609 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1610 // self-start is based on the child's direction. That's why we need to c
heck against the grid container's direction. |
| 1611 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisStart :
GridAxisEnd; |
| 1612 case ItemPositionSelfEnd: |
| 1613 // For orthogonal writing-modes, this computes to 'start' |
| 1614 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. |
| 1615 return (hasOrthogonalWritingMode || hasSameDirection) ? GridAxisEnd : Gr
idAxisStart; |
| 1616 case ItemPositionLeft: |
| 1617 return isLTR ? GridAxisStart : GridAxisEnd; |
| 1618 case ItemPositionRight: |
| 1619 return isLTR ? GridAxisEnd : GridAxisStart; |
| 1620 case ItemPositionCenter: |
| 1621 return GridAxisCenter; |
| 1622 case ItemPositionFlexStart: // Only used in flex layout, otherwise equivalen
t to 'start'. |
| 1623 case ItemPositionStart: |
| 1624 return GridAxisStart; |
| 1625 case ItemPositionFlexEnd: // Only used in flex layout, otherwise equivalent
to 'end'. |
| 1626 case ItemPositionEnd: |
| 1627 return GridAxisEnd; |
| 1628 case ItemPositionStretch: |
| 1629 return GridAxisStart; |
| 1630 case ItemPositionBaseline: |
| 1631 case ItemPositionLastBaseline: |
| 1632 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
| 1633 // crbug.com/234191 |
| 1634 return GridAxisStart; |
| 1635 case ItemPositionAuto: |
| 1636 break; |
| 1637 } |
| 1638 |
| 1639 ASSERT_NOT_REACHED(); |
| 1640 return GridAxisStart; |
| 1641 } |
| 1642 |
| 1692 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const | 1643 LayoutUnit LayoutGrid::rowPositionForChild(const LayoutBox& child) const |
| 1693 { | 1644 { |
| 1694 bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizon
talWritingMode(); | 1645 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1695 switch (ComputedStyle::resolveAlignment(styleRef(), child.styleRef(), ItemPo
sitionStretch)) { | 1646 LayoutUnit startOfRow = m_rowPositions[coordinate.rows.resolvedInitialPositi
on.toInt()]; |
| 1696 case ItemPositionSelfStart: | 1647 LayoutUnit endOfRow = m_rowPositions[coordinate.rows.resolvedFinalPosition.n
ext().toInt()]; |
| 1697 // If orthogonal writing-modes, this computes to 'start'. | 1648 LayoutUnit startPosition = startOfRow + marginBeforeForChild(child); |
| 1698 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | 1649 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(child.st
yleRef().alignSelfOverflowAlignment(), endOfRow - startOfRow, child.logicalHeigh
t() + child.marginLogicalHeight()); |
| 1699 if (hasOrthogonalWritingMode) | |
| 1700 return startOfRowForChild(child); | |
| 1701 | 1650 |
| 1702 // self-start is based on the child's block axis direction. That's why w
e need to check against the grid container's block flow. | 1651 switch (columnAxisPositionForChild(child)) { |
| 1703 if (child.style()->writingMode() != style()->writingMode()) | 1652 case GridAxisStart: |
| 1704 return endOfRowForChild(child); | 1653 return startPosition; |
| 1705 | 1654 case GridAxisEnd: |
| 1706 return startOfRowForChild(child); | 1655 return startPosition + offsetFromStartPosition; |
| 1707 case ItemPositionSelfEnd: | 1656 case GridAxisCenter: |
| 1708 // If orthogonal writing-modes, this computes to 'end'. | 1657 return startPosition + offsetFromStartPosition / 2; |
| 1709 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | |
| 1710 if (hasOrthogonalWritingMode) | |
| 1711 return endOfRowForChild(child); | |
| 1712 | |
| 1713 // self-end is based on the child's block axis direction. That's why we
need to check against the grid container's block flow. | |
| 1714 if (child.style()->writingMode() != style()->writingMode()) | |
| 1715 return startOfRowForChild(child); | |
| 1716 | |
| 1717 return endOfRowForChild(child); | |
| 1718 case ItemPositionLeft: | |
| 1719 // The alignment axis (column axis) and the inline axis are parallell in | |
| 1720 // orthogonal writing mode. | |
| 1721 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | |
| 1722 if (hasOrthogonalWritingMode) | |
| 1723 return startOfRowForChild(child); | |
| 1724 | |
| 1725 // Otherwise this this is equivalent to 'start'. | |
| 1726 return startOfRowForChild(child); | |
| 1727 case ItemPositionRight: | |
| 1728 // The alignment axis (column axis) and the inline axis are parallell in | |
| 1729 // orthogonal writing mode. | |
| 1730 // FIXME: grid track sizing and positioning do not support orthogonal mo
des yet. | |
| 1731 if (hasOrthogonalWritingMode) | |
| 1732 return endOfRowForChild(child); | |
| 1733 | |
| 1734 // Otherwise this this is equivalent to 'start'. | |
| 1735 return startOfRowForChild(child); | |
| 1736 case ItemPositionCenter: | |
| 1737 return centeredRowPositionForChild(child); | |
| 1738 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | |
| 1739 case ItemPositionFlexStart: | |
| 1740 case ItemPositionStart: | |
| 1741 return startOfRowForChild(child); | |
| 1742 // Only used in flex layout, for other layout, it's equivalent to 'end'. | |
| 1743 case ItemPositionFlexEnd: | |
| 1744 case ItemPositionEnd: | |
| 1745 return endOfRowForChild(child); | |
| 1746 case ItemPositionStretch: | |
| 1747 return startOfRowForChild(child); | |
| 1748 case ItemPositionBaseline: | |
| 1749 case ItemPositionLastBaseline: | |
| 1750 // FIXME: Implement the ItemPositionBaseline value. For now, we always '
start' align the child. | |
| 1751 return startOfRowForChild(child); | |
| 1752 case ItemPositionAuto: | |
| 1753 break; | |
| 1754 } | 1658 } |
| 1755 | 1659 |
| 1756 ASSERT_NOT_REACHED(); | 1660 ASSERT_NOT_REACHED(); |
| 1757 return 0; | 1661 return 0; |
| 1758 } | 1662 } |
| 1759 | 1663 |
| 1664 LayoutUnit LayoutGrid::columnPositionForChild(const LayoutBox& child) const |
| 1665 { |
| 1666 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
| 1667 LayoutUnit startOfColumn = m_columnPositions[coordinate.columns.resolvedInit
ialPosition.toInt()]; |
| 1668 LayoutUnit endOfColumn = m_columnPositions[coordinate.columns.resolvedFinalP
osition.next().toInt()]; |
| 1669 LayoutUnit startPosition = startOfColumn + marginStartForChild(child); |
| 1670 LayoutUnit offsetFromStartPosition = computeOverflowAlignmentOffset(child.st
yleRef().justifySelfOverflowAlignment(), endOfColumn - startOfColumn, child.logi
calWidth() + child.marginLogicalWidth()); |
| 1671 |
| 1672 switch (rowAxisPositionForChild(child)) { |
| 1673 case GridAxisStart: |
| 1674 return startPosition; |
| 1675 case GridAxisEnd: |
| 1676 return startPosition + offsetFromStartPosition; |
| 1677 case GridAxisCenter: |
| 1678 return startPosition + offsetFromStartPosition / 2; |
| 1679 } |
| 1680 |
| 1681 ASSERT_NOT_REACHED(); |
| 1682 return 0; |
| 1683 } |
| 1684 |
| 1760 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) | 1685 ContentPosition static resolveContentDistributionFallback(ContentDistributionTyp
e distribution) |
| 1761 { | 1686 { |
| 1762 switch (distribution) { | 1687 switch (distribution) { |
| 1763 case ContentDistributionSpaceBetween: | 1688 case ContentDistributionSpaceBetween: |
| 1764 return ContentPositionStart; | 1689 return ContentPositionStart; |
| 1765 case ContentDistributionSpaceAround: | 1690 case ContentDistributionSpaceAround: |
| 1766 return ContentPositionCenter; | 1691 return ContentPositionCenter; |
| 1767 case ContentDistributionSpaceEvenly: | 1692 case ContentDistributionSpaceEvenly: |
| 1768 return ContentPositionCenter; | 1693 return ContentPositionCenter; |
| 1769 case ContentDistributionStretch: | 1694 case ContentDistributionStretch: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 case ContentPositionEnd: | 1779 case ContentPositionEnd: |
| 1855 sizingData.columnsPositionOffset = offsetToEndEdge(style()->isLeftToRigh
tDirection(), availableFreeSpace); | 1780 sizingData.columnsPositionOffset = offsetToEndEdge(style()->isLeftToRigh
tDirection(), availableFreeSpace); |
| 1856 return; | 1781 return; |
| 1857 case ContentPositionFlexStart: | 1782 case ContentPositionFlexStart: |
| 1858 // Only used in flex layout, for other layout, it's equivalent to 'start
'. | 1783 // Only used in flex layout, for other layout, it's equivalent to 'start
'. |
| 1859 case ContentPositionStart: | 1784 case ContentPositionStart: |
| 1860 sizingData.columnsPositionOffset = offsetToStartEdge(style()->isLeftToRi
ghtDirection(), availableFreeSpace); | 1785 sizingData.columnsPositionOffset = offsetToStartEdge(style()->isLeftToRi
ghtDirection(), availableFreeSpace); |
| 1861 return; | 1786 return; |
| 1862 case ContentPositionBaseline: | 1787 case ContentPositionBaseline: |
| 1863 case ContentPositionLastBaseline: | 1788 case ContentPositionLastBaseline: |
| 1864 // FIXME: Implement the previous values. For now, we always 'start' alig
n. | 1789 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
| 1865 // crbug.com/234191 | 1790 // crbug.com/234191 |
| 1866 sizingData.columnsPositionOffset = offsetToStartEdge(style()->isLeftToRi
ghtDirection(), availableFreeSpace); | 1791 sizingData.columnsPositionOffset = offsetToStartEdge(style()->isLeftToRi
ghtDirection(), availableFreeSpace); |
| 1867 return; | 1792 return; |
| 1868 case ContentPositionAuto: | 1793 case ContentPositionAuto: |
| 1869 break; | 1794 break; |
| 1870 } | 1795 } |
| 1871 | 1796 |
| 1872 ASSERT_NOT_REACHED(); | 1797 ASSERT_NOT_REACHED(); |
| 1873 } | 1798 } |
| 1874 | 1799 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1902 case ContentPositionEnd: | 1827 case ContentPositionEnd: |
| 1903 sizingData.rowsPositionOffset = availableFreeSpace; | 1828 sizingData.rowsPositionOffset = availableFreeSpace; |
| 1904 return; | 1829 return; |
| 1905 case ContentPositionFlexStart: | 1830 case ContentPositionFlexStart: |
| 1906 // Only used in flex layout, for other layout, it's equivalent to 'Start
'. | 1831 // Only used in flex layout, for other layout, it's equivalent to 'Start
'. |
| 1907 case ContentPositionStart: | 1832 case ContentPositionStart: |
| 1908 sizingData.rowsPositionOffset = 0; | 1833 sizingData.rowsPositionOffset = 0; |
| 1909 return; | 1834 return; |
| 1910 case ContentPositionBaseline: | 1835 case ContentPositionBaseline: |
| 1911 case ContentPositionLastBaseline: | 1836 case ContentPositionLastBaseline: |
| 1912 // FIXME: Implement the previous values. For now, we always start align. | 1837 // FIXME: These two require implementing Baseline Alignment. For now, we
always 'start' align the child. |
| 1913 // crbug.com/234191 | 1838 // crbug.com/234191 |
| 1914 sizingData.rowsPositionOffset = 0; | 1839 sizingData.rowsPositionOffset = 0; |
| 1915 return; | 1840 return; |
| 1916 case ContentPositionAuto: | 1841 case ContentPositionAuto: |
| 1917 break; | 1842 break; |
| 1918 } | 1843 } |
| 1919 | 1844 |
| 1920 ASSERT_NOT_REACHED(); | 1845 ASSERT_NOT_REACHED(); |
| 1921 } | 1846 } |
| 1922 | 1847 |
| 1923 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const | 1848 LayoutPoint LayoutGrid::findChildLogicalPosition(const LayoutBox& child, GridSiz
ingData& sizingData) const |
| 1924 { | 1849 { |
| 1925 LayoutUnit columnPosition = columnPositionForChild(child); | 1850 LayoutUnit columnPosition = columnPositionForChild(child); |
| 1926 // We stored m_columnPositions's data ignoring the direction, hence we might
need now | 1851 // We stored m_columnPositions's data ignoring the direction, hence we might
need now |
| 1927 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. | 1852 // to translate positions from RTL to LTR, as it's more convenient for paint
ing. |
| 1928 if (!style()->isLeftToRightDirection()) | 1853 if (!style()->isLeftToRightDirection()) |
| 1929 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord
erAndPaddingLogicalLeft() + sizingData.columnsPositionOffset) - columnPosition -
sizingData.columnsDistributionOffset - child.logicalWidth(); | 1854 columnPosition = (m_columnPositions[m_columnPositions.size() - 1] + bord
erAndPaddingLogicalLeft() + sizingData.columnsPositionOffset) - columnPosition -
sizingData.columnsDistributionOffset - child.logicalWidth(); |
| 1930 | 1855 |
| 1931 return LayoutPoint(columnPosition, rowPositionForChild(child)); | 1856 return LayoutPoint(columnPosition, rowPositionForChild(child)); |
| 1932 } | 1857 } |
| 1933 | 1858 |
| 1934 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) | 1859 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) |
| 1935 { | 1860 { |
| 1936 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 1861 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
| 1937 } | 1862 } |
| 1938 | 1863 |
| 1939 } // namespace blink | 1864 } // namespace blink |
| OLD | NEW |