Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 #include "core/layout/LayoutTableCell.h" | 26 #include "core/layout/LayoutTableCell.h" |
| 27 | 27 |
| 28 #include "core/HTMLNames.h" | 28 #include "core/HTMLNames.h" |
| 29 #include "core/css/StylePropertySet.h" | 29 #include "core/css/StylePropertySet.h" |
| 30 #include "core/html/HTMLTableCellElement.h" | 30 #include "core/html/HTMLTableCellElement.h" |
| 31 #include "core/layout/LayoutAnalyzer.h" | 31 #include "core/layout/LayoutAnalyzer.h" |
| 32 #include "core/layout/LayoutTableCol.h" | 32 #include "core/layout/LayoutTableCol.h" |
| 33 #include "core/layout/SubtreeLayoutScope.h" | 33 #include "core/layout/SubtreeLayoutScope.h" |
| 34 #include "core/paint/ObjectPaintInvalidator.h" | 34 #include "core/paint/ObjectPaintInvalidator.h" |
| 35 #include "core/paint/PaintLayer.h" | |
| 35 #include "core/paint/TableCellPainter.h" | 36 #include "core/paint/TableCellPainter.h" |
| 36 #include "core/style/CollapsedBorderValue.h" | 37 #include "core/style/CollapsedBorderValue.h" |
| 37 #include "platform/geometry/FloatQuad.h" | 38 #include "platform/geometry/FloatQuad.h" |
| 38 #include "platform/geometry/TransformState.h" | 39 #include "platform/geometry/TransformState.h" |
| 39 #include "wtf/PtrUtil.h" | 40 #include "wtf/PtrUtil.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 44 | 45 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 58 m_absoluteColumnIndex(unsetColumnIndex), | 59 m_absoluteColumnIndex(unsetColumnIndex), |
| 59 m_cellWidthChanged(false), | 60 m_cellWidthChanged(false), |
| 60 m_intrinsicPaddingBefore(0), | 61 m_intrinsicPaddingBefore(0), |
| 61 m_intrinsicPaddingAfter(0) { | 62 m_intrinsicPaddingAfter(0) { |
| 62 // We only update the flags when notified of DOM changes in | 63 // We only update the flags when notified of DOM changes in |
| 63 // colSpanOrRowSpanChanged() so we need to set their initial values here in | 64 // colSpanOrRowSpanChanged() so we need to set their initial values here in |
| 64 // case something asks for colSpan()/rowSpan() before then. | 65 // case something asks for colSpan()/rowSpan() before then. |
| 65 updateColAndRowSpanFlags(); | 66 updateColAndRowSpanFlags(); |
| 66 } | 67 } |
| 67 | 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 | |
| 68 void LayoutTableCell::willBeRemovedFromTree() { | 97 void LayoutTableCell::willBeRemovedFromTree() { |
| 69 LayoutBlockFlow::willBeRemovedFromTree(); | 98 LayoutBlockFlow::willBeRemovedFromTree(); |
| 70 | 99 |
| 71 section()->setNeedsCellRecalc(); | 100 section()->setNeedsCellRecalc(); |
| 72 | 101 |
| 73 // 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 |
| 74 // neighboring cells. | 103 // neighboring cells. |
| 75 LayoutTable* enclosingTable = table(); | 104 LayoutTable* enclosingTable = table(); |
| 76 DCHECK(enclosingTable); | 105 DCHECK(enclosingTable); |
| 77 if (!enclosingTable->collapseBorders()) | 106 if (!enclosingTable->collapseBorders()) |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1257 size_t count = borderValues.size(); | 1286 size_t count = borderValues.size(); |
| 1258 for (size_t i = 0; i < count; ++i) { | 1287 for (size_t i = 0; i < count; ++i) { |
| 1259 if (borderValues[i].isSameIgnoringColor(borderValue)) | 1288 if (borderValues[i].isSameIgnoringColor(borderValue)) |
| 1260 return; | 1289 return; |
| 1261 } | 1290 } |
| 1262 borderValues.append(borderValue); | 1291 borderValues.append(borderValue); |
| 1263 } | 1292 } |
| 1264 | 1293 |
| 1265 void LayoutTableCell::collectBorderValues( | 1294 void LayoutTableCell::collectBorderValues( |
| 1266 LayoutTable::CollapsedBorderValues& borderValues) { | 1295 LayoutTable::CollapsedBorderValues& borderValues) { |
| 1267 CollapsedBorderValues newValues = { | 1296 CollapsedBorderValues newValues( |
| 1268 computeCollapsedStartBorder(), computeCollapsedEndBorder(), | 1297 *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(), |
| 1269 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()}; | 1298 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()); |
| 1270 | 1299 |
| 1271 bool changed = false; | 1300 bool changed = false; |
| 1272 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && | 1301 if (!newValues.startBorder().isVisible() && |
| 1273 !newValues.beforeBorder.isVisible() && | 1302 !newValues.endBorder().isVisible() && |
| 1274 !newValues.afterBorder.isVisible()) { | 1303 !newValues.beforeBorder().isVisible() && |
| 1304 !newValues.afterBorder().isVisible()) { | |
| 1275 changed = !!m_collapsedBorderValues; | 1305 changed = !!m_collapsedBorderValues; |
| 1276 m_collapsedBorderValues = nullptr; | 1306 m_collapsedBorderValues = nullptr; |
| 1277 } else if (!m_collapsedBorderValues) { | 1307 } else if (!m_collapsedBorderValues) { |
| 1278 changed = true; | 1308 changed = true; |
| 1279 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); | 1309 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues( |
| 1310 *table(), newValues.startBorder(), newValues.endBorder(), | |
| 1311 newValues.beforeBorder(), newValues.afterBorder())); | |
| 1280 } else { | 1312 } else { |
| 1281 // We check visuallyEquals so that the table cell is invalidated only if a | 1313 // We check visuallyEquals so that the table cell is invalidated only if a |
| 1282 // changed collapsed border is visible in the first place. | 1314 // changed collapsed border is visible in the first place. |
| 1283 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( | 1315 changed = !m_collapsedBorderValues->startBorder().visuallyEquals( |
| 1284 newValues.startBorder) || | 1316 newValues.startBorder()) || |
| 1285 !m_collapsedBorderValues->endBorder.visuallyEquals( | 1317 !m_collapsedBorderValues->endBorder().visuallyEquals( |
| 1286 newValues.endBorder) || | 1318 newValues.endBorder()) || |
| 1287 !m_collapsedBorderValues->beforeBorder.visuallyEquals( | 1319 !m_collapsedBorderValues->beforeBorder().visuallyEquals( |
| 1288 newValues.beforeBorder) || | 1320 newValues.beforeBorder()) || |
| 1289 !m_collapsedBorderValues->afterBorder.visuallyEquals( | 1321 !m_collapsedBorderValues->afterBorder().visuallyEquals( |
| 1290 newValues.afterBorder); | 1322 newValues.afterBorder()); |
| 1291 if (changed) | 1323 if (changed) |
| 1292 *m_collapsedBorderValues = newValues; | 1324 m_collapsedBorderValues->setCollapsedBorderValues(newValues); |
| 1293 } | 1325 } |
| 1294 | 1326 |
| 1295 // If collapsed borders changed, invalidate the cell's display item client on | 1327 // If collapsed borders changed, invalidate the cell's display item client on |
| 1296 // the table's backing. | 1328 // the table's backing. |
| 1297 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders | 1329 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders |
| 1298 // only. | 1330 // only. |
| 1299 if (changed) | 1331 if (changed) |
| 1300 ObjectPaintInvalidator(*table()) | 1332 ObjectPaintInvalidator(*table()) |
| 1301 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 1333 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| 1302 *this, PaintInvalidationStyleChange); | 1334 *this, PaintInvalidationStyleChange); |
| 1303 | 1335 |
| 1304 addBorderStyle(borderValues, newValues.startBorder); | 1336 addBorderStyle(borderValues, newValues.startBorder()); |
| 1305 addBorderStyle(borderValues, newValues.endBorder); | 1337 addBorderStyle(borderValues, newValues.endBorder()); |
| 1306 addBorderStyle(borderValues, newValues.beforeBorder); | 1338 addBorderStyle(borderValues, newValues.beforeBorder()); |
| 1307 addBorderStyle(borderValues, newValues.afterBorder); | 1339 addBorderStyle(borderValues, newValues.afterBorder()); |
| 1308 } | 1340 } |
| 1309 | 1341 |
| 1310 void LayoutTableCell::sortBorderValues( | 1342 void LayoutTableCell::sortBorderValues( |
| 1311 LayoutTable::CollapsedBorderValues& borderValues) { | 1343 LayoutTable::CollapsedBorderValues& borderValues) { |
| 1312 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 1344 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
| 1313 } | 1345 } |
| 1314 | 1346 |
| 1315 void LayoutTableCell::paintBoxDecorationBackground( | 1347 void LayoutTableCell::paintBoxDecorationBackground( |
| 1316 const PaintInfo& paintInfo, | 1348 const PaintInfo& paintInfo, |
| 1317 const LayoutPoint& paintOffset) const { | 1349 const LayoutPoint& paintOffset) const { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1382 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1414 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| 1383 const LayoutRect& localRect) const { | 1415 const LayoutRect& localRect) const { |
| 1384 // If this object has layer, the area of collapsed borders should be | 1416 // If this object has layer, the area of collapsed borders should be |
| 1385 // transparent to expose the collapsed borders painted on the underlying | 1417 // transparent to expose the collapsed borders painted on the underlying |
| 1386 // layer. | 1418 // layer. |
| 1387 if (hasLayer() && table()->collapseBorders()) | 1419 if (hasLayer() && table()->collapseBorders()) |
| 1388 return false; | 1420 return false; |
| 1389 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1421 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| 1390 } | 1422 } |
| 1391 | 1423 |
| 1424 bool LayoutTableCell::usesTableAsDisplayItemClient() const { | |
| 1425 return (hasLayer() && layer()->compositingState() != NotComposited) || | |
|
chrishtr
2016/10/19 01:13:21
Add a note explaining this conditional.
wkorman
2016/10/19 23:07:39
Done.
| |
| 1426 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | |
| 1427 } | |
| 1428 | |
| 1429 void LayoutTableCell::invalidateDisplayItemClients( | |
| 1430 PaintInvalidationReason reason) const { | |
| 1431 if (m_collapsedBorderValues && usesTableAsDisplayItemClient()) { | |
| 1432 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( | |
| 1433 *m_collapsedBorderValues, reason); | |
| 1434 } | |
| 1435 LayoutBlockFlow::invalidateDisplayItemClients(reason); | |
| 1436 } | |
| 1437 | |
| 1392 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1438 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| 1393 // is what current results reflect. We'd like to clean up the results to dump | 1439 // is what current results reflect. We'd like to clean up the results to dump |
| 1394 // both the outer box and the intrinsic padding so that both bits of information | 1440 // both the outer box and the intrinsic padding so that both bits of information |
| 1395 // are captured by the results. | 1441 // are captured by the results. |
| 1396 LayoutRect LayoutTableCell::debugRect() const { | 1442 LayoutRect LayoutTableCell::debugRect() const { |
| 1397 LayoutRect rect = LayoutRect( | 1443 LayoutRect rect = LayoutRect( |
| 1398 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1444 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
| 1399 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1445 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
| 1400 | 1446 |
| 1401 LayoutBlock* cb = containingBlock(); | 1447 LayoutBlock* cb = containingBlock(); |
| 1402 if (cb) | 1448 if (cb) |
| 1403 cb->adjustChildDebugRect(rect); | 1449 cb->adjustChildDebugRect(rect); |
| 1404 | 1450 |
| 1405 return rect; | 1451 return rect; |
| 1406 } | 1452 } |
| 1407 | 1453 |
| 1408 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1454 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
| 1409 r.move(0, -intrinsicPaddingBefore()); | 1455 r.move(0, -intrinsicPaddingBefore()); |
| 1410 } | 1456 } |
| 1411 | 1457 |
| 1412 } // namespace blink | 1458 } // namespace blink |
| OLD | NEW |