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 bool 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 bool changed = false; |
1302 if (!newValues.startBorder().isVisible() && | 1274 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && |
1303 !newValues.endBorder().isVisible() && | 1275 !newValues.beforeBorder.isVisible() && |
1304 !newValues.beforeBorder().isVisible() && | 1276 !newValues.afterBorder.isVisible()) { |
1305 !newValues.afterBorder().isVisible()) { | |
1306 changed = !!m_collapsedBorderValues; | 1277 changed = !!m_collapsedBorderValues; |
1307 m_collapsedBorderValues = nullptr; | 1278 m_collapsedBorderValues = nullptr; |
1308 } else if (!m_collapsedBorderValues) { | 1279 } else if (!m_collapsedBorderValues) { |
1309 changed = true; | 1280 changed = true; |
1310 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues( | 1281 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); |
1311 *table(), newValues.startBorder(), newValues.endBorder(), | |
1312 newValues.beforeBorder(), newValues.afterBorder())); | |
1313 } else { | 1282 } else { |
1314 // We check visuallyEquals so that the table cell is invalidated only if a | 1283 // We check visuallyEquals so that the table cell is invalidated only if a |
1315 // changed collapsed border is visible in the first place. | 1284 // changed collapsed border is visible in the first place. |
1316 changed = !m_collapsedBorderValues->startBorder().visuallyEquals( | 1285 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( |
1317 newValues.startBorder()) || | 1286 newValues.startBorder) || |
1318 !m_collapsedBorderValues->endBorder().visuallyEquals( | 1287 !m_collapsedBorderValues->endBorder.visuallyEquals( |
1319 newValues.endBorder()) || | 1288 newValues.endBorder) || |
1320 !m_collapsedBorderValues->beforeBorder().visuallyEquals( | 1289 !m_collapsedBorderValues->beforeBorder.visuallyEquals( |
1321 newValues.beforeBorder()) || | 1290 newValues.beforeBorder) || |
1322 !m_collapsedBorderValues->afterBorder().visuallyEquals( | 1291 !m_collapsedBorderValues->afterBorder.visuallyEquals( |
1323 newValues.afterBorder()); | 1292 newValues.afterBorder); |
1324 if (changed) | 1293 if (changed) |
1325 m_collapsedBorderValues->setCollapsedBorderValues(newValues); | 1294 *m_collapsedBorderValues = newValues; |
1326 } | 1295 } |
1327 | 1296 |
1328 // If collapsed borders changed, invalidate the cell's display item client on | 1297 addBorderStyle(borderValues, newValues.startBorder); |
1329 // the table's backing. | 1298 addBorderStyle(borderValues, newValues.endBorder); |
1330 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders | 1299 addBorderStyle(borderValues, newValues.beforeBorder); |
1331 // only. | 1300 addBorderStyle(borderValues, newValues.afterBorder); |
1332 if (changed) | 1301 return 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 } | 1302 } |
1342 | 1303 |
1343 void LayoutTableCell::sortBorderValues( | 1304 void LayoutTableCell::sortBorderValues( |
1344 LayoutTable::CollapsedBorderValues& borderValues) { | 1305 Vector<CollapsedBorderValue>& borderValues) { |
1345 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 1306 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
1346 } | 1307 } |
1347 | 1308 |
1348 void LayoutTableCell::paintBoxDecorationBackground( | 1309 void LayoutTableCell::paintBoxDecorationBackground( |
1349 const PaintInfo& paintInfo, | 1310 const PaintInfo& paintInfo, |
1350 const LayoutPoint& paintOffset) const { | 1311 const LayoutPoint& paintOffset) const { |
1351 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); | 1312 TableCellPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
1352 } | 1313 } |
1353 | 1314 |
1354 void LayoutTableCell::paintMask(const PaintInfo& paintInfo, | 1315 void LayoutTableCell::paintMask(const PaintInfo& paintInfo, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1370 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
1410 const LayoutRect& localRect) const { | 1371 const LayoutRect& localRect) const { |
1411 // If this object has layer, the area of collapsed borders should be | 1372 // If this object has layer, the area of collapsed borders should be |
1412 // transparent to expose the collapsed borders painted on the underlying | 1373 // transparent to expose the collapsed borders painted on the underlying |
1413 // layer. | 1374 // layer. |
1414 if (hasLayer() && table()->collapseBorders()) | 1375 if (hasLayer() && table()->collapseBorders()) |
1415 return false; | 1376 return false; |
1416 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1377 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
1417 } | 1378 } |
1418 | 1379 |
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 | |
1436 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1380 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
1437 // is what current results reflect. We'd like to clean up the results to dump | 1381 // is what current results reflect. We'd like to clean up the results to dump |
1438 // both the outer box and the intrinsic padding so that both bits of information | 1382 // both the outer box and the intrinsic padding so that both bits of information |
1439 // are captured by the results. | 1383 // are captured by the results. |
1440 LayoutRect LayoutTableCell::debugRect() const { | 1384 LayoutRect LayoutTableCell::debugRect() const { |
1441 LayoutRect rect = LayoutRect( | 1385 LayoutRect rect = LayoutRect( |
1442 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1386 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
1443 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1387 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
1444 | 1388 |
1445 LayoutBlock* cb = containingBlock(); | 1389 LayoutBlock* cb = containingBlock(); |
1446 if (cb) | 1390 if (cb) |
1447 cb->adjustChildDebugRect(rect); | 1391 cb->adjustChildDebugRect(rect); |
1448 | 1392 |
1449 return rect; | 1393 return rect; |
1450 } | 1394 } |
1451 | 1395 |
1452 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1396 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
1453 r.move(0, -intrinsicPaddingBefore()); | 1397 r.move(0, -intrinsicPaddingBefore()); |
1454 } | 1398 } |
1455 | 1399 |
1456 } // namespace blink | 1400 } // namespace blink |
OLD | NEW |