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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 1489 |
1490 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromStyle(*st yle(), child, direction); | 1490 GridSpan positions = GridResolvedPosition::resolveGridPositionsFromStyle(*st yle(), child, direction); |
1491 if (positions.isIndefinite()) { | 1491 if (positions.isIndefinite()) { |
1492 offset = LayoutUnit(); | 1492 offset = LayoutUnit(); |
1493 breadth = (direction == ForColumns) ? clientLogicalWidth() : clientLogic alHeight(); | 1493 breadth = (direction == ForColumns) ? clientLogicalWidth() : clientLogic alHeight(); |
1494 return; | 1494 return; |
1495 } | 1495 } |
1496 positions.translate(direction == ForColumns ? m_smallestColumnStart : m_smal lestRowStart); | 1496 int smallestStart = abs(direction == ForColumns ? m_smallestColumnStart : m_ smallestRowStart); |
svillar
2016/01/19 12:04:51
I'm starting to do
bool isRowAxis = direction ==
Manuel Rego
2016/01/19 15:52:25
Done.
| |
1497 int resolvedInitialPosition = positions.untranslatedResolvedInitialPosition( ) + smallestStart; | |
1498 int resolvedFinalPosition = positions.untranslatedResolvedFinalPosition() + smallestStart; | |
svillar
2016/01/19 12:04:51
This manual translation requires some explanation
Manuel Rego
2016/01/19 15:52:25
Added comment.
| |
1497 | 1499 |
1498 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid ColumnStart() : child.style()->gridRowStart(); | 1500 GridPosition startPosition = (direction == ForColumns) ? child.style()->grid ColumnStart() : child.style()->gridRowStart(); |
1499 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo lumnEnd() : child.style()->gridRowEnd(); | 1501 GridPosition endPosition = (direction == ForColumns) ? child.style()->gridCo lumnEnd() : child.style()->gridRowEnd(); |
1500 size_t lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridR owCount()) - 1; | 1502 int lastTrackIndex = (direction == ForColumns ? gridColumnCount() : gridRowC ount()); |
svillar
2016/01/19 12:04:51
Perhaps we should use this change to rename this t
Manuel Rego
2016/01/19 15:52:25
Done.
| |
1501 | 1503 |
1502 bool startIsAuto = startPosition.isAuto() | 1504 bool startIsAuto = startPosition.isAuto() |
1503 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in itialPositionSide(direction))) | 1505 || (startPosition.isNamedGridArea() && !GridResolvedPosition::isValidNam edLineOrArea(startPosition.namedGridLine(), styleRef(), GridResolvedPosition::in itialPositionSide(direction))) |
1504 || (positions.resolvedInitialPosition() > lastTrackIndex); | 1506 || (resolvedInitialPosition < 0) |
1507 || (resolvedInitialPosition > lastTrackIndex); | |
1505 bool endIsAuto = endPosition.isAuto() | 1508 bool endIsAuto = endPosition.isAuto() |
1506 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP ositionSide(direction))) | 1509 || (endPosition.isNamedGridArea() && !GridResolvedPosition::isValidNamed LineOrArea(endPosition.namedGridLine(), styleRef(), GridResolvedPosition::finalP ositionSide(direction))) |
1507 || (positions.resolvedFinalPosition() - 1 > lastTrackIndex); | 1510 || (resolvedFinalPosition < 0) |
1511 || (resolvedFinalPosition > lastTrackIndex); | |
1508 | 1512 |
1509 size_t firstPosition = 0; | 1513 size_t initialPosition = startIsAuto ? 0 : resolvedInitialPosition; |
1510 size_t initialPosition = startIsAuto ? firstPosition : positions.resolvedIni tialPosition(); | 1514 size_t finalPosition = endIsAuto ? lastTrackIndex : resolvedFinalPosition; |
1511 size_t lastPosition = lastTrackIndex; | |
1512 size_t finalPosition = endIsAuto ? lastPosition : positions.resolvedFinalPos ition() - 1; | |
1513 | |
1514 // Positioned children do not grow the grid, so we need to clamp the positio ns to avoid ending up outside of it. | |
1515 initialPosition = std::min(initialPosition, lastPosition); | |
1516 finalPosition = std::min(finalPosition, lastPosition); | |
1517 | 1515 |
1518 LayoutUnit start = startIsAuto ? LayoutUnit() : (direction == ForColumns) ? m_columnPositions[initialPosition] : m_rowPositions[initialPosition]; | 1516 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]; | 1517 LayoutUnit end = endIsAuto ? (direction == ForColumns) ? logicalWidth() : lo gicalHeight() : (direction == ForColumns) ? m_columnPositions[finalPosition] : m_rowPositions[finalPosition]; |
jfernandez
2016/01/18 17:57:42
I'd simplify this line, if possible.
Manuel Rego
2016/01/19 15:52:25
Now that we use isForColumns I think it's not that
| |
1520 | 1518 |
1521 breadth = end - start; | 1519 breadth = end - start; |
1522 | 1520 |
1523 if (startIsAuto) | 1521 if (startIsAuto) |
1524 breadth -= (direction == ForColumns) ? borderStart() : borderBefore(); | 1522 breadth -= (direction == ForColumns) ? borderStart() : borderBefore(); |
1525 else | 1523 else |
1526 start -= ((direction == ForColumns) ? borderStart() : borderBefore()); | 1524 start -= ((direction == ForColumns) ? borderStart() : borderBefore()); |
1527 | 1525 |
1528 if (endIsAuto) { | 1526 if (endIsAuto) { |
1529 breadth -= (direction == ForColumns) ? borderEnd() : borderAfter(); | 1527 breadth -= (direction == ForColumns) ? borderEnd() : borderAfter(); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2070 | 2068 |
2071 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); | 2069 return LayoutPoint(rowAxisOffset, columnAxisOffsetForChild(child)); |
2072 } | 2070 } |
2073 | 2071 |
2074 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const | 2072 void LayoutGrid::paintChildren(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset) const |
2075 { | 2073 { |
2076 GridPainter(*this).paintChildren(paintInfo, paintOffset); | 2074 GridPainter(*this).paintChildren(paintInfo, paintOffset); |
2077 } | 2075 } |
2078 | 2076 |
2079 } // namespace blink | 2077 } // namespace blink |
OLD | NEW |