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

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

Issue 2495343002: Revert of Paint collapsed borders of a table as one display item (Closed)
Patch Set: Created 4 years, 1 month 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 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 m_absoluteColumnIndex(unsetColumnIndex), 59 m_absoluteColumnIndex(unsetColumnIndex),
60 m_cellWidthChanged(false), 60 m_cellWidthChanged(false),
61 m_intrinsicPaddingBefore(0), 61 m_intrinsicPaddingBefore(0),
62 m_intrinsicPaddingAfter(0) { 62 m_intrinsicPaddingAfter(0) {
63 // We only update the flags when notified of DOM changes in 63 // We only update the flags when notified of DOM changes in
64 // colSpanOrRowSpanChanged() so we need to set their initial values here in 64 // colSpanOrRowSpanChanged() so we need to set their initial values here in
65 // case something asks for colSpan()/rowSpan() before then. 65 // case something asks for colSpan()/rowSpan() before then.
66 updateColAndRowSpanFlags(); 66 updateColAndRowSpanFlags();
67 } 67 }
68 68
69 LayoutTableCell::CollapsedBorderValues::CollapsedBorderValues(
70 const LayoutTable& layoutTable,
71 const CollapsedBorderValue& startBorder,
72 const CollapsedBorderValue& endBorder,
73 const CollapsedBorderValue& beforeBorder,
74 const CollapsedBorderValue& afterBorder)
75 : m_layoutTable(layoutTable),
76 m_startBorder(startBorder),
77 m_endBorder(endBorder),
78 m_beforeBorder(beforeBorder),
79 m_afterBorder(afterBorder) {}
80
81 void LayoutTableCell::CollapsedBorderValues::setCollapsedBorderValues(
82 const CollapsedBorderValues& other) {
83 m_startBorder = other.startBorder();
84 m_endBorder = other.endBorder();
85 m_beforeBorder = other.beforeBorder();
86 m_afterBorder = other.afterBorder();
87 }
88
89 String LayoutTableCell::CollapsedBorderValues::debugName() const {
90 return "CollapsedBorderValues";
91 }
92
93 LayoutRect LayoutTableCell::CollapsedBorderValues::visualRect() const {
94 return m_layoutTable.visualRect();
95 }
96
69 void LayoutTableCell::willBeRemovedFromTree() { 97 void LayoutTableCell::willBeRemovedFromTree() {
70 LayoutBlockFlow::willBeRemovedFromTree(); 98 LayoutBlockFlow::willBeRemovedFromTree();
71 99
72 section()->setNeedsCellRecalc(); 100 section()->setNeedsCellRecalc();
73 101
74 // When borders collapse, removing a cell can affect the the width of 102 // When borders collapse, removing a cell can affect the the width of
75 // neighboring cells. 103 // neighboring cells.
76 LayoutTable* enclosingTable = table(); 104 LayoutTable* enclosingTable = table();
77 DCHECK(enclosingTable); 105 DCHECK(enclosingTable);
78 if (!enclosingTable->collapseBorders()) 106 if (!enclosingTable->collapseBorders())
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 : 0)) / 1273 : 0)) /
1246 2; 1274 2;
1247 return 0; 1275 return 0;
1248 } 1276 }
1249 1277
1250 void LayoutTableCell::paint(const PaintInfo& paintInfo, 1278 void LayoutTableCell::paint(const PaintInfo& paintInfo,
1251 const LayoutPoint& paintOffset) const { 1279 const LayoutPoint& paintOffset) const {
1252 TableCellPainter(*this).paint(paintInfo, paintOffset); 1280 TableCellPainter(*this).paint(paintInfo, paintOffset);
1253 } 1281 }
1254 1282
1255 static void addBorderStyle(Vector<CollapsedBorderValue>& borderValues, 1283 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues,
1256 CollapsedBorderValue borderValue) { 1284 CollapsedBorderValue borderValue) {
1257 if (!borderValue.isVisible()) 1285 if (!borderValue.isVisible())
1258 return; 1286 return;
1259 size_t count = borderValues.size(); 1287 size_t count = borderValues.size();
1260 for (size_t i = 0; i < count; ++i) { 1288 for (size_t i = 0; i < count; ++i) {
1261 if (borderValues[i].isSameIgnoringColor(borderValue)) 1289 if (borderValues[i].isSameIgnoringColor(borderValue))
1262 return; 1290 return;
1263 } 1291 }
1264 borderValues.append(borderValue); 1292 borderValues.append(borderValue);
1265 } 1293 }
1266 1294
1267 bool LayoutTableCell::collectBorderValues( 1295 void LayoutTableCell::collectBorderValues(
1268 Vector<CollapsedBorderValue>& borderValues) { 1296 LayoutTable::CollapsedBorderValues& borderValues) {
1269 CollapsedBorderValues newValues = { 1297 CollapsedBorderValues newValues(
1270 computeCollapsedStartBorder(), computeCollapsedEndBorder(), 1298 *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(),
1271 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()}; 1299 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder());
1272 1300
1273 bool changed = false; 1301 bool changed = false;
1274 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && 1302 if (!newValues.startBorder().isVisible() &&
1275 !newValues.beforeBorder.isVisible() && 1303 !newValues.endBorder().isVisible() &&
1276 !newValues.afterBorder.isVisible()) { 1304 !newValues.beforeBorder().isVisible() &&
1305 !newValues.afterBorder().isVisible()) {
1277 changed = !!m_collapsedBorderValues; 1306 changed = !!m_collapsedBorderValues;
1278 m_collapsedBorderValues = nullptr; 1307 m_collapsedBorderValues = nullptr;
1279 } else if (!m_collapsedBorderValues) { 1308 } else if (!m_collapsedBorderValues) {
1280 changed = true; 1309 changed = true;
1281 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); 1310 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(
1311 *table(), newValues.startBorder(), newValues.endBorder(),
1312 newValues.beforeBorder(), newValues.afterBorder()));
1282 } else { 1313 } else {
1283 // We check visuallyEquals so that the table cell is invalidated only if a 1314 // We check visuallyEquals so that the table cell is invalidated only if a
1284 // changed collapsed border is visible in the first place. 1315 // changed collapsed border is visible in the first place.
1285 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( 1316 changed = !m_collapsedBorderValues->startBorder().visuallyEquals(
1286 newValues.startBorder) || 1317 newValues.startBorder()) ||
1287 !m_collapsedBorderValues->endBorder.visuallyEquals( 1318 !m_collapsedBorderValues->endBorder().visuallyEquals(
1288 newValues.endBorder) || 1319 newValues.endBorder()) ||
1289 !m_collapsedBorderValues->beforeBorder.visuallyEquals( 1320 !m_collapsedBorderValues->beforeBorder().visuallyEquals(
1290 newValues.beforeBorder) || 1321 newValues.beforeBorder()) ||
1291 !m_collapsedBorderValues->afterBorder.visuallyEquals( 1322 !m_collapsedBorderValues->afterBorder().visuallyEquals(
1292 newValues.afterBorder); 1323 newValues.afterBorder());
1293 if (changed) 1324 if (changed)
1294 *m_collapsedBorderValues = newValues; 1325 m_collapsedBorderValues->setCollapsedBorderValues(newValues);
1295 } 1326 }
1296 1327
1297 addBorderStyle(borderValues, newValues.startBorder); 1328 // If collapsed borders changed, invalidate the cell's display item client on
1298 addBorderStyle(borderValues, newValues.endBorder); 1329 // the table's backing.
1299 addBorderStyle(borderValues, newValues.beforeBorder); 1330 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders
1300 addBorderStyle(borderValues, newValues.afterBorder); 1331 // only.
1301 return changed; 1332 if (changed)
1333 ObjectPaintInvalidator(*table())
1334 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
1335 *this, PaintInvalidationStyleChange);
1336
1337 addBorderStyle(borderValues, newValues.startBorder());
1338 addBorderStyle(borderValues, newValues.endBorder());
1339 addBorderStyle(borderValues, newValues.beforeBorder());
1340 addBorderStyle(borderValues, newValues.afterBorder());
1302 } 1341 }
1303 1342
1304 void LayoutTableCell::sortBorderValues( 1343 void LayoutTableCell::sortBorderValues(
1305 Vector<CollapsedBorderValue>& borderValues) { 1344 LayoutTable::CollapsedBorderValues& borderValues) {
1306 std::sort(borderValues.begin(), borderValues.end(), compareBorders); 1345 std::sort(borderValues.begin(), borderValues.end(), compareBorders);
1307 } 1346 }
1308 1347
1309 void LayoutTableCell::paintBoxDecorationBackground( 1348 void LayoutTableCell::paintBoxDecorationBackground(
1310 const PaintInfo& paintInfo, 1349 const PaintInfo& paintInfo,
1311 const LayoutPoint& paintOffset) const { 1350 const LayoutPoint& paintOffset) const {
1312 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); 1351 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset);
1313 } 1352 }
1314 1353
1315 void LayoutTableCell::paintMask(const PaintInfo& paintInfo, 1354 void LayoutTableCell::paintMask(const PaintInfo& paintInfo,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( 1409 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(
1371 const LayoutRect& localRect) const { 1410 const LayoutRect& localRect) const {
1372 // If this object has layer, the area of collapsed borders should be 1411 // If this object has layer, the area of collapsed borders should be
1373 // transparent to expose the collapsed borders painted on the underlying 1412 // transparent to expose the collapsed borders painted on the underlying
1374 // layer. 1413 // layer.
1375 if (hasLayer() && table()->collapseBorders()) 1414 if (hasLayer() && table()->collapseBorders())
1376 return false; 1415 return false;
1377 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); 1416 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect);
1378 } 1417 }
1379 1418
1419 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const {
1420 // In certain cases such as collapsed borders for composited table cells we
1421 // paint content for the cell into the table graphics layer backing and so
1422 // must use the table's visual rect.
1423 return (hasLayer() && layer()->compositingState() != NotComposited) ||
1424 RuntimeEnabledFeatures::slimmingPaintV2Enabled();
1425 }
1426
1427 void LayoutTableCell::invalidateDisplayItemClients(
1428 PaintInvalidationReason reason) const {
1429 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) {
1430 ObjectPaintInvalidator(*this).invalidateDisplayItemClient(
1431 *m_collapsedBorderValues, reason);
1432 }
1433 LayoutBlockFlow::invalidateDisplayItemClients(reason);
1434 }
1435
1380 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that 1436 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that
1381 // is what current results reflect. We'd like to clean up the results to dump 1437 // is what current results reflect. We'd like to clean up the results to dump
1382 // both the outer box and the intrinsic padding so that both bits of information 1438 // both the outer box and the intrinsic padding so that both bits of information
1383 // are captured by the results. 1439 // are captured by the results.
1384 LayoutRect LayoutTableCell::debugRect() const { 1440 LayoutRect LayoutTableCell::debugRect() const {
1385 LayoutRect rect = LayoutRect( 1441 LayoutRect rect = LayoutRect(
1386 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), 1442 location().x(), location().y() + intrinsicPaddingBefore(), size().width(),
1387 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); 1443 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter());
1388 1444
1389 LayoutBlock* cb = containingBlock(); 1445 LayoutBlock* cb = containingBlock();
1390 if (cb) 1446 if (cb)
1391 cb->adjustChildDebugRect(rect); 1447 cb->adjustChildDebugRect(rect);
1392 1448
1393 return rect; 1449 return rect;
1394 } 1450 }
1395 1451
1396 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { 1452 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const {
1397 r.move(0, -intrinsicPaddingBefore()); 1453 r.move(0, -intrinsicPaddingBefore());
1398 } 1454 }
1399 1455
1400 } // namespace blink 1456 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698