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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return; | 190 return; |
191 } | 191 } |
192 | 192 |
193 RenderBox* newChildBox = toRenderBox(newChild); | 193 RenderBox* newChildBox = toRenderBox(newChild); |
194 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(newChildBox, F
orRows); | 194 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(newChildBox, F
orRows); |
195 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(newChildBox
, ForColumns); | 195 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(newChildBox
, ForColumns); |
196 if (!rowPositions || !columnPositions) { | 196 if (!rowPositions || !columnPositions) { |
197 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. | 197 // The new child requires the auto-placement algorithm to run so we need
to recompute the grid fully. |
198 dirtyGrid(); | 198 dirtyGrid(); |
199 } else { | 199 } else { |
200 if (gridRowCount() <= rowPositions->finalPositionIndex || gridColumnCoun
t() <= columnPositions->finalPositionIndex) { | 200 if (gridRowCount() <= rowPositions->finalPositionIndex.integerPosition()
|| gridColumnCount() <= columnPositions->finalPositionIndex.integerPosition())
{ |
201 // FIXME: We could just insert the new child provided we had a primi
tive to arbitrarily grow the grid. | 201 // FIXME: We could just insert the new child provided we had a primi
tive to arbitrarily grow the grid. |
202 dirtyGrid(); | 202 dirtyGrid(); |
203 } else { | 203 } else { |
204 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *colum
nPositions)); | 204 insertItemIntoGrid(newChildBox, GridCoordinate(*rowPositions, *colum
nPositions)); |
205 } | 205 } |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void RenderGrid::removeChild(RenderObject* child) | 209 void RenderGrid::removeChild(RenderObject* child) |
210 { | 210 { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 m_grid[row].grow(oldColumnSize + 1); | 673 m_grid[row].grow(oldColumnSize + 1); |
674 } else { | 674 } else { |
675 const size_t oldRowSize = m_grid.size(); | 675 const size_t oldRowSize = m_grid.size(); |
676 m_grid.grow(oldRowSize + 1); | 676 m_grid.grow(oldRowSize + 1); |
677 m_grid[oldRowSize].grow(m_grid[0].size()); | 677 m_grid[oldRowSize].grow(m_grid[0].size()); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor
dinate) | 681 void RenderGrid::insertItemIntoGrid(RenderBox* child, const GridCoordinate& coor
dinate) |
682 { | 682 { |
683 for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.ro
ws.finalPositionIndex; ++row) { | 683 for (size_t row = coordinate.rows.initialPositionIndex; row <= coordinate.ro
ws.finalPositionIndex.integerPosition(); ++row) { |
684 for (size_t column = coordinate.columns.initialPositionIndex; column <=
coordinate.columns.finalPositionIndex; ++column) | 684 for (size_t column = coordinate.columns.initialPositionIndex; column <=
coordinate.columns.finalPositionIndex.integerPosition(); ++column) |
685 m_grid[row][column].append(child); | 685 m_grid[row][column].append(child); |
686 } | 686 } |
687 | 687 |
688 m_gridItemCoordinate.set(child, coordinate); | 688 m_gridItemCoordinate.set(child, coordinate); |
689 } | 689 } |
690 | 690 |
691 void RenderGrid::insertItemIntoGrid(RenderBox* child, size_t rowTrack, size_t co
lumnTrack) | 691 void RenderGrid::insertItemIntoGrid(RenderBox* child, size_t rowTrack, size_t co
lumnTrack) |
692 { | 692 { |
693 const GridSpan& rowSpan = resolveGridPositionsFromAutoPlacementPosition(chil
d, ForRows, rowTrack); | 693 const GridSpan& rowSpan = resolveGridPositionsFromAutoPlacementPosition(chil
d, ForRows, rowTrack); |
694 const GridSpan& columnSpan = resolveGridPositionsFromAutoPlacementPosition(c
hild, ForColumns, columnTrack); | 694 const GridSpan& columnSpan = resolveGridPositionsFromAutoPlacementPosition(c
hild, ForColumns, columnTrack); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { | 753 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBo
x()) { |
754 populator.collectChild(child); | 754 populator.collectChild(child); |
755 | 755 |
756 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. | 756 // This function bypasses the cache (cachedGridCoordinate()) as it is us
ed to build it. |
757 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(child, For
Rows); | 757 OwnPtr<GridSpan> rowPositions = resolveGridPositionsFromStyle(child, For
Rows); |
758 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(child,
ForColumns); | 758 OwnPtr<GridSpan> columnPositions = resolveGridPositionsFromStyle(child,
ForColumns); |
759 | 759 |
760 // |positions| is 0 if we need to run the auto-placement algorithm. Our
estimation ignores | 760 // |positions| is 0 if we need to run the auto-placement algorithm. Our
estimation ignores |
761 // this case as the auto-placement algorithm will grow the grid as neede
d. | 761 // this case as the auto-placement algorithm will grow the grid as neede
d. |
762 if (rowPositions) | 762 if (rowPositions) |
763 maximumRowIndex = std::max(maximumRowIndex, rowPositions->finalPosit
ionIndex + 1); | 763 maximumRowIndex = std::max(maximumRowIndex, rowPositions->finalPosit
ionIndex.integerPosition() + 1); |
764 if (columnPositions) | 764 if (columnPositions) |
765 maximumColumnIndex = std::max(maximumColumnIndex, columnPositions->f
inalPositionIndex + 1); | 765 maximumColumnIndex = std::max(maximumColumnIndex, columnPositions->f
inalPositionIndex.integerPosition() + 1); |
766 } | 766 } |
767 | 767 |
768 m_grid.grow(maximumRowIndex); | 768 m_grid.grow(maximumRowIndex); |
769 for (size_t i = 0; i < m_grid.size(); ++i) | 769 for (size_t i = 0; i < m_grid.size(); ++i) |
770 m_grid[i].grow(maximumColumnIndex); | 770 m_grid[i].grow(maximumColumnIndex); |
771 } | 771 } |
772 | 772 |
773 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>& au
toGridItems) | 773 void RenderGrid::placeSpecifiedMajorAxisItemsOnGrid(const Vector<RenderBox*>& au
toGridItems) |
774 { | 774 { |
775 for (size_t i = 0; i < autoGridItems.size(); ++i) { | 775 for (size_t i = 0; i < autoGridItems.size(); ++i) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 if (initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPositi
on.shouldBeResolvedAgainstOppositePosition()) { | 926 if (initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPositi
on.shouldBeResolvedAgainstOppositePosition()) { |
927 if (style()->gridAutoFlow() == AutoFlowNone) | 927 if (style()->gridAutoFlow() == AutoFlowNone) |
928 return adoptPtr(new GridSpan(0, 0)); | 928 return adoptPtr(new GridSpan(0, 0)); |
929 | 929 |
930 // We can't get our grid positions without running the auto placement al
gorithm. | 930 // We can't get our grid positions without running the auto placement al
gorithm. |
931 return nullptr; | 931 return nullptr; |
932 } | 932 } |
933 | 933 |
934 if (initialPosition.shouldBeResolvedAgainstOppositePosition()) { | 934 if (initialPosition.shouldBeResolvedAgainstOppositePosition()) { |
935 // Infer the position from the final position ('auto / 1' or 'span 2 / 3
' case). | 935 // Infer the position from the final position ('auto / 1' or 'span 2 / 3
' case). |
936 const size_t finalResolvedPosition = resolveGridPositionFromStyle(finalP
osition, finalPositionSide); | 936 GridResolvedPosition finalResolvedPosition = resolveGridPositionFromStyl
e(finalPosition, finalPositionSide); |
937 return resolveGridPositionAgainstOppositePosition(finalResolvedPosition,
initialPosition, initialPositionSide); | 937 return resolveGridPositionAgainstOppositePosition(finalResolvedPosition,
initialPosition, initialPositionSide); |
938 } | 938 } |
939 | 939 |
940 if (finalPosition.shouldBeResolvedAgainstOppositePosition()) { | 940 if (finalPosition.shouldBeResolvedAgainstOppositePosition()) { |
941 // Infer our position from the initial position ('1 / auto' or '3 / span
2' case). | 941 // Infer our position from the initial position ('1 / auto' or '3 / span
2' case). |
942 const size_t initialResolvedPosition = resolveGridPositionFromStyle(init
ialPosition, initialPositionSide); | 942 GridResolvedPosition initialResolvedPosition = resolveGridPositionFromSt
yle(initialPosition, initialPositionSide); |
943 return resolveGridPositionAgainstOppositePosition(initialResolvedPositio
n, finalPosition, finalPositionSide); | 943 return resolveGridPositionAgainstOppositePosition(initialResolvedPositio
n, finalPosition, finalPositionSide); |
944 } | 944 } |
945 | 945 |
946 size_t resolvedInitialPosition = resolveGridPositionFromStyle(initialPositio
n, initialPositionSide); | 946 GridResolvedPosition resolvedInitialPosition = resolveGridPositionFromStyle(
initialPosition, initialPositionSide); |
947 size_t resolvedFinalPosition = resolveGridPositionFromStyle(finalPosition, f
inalPositionSide); | 947 GridResolvedPosition resolvedFinalPosition = resolveGridPositionFromStyle(fi
nalPosition, finalPositionSide); |
948 | 948 |
949 // If 'grid-after' specifies a line at or before that specified by 'grid-bef
ore', it computes to 'span 1'. | 949 // If 'grid-after' specifies a line at or before that specified by 'grid-bef
ore', it computes to 'span 1'. |
950 if (resolvedFinalPosition < resolvedInitialPosition) | 950 if (resolvedFinalPosition < resolvedInitialPosition) |
951 resolvedFinalPosition = resolvedInitialPosition; | 951 resolvedFinalPosition.setIntegerPosition(resolvedInitialPosition.integer
Position()); |
952 | 952 |
953 return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosition)
); | 953 return adoptPtr(new GridSpan(resolvedInitialPosition.integerPosition(), reso
lvedFinalPosition.integerPosition())); |
954 } | 954 } |
955 | 955 |
956 size_t RenderGrid::resolveNamedGridLinePositionFromStyle(const GridPosition& pos
ition, GridPositionSide side) const | 956 GridResolvedPosition RenderGrid::resolveNamedGridLinePositionFromStyle(const Gri
dPosition& position, GridPositionSide side) const |
957 { | 957 { |
958 ASSERT(!position.namedGridLine().isNull()); | 958 ASSERT(!position.namedGridLine().isNull()); |
959 | 959 |
960 const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side =
= ColumnEndSide) ? style()->namedGridColumnLines() : style()->namedGridRowLines(
); | 960 const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side =
= ColumnEndSide) ? style()->namedGridColumnLines() : style()->namedGridRowLines(
); |
961 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); | 961 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); |
962 if (it == gridLinesNames.end()) { | 962 if (it == gridLinesNames.end()) { |
963 if (position.isPositive()) | 963 if (position.isPositive()) |
964 return 0; | 964 return GridResolvedPosition(); |
965 const size_t lastLine = explicitGridSizeForSide(side); | 965 const size_t lastLine = explicitGridSizeForSide(side); |
966 return GridPosition::adjustGridPositionForSide(lastLine, side); | 966 return GridResolvedPosition::adjustGridPositionForSide(lastLine, side); |
967 } | 967 } |
968 | 968 |
969 size_t namedGridLineIndex; | 969 size_t namedGridLineIndex; |
970 if (position.isPositive()) | 970 if (position.isPositive()) |
971 namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->va
lue.size()) - 1; | 971 namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->va
lue.size()) - 1; |
972 else | 972 else |
973 namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integ
erPosition()), 0); | 973 namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integ
erPosition()), 0); |
974 return GridPosition::adjustGridPositionForSide(it->value[namedGridLineIndex]
, side); | 974 return GridResolvedPosition::adjustGridPositionForSide(it->value[namedGridLi
neIndex], side); |
975 } | 975 } |
976 | 976 |
977 size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, Gr
idPositionSide side) const | 977 GridResolvedPosition RenderGrid::resolveGridPositionFromStyle(const GridPosition
& position, GridPositionSide side) const |
978 { | 978 { |
979 switch (position.type()) { | 979 switch (position.type()) { |
980 case ExplicitPosition: { | 980 case ExplicitPosition: { |
981 ASSERT(position.integerPosition()); | 981 ASSERT(position.integerPosition()); |
982 | 982 |
983 if (!position.namedGridLine().isNull()) | 983 if (!position.namedGridLine().isNull()) |
984 return resolveNamedGridLinePositionFromStyle(position, side); | 984 return resolveNamedGridLinePositionFromStyle(position, side); |
985 | 985 |
986 // Handle <integer> explicit position. | 986 // Handle <integer> explicit position. |
987 if (position.isPositive()) | 987 if (position.isPositive()) |
988 return GridPosition::adjustGridPositionForSide(position.integerPosit
ion() - 1, side); | 988 return GridResolvedPosition::adjustGridPositionForSide(position.inte
gerPosition() - 1, side); |
989 | 989 |
990 size_t resolvedPosition = abs(position.integerPosition()) - 1; | 990 size_t resolvedPosition = abs(position.integerPosition()) - 1; |
991 const size_t endOfTrack = explicitGridSizeForSide(side); | 991 const size_t endOfTrack = explicitGridSizeForSide(side); |
992 | 992 |
993 // Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html,
we clamp negative value to the first line. | 993 // Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html,
we clamp negative value to the first line. |
994 if (endOfTrack < resolvedPosition) | 994 if (endOfTrack < resolvedPosition) |
995 return 0; | 995 return GridResolvedPosition(); |
996 | 996 |
997 return GridPosition::adjustGridPositionForSide(endOfTrack - resolvedPosi
tion, side); | 997 return GridResolvedPosition::adjustGridPositionForSide(endOfTrack - reso
lvedPosition, side); |
998 } | 998 } |
999 case NamedGridAreaPosition: | 999 case NamedGridAreaPosition: |
1000 { | 1000 { |
1001 NamedGridAreaMap::const_iterator it = style()->namedGridArea().find(posi
tion.namedGridLine()); | 1001 NamedGridAreaMap::const_iterator it = style()->namedGridArea().find(posi
tion.namedGridLine()); |
1002 // Unknown grid area should have been computed to 'auto' by now. | 1002 // Unknown grid area should have been computed to 'auto' by now. |
1003 ASSERT_WITH_SECURITY_IMPLICATION(it != style()->namedGridArea().end()); | 1003 ASSERT_WITH_SECURITY_IMPLICATION(it != style()->namedGridArea().end()); |
1004 const GridCoordinate& gridAreaCoordinate = it->value; | 1004 const GridCoordinate& gridAreaCoordinate = it->value; |
1005 switch (side) { | 1005 switch (side) { |
1006 case ColumnStartSide: | 1006 case ColumnStartSide: |
1007 return gridAreaCoordinate.columns.initialPositionIndex; | 1007 return GridResolvedPosition(gridAreaCoordinate.columns.initialPositi
onIndex); |
1008 case ColumnEndSide: | 1008 case ColumnEndSide: |
1009 return gridAreaCoordinate.columns.finalPositionIndex; | 1009 return GridResolvedPosition(gridAreaCoordinate.columns.finalPosition
Index); |
1010 case RowStartSide: | 1010 case RowStartSide: |
1011 return gridAreaCoordinate.rows.initialPositionIndex; | 1011 return GridResolvedPosition(gridAreaCoordinate.rows.initialPositionI
ndex); |
1012 case RowEndSide: | 1012 case RowEndSide: |
1013 return gridAreaCoordinate.rows.finalPositionIndex; | 1013 return GridResolvedPosition(gridAreaCoordinate.rows.finalPositionInd
ex); |
1014 } | 1014 } |
1015 ASSERT_NOT_REACHED(); | 1015 ASSERT_NOT_REACHED(); |
1016 return 0; | 1016 return GridResolvedPosition(); |
1017 } | 1017 } |
1018 case AutoPosition: | 1018 case AutoPosition: |
1019 case SpanPosition: | 1019 case SpanPosition: |
1020 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). | 1020 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). |
1021 ASSERT_NOT_REACHED(); | 1021 ASSERT_NOT_REACHED(); |
1022 return 0; | 1022 return GridResolvedPosition(); |
1023 } | 1023 } |
1024 ASSERT_NOT_REACHED(); | 1024 ASSERT_NOT_REACHED(); |
1025 return 0; | 1025 return GridResolvedPosition(); |
1026 } | 1026 } |
1027 | 1027 |
1028 PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(size
_t resolvedOppositePosition, const GridPosition& position, GridPositionSide side
) const | 1028 PassOwnPtr<GridSpan> RenderGrid::resolveGridPositionAgainstOppositePosition(cons
t GridResolvedPosition& resolvedOppositePosition, const GridPosition& position,
GridPositionSide side) const |
1029 { | 1029 { |
1030 if (position.isAuto()) | 1030 if (position.isAuto()) |
1031 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi
on); | 1031 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi
on); |
1032 | 1032 |
1033 ASSERT(position.isSpan()); | 1033 ASSERT(position.isSpan()); |
1034 ASSERT(position.spanPosition() > 0); | 1034 ASSERT(position.spanPosition() > 0); |
1035 | 1035 |
1036 if (!position.namedGridLine().isNull()) { | 1036 if (!position.namedGridLine().isNull()) { |
1037 // span 2 'c' -> we need to find the appropriate grid line before / afte
r our opposite position. | 1037 // span 2 'c' -> we need to find the appropriate grid line before / afte
r our opposite position. |
1038 return resolveNamedGridLinePositionAgainstOppositePosition(resolvedOppos
itePosition, position, side); | 1038 return resolveNamedGridLinePositionAgainstOppositePosition(resolvedOppos
itePosition, position, side); |
1039 } | 1039 } |
1040 | 1040 |
1041 return GridSpan::createWithSpanAgainstOpposite(resolvedOppositePosition, pos
ition, side); | 1041 return GridSpan::createWithSpanAgainstOpposite(resolvedOppositePosition, pos
ition, side); |
1042 } | 1042 } |
1043 | 1043 |
1044 PassOwnPtr<GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosi
tion(size_t resolvedOppositePosition, const GridPosition& position, GridPosition
Side side) const | 1044 PassOwnPtr<GridSpan> RenderGrid::resolveNamedGridLinePositionAgainstOppositePosi
tion(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& p
osition, GridPositionSide side) const |
1045 { | 1045 { |
1046 ASSERT(position.isSpan()); | 1046 ASSERT(position.isSpan()); |
1047 ASSERT(!position.namedGridLine().isNull()); | 1047 ASSERT(!position.namedGridLine().isNull()); |
1048 // Negative positions are not allowed per the specification and should have
been handled during parsing. | 1048 // Negative positions are not allowed per the specification and should have
been handled during parsing. |
1049 ASSERT(position.spanPosition() > 0); | 1049 ASSERT(position.spanPosition() > 0); |
1050 | 1050 |
1051 const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side =
= ColumnEndSide) ? style()->namedGridColumnLines() : style()->namedGridRowLines(
); | 1051 const NamedGridLinesMap& gridLinesNames = (side == ColumnStartSide || side =
= ColumnEndSide) ? style()->namedGridColumnLines() : style()->namedGridRowLines(
); |
1052 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); | 1052 NamedGridLinesMap::const_iterator it = gridLinesNames.find(position.namedGri
dLine()); |
1053 | 1053 |
1054 // If there is no named grid line of that name, we resolve the position to '
auto' (which is equivalent to 'span 1' in this case). | 1054 // If there is no named grid line of that name, we resolve the position to '
auto' (which is equivalent to 'span 1' in this case). |
1055 // See http://lists.w3.org/Archives/Public/www-style/2013Jun/0394.html. | 1055 // See http://lists.w3.org/Archives/Public/www-style/2013Jun/0394.html. |
1056 if (it == gridLinesNames.end()) | 1056 if (it == gridLinesNames.end()) |
1057 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi
on); | 1057 return GridSpan::create(resolvedOppositePosition, resolvedOppositePositi
on); |
1058 | 1058 |
1059 return GridSpan::createWithNamedSpanAgainstOpposite(resolvedOppositePosition
, position, side, it->value); | 1059 return GridSpan::createWithNamedSpanAgainstOpposite(resolvedOppositePosition
, position, side, it->value); |
1060 } | 1060 } |
1061 | 1061 |
1062 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const | 1062 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, GridTrack
SizingDirection direction, const Vector<GridTrack>& tracks) const |
1063 { | 1063 { |
1064 const GridCoordinate& coordinate = cachedGridCoordinate(child); | 1064 const GridCoordinate& coordinate = cachedGridCoordinate(child); |
1065 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; | 1065 const GridSpan& span = (direction == ForColumns) ? coordinate.columns : coor
dinate.rows; |
1066 LayoutUnit gridAreaBreadth = 0; | 1066 LayoutUnit gridAreaBreadth = 0; |
1067 for (size_t trackIndex = span.initialPositionIndex; trackIndex <= span.final
PositionIndex; ++trackIndex) | 1067 for (size_t trackIndex = span.initialPositionIndex; trackIndex <= span.final
PositionIndex.integerPosition(); ++trackIndex) |
1068 gridAreaBreadth += tracks[trackIndex].m_usedBreadth; | 1068 gridAreaBreadth += tracks[trackIndex].m_usedBreadth; |
1069 return gridAreaBreadth; | 1069 return gridAreaBreadth; |
1070 } | 1070 } |
1071 | 1071 |
1072 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) | 1072 void RenderGrid::populateGridPositions(const GridSizingData& sizingData) |
1073 { | 1073 { |
1074 m_columnPositions.resize(sizingData.columnTracks.size() + 1); | 1074 m_columnPositions.resize(sizingData.columnTracks.size() + 1); |
1075 m_columnPositions[0] = borderAndPaddingStart(); | 1075 m_columnPositions[0] = borderAndPaddingStart(); |
1076 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) | 1076 for (size_t i = 0; i < m_columnPositions.size() - 1; ++i) |
1077 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack
s[i].m_usedBreadth; | 1077 m_columnPositions[i + 1] = m_columnPositions[i] + sizingData.columnTrack
s[i].m_usedBreadth; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 LayoutRect localRepaintRect = paintInfo.rect; | 1123 LayoutRect localRepaintRect = paintInfo.rect; |
1124 localRepaintRect.moveBy(-paintOffset); | 1124 localRepaintRect.moveBy(-paintOffset); |
1125 | 1125 |
1126 GridSpan dirtiedColumns = dirtiedGridAreas(m_columnPositions, localRepaintRe
ct.x(), localRepaintRect.maxX()); | 1126 GridSpan dirtiedColumns = dirtiedGridAreas(m_columnPositions, localRepaintRe
ct.x(), localRepaintRect.maxX()); |
1127 GridSpan dirtiedRows = dirtiedGridAreas(m_rowPositions, localRepaintRect.y()
, localRepaintRect.maxY()); | 1127 GridSpan dirtiedRows = dirtiedGridAreas(m_rowPositions, localRepaintRect.y()
, localRepaintRect.maxY()); |
1128 | 1128 |
1129 OrderIterator paintIterator(this); | 1129 OrderIterator paintIterator(this); |
1130 { | 1130 { |
1131 OrderIteratorPopulator populator(paintIterator); | 1131 OrderIteratorPopulator populator(paintIterator); |
1132 | 1132 |
1133 for (size_t row = dirtiedRows.initialPositionIndex; row < dirtiedRows.fi
nalPositionIndex; ++row) { | 1133 for (size_t row = dirtiedRows.initialPositionIndex; row < dirtiedRows.fi
nalPositionIndex.integerPosition(); ++row) { |
1134 for (size_t column = dirtiedColumns.initialPositionIndex; column < d
irtiedColumns.finalPositionIndex; ++column) { | 1134 for (size_t column = dirtiedColumns.initialPositionIndex; column < d
irtiedColumns.finalPositionIndex.integerPosition(); ++column) { |
1135 const Vector<RenderBox*, 1>& children = m_grid[row][column]; | 1135 const Vector<RenderBox*, 1>& children = m_grid[row][column]; |
1136 // FIXME: If we start adding spanning children in all grid areas
they span, this | 1136 // FIXME: If we start adding spanning children in all grid areas
they span, this |
1137 // would make us paint them several times, which is wrong! | 1137 // would make us paint them several times, which is wrong! |
1138 for (size_t j = 0; j < children.size(); ++j) | 1138 for (size_t j = 0; j < children.size(); ++j) |
1139 populator.storeChild(children[j]); | 1139 populator.storeChild(children[j]); |
1140 } | 1140 } |
1141 } | 1141 } |
1142 } | 1142 } |
1143 | 1143 |
1144 for (RenderBox* child = paintIterator.first(); child; child = paintIterator.
next()) | 1144 for (RenderBox* child = paintIterator.first(); child; child = paintIterator.
next()) |
1145 paintChild(child, paintInfo, paintOffset); | 1145 paintChild(child, paintInfo, paintOffset); |
1146 } | 1146 } |
1147 | 1147 |
1148 const char* RenderGrid::renderName() const | 1148 const char* RenderGrid::renderName() const |
1149 { | 1149 { |
1150 if (isFloating()) | 1150 if (isFloating()) |
1151 return "RenderGrid (floating)"; | 1151 return "RenderGrid (floating)"; |
1152 if (isOutOfFlowPositioned()) | 1152 if (isOutOfFlowPositioned()) |
1153 return "RenderGrid (positioned)"; | 1153 return "RenderGrid (positioned)"; |
1154 if (isAnonymous()) | 1154 if (isAnonymous()) |
1155 return "RenderGrid (generated)"; | 1155 return "RenderGrid (generated)"; |
1156 if (isRelPositioned()) | 1156 if (isRelPositioned()) |
1157 return "RenderGrid (relative positioned)"; | 1157 return "RenderGrid (relative positioned)"; |
1158 return "RenderGrid"; | 1158 return "RenderGrid"; |
1159 } | 1159 } |
1160 | 1160 |
1161 } // namespace WebCore | 1161 } // namespace WebCore |
OLD | NEW |