OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 // The slow path does not make any use of the overflowing ce
lls info, don't hold on to the memory. | 1058 // The slow path does not make any use of the overflowing ce
lls info, don't hold on to the memory. |
1059 m_overflowingCells.clear(); | 1059 m_overflowingCells.clear(); |
1060 } | 1060 } |
1061 } | 1061 } |
1062 } | 1062 } |
1063 } | 1063 } |
1064 | 1064 |
1065 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); | 1065 ASSERT(hasOverflowingCell == this->hasOverflowingCell()); |
1066 } | 1066 } |
1067 | 1067 |
1068 int RenderTableSection::calcOuterBorderBefore() const | 1068 int RenderTableSection::calcBlockDirectionOuterBorder(BlockBorderSide side) cons
t |
1069 { | 1069 { |
1070 unsigned totalCols = table()->numEffCols(); | 1070 unsigned totalCols = table()->numEffCols(); |
1071 if (!m_grid.size() || !totalCols) | 1071 if (!m_grid.size() || !totalCols) |
1072 return 0; | 1072 return 0; |
1073 | 1073 |
1074 unsigned borderWidth = 0; | 1074 unsigned borderWidth = 0; |
1075 | 1075 |
1076 const BorderValue& sb = style()->borderBefore(); | 1076 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty
le()->borderAfter(); |
1077 if (sb.style() == BHIDDEN) | 1077 if (sb.style() == BHIDDEN) |
1078 return -1; | 1078 return -1; |
1079 if (sb.style() > BHIDDEN) | 1079 if (sb.style() > BHIDDEN) |
1080 borderWidth = sb.width(); | 1080 borderWidth = sb.width(); |
1081 | 1081 |
1082 const BorderValue& rb = firstChild()->style()->borderBefore(); | 1082 const BorderValue& rb = side == BorderBefore ? firstChild()->style()->border
Before() : lastChild()->style()->borderAfter(); |
1083 if (rb.style() == BHIDDEN) | 1083 if (rb.style() == BHIDDEN) |
1084 return -1; | 1084 return -1; |
1085 if (rb.style() > BHIDDEN && rb.width() > borderWidth) | 1085 if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
1086 borderWidth = rb.width(); | 1086 borderWidth = rb.width(); |
1087 | 1087 |
1088 bool allHidden = true; | 1088 bool allHidden = true; |
1089 for (unsigned c = 0; c < totalCols; c++) { | 1089 for (unsigned c = 0; c < totalCols; c++) { |
1090 const CellStruct& current = cellAt(0, c); | 1090 const CellStruct& current = cellAt(side == BorderBefore ? 0 : m_grid.siz
e() - 1, c); |
1091 if (current.inColSpan || !current.hasCells()) | 1091 if (current.inColSpan || !current.hasCells()) |
1092 continue; | 1092 continue; |
1093 const BorderValue& cb = current.primaryCell()->style()->borderBefore();
// FIXME: Make this work with perpendicular and flipped cells. | 1093 const RenderStyle* primaryCellStyle = current.primaryCell()->style(); |
| 1094 const BorderValue& cb = side == BorderBefore ? primaryCellStyle->borderB
efore() : primaryCellStyle->borderAfter(); // FIXME: Make this work with perpend
icular and flipped cells. |
1094 // FIXME: Don't repeat for the same col group | 1095 // FIXME: Don't repeat for the same col group |
1095 RenderTableCol* colGroup = table()->colElement(c); | 1096 RenderTableCol* colGroup = table()->colElement(c); |
1096 if (colGroup) { | 1097 if (colGroup) { |
1097 const BorderValue& gb = colGroup->style()->borderBefore(); | 1098 const BorderValue& gb = side == BorderBefore ? colGroup->style()->bo
rderBefore() : colGroup->style()->borderAfter(); |
1098 if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) | 1099 if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) |
1099 continue; | 1100 continue; |
1100 allHidden = false; | 1101 allHidden = false; |
1101 if (gb.style() > BHIDDEN && gb.width() > borderWidth) | 1102 if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
1102 borderWidth = gb.width(); | 1103 borderWidth = gb.width(); |
1103 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | 1104 if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
1104 borderWidth = cb.width(); | 1105 borderWidth = cb.width(); |
1105 } else { | 1106 } else { |
1106 if (cb.style() == BHIDDEN) | 1107 if (cb.style() == BHIDDEN) |
1107 continue; | 1108 continue; |
1108 allHidden = false; | 1109 allHidden = false; |
1109 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | 1110 if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
1110 borderWidth = cb.width(); | 1111 borderWidth = cb.width(); |
1111 } | 1112 } |
1112 } | 1113 } |
1113 if (allHidden) | 1114 if (allHidden) |
1114 return -1; | 1115 return -1; |
1115 | 1116 |
| 1117 if (side == BorderAfter) |
| 1118 borderWidth++; // Distribute rounding error |
1116 return borderWidth / 2; | 1119 return borderWidth / 2; |
1117 } | 1120 } |
1118 | 1121 |
1119 int RenderTableSection::calcOuterBorderAfter() const | 1122 int RenderTableSection::calcInlineDirectionOuterBorder(InlineBorderSide side) co
nst |
1120 { | 1123 { |
1121 unsigned totalCols = table()->numEffCols(); | 1124 unsigned totalCols = table()->numEffCols(); |
1122 if (!m_grid.size() || !totalCols) | 1125 if (!m_grid.size() || !totalCols) |
1123 return 0; | 1126 return 0; |
| 1127 unsigned colIndex = side == BorderStart ? 0 : totalCols - 1; |
1124 | 1128 |
1125 unsigned borderWidth = 0; | 1129 unsigned borderWidth = 0; |
1126 | 1130 |
1127 const BorderValue& sb = style()->borderAfter(); | 1131 const BorderValue& sb = side == BorderStart ? style()->borderStart() : style
()->borderEnd(); |
1128 if (sb.style() == BHIDDEN) | 1132 if (sb.style() == BHIDDEN) |
1129 return -1; | 1133 return -1; |
1130 if (sb.style() > BHIDDEN) | 1134 if (sb.style() > BHIDDEN) |
1131 borderWidth = sb.width(); | 1135 borderWidth = sb.width(); |
1132 | 1136 |
1133 const BorderValue& rb = lastChild()->style()->borderAfter(); | 1137 if (RenderTableCol* colGroup = table()->colElement(colIndex)) { |
1134 if (rb.style() == BHIDDEN) | 1138 const BorderValue& gb = side == BorderStart ? colGroup->style()->borderS
tart() : colGroup->style()->borderEnd(); |
1135 return -1; | |
1136 if (rb.style() > BHIDDEN && rb.width() > borderWidth) | |
1137 borderWidth = rb.width(); | |
1138 | |
1139 bool allHidden = true; | |
1140 for (unsigned c = 0; c < totalCols; c++) { | |
1141 const CellStruct& current = cellAt(m_grid.size() - 1, c); | |
1142 if (current.inColSpan || !current.hasCells()) | |
1143 continue; | |
1144 const BorderValue& cb = current.primaryCell()->style()->borderAfter(); /
/ FIXME: Make this work with perpendicular and flipped cells. | |
1145 // FIXME: Don't repeat for the same col group | |
1146 RenderTableCol* colGroup = table()->colElement(c); | |
1147 if (colGroup) { | |
1148 const BorderValue& gb = colGroup->style()->borderAfter(); | |
1149 if (gb.style() == BHIDDEN || cb.style() == BHIDDEN) | |
1150 continue; | |
1151 allHidden = false; | |
1152 if (gb.style() > BHIDDEN && gb.width() > borderWidth) | |
1153 borderWidth = gb.width(); | |
1154 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | |
1155 borderWidth = cb.width(); | |
1156 } else { | |
1157 if (cb.style() == BHIDDEN) | |
1158 continue; | |
1159 allHidden = false; | |
1160 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | |
1161 borderWidth = cb.width(); | |
1162 } | |
1163 } | |
1164 if (allHidden) | |
1165 return -1; | |
1166 | |
1167 return (borderWidth + 1) / 2; | |
1168 } | |
1169 | |
1170 int RenderTableSection::calcOuterBorderStart() const | |
1171 { | |
1172 unsigned totalCols = table()->numEffCols(); | |
1173 if (!m_grid.size() || !totalCols) | |
1174 return 0; | |
1175 | |
1176 unsigned borderWidth = 0; | |
1177 | |
1178 const BorderValue& sb = style()->borderStart(); | |
1179 if (sb.style() == BHIDDEN) | |
1180 return -1; | |
1181 if (sb.style() > BHIDDEN) | |
1182 borderWidth = sb.width(); | |
1183 | |
1184 if (RenderTableCol* colGroup = table()->colElement(0)) { | |
1185 const BorderValue& gb = colGroup->style()->borderStart(); | |
1186 if (gb.style() == BHIDDEN) | 1139 if (gb.style() == BHIDDEN) |
1187 return -1; | 1140 return -1; |
1188 if (gb.style() > BHIDDEN && gb.width() > borderWidth) | 1141 if (gb.style() > BHIDDEN && gb.width() > borderWidth) |
1189 borderWidth = gb.width(); | |
1190 } | |
1191 | |
1192 bool allHidden = true; | |
1193 for (unsigned r = 0; r < m_grid.size(); r++) { | |
1194 const CellStruct& current = cellAt(r, 0); | |
1195 if (!current.hasCells()) | |
1196 continue; | |
1197 // FIXME: Don't repeat for the same cell | |
1198 const BorderValue& cb = current.primaryCell()->style()->borderStart(); /
/ FIXME: Make this work with perpendicular and flipped cells. | |
1199 const BorderValue& rb = current.primaryCell()->parent()->style()->border
Start(); | |
1200 if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) | |
1201 continue; | |
1202 allHidden = false; | |
1203 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | |
1204 borderWidth = cb.width(); | |
1205 if (rb.style() > BHIDDEN && rb.width() > borderWidth) | |
1206 borderWidth = rb.width(); | |
1207 } | |
1208 if (allHidden) | |
1209 return -1; | |
1210 | |
1211 return (borderWidth + (table()->style()->isLeftToRightDirection() ? 0 : 1))
/ 2; | |
1212 } | |
1213 | |
1214 int RenderTableSection::calcOuterBorderEnd() const | |
1215 { | |
1216 unsigned totalCols = table()->numEffCols(); | |
1217 if (!m_grid.size() || !totalCols) | |
1218 return 0; | |
1219 | |
1220 unsigned borderWidth = 0; | |
1221 | |
1222 const BorderValue& sb = style()->borderEnd(); | |
1223 if (sb.style() == BHIDDEN) | |
1224 return -1; | |
1225 if (sb.style() > BHIDDEN) | |
1226 borderWidth = sb.width(); | |
1227 | |
1228 if (RenderTableCol* colGroup = table()->colElement(totalCols - 1)) { | |
1229 const BorderValue& gb = colGroup->style()->borderEnd(); | |
1230 if (gb.style() == BHIDDEN) | |
1231 return -1; | |
1232 if (gb.style() > BHIDDEN && gb.width() > borderWidth) | |
1233 borderWidth = gb.width(); | 1142 borderWidth = gb.width(); |
1234 } | 1143 } |
1235 | 1144 |
1236 bool allHidden = true; | 1145 bool allHidden = true; |
1237 for (unsigned r = 0; r < m_grid.size(); r++) { | 1146 for (unsigned r = 0; r < m_grid.size(); r++) { |
1238 const CellStruct& current = cellAt(r, totalCols - 1); | 1147 const CellStruct& current = cellAt(r, colIndex); |
1239 if (!current.hasCells()) | 1148 if (!current.hasCells()) |
1240 continue; | 1149 continue; |
1241 // FIXME: Don't repeat for the same cell | 1150 // FIXME: Don't repeat for the same cell |
1242 const BorderValue& cb = current.primaryCell()->style()->borderEnd(); //
FIXME: Make this work with perpendicular and flipped cells. | 1151 const RenderStyle* primaryCellStyle = current.primaryCell()->style(); |
1243 const BorderValue& rb = current.primaryCell()->parent()->style()->border
End(); | 1152 const RenderStyle* primaryCellParentStyle = current.primaryCell()->paren
t()->style(); |
| 1153 const BorderValue& cb = side == BorderStart ? primaryCellStyle->borderSt
art() : primaryCellStyle->borderEnd(); // FIXME: Make this work with perpendicul
ar and flipped cells. |
| 1154 const BorderValue& rb = side == BorderStart ? primaryCellParentStyle->bo
rderStart() : primaryCellParentStyle->borderEnd(); |
1244 if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) | 1155 if (cb.style() == BHIDDEN || rb.style() == BHIDDEN) |
1245 continue; | 1156 continue; |
1246 allHidden = false; | 1157 allHidden = false; |
1247 if (cb.style() > BHIDDEN && cb.width() > borderWidth) | 1158 if (cb.style() > BHIDDEN && cb.width() > borderWidth) |
1248 borderWidth = cb.width(); | 1159 borderWidth = cb.width(); |
1249 if (rb.style() > BHIDDEN && rb.width() > borderWidth) | 1160 if (rb.style() > BHIDDEN && rb.width() > borderWidth) |
1250 borderWidth = rb.width(); | 1161 borderWidth = rb.width(); |
1251 } | 1162 } |
1252 if (allHidden) | 1163 if (allHidden) |
1253 return -1; | 1164 return -1; |
1254 | 1165 |
1255 return (borderWidth + (table()->style()->isLeftToRightDirection() ? 1 : 0))
/ 2; | 1166 if ((side == BorderStart) != table()->style()->isLeftToRightDirection()) |
| 1167 borderWidth++; // Distribute rounding error |
| 1168 return borderWidth / 2; |
1256 } | 1169 } |
1257 | 1170 |
1258 void RenderTableSection::recalcOuterBorder() | 1171 void RenderTableSection::recalcOuterBorder() |
1259 { | 1172 { |
1260 m_outerBorderBefore = calcOuterBorderBefore(); | 1173 m_outerBorderBefore = calcBlockDirectionOuterBorder(BorderBefore); |
1261 m_outerBorderAfter = calcOuterBorderAfter(); | 1174 m_outerBorderAfter = calcBlockDirectionOuterBorder(BorderAfter); |
1262 m_outerBorderStart = calcOuterBorderStart(); | 1175 m_outerBorderStart = calcInlineDirectionOuterBorder(BorderStart); |
1263 m_outerBorderEnd = calcOuterBorderEnd(); | 1176 m_outerBorderEnd = calcInlineDirectionOuterBorder(BorderEnd); |
1264 } | 1177 } |
1265 | 1178 |
1266 int RenderTableSection::firstLineBoxBaseline() const | 1179 int RenderTableSection::firstLineBoxBaseline() const |
1267 { | 1180 { |
1268 if (!m_grid.size()) | 1181 if (!m_grid.size()) |
1269 return -1; | 1182 return -1; |
1270 | 1183 |
1271 int firstLineBaseline = m_grid[0].baseline; | 1184 int firstLineBaseline = m_grid[0].baseline; |
1272 if (firstLineBaseline) | 1185 if (firstLineBaseline) |
1273 return firstLineBaseline + m_rowPos[0]; | 1186 return firstLineBaseline + m_rowPos[0]; |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 if (!style()->isLeftToRightDirection()) | 1727 if (!style()->isLeftToRightDirection()) |
1815 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta
ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] +
horizontalBorderSpacing); | 1728 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta
ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] +
horizontalBorderSpacing); |
1816 else | 1729 else |
1817 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont
alBorderSpacing); | 1730 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont
alBorderSpacing); |
1818 | 1731 |
1819 cell->setLogicalLocation(cellLocation); | 1732 cell->setLogicalLocation(cellLocation); |
1820 view()->addLayoutDelta(oldCellLocation - cell->location()); | 1733 view()->addLayoutDelta(oldCellLocation - cell->location()); |
1821 } | 1734 } |
1822 | 1735 |
1823 } // namespace WebCore | 1736 } // namespace WebCore |
OLD | NEW |