| 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 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 Loading... |
| 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 | |
| 97 void LayoutTableCell::willBeRemovedFromTree() { | 69 void LayoutTableCell::willBeRemovedFromTree() { |
| 98 LayoutBlockFlow::willBeRemovedFromTree(); | 70 LayoutBlockFlow::willBeRemovedFromTree(); |
| 99 | 71 |
| 100 section()->setNeedsCellRecalc(); | 72 section()->setNeedsCellRecalc(); |
| 101 | 73 |
| 102 // When borders collapse, removing a cell can affect the the width of | 74 // When borders collapse, removing a cell can affect the the width of |
| 103 // neighboring cells. | 75 // neighboring cells. |
| 104 LayoutTable* enclosingTable = table(); | 76 LayoutTable* enclosingTable = table(); |
| 105 DCHECK(enclosingTable); | 77 DCHECK(enclosingTable); |
| 106 if (!enclosingTable->collapseBorders()) | 78 if (!enclosingTable->collapseBorders()) |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 : 0)) / | 1245 : 0)) / |
| 1274 2; | 1246 2; |
| 1275 return 0; | 1247 return 0; |
| 1276 } | 1248 } |
| 1277 | 1249 |
| 1278 void LayoutTableCell::paint(const PaintInfo& paintInfo, | 1250 void LayoutTableCell::paint(const PaintInfo& paintInfo, |
| 1279 const LayoutPoint& paintOffset) const { | 1251 const LayoutPoint& paintOffset) const { |
| 1280 TableCellPainter(*this).paint(paintInfo, paintOffset); | 1252 TableCellPainter(*this).paint(paintInfo, paintOffset); |
| 1281 } | 1253 } |
| 1282 | 1254 |
| 1283 static void addBorderStyle(LayoutTable::CollapsedBorderValues& borderValues, | 1255 static void addBorderStyle(Vector<CollapsedBorderValue>& borderValues, |
| 1284 CollapsedBorderValue borderValue) { | 1256 CollapsedBorderValue borderValue) { |
| 1285 if (!borderValue.isVisible()) | 1257 if (!borderValue.isVisible()) |
| 1286 return; | 1258 return; |
| 1287 size_t count = borderValues.size(); | 1259 size_t count = borderValues.size(); |
| 1288 for (size_t i = 0; i < count; ++i) { | 1260 for (size_t i = 0; i < count; ++i) { |
| 1289 if (borderValues[i].isSameIgnoringColor(borderValue)) | 1261 if (borderValues[i].isSameIgnoringColor(borderValue)) |
| 1290 return; | 1262 return; |
| 1291 } | 1263 } |
| 1292 borderValues.append(borderValue); | 1264 borderValues.append(borderValue); |
| 1293 } | 1265 } |
| 1294 | 1266 |
| 1295 void LayoutTableCell::collectBorderValues( | 1267 void LayoutTableCell::collectBorderValues( |
| 1296 LayoutTable::CollapsedBorderValues& borderValues) { | 1268 Vector<CollapsedBorderValue>& borderValues) { |
| 1297 CollapsedBorderValues newValues( | 1269 CollapsedBorderValues newValues = { |
| 1298 *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(), | 1270 computeCollapsedStartBorder(), computeCollapsedEndBorder(), |
| 1299 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()); | 1271 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()}; |
| 1300 | 1272 |
| 1301 bool changed = false; | 1273 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && |
| 1302 if (!newValues.startBorder().isVisible() && | 1274 !newValues.beforeBorder.isVisible() && !newValues.afterBorder.isVisible()) |
| 1303 !newValues.endBorder().isVisible() && | |
| 1304 !newValues.beforeBorder().isVisible() && | |
| 1305 !newValues.afterBorder().isVisible()) { | |
| 1306 changed = !!m_collapsedBorderValues; | |
| 1307 m_collapsedBorderValues = nullptr; | 1275 m_collapsedBorderValues = nullptr; |
| 1308 } else if (!m_collapsedBorderValues) { | 1276 else if (!m_collapsedBorderValues) |
| 1309 changed = true; | 1277 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); |
| 1310 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues( | 1278 else |
| 1311 *table(), newValues.startBorder(), newValues.endBorder(), | 1279 *m_collapsedBorderValues = newValues; |
| 1312 newValues.beforeBorder(), newValues.afterBorder())); | |
| 1313 } else { | |
| 1314 // We check visuallyEquals so that the table cell is invalidated only if a | |
| 1315 // changed collapsed border is visible in the first place. | |
| 1316 changed = !m_collapsedBorderValues->startBorder().visuallyEquals( | |
| 1317 newValues.startBorder()) || | |
| 1318 !m_collapsedBorderValues->endBorder().visuallyEquals( | |
| 1319 newValues.endBorder()) || | |
| 1320 !m_collapsedBorderValues->beforeBorder().visuallyEquals( | |
| 1321 newValues.beforeBorder()) || | |
| 1322 !m_collapsedBorderValues->afterBorder().visuallyEquals( | |
| 1323 newValues.afterBorder()); | |
| 1324 if (changed) | |
| 1325 m_collapsedBorderValues->setCollapsedBorderValues(newValues); | |
| 1326 } | |
| 1327 | 1280 |
| 1328 // If collapsed borders changed, invalidate the cell's display item client on | 1281 addBorderStyle(borderValues, newValues.startBorder); |
| 1329 // the table's backing. | 1282 addBorderStyle(borderValues, newValues.endBorder); |
| 1330 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders | 1283 addBorderStyle(borderValues, newValues.beforeBorder); |
| 1331 // only. | 1284 addBorderStyle(borderValues, newValues.afterBorder); |
| 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()); | |
| 1341 } | 1285 } |
| 1342 | 1286 |
| 1343 void LayoutTableCell::sortBorderValues( | 1287 void LayoutTableCell::sortBorderValues( |
| 1344 LayoutTable::CollapsedBorderValues& borderValues) { | 1288 Vector<CollapsedBorderValue>& borderValues) { |
| 1345 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 1289 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
| 1346 } | 1290 } |
| 1347 | 1291 |
| 1348 void LayoutTableCell::paintBoxDecorationBackground( | 1292 void LayoutTableCell::paintBoxDecorationBackground( |
| 1349 const PaintInfo& paintInfo, | 1293 const PaintInfo& paintInfo, |
| 1350 const LayoutPoint& paintOffset) const { | 1294 const LayoutPoint& paintOffset) const { |
| 1351 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); | 1295 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
| 1352 } | 1296 } |
| 1353 | 1297 |
| 1354 void LayoutTableCell::paintMask(const PaintInfo& paintInfo, | 1298 void LayoutTableCell::paintMask(const PaintInfo& paintInfo, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1359 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| 1416 const LayoutRect& localRect) const { | 1360 const LayoutRect& localRect) const { |
| 1417 // If this object has layer, the area of collapsed borders should be | 1361 // If this object has layer, the area of collapsed borders should be |
| 1418 // transparent to expose the collapsed borders painted on the underlying | 1362 // transparent to expose the collapsed borders painted on the underlying |
| 1419 // layer. | 1363 // layer. |
| 1420 if (hasLayer() && table()->collapseBorders()) | 1364 if (hasLayer() && table()->collapseBorders()) |
| 1421 return false; | 1365 return false; |
| 1422 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1366 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| 1423 } | 1367 } |
| 1424 | 1368 |
| 1425 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const { | |
| 1426 // In certain cases such as collapsed borders for composited table cells we | |
| 1427 // paint content for the cell into the table graphics layer backing and so | |
| 1428 // must use the table's visual rect. | |
| 1429 return (hasLayer() && layer()->compositingState() != NotComposited) || | |
| 1430 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | |
| 1431 } | |
| 1432 | |
| 1433 void LayoutTableCell::invalidateDisplayItemClients( | |
| 1434 PaintInvalidationReason reason) const { | |
| 1435 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) { | |
| 1436 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( | |
| 1437 *m_collapsedBorderValues, reason); | |
| 1438 } | |
| 1439 LayoutBlockFlow::invalidateDisplayItemClients(reason); | |
| 1440 } | |
| 1441 | |
| 1442 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1369 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| 1443 // is what current results reflect. We'd like to clean up the results to dump | 1370 // is what current results reflect. We'd like to clean up the results to dump |
| 1444 // both the outer box and the intrinsic padding so that both bits of information | 1371 // both the outer box and the intrinsic padding so that both bits of information |
| 1445 // are captured by the results. | 1372 // are captured by the results. |
| 1446 LayoutRect LayoutTableCell::debugRect() const { | 1373 LayoutRect LayoutTableCell::debugRect() const { |
| 1447 LayoutRect rect = LayoutRect( | 1374 LayoutRect rect = LayoutRect( |
| 1448 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1375 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
| 1449 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1376 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
| 1450 | 1377 |
| 1451 LayoutBlock* cb = containingBlock(); | 1378 LayoutBlock* cb = containingBlock(); |
| 1452 if (cb) | 1379 if (cb) |
| 1453 cb->adjustChildDebugRect(rect); | 1380 cb->adjustChildDebugRect(rect); |
| 1454 | 1381 |
| 1455 return rect; | 1382 return rect; |
| 1456 } | 1383 } |
| 1457 | 1384 |
| 1458 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1385 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
| 1459 r.move(0, -intrinsicPaddingBefore()); | 1386 r.move(0, -intrinsicPaddingBefore()); |
| 1460 } | 1387 } |
| 1461 | 1388 |
| 1462 } // namespace blink | 1389 } // namespace blink |
| OLD | NEW |