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 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 if (side == RowStartSide || side == ColumnStartSide) | 1069 if (side == RowStartSide || side == ColumnStartSide) |
1070 return resolveBeforeStartNamedGridLinePositionAgainstOppositePosition(re
solvedOppositePosition, position, it->value); | 1070 return resolveBeforeStartNamedGridLinePositionAgainstOppositePosition(re
solvedOppositePosition, position, it->value); |
1071 | 1071 |
1072 return resolveAfterEndNamedGridLinePositionAgainstOppositePosition(resolvedO
ppositePosition, position, it->value); | 1072 return resolveAfterEndNamedGridLinePositionAgainstOppositePosition(resolvedO
ppositePosition, position, it->value); |
1073 } | 1073 } |
1074 | 1074 |
1075 PassOwnPtr<GridSpan> RenderGrid::resolveBeforeStartNamedGridLinePositionAgainstO
ppositePosition(size_t resolvedOppositePosition, const GridPosition& position, c
onst Vector<size_t>& gridLines) const | 1075 PassOwnPtr<GridSpan> RenderGrid::resolveBeforeStartNamedGridLinePositionAgainstO
ppositePosition(size_t resolvedOppositePosition, const GridPosition& position, c
onst Vector<size_t>& gridLines) const |
1076 { | 1076 { |
1077 // The grid line inequality needs to be strict (which doesn't match the afte
r / end case) because |resolvedOppositePosition| | 1077 // The grid line inequality needs to be strict (which doesn't match the afte
r / end case) because |resolvedOppositePosition| |
1078 // is already converted to an index in our grid representation (ie one was r
emoved from the grid line to account for the side). | 1078 // is already converted to an index in our grid representation (ie one was r
emoved from the grid line to account for the side). |
1079 // FIXME: This could be a binary search as |gridLines| is ordered. | 1079 size_t firstLineBeforeOppositePositionIndex = 0; |
1080 int firstLineBeforeOppositePositionIndex = gridLines.size() - 1; | 1080 const size_t* firstLineBeforeOppositePosition = std::lower_bound(gridLines.b
egin(), gridLines.end(), resolvedOppositePosition); |
1081 for (; firstLineBeforeOppositePositionIndex >= 0 && gridLines[firstLineBefor
eOppositePositionIndex] > resolvedOppositePosition; --firstLineBeforeOppositePos
itionIndex) { } | 1081 if (firstLineBeforeOppositePosition != gridLines.end()) |
| 1082 firstLineBeforeOppositePositionIndex = firstLineBeforeOppositePosition -
gridLines.begin(); |
1082 | 1083 |
1083 size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex
- position.spanPosition() + 1); | 1084 size_t gridLineIndex = std::max<int>(0, firstLineBeforeOppositePositionIndex
- position.spanPosition() + 1); |
1084 size_t resolvedGridLinePosition = gridLines[gridLineIndex]; | 1085 size_t resolvedGridLinePosition = gridLines[gridLineIndex]; |
1085 if (resolvedGridLinePosition > resolvedOppositePosition) | 1086 if (resolvedGridLinePosition > resolvedOppositePosition) |
1086 resolvedGridLinePosition = resolvedOppositePosition; | 1087 resolvedGridLinePosition = resolvedOppositePosition; |
1087 return GridSpan::create(resolvedGridLinePosition, resolvedOppositePosition); | 1088 return GridSpan::create(resolvedGridLinePosition, resolvedOppositePosition); |
1088 } | 1089 } |
1089 | 1090 |
1090 PassOwnPtr<GridSpan> RenderGrid::resolveAfterEndNamedGridLinePositionAgainstOppo
sitePosition(size_t resolvedOppositePosition, const GridPosition& position, cons
t Vector<size_t>& gridLines) const | 1091 PassOwnPtr<GridSpan> RenderGrid::resolveAfterEndNamedGridLinePositionAgainstOppo
sitePosition(size_t resolvedOppositePosition, const GridPosition& position, cons
t Vector<size_t>& gridLines) const |
1091 { | 1092 { |
1092 // FIXME: This could be a binary search as |gridLines| is ordered. | 1093 size_t firstLineAfterOppositePositionIndex = gridLines.size() - 1; |
1093 size_t firstLineAfterOppositePositionIndex = 0; | 1094 const size_t* firstLineAfterOppositePosition = std::upper_bound(gridLines.be
gin(), gridLines.end(), resolvedOppositePosition); |
1094 for (; firstLineAfterOppositePositionIndex < gridLines.size() && gridLines[f
irstLineAfterOppositePositionIndex] <= resolvedOppositePosition; ++firstLineAfte
rOppositePositionIndex) { } | 1095 if (firstLineAfterOppositePosition != gridLines.end()) |
| 1096 firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - g
ridLines.begin(); |
1095 | 1097 |
1096 size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOpposite
PositionIndex + position.spanPosition() - 1); | 1098 size_t gridLineIndex = std::min(gridLines.size() - 1, firstLineAfterOpposite
PositionIndex + position.spanPosition() - 1); |
1097 size_t resolvedGridLinePosition = adjustGridPositionForAfterEndSide(gridLine
s[gridLineIndex]); | 1099 size_t resolvedGridLinePosition = adjustGridPositionForAfterEndSide(gridLine
s[gridLineIndex]); |
1098 if (resolvedGridLinePosition < resolvedOppositePosition) | 1100 if (resolvedGridLinePosition < resolvedOppositePosition) |
1099 resolvedGridLinePosition = resolvedOppositePosition; | 1101 resolvedGridLinePosition = resolvedOppositePosition; |
1100 return GridSpan::create(resolvedOppositePosition, resolvedGridLinePosition); | 1102 return GridSpan::create(resolvedOppositePosition, resolvedGridLinePosition); |
1101 } | 1103 } |
1102 | 1104 |
1103 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizi
ngDirection direction, const Vector<GridTrack>& tracks) const | 1105 LayoutUnit RenderGrid::gridAreaBreadthForChild(const RenderBox* child, TrackSizi
ngDirection direction, const Vector<GridTrack>& tracks) const |
1104 { | 1106 { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 if (isOutOfFlowPositioned()) | 1195 if (isOutOfFlowPositioned()) |
1194 return "RenderGrid (positioned)"; | 1196 return "RenderGrid (positioned)"; |
1195 if (isAnonymous()) | 1197 if (isAnonymous()) |
1196 return "RenderGrid (generated)"; | 1198 return "RenderGrid (generated)"; |
1197 if (isRelPositioned()) | 1199 if (isRelPositioned()) |
1198 return "RenderGrid (relative positioned)"; | 1200 return "RenderGrid (relative positioned)"; |
1199 return "RenderGrid"; | 1201 return "RenderGrid"; |
1200 } | 1202 } |
1201 | 1203 |
1202 } // namespace WebCore | 1204 } // namespace WebCore |
OLD | NEW |