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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 size_t namedGridLineIndex; | 968 size_t namedGridLineIndex; |
969 if (position.isPositive()) | 969 if (position.isPositive()) |
970 namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->va
lue.size()) - 1; | 970 namedGridLineIndex = std::min<size_t>(position.integerPosition(), it->va
lue.size()) - 1; |
971 else | 971 else |
972 namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integ
erPosition()), 0); | 972 namedGridLineIndex = std::max<int>(it->value.size() - abs(position.integ
erPosition()), 0); |
973 return adjustGridPositionForSide(it->value[namedGridLineIndex], side); | 973 return adjustGridPositionForSide(it->value[namedGridLineIndex], side); |
974 } | 974 } |
975 | 975 |
976 size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, Gr
idPositionSide side) const | 976 size_t RenderGrid::resolveGridPositionFromStyle(const GridPosition& position, Gr
idPositionSide side) const |
977 { | 977 { |
978 // FIXME: Handle other values for grid-{row,column} like ranges or line name
s. | |
979 switch (position.type()) { | 978 switch (position.type()) { |
980 case ExplicitPosition: { | 979 case ExplicitPosition: { |
981 ASSERT(position.integerPosition()); | 980 ASSERT(position.integerPosition()); |
982 | 981 |
983 if (!position.namedGridLine().isNull()) | 982 if (!position.namedGridLine().isNull()) |
984 return resolveNamedGridLinePositionFromStyle(position, side); | 983 return resolveNamedGridLinePositionFromStyle(position, side); |
985 | 984 |
986 // Handle <integer> explicit position. | 985 // Handle <integer> explicit position. |
987 if (position.isPositive()) | 986 if (position.isPositive()) |
988 return adjustGridPositionForSide(position.integerPosition() - 1, sid
e); | 987 return adjustGridPositionForSide(position.integerPosition() - 1, sid
e); |
989 | 988 |
990 size_t resolvedPosition = abs(position.integerPosition()) - 1; | 989 size_t resolvedPosition = abs(position.integerPosition()) - 1; |
991 const size_t endOfTrack = explicitGridSizeForSide(side); | 990 const size_t endOfTrack = explicitGridSizeForSide(side); |
992 | 991 |
993 // Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html,
we clamp negative value to the first line. | 992 // Per http://lists.w3.org/Archives/Public/www-style/2013Mar/0589.html,
we clamp negative value to the first line. |
994 if (endOfTrack < resolvedPosition) | 993 if (endOfTrack < resolvedPosition) |
995 return 0; | 994 return 0; |
996 | 995 |
997 return adjustGridPositionForSide(endOfTrack - resolvedPosition, side); | 996 return adjustGridPositionForSide(endOfTrack - resolvedPosition, side); |
998 } | 997 } |
999 case NamedGridAreaPosition: | 998 case NamedGridAreaPosition: |
1000 // FIXME: Support resolving named grid area (crbug.com/258092). | 999 { |
| 1000 NamedGridAreaMap::const_iterator it = style()->namedGridArea().find(posi
tion.namedGridLine()); |
| 1001 // Unknown grid area should have been computed to 'auto' by now. |
| 1002 ASSERT(it != style()->namedGridArea().end()); |
| 1003 const GridCoordinate& gridAreaCoordinate = it->value; |
| 1004 switch (side) { |
| 1005 case ColumnStartSide: |
| 1006 return gridAreaCoordinate.columns.initialPositionIndex; |
| 1007 case ColumnEndSide: |
| 1008 return gridAreaCoordinate.columns.finalPositionIndex; |
| 1009 case RowStartSide: |
| 1010 return gridAreaCoordinate.rows.initialPositionIndex; |
| 1011 case RowEndSide: |
| 1012 return gridAreaCoordinate.rows.finalPositionIndex; |
| 1013 } |
| 1014 ASSERT_NOT_REACHED(); |
1001 return 0; | 1015 return 0; |
| 1016 } |
1002 case AutoPosition: | 1017 case AutoPosition: |
1003 case SpanPosition: | 1018 case SpanPosition: |
1004 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). | 1019 // 'auto' and span depend on the opposite position for resolution (e.g.
grid-row: auto / 1 or grid-column: span 3 / "myHeader"). |
1005 ASSERT_NOT_REACHED(); | 1020 ASSERT_NOT_REACHED(); |
1006 return 0; | 1021 return 0; |
1007 } | 1022 } |
1008 ASSERT_NOT_REACHED(); | 1023 ASSERT_NOT_REACHED(); |
1009 return 0; | 1024 return 0; |
1010 } | 1025 } |
1011 | 1026 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 if (isOutOfFlowPositioned()) | 1136 if (isOutOfFlowPositioned()) |
1122 return "RenderGrid (positioned)"; | 1137 return "RenderGrid (positioned)"; |
1123 if (isAnonymous()) | 1138 if (isAnonymous()) |
1124 return "RenderGrid (generated)"; | 1139 return "RenderGrid (generated)"; |
1125 if (isRelPositioned()) | 1140 if (isRelPositioned()) |
1126 return "RenderGrid (relative positioned)"; | 1141 return "RenderGrid (relative positioned)"; |
1127 return "RenderGrid"; | 1142 return "RenderGrid"; |
1128 } | 1143 } |
1129 | 1144 |
1130 } // namespace WebCore | 1145 } // namespace WebCore |
OLD | NEW |