Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTable.cpp

Issue 2906253003: Replace call sites to BorderValue functions to save the BorderValue construction cost (Closed)
Patch Set: rune@ renames Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 if (!ShouldCollapseBorders()) 1182 if (!ShouldCollapseBorders())
1183 return LayoutBlock::BorderStart().ToInt(); 1183 return LayoutBlock::BorderStart().ToInt();
1184 1184
1185 // Determined by the first cell of the first row. See the CSS 2.1 spec, 1185 // Determined by the first cell of the first row. See the CSS 2.1 spec,
1186 // section 17.6.2. 1186 // section 17.6.2.
1187 if (!NumEffectiveColumns()) 1187 if (!NumEffectiveColumns())
1188 return 0; 1188 return 0;
1189 1189
1190 int border_width = 0; 1190 int border_width = 0;
1191 1191
1192 const BorderValue& table_start_border = Style()->BorderStart(); 1192 EBorderStyle table_start_border_style = Style()->BorderStartStyle();
1193 if (table_start_border.Style() == EBorderStyle::kHidden) 1193 if (table_start_border_style == EBorderStyle::kHidden)
1194 return 0; 1194 return 0;
1195 if (ComputedStyle::BorderStyleIsVisible(table_start_border.Style())) 1195 if (ComputedStyle::BorderStyleIsVisible(table_start_border_style))
1196 border_width = table_start_border.Width(); 1196 border_width = Style()->BorderStartWidth();
1197 1197
1198 // TODO(dgrogan): This logic doesn't properly account for the first column in 1198 // TODO(dgrogan): This logic doesn't properly account for the first column in
1199 // the first column-group case. 1199 // the first column-group case.
1200 if (LayoutTableCol* column = 1200 if (LayoutTableCol* column =
1201 ColElementAtAbsoluteColumn(0).InnermostColOrColGroup()) { 1201 ColElementAtAbsoluteColumn(0).InnermostColOrColGroup()) {
1202 // FIXME: We don't account for direction on columns and column groups. 1202 // FIXME: We don't account for direction on columns and column groups.
1203 const BorderValue& column_adjoining_border = column->Style()->BorderStart(); 1203 EBorderStyle column_adjoining_border_style =
1204 if (column_adjoining_border.Style() == EBorderStyle::kHidden) 1204 column->Style()->BorderStartStyle();
1205 if (column_adjoining_border_style == EBorderStyle::kHidden)
1205 return 0; 1206 return 0;
1206 if (ComputedStyle::BorderStyleIsVisible(column_adjoining_border.Style())) 1207 if (ComputedStyle::BorderStyleIsVisible(column_adjoining_border_style)) {
1207 border_width = 1208 border_width =
1208 std::max<int>(border_width, column_adjoining_border.Width()); 1209 std::max<int>(border_width, column->Style()->BorderStartWidth());
1210 }
1209 } 1211 }
1210 1212
1211 if (const LayoutTableSection* top_non_empty_section = 1213 if (const LayoutTableSection* top_non_empty_section =
1212 this->TopNonEmptySection()) { 1214 this->TopNonEmptySection()) {
1213 const BorderValue& section_adjoining_border = 1215 const BorderValue& section_adjoining_border =
1214 top_non_empty_section->BorderAdjoiningTableStart(); 1216 top_non_empty_section->BorderAdjoiningTableStart();
1215 if (section_adjoining_border.Style() == EBorderStyle::kHidden) 1217 if (section_adjoining_border.Style() == EBorderStyle::kHidden)
1216 return 0; 1218 return 0;
1217 1219
1218 if (ComputedStyle::BorderStyleIsVisible(section_adjoining_border.Style())) 1220 if (ComputedStyle::BorderStyleIsVisible(section_adjoining_border.Style()))
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 if (!ShouldCollapseBorders()) 1253 if (!ShouldCollapseBorders())
1252 return LayoutBlock::BorderEnd().ToInt(); 1254 return LayoutBlock::BorderEnd().ToInt();
1253 1255
1254 // Determined by the last cell of the first row. See the CSS 2.1 spec, section 1256 // Determined by the last cell of the first row. See the CSS 2.1 spec, section
1255 // 17.6.2. 1257 // 17.6.2.
1256 if (!NumEffectiveColumns()) 1258 if (!NumEffectiveColumns())
1257 return 0; 1259 return 0;
1258 1260
1259 int border_width = 0; 1261 int border_width = 0;
1260 1262
1261 const BorderValue& table_end_border = Style()->BorderEnd(); 1263 EBorderStyle table_end_border_style = Style()->BorderEndStyle();
1262 if (table_end_border.Style() == EBorderStyle::kHidden) 1264 if (table_end_border_style == EBorderStyle::kHidden)
1263 return 0; 1265 return 0;
1264 if (ComputedStyle::BorderStyleIsVisible(table_end_border.Style())) 1266 if (ComputedStyle::BorderStyleIsVisible(table_end_border_style))
1265 border_width = table_end_border.Width(); 1267 border_width = Style()->BorderEndWidth();
1266 1268
1267 unsigned end_column = NumEffectiveColumns() - 1; 1269 unsigned end_column = NumEffectiveColumns() - 1;
1268 1270
1269 // TODO(dgrogan): This logic doesn't properly account for the last column in 1271 // TODO(dgrogan): This logic doesn't properly account for the last column in
1270 // the last column-group case. 1272 // the last column-group case.
1271 if (LayoutTableCol* column = 1273 if (LayoutTableCol* column =
1272 ColElementAtAbsoluteColumn(end_column).InnermostColOrColGroup()) { 1274 ColElementAtAbsoluteColumn(end_column).InnermostColOrColGroup()) {
1273 // FIXME: We don't account for direction on columns and column groups. 1275 // FIXME: We don't account for direction on columns and column groups.
1274 const BorderValue& column_adjoining_border = column->Style()->BorderEnd(); 1276 EBorderStyle column_adjoining_border_style =
1275 if (column_adjoining_border.Style() == EBorderStyle::kHidden) 1277 column->Style()->BorderEndStyle();
1278 if (column_adjoining_border_style == EBorderStyle::kHidden)
1276 return 0; 1279 return 0;
1277 if (ComputedStyle::BorderStyleIsVisible(column_adjoining_border.Style())) 1280 if (ComputedStyle::BorderStyleIsVisible(column_adjoining_border_style)) {
1278 border_width = 1281 border_width =
1279 std::max<int>(border_width, column_adjoining_border.Width()); 1282 std::max<int>(border_width, column->Style()->BorderEndWidth());
1283 }
1280 } 1284 }
1281 1285
1282 if (const LayoutTableSection* top_non_empty_section = 1286 if (const LayoutTableSection* top_non_empty_section =
1283 this->TopNonEmptySection()) { 1287 this->TopNonEmptySection()) {
1284 const BorderValue& section_adjoining_border = 1288 const BorderValue& section_adjoining_border =
1285 top_non_empty_section->BorderAdjoiningTableEnd(); 1289 top_non_empty_section->BorderAdjoiningTableEnd();
1286 if (section_adjoining_border.Style() == EBorderStyle::kHidden) 1290 if (section_adjoining_border.Style() == EBorderStyle::kHidden)
1287 return 0; 1291 return 0;
1288 1292
1289 if (ComputedStyle::BorderStyleIsVisible(section_adjoining_border.Style())) 1293 if (ComputedStyle::BorderStyleIsVisible(section_adjoining_border.Style()))
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 1347
1344 int LayoutTable::OuterBorderBefore() const { 1348 int LayoutTable::OuterBorderBefore() const {
1345 if (!ShouldCollapseBorders()) 1349 if (!ShouldCollapseBorders())
1346 return 0; 1350 return 0;
1347 int border_width = 0; 1351 int border_width = 0;
1348 if (LayoutTableSection* top_section = this->TopSection()) { 1352 if (LayoutTableSection* top_section = this->TopSection()) {
1349 border_width = top_section->OuterBorderBefore(); 1353 border_width = top_section->OuterBorderBefore();
1350 if (border_width < 0) 1354 if (border_width < 0)
1351 return 0; // Overridden by hidden 1355 return 0; // Overridden by hidden
1352 } 1356 }
1353 const BorderValue& tb = Style()->BorderBefore(); 1357 EBorderStyle tbs = Style()->BorderBeforeStyle();
1354 if (tb.Style() == EBorderStyle::kHidden) 1358 if (tbs == EBorderStyle::kHidden)
1355 return 0; 1359 return 0;
1356 if (ComputedStyle::BorderStyleIsVisible(tb.Style())) 1360 if (ComputedStyle::BorderStyleIsVisible(tbs)) {
1357 border_width = std::max<int>(border_width, tb.Width() / 2); 1361 border_width =
1362 std::max<int>(border_width, Style()->BorderBeforeWidth() / 2);
1363 }
1358 return border_width; 1364 return border_width;
1359 } 1365 }
1360 1366
1361 int LayoutTable::OuterBorderAfter() const { 1367 int LayoutTable::OuterBorderAfter() const {
1362 if (!ShouldCollapseBorders()) 1368 if (!ShouldCollapseBorders())
1363 return 0; 1369 return 0;
1364 int border_width = 0; 1370 int border_width = 0;
1365 1371
1366 if (LayoutTableSection* section = BottomSection()) { 1372 if (LayoutTableSection* section = BottomSection()) {
1367 border_width = section->OuterBorderAfter(); 1373 border_width = section->OuterBorderAfter();
1368 if (border_width < 0) 1374 if (border_width < 0)
1369 return 0; // Overridden by hidden 1375 return 0; // Overridden by hidden
1370 } 1376 }
1371 const BorderValue& tb = Style()->BorderAfter(); 1377 EBorderStyle tbs = Style()->BorderAfterStyle();
1372 if (tb.Style() == EBorderStyle::kHidden) 1378 if (tbs == EBorderStyle::kHidden)
1373 return 0; 1379 return 0;
1374 if (ComputedStyle::BorderStyleIsVisible(tb.Style())) 1380 if (ComputedStyle::BorderStyleIsVisible(tbs)) {
1375 border_width = std::max<int>(border_width, (tb.Width() + 1) / 2); 1381 border_width =
1382 std::max<int>(border_width, (Style()->BorderAfterWidth() + 1) / 2);
1383 }
1376 return border_width; 1384 return border_width;
1377 } 1385 }
1378 1386
1379 int LayoutTable::OuterBorderStart() const { 1387 int LayoutTable::OuterBorderStart() const {
1380 if (!ShouldCollapseBorders()) 1388 if (!ShouldCollapseBorders())
1381 return 0; 1389 return 0;
1382 1390
1383 int border_width = 0; 1391 int border_width = 0;
1384 1392
1385 const BorderValue& tb = Style()->BorderStart(); 1393 EBorderStyle tbs = Style()->BorderStartStyle();
1386 if (tb.Style() == EBorderStyle::kHidden) 1394 if (tbs == EBorderStyle::kHidden)
1387 return 0; 1395 return 0;
1388 if (ComputedStyle::BorderStyleIsVisible(tb.Style())) 1396 if (ComputedStyle::BorderStyleIsVisible(tbs)) {
1389 border_width = 1397 border_width = (Style()->BorderStartWidth() +
1390 (tb.Width() + (Style()->IsLeftToRightDirection() ? 0 : 1)) / 2; 1398 (Style()->IsLeftToRightDirection() ? 0 : 1)) /
1399 2;
1400 }
1391 1401
1392 bool all_hidden = true; 1402 bool all_hidden = true;
1393 for (LayoutTableSection* section = TopSection(); section; 1403 for (LayoutTableSection* section = TopSection(); section;
1394 section = SectionBelow(section)) { 1404 section = SectionBelow(section)) {
1395 int sw = section->OuterBorderStart(); 1405 int sw = section->OuterBorderStart();
1396 if (sw < 0) 1406 if (sw < 0)
1397 continue; 1407 continue;
1398 all_hidden = false; 1408 all_hidden = false;
1399 border_width = std::max(border_width, sw); 1409 border_width = std::max(border_width, sw);
1400 } 1410 }
1401 if (all_hidden) 1411 if (all_hidden)
1402 return 0; 1412 return 0;
1403 1413
1404 return border_width; 1414 return border_width;
1405 } 1415 }
1406 1416
1407 int LayoutTable::OuterBorderEnd() const { 1417 int LayoutTable::OuterBorderEnd() const {
1408 if (!ShouldCollapseBorders()) 1418 if (!ShouldCollapseBorders())
1409 return 0; 1419 return 0;
1410 1420
1411 int border_width = 0; 1421 int border_width = 0;
1412 1422
1413 const BorderValue& tb = Style()->BorderEnd(); 1423 EBorderStyle tbs = Style()->BorderEndStyle();
1414 if (tb.Style() == EBorderStyle::kHidden) 1424 if (tbs == EBorderStyle::kHidden)
1415 return 0; 1425 return 0;
1416 if (ComputedStyle::BorderStyleIsVisible(tb.Style())) 1426 if (ComputedStyle::BorderStyleIsVisible(tbs)) {
1417 border_width = 1427 border_width = (Style()->BorderEndWidth() +
1418 (tb.Width() + (Style()->IsLeftToRightDirection() ? 1 : 0)) / 2; 1428 (Style()->IsLeftToRightDirection() ? 1 : 0)) /
1429 2;
1430 }
1419 1431
1420 bool all_hidden = true; 1432 bool all_hidden = true;
1421 for (LayoutTableSection* section = TopSection(); section; 1433 for (LayoutTableSection* section = TopSection(); section;
1422 section = SectionBelow(section)) { 1434 section = SectionBelow(section)) {
1423 int sw = section->OuterBorderEnd(); 1435 int sw = section->OuterBorderEnd();
1424 if (sw < 0) 1436 if (sw < 0)
1425 continue; 1437 continue;
1426 all_hidden = false; 1438 all_hidden = false;
1427 border_width = std::max(border_width, sw); 1439 border_width = std::max(border_width, sw);
1428 } 1440 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 } 1776 }
1765 1777
1766 LayoutUnit LayoutTable::PaddingRight() const { 1778 LayoutUnit LayoutTable::PaddingRight() const {
1767 if (ShouldCollapseBorders()) 1779 if (ShouldCollapseBorders())
1768 return LayoutUnit(); 1780 return LayoutUnit();
1769 1781
1770 return LayoutBlock::PaddingRight(); 1782 return LayoutBlock::PaddingRight();
1771 } 1783 }
1772 1784
1773 } // namespace blink 1785 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698