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 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 child->setExtraInlineOffset(columnOffset); | 1479 child->setExtraInlineOffset(columnOffset); |
1480 child->setExtraBlockOffset(rowOffset); | 1480 child->setExtraBlockOffset(rowOffset); |
1481 } | 1481 } |
1482 | 1482 |
1483 LayoutBlock::layoutPositionedObjects(relayoutChildren, info); | 1483 LayoutBlock::layoutPositionedObjects(relayoutChildren, info); |
1484 } | 1484 } |
1485 | 1485 |
1486 void LayoutGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid
TrackSizingDirection direction, LayoutUnit& offset, LayoutUnit& breadth) | 1486 void LayoutGrid::offsetAndBreadthForPositionedChild(const LayoutBox& child, Grid
TrackSizingDirection direction, LayoutUnit& offset, LayoutUnit& breadth) |
1487 { | 1487 { |
1488 ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode()); | 1488 ASSERT(child.isHorizontalWritingMode() == isHorizontalWritingMode()); |
| 1489 bool isForColumns = direction == ForColumns; |
1489 | 1490 |
1490 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromStyle(*st
yle(), child, direction); | 1491 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromStyle(*st
yle(), child, direction); |
1491 if (positions.isIndefinite()) { | 1492 if (positions.isIndefinite()) { |
1492 offset = LayoutUnit(); | 1493 offset = LayoutUnit(); |
1493 breadth = (direction == ForColumns) ? clientLogicalWidth() : clientLogic
alHeight(); | 1494 breadth = isForColumns ? clientLogicalWidth() : clientLogicalHeight(); |
1494 return; | 1495 return; |
1495 } | 1496 } |
1496 positions.translate(direction == ForColumns ? m_smallestColumnStart : m_smal
lestRowStart); | |
1497 | 1497 |
1498 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid
ColumnStart() : child.style()->gridRowStart(); | 1498 // For positioned items we cannot use GridSpan::translate(). Because we coul
d end up with negative values, as the positioned items do not create implicit tr
acks per spec. |
1499 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo
lumnEnd() : child.style()->gridRowEnd(); | 1499 int smallestStart = abs(isForColumns ? m_smallestColumnStart : m_smallestRow
Start); |
1500 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR
owCount()) - 1; | 1500 int resolvedInitialPosition = positions.untranslatedResolvedInitialPosition(
) + smallestStart; |
| 1501 int resolvedFinalPosition = positions.untranslatedResolvedFinalPosition() +
smallestStart; |
| 1502 |
| 1503 GridPosition startPosition = isForColumns ? child.style()->gridColumnStart()
: child.style()->gridRowStart(); |
| 1504 GridPosition endPosition = isForColumns ? child.style()->gridColumnEnd() : c
hild.style()->gridRowEnd(); |
| 1505 int lastExplicitLine = isForColumns ? gridColumnCount() : gridRowCount(); |
1501 | 1506 |
1502 bool startIsAuto = startPosition.isAuto() | 1507 bool startIsAuto = startPosition.isAuto() |
1503 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam
edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in
itialPositionSide(direction))) | 1508 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam
edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in
itialPositionSide(direction))) |
1504 || (positions.resolvedInitialPosition() > lastTrackIndex); | 1509 || (resolvedInitialPosition < 0) |
| 1510 || (resolvedInitialPosition > lastExplicitLine); |
1505 bool endIsAuto = endPosition.isAuto() | 1511 bool endIsAuto = endPosition.isAuto() |
1506 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed
LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP
ositionSide(direction))) | 1512 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed
LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP
ositionSide(direction))) |
1507 || (positions.resolvedFinalPosition() - 1 > lastTrackIndex); | 1513 || (resolvedFinalPosition < 0) |
| 1514 || (resolvedFinalPosition > lastExplicitLine); |
1508 | 1515 |
1509 size_t firstPosition = 0; | 1516 size_t initialPosition = startIsAuto ? 0 : resolvedInitialPosition; |
1510 size_t initialPosition = startIsAuto ? firstPosition : positions.resolvedIni
tialPosition(); | 1517 size_t finalPosition = endIsAuto ? lastExplicitLine : resolvedFinalPosition; |
1511 size_t lastPosition = lastTrackIndex; | |
1512 size_t finalPosition = endIsAuto ? lastPosition : positions.resolvedFinalPos
ition() - 1; | |
1513 | 1518 |
1514 // Positioned children do not grow the grid, so we need to clamp the positio
ns to avoid ending up outside of it. | 1519 LayoutUnit start = startIsAuto ? LayoutUnit() : isForColumns ? m_columnPosi
tions[initialPosition] : m_rowPositions[initialPosition]; |
1515 initialPosition = std::min(initialPosition, lastPosition); | 1520 LayoutUnit end = endIsAuto ? isForColumns ? logicalWidth() : logicalHeight()
: isForColumns ? m_columnPositions[finalPosition] : m_rowPositions[finalPositi
on]; |
1516 finalPosition = std::min(finalPosition, lastPosition); | |
1517 | |
1518 LayoutUnit start = startIsAuto ? LayoutUnit() : (direction == ForColumns) ?
m_columnPositions[initialPosition] : m_rowPositions[initialPosition]; | |
1519 LayoutUnit end = endIsAuto ? (direction == ForColumns) ? logicalWidth() : lo
gicalHeight() : (direction == ForColumns) ? m_columnPositions[finalPosition + 1
] : m_rowPositions[finalPosition + 1]; | |
1520 | 1521 |
1521 breadth = end - start; | 1522 breadth = end - start; |
1522 | 1523 |
1523 if (startIsAuto) | 1524 if (startIsAuto) |
1524 breadth -= (direction == ForColumns) ? borderStart() : borderBefore(); | 1525 breadth -= isForColumns ? borderStart() : borderBefore(); |
1525 else | 1526 else |
1526 start -= ((direction == ForColumns) ? borderStart() : borderBefore()); | 1527 start -= isForColumns ? borderStart() : borderBefore(); |
1527 | 1528 |
1528 if (endIsAuto) { | 1529 if (endIsAuto) { |
1529 breadth -= (direction == ForColumns) ? borderEnd() : borderAfter(); | 1530 breadth -= isForColumns ? borderEnd() : borderAfter(); |
1530 breadth -= scrollbarLogicalWidth(); | 1531 breadth -= scrollbarLogicalWidth(); |
1531 } | 1532 } |
1532 | 1533 |
1533 offset = start; | 1534 offset = start; |
1534 | 1535 |
1535 if (child.parent() == this && !startIsAuto) { | 1536 if (child.parent() == this && !startIsAuto) { |
1536 // If column/row start is "auto" the static position has been already se
t in prepareChildForPositionedLayout(). | 1537 // If column/row start is "auto" the static position has been already se
t in prepareChildForPositionedLayout(). |
1537 PaintLayer* childLayer = child.layer(); | 1538 PaintLayer* childLayer = child.layer(); |
1538 if (direction == ForColumns) | 1539 if (isForColumns) |
1539 childLayer->setStaticInlinePosition(borderStart() + offset); | 1540 childLayer->setStaticInlinePosition(borderStart() + offset); |
1540 else | 1541 else |
1541 childLayer->setStaticBlockPosition(borderBefore() + offset); | 1542 childLayer->setStaticBlockPosition(borderBefore() + offset); |
1542 } | 1543 } |
1543 } | 1544 } |
1544 | 1545 |
1545 GridCoordinate LayoutGrid::cachedGridCoordinate(const LayoutBox& gridItem) const | 1546 GridCoordinate LayoutGrid::cachedGridCoordinate(const LayoutBox& gridItem) const |
1546 { | 1547 { |
1547 ASSERT(m_gridItemCoordinate.contains(&gridItem)); | 1548 ASSERT(m_gridItemCoordinate.contains(&gridItem)); |
1548 return m_gridItemCoordinate.get(&gridItem); | 1549 return m_gridItemCoordinate.get(&gridItem); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 | 2071 |
2071 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2072 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
2072 } | 2073 } |
2073 | 2074 |
2074 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const | 2075 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) const |
2075 { | 2076 { |
2076 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2077 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2077 } | 2078 } |
2078 | 2079 |
2079 } // namespace blink | 2080 } // namespace blink |
OLD | NEW |