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, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
10 * | 10 * |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 LayoutTableCell::sortBorderValues(m_collapsedBorders); | 781 LayoutTableCell::sortBorderValues(m_collapsedBorders); |
782 } | 782 } |
783 | 783 |
784 void LayoutTable::addOverflowFromChildren() { | 784 void LayoutTable::addOverflowFromChildren() { |
785 // Add overflow from borders. | 785 // Add overflow from borders. |
786 // Technically it's odd that we are incorporating the borders into layout | 786 // Technically it's odd that we are incorporating the borders into layout |
787 // overflow, which is only supposed to be about overflow from our | 787 // overflow, which is only supposed to be about overflow from our |
788 // descendant objects, but since tables don't support overflow:auto, this | 788 // descendant objects, but since tables don't support overflow:auto, this |
789 // works out fine. | 789 // works out fine. |
790 if (collapseBorders()) { | 790 if (collapseBorders()) { |
791 int rightBorderOverflow = | 791 LayoutUnit rightBorderOverflow = |
792 (size().width() + outerBorderRight() - borderRight()).toInt(); | 792 size().width() + outerBorderRight() - borderRight(); |
793 int leftBorderOverflow = borderLeft() - outerBorderLeft(); | 793 LayoutUnit leftBorderOverflow = borderLeft() - outerBorderLeft(); |
794 int bottomBorderOverflow = | 794 LayoutUnit bottomBorderOverflow = |
795 (size().height() + outerBorderBottom() - borderBottom()).toInt(); | 795 size().height() + outerBorderBottom() - borderBottom(); |
796 int topBorderOverflow = borderTop() - outerBorderTop(); | 796 LayoutUnit topBorderOverflow = borderTop() - outerBorderTop(); |
797 IntRect borderOverflowRect(leftBorderOverflow, topBorderOverflow, | 797 IntRect borderOverflowRect( |
798 rightBorderOverflow - leftBorderOverflow, | 798 leftBorderOverflow.toInt(), topBorderOverflow.toInt(), |
799 bottomBorderOverflow - topBorderOverflow); | 799 (rightBorderOverflow - leftBorderOverflow).toInt(), |
| 800 (bottomBorderOverflow - topBorderOverflow).toInt()); |
800 if (borderOverflowRect != pixelSnappedBorderBoxRect()) { | 801 if (borderOverflowRect != pixelSnappedBorderBoxRect()) { |
801 LayoutRect borderLayoutRect(borderOverflowRect); | 802 LayoutRect borderLayoutRect(borderOverflowRect); |
802 addLayoutOverflow(borderLayoutRect); | 803 addLayoutOverflow(borderLayoutRect); |
803 addContentsVisualOverflow(borderLayoutRect); | 804 addContentsVisualOverflow(borderLayoutRect); |
804 } | 805 } |
805 } | 806 } |
806 | 807 |
807 // Add overflow from our caption. | 808 // Add overflow from our caption. |
808 for (unsigned i = 0; i < m_captions.size(); i++) | 809 for (unsigned i = 0; i < m_captions.size(); i++) |
809 addOverflowFromChild(m_captions[i]); | 810 addOverflowFromChild(m_captions[i]); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 m_effectiveColumnPositions.resize(maxCols + 1); | 1119 m_effectiveColumnPositions.resize(maxCols + 1); |
1119 m_noCellColspanAtLeast = calcNoCellColspanAtLeast(); | 1120 m_noCellColspanAtLeast = calcNoCellColspanAtLeast(); |
1120 | 1121 |
1121 ASSERT(selfNeedsLayout()); | 1122 ASSERT(selfNeedsLayout()); |
1122 | 1123 |
1123 m_needsSectionRecalc = false; | 1124 m_needsSectionRecalc = false; |
1124 } | 1125 } |
1125 | 1126 |
1126 int LayoutTable::calcBorderStart() const { | 1127 int LayoutTable::calcBorderStart() const { |
1127 if (!collapseBorders()) | 1128 if (!collapseBorders()) |
1128 return LayoutBlock::borderStart(); | 1129 return LayoutBlock::borderStart().toInt(); |
1129 | 1130 |
1130 // Determined by the first cell of the first row. See the CSS 2.1 spec, | 1131 // Determined by the first cell of the first row. See the CSS 2.1 spec, |
1131 // section 17.6.2. | 1132 // section 17.6.2. |
1132 if (!numEffectiveColumns()) | 1133 if (!numEffectiveColumns()) |
1133 return 0; | 1134 return 0; |
1134 | 1135 |
1135 int borderWidth = 0; | 1136 int borderWidth = 0; |
1136 | 1137 |
1137 const BorderValue& tableStartBorder = style()->borderStart(); | 1138 const BorderValue& tableStartBorder = style()->borderStart(); |
1138 if (tableStartBorder.style() == BorderStyleHidden) | 1139 if (tableStartBorder.style() == BorderStyleHidden) |
1139 return 0; | 1140 return 0; |
1140 if (tableStartBorder.style() > BorderStyleHidden) | 1141 if (tableStartBorder.style() > BorderStyleHidden) |
1141 borderWidth = tableStartBorder.width(); | 1142 borderWidth = tableStartBorder.width(); |
1142 | 1143 |
1143 // TODO(dgrogan): This logic doesn't properly account for the first column in | 1144 // TODO(dgrogan): This logic doesn't properly account for the first column in |
1144 // the first column-group case. | 1145 // the first column-group case. |
1145 if (LayoutTableCol* column = | 1146 if (LayoutTableCol* column = |
1146 colElementAtAbsoluteColumn(0).innermostColOrColGroup()) { | 1147 colElementAtAbsoluteColumn(0).innermostColOrColGroup()) { |
1147 // FIXME: We don't account for direction on columns and column groups. | 1148 // FIXME: We don't account for direction on columns and column groups. |
1148 const BorderValue& columnAdjoiningBorder = column->style()->borderStart(); | 1149 const BorderValue& columnAdjoiningBorder = column->style()->borderStart(); |
1149 if (columnAdjoiningBorder.style() == BorderStyleHidden) | 1150 if (columnAdjoiningBorder.style() == BorderStyleHidden) |
1150 return 0; | 1151 return 0; |
1151 if (columnAdjoiningBorder.style() > BorderStyleHidden) | 1152 if (columnAdjoiningBorder.style() > BorderStyleHidden) |
1152 borderWidth = std::max(borderWidth, columnAdjoiningBorder.width()); | 1153 borderWidth = std::max<int>(borderWidth, columnAdjoiningBorder.width()); |
1153 } | 1154 } |
1154 | 1155 |
1155 if (const LayoutTableSection* topNonEmptySection = | 1156 if (const LayoutTableSection* topNonEmptySection = |
1156 this->topNonEmptySection()) { | 1157 this->topNonEmptySection()) { |
1157 const BorderValue& sectionAdjoiningBorder = | 1158 const BorderValue& sectionAdjoiningBorder = |
1158 topNonEmptySection->borderAdjoiningTableStart(); | 1159 topNonEmptySection->borderAdjoiningTableStart(); |
1159 if (sectionAdjoiningBorder.style() == BorderStyleHidden) | 1160 if (sectionAdjoiningBorder.style() == BorderStyleHidden) |
1160 return 0; | 1161 return 0; |
1161 | 1162 |
1162 if (sectionAdjoiningBorder.style() > BorderStyleHidden) | 1163 if (sectionAdjoiningBorder.style() > BorderStyleHidden) |
1163 borderWidth = std::max(borderWidth, sectionAdjoiningBorder.width()); | 1164 borderWidth = std::max<int>(borderWidth, sectionAdjoiningBorder.width()); |
1164 | 1165 |
1165 if (const LayoutTableCell* adjoiningStartCell = | 1166 if (const LayoutTableCell* adjoiningStartCell = |
1166 topNonEmptySection->firstRowCellAdjoiningTableStart()) { | 1167 topNonEmptySection->firstRowCellAdjoiningTableStart()) { |
1167 // FIXME: Make this work with perpendicular and flipped cells. | 1168 // FIXME: Make this work with perpendicular and flipped cells. |
1168 const BorderValue& startCellAdjoiningBorder = | 1169 const BorderValue& startCellAdjoiningBorder = |
1169 adjoiningStartCell->borderAdjoiningTableStart(); | 1170 adjoiningStartCell->borderAdjoiningTableStart(); |
1170 if (startCellAdjoiningBorder.style() == BorderStyleHidden) | 1171 if (startCellAdjoiningBorder.style() == BorderStyleHidden) |
1171 return 0; | 1172 return 0; |
1172 | 1173 |
1173 const BorderValue& firstRowAdjoiningBorder = | 1174 const BorderValue& firstRowAdjoiningBorder = |
1174 adjoiningStartCell->row()->borderAdjoiningTableStart(); | 1175 adjoiningStartCell->row()->borderAdjoiningTableStart(); |
1175 if (firstRowAdjoiningBorder.style() == BorderStyleHidden) | 1176 if (firstRowAdjoiningBorder.style() == BorderStyleHidden) |
1176 return 0; | 1177 return 0; |
1177 | 1178 |
1178 if (startCellAdjoiningBorder.style() > BorderStyleHidden) | 1179 if (startCellAdjoiningBorder.style() > BorderStyleHidden) { |
1179 borderWidth = std::max(borderWidth, startCellAdjoiningBorder.width()); | 1180 borderWidth = |
1180 if (firstRowAdjoiningBorder.style() > BorderStyleHidden) | 1181 std::max<int>(borderWidth, startCellAdjoiningBorder.width()); |
1181 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.width()); | 1182 } |
| 1183 if (firstRowAdjoiningBorder.style() > BorderStyleHidden) { |
| 1184 borderWidth = |
| 1185 std::max<int>(borderWidth, firstRowAdjoiningBorder.width()); |
| 1186 } |
1182 } | 1187 } |
1183 } | 1188 } |
1184 return (borderWidth + (style()->isLeftToRightDirection() ? 0 : 1)) / 2; | 1189 return (borderWidth + (style()->isLeftToRightDirection() ? 0 : 1)) / 2; |
1185 } | 1190 } |
1186 | 1191 |
1187 int LayoutTable::calcBorderEnd() const { | 1192 int LayoutTable::calcBorderEnd() const { |
1188 if (!collapseBorders()) | 1193 if (!collapseBorders()) |
1189 return LayoutBlock::borderEnd(); | 1194 return LayoutBlock::borderEnd().toInt(); |
1190 | 1195 |
1191 // Determined by the last cell of the first row. See the CSS 2.1 spec, section | 1196 // Determined by the last cell of the first row. See the CSS 2.1 spec, section |
1192 // 17.6.2. | 1197 // 17.6.2. |
1193 if (!numEffectiveColumns()) | 1198 if (!numEffectiveColumns()) |
1194 return 0; | 1199 return 0; |
1195 | 1200 |
1196 int borderWidth = 0; | 1201 int borderWidth = 0; |
1197 | 1202 |
1198 const BorderValue& tableEndBorder = style()->borderEnd(); | 1203 const BorderValue& tableEndBorder = style()->borderEnd(); |
1199 if (tableEndBorder.style() == BorderStyleHidden) | 1204 if (tableEndBorder.style() == BorderStyleHidden) |
1200 return 0; | 1205 return 0; |
1201 if (tableEndBorder.style() > BorderStyleHidden) | 1206 if (tableEndBorder.style() > BorderStyleHidden) |
1202 borderWidth = tableEndBorder.width(); | 1207 borderWidth = tableEndBorder.width(); |
1203 | 1208 |
1204 unsigned endColumn = numEffectiveColumns() - 1; | 1209 unsigned endColumn = numEffectiveColumns() - 1; |
1205 | 1210 |
1206 // TODO(dgrogan): This logic doesn't properly account for the last column in | 1211 // TODO(dgrogan): This logic doesn't properly account for the last column in |
1207 // the last column-group case. | 1212 // the last column-group case. |
1208 if (LayoutTableCol* column = | 1213 if (LayoutTableCol* column = |
1209 colElementAtAbsoluteColumn(endColumn).innermostColOrColGroup()) { | 1214 colElementAtAbsoluteColumn(endColumn).innermostColOrColGroup()) { |
1210 // FIXME: We don't account for direction on columns and column groups. | 1215 // FIXME: We don't account for direction on columns and column groups. |
1211 const BorderValue& columnAdjoiningBorder = column->style()->borderEnd(); | 1216 const BorderValue& columnAdjoiningBorder = column->style()->borderEnd(); |
1212 if (columnAdjoiningBorder.style() == BorderStyleHidden) | 1217 if (columnAdjoiningBorder.style() == BorderStyleHidden) |
1213 return 0; | 1218 return 0; |
1214 if (columnAdjoiningBorder.style() > BorderStyleHidden) | 1219 if (columnAdjoiningBorder.style() > BorderStyleHidden) |
1215 borderWidth = std::max(borderWidth, columnAdjoiningBorder.width()); | 1220 borderWidth = std::max<int>(borderWidth, columnAdjoiningBorder.width()); |
1216 } | 1221 } |
1217 | 1222 |
1218 if (const LayoutTableSection* topNonEmptySection = | 1223 if (const LayoutTableSection* topNonEmptySection = |
1219 this->topNonEmptySection()) { | 1224 this->topNonEmptySection()) { |
1220 const BorderValue& sectionAdjoiningBorder = | 1225 const BorderValue& sectionAdjoiningBorder = |
1221 topNonEmptySection->borderAdjoiningTableEnd(); | 1226 topNonEmptySection->borderAdjoiningTableEnd(); |
1222 if (sectionAdjoiningBorder.style() == BorderStyleHidden) | 1227 if (sectionAdjoiningBorder.style() == BorderStyleHidden) |
1223 return 0; | 1228 return 0; |
1224 | 1229 |
1225 if (sectionAdjoiningBorder.style() > BorderStyleHidden) | 1230 if (sectionAdjoiningBorder.style() > BorderStyleHidden) |
1226 borderWidth = std::max(borderWidth, sectionAdjoiningBorder.width()); | 1231 borderWidth = std::max<int>(borderWidth, sectionAdjoiningBorder.width()); |
1227 | 1232 |
1228 if (const LayoutTableCell* adjoiningEndCell = | 1233 if (const LayoutTableCell* adjoiningEndCell = |
1229 topNonEmptySection->firstRowCellAdjoiningTableEnd()) { | 1234 topNonEmptySection->firstRowCellAdjoiningTableEnd()) { |
1230 // FIXME: Make this work with perpendicular and flipped cells. | 1235 // FIXME: Make this work with perpendicular and flipped cells. |
1231 const BorderValue& endCellAdjoiningBorder = | 1236 const BorderValue& endCellAdjoiningBorder = |
1232 adjoiningEndCell->borderAdjoiningTableEnd(); | 1237 adjoiningEndCell->borderAdjoiningTableEnd(); |
1233 if (endCellAdjoiningBorder.style() == BorderStyleHidden) | 1238 if (endCellAdjoiningBorder.style() == BorderStyleHidden) |
1234 return 0; | 1239 return 0; |
1235 | 1240 |
1236 const BorderValue& firstRowAdjoiningBorder = | 1241 const BorderValue& firstRowAdjoiningBorder = |
1237 adjoiningEndCell->row()->borderAdjoiningTableEnd(); | 1242 adjoiningEndCell->row()->borderAdjoiningTableEnd(); |
1238 if (firstRowAdjoiningBorder.style() == BorderStyleHidden) | 1243 if (firstRowAdjoiningBorder.style() == BorderStyleHidden) |
1239 return 0; | 1244 return 0; |
1240 | 1245 |
1241 if (endCellAdjoiningBorder.style() > BorderStyleHidden) | 1246 if (endCellAdjoiningBorder.style() > BorderStyleHidden) { |
1242 borderWidth = std::max(borderWidth, endCellAdjoiningBorder.width()); | 1247 borderWidth = |
1243 if (firstRowAdjoiningBorder.style() > BorderStyleHidden) | 1248 std::max<int>(borderWidth, endCellAdjoiningBorder.width()); |
1244 borderWidth = std::max(borderWidth, firstRowAdjoiningBorder.width()); | 1249 } |
| 1250 if (firstRowAdjoiningBorder.style() > BorderStyleHidden) { |
| 1251 borderWidth = |
| 1252 std::max<int>(borderWidth, firstRowAdjoiningBorder.width()); |
| 1253 } |
1245 } | 1254 } |
1246 } | 1255 } |
1247 return (borderWidth + (style()->isLeftToRightDirection() ? 1 : 0)) / 2; | 1256 return (borderWidth + (style()->isLeftToRightDirection() ? 1 : 0)) / 2; |
1248 } | 1257 } |
1249 | 1258 |
1250 void LayoutTable::recalcBordersInRowDirection() { | 1259 void LayoutTable::recalcBordersInRowDirection() { |
1251 // FIXME: We need to compute the collapsed before / after borders in the same | 1260 // FIXME: We need to compute the collapsed before / after borders in the same |
1252 // fashion. | 1261 // fashion. |
1253 m_borderStart = calcBorderStart(); | 1262 m_borderStart = calcBorderStart(); |
1254 m_borderEnd = calcBorderEnd(); | 1263 m_borderEnd = calcBorderEnd(); |
1255 } | 1264 } |
1256 | 1265 |
1257 int LayoutTable::borderBefore() const { | 1266 LayoutUnit LayoutTable::borderBefore() const { |
1258 if (collapseBorders()) { | 1267 if (collapseBorders()) { |
1259 recalcSectionsIfNeeded(); | 1268 recalcSectionsIfNeeded(); |
1260 return outerBorderBefore(); | 1269 return LayoutUnit(outerBorderBefore()); |
1261 } | 1270 } |
1262 return LayoutBlock::borderBefore(); | 1271 return LayoutBlock::borderBefore(); |
1263 } | 1272 } |
1264 | 1273 |
1265 int LayoutTable::borderAfter() const { | 1274 LayoutUnit LayoutTable::borderAfter() const { |
1266 if (collapseBorders()) { | 1275 if (collapseBorders()) { |
1267 recalcSectionsIfNeeded(); | 1276 recalcSectionsIfNeeded(); |
1268 return outerBorderAfter(); | 1277 return LayoutUnit(outerBorderAfter()); |
1269 } | 1278 } |
1270 return LayoutBlock::borderAfter(); | 1279 return LayoutBlock::borderAfter(); |
1271 } | 1280 } |
1272 | 1281 |
1273 int LayoutTable::outerBorderBefore() const { | 1282 int LayoutTable::outerBorderBefore() const { |
1274 if (!collapseBorders()) | 1283 if (!collapseBorders()) |
1275 return 0; | 1284 return 0; |
1276 int borderWidth = 0; | 1285 int borderWidth = 0; |
1277 if (LayoutTableSection* topSection = this->topSection()) { | 1286 if (LayoutTableSection* topSection = this->topSection()) { |
1278 borderWidth = topSection->outerBorderBefore(); | 1287 borderWidth = topSection->outerBorderBefore(); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 } | 1695 } |
1687 | 1696 |
1688 LayoutUnit LayoutTable::paddingRight() const { | 1697 LayoutUnit LayoutTable::paddingRight() const { |
1689 if (collapseBorders()) | 1698 if (collapseBorders()) |
1690 return LayoutUnit(); | 1699 return LayoutUnit(); |
1691 | 1700 |
1692 return LayoutBlock::paddingRight(); | 1701 return LayoutBlock::paddingRight(); |
1693 } | 1702 } |
1694 | 1703 |
1695 } // namespace blink | 1704 } // namespace blink |
OLD | NEW |