| 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. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include "core/layout/LayoutTableCell.h" | 25 #include "core/layout/LayoutTableCell.h" |
| 26 | 26 |
| 27 #include "core/HTMLNames.h" | 27 #include "core/HTMLNames.h" |
| 28 #include "core/css/StylePropertySet.h" | 28 #include "core/css/StylePropertySet.h" |
| 29 #include "core/html/HTMLTableCellElement.h" | 29 #include "core/html/HTMLTableCellElement.h" |
| 30 #include "core/layout/LayoutAnalyzer.h" | 30 #include "core/layout/LayoutAnalyzer.h" |
| 31 #include "core/layout/LayoutTableCol.h" | 31 #include "core/layout/LayoutTableCol.h" |
| 32 #include "core/layout/SubtreeLayoutScope.h" | 32 #include "core/layout/SubtreeLayoutScope.h" |
| 33 #include "core/paint/ObjectPaintInvalidator.h" | 33 #include "core/paint/ObjectPaintInvalidator.h" |
| 34 #include "core/paint/PaintLayer.h" |
| 34 #include "core/paint/TableCellPainter.h" | 35 #include "core/paint/TableCellPainter.h" |
| 35 #include "core/style/CollapsedBorderValue.h" | 36 #include "core/style/CollapsedBorderValue.h" |
| 36 #include "platform/geometry/FloatQuad.h" | 37 #include "platform/geometry/FloatQuad.h" |
| 37 #include "platform/geometry/TransformState.h" | 38 #include "platform/geometry/TransformState.h" |
| 38 #include "wtf/PtrUtil.h" | 39 #include "wtf/PtrUtil.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 using namespace HTMLNames; | 43 using namespace HTMLNames; |
| 43 | 44 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 : LayoutBlockFlow(element), | 57 : LayoutBlockFlow(element), |
| 57 m_absoluteColumnIndex(unsetColumnIndex), | 58 m_absoluteColumnIndex(unsetColumnIndex), |
| 58 m_cellWidthChanged(false), | 59 m_cellWidthChanged(false), |
| 59 m_intrinsicPaddingBefore(0), | 60 m_intrinsicPaddingBefore(0), |
| 60 m_intrinsicPaddingAfter(0) { | 61 m_intrinsicPaddingAfter(0) { |
| 61 // We only update the flags when notified of DOM changes in colSpanOrRowSpanCh
anged() | 62 // We only update the flags when notified of DOM changes in colSpanOrRowSpanCh
anged() |
| 62 // so we need to set their initial values here in case something asks for colS
pan()/rowSpan() before then. | 63 // so we need to set their initial values here in case something asks for colS
pan()/rowSpan() before then. |
| 63 updateColAndRowSpanFlags(); | 64 updateColAndRowSpanFlags(); |
| 64 } | 65 } |
| 65 | 66 |
| 67 LayoutTableCell::CollapsedBorderValues::CollapsedBorderValues( |
| 68 const LayoutTable& layoutTable, |
| 69 const CollapsedBorderValue& startBorder, |
| 70 const CollapsedBorderValue& endBorder, |
| 71 const CollapsedBorderValue& beforeBorder, |
| 72 const CollapsedBorderValue& afterBorder) |
| 73 : m_layoutTable(layoutTable), |
| 74 m_startBorder(startBorder), |
| 75 m_endBorder(endBorder), |
| 76 m_beforeBorder(beforeBorder), |
| 77 m_afterBorder(afterBorder) {} |
| 78 |
| 79 void LayoutTableCell::CollapsedBorderValues::setCollapsedBorderValues( |
| 80 const CollapsedBorderValues& other) { |
| 81 m_startBorder = other.startBorder(); |
| 82 m_endBorder = other.endBorder(); |
| 83 m_beforeBorder = other.beforeBorder(); |
| 84 m_afterBorder = other.afterBorder(); |
| 85 } |
| 86 |
| 87 String LayoutTableCell::CollapsedBorderValues::debugName() const { |
| 88 return "CollapsedBorderValues"; |
| 89 } |
| 90 |
| 91 LayoutRect LayoutTableCell::CollapsedBorderValues::visualRect() const { |
| 92 return m_layoutTable.visualRect(); |
| 93 } |
| 94 |
| 66 void LayoutTableCell::willBeRemovedFromTree() { | 95 void LayoutTableCell::willBeRemovedFromTree() { |
| 67 LayoutBlockFlow::willBeRemovedFromTree(); | 96 LayoutBlockFlow::willBeRemovedFromTree(); |
| 68 | 97 |
| 69 section()->setNeedsCellRecalc(); | 98 section()->setNeedsCellRecalc(); |
| 70 | 99 |
| 71 // When borders collapse, removing a cell can affect the the width of neighbor
ing cells. | 100 // When borders collapse, removing a cell can affect the the width of neighbor
ing cells. |
| 72 LayoutTable* enclosingTable = table(); | 101 LayoutTable* enclosingTable = table(); |
| 73 DCHECK(enclosingTable); | 102 DCHECK(enclosingTable); |
| 74 if (!enclosingTable->collapseBorders()) | 103 if (!enclosingTable->collapseBorders()) |
| 75 return; | 104 return; |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 size_t count = borderValues.size(); | 1246 size_t count = borderValues.size(); |
| 1218 for (size_t i = 0; i < count; ++i) { | 1247 for (size_t i = 0; i < count; ++i) { |
| 1219 if (borderValues[i].isSameIgnoringColor(borderValue)) | 1248 if (borderValues[i].isSameIgnoringColor(borderValue)) |
| 1220 return; | 1249 return; |
| 1221 } | 1250 } |
| 1222 borderValues.append(borderValue); | 1251 borderValues.append(borderValue); |
| 1223 } | 1252 } |
| 1224 | 1253 |
| 1225 void LayoutTableCell::collectBorderValues( | 1254 void LayoutTableCell::collectBorderValues( |
| 1226 LayoutTable::CollapsedBorderValues& borderValues) { | 1255 LayoutTable::CollapsedBorderValues& borderValues) { |
| 1227 CollapsedBorderValues newValues = { | 1256 CollapsedBorderValues newValues( |
| 1228 computeCollapsedStartBorder(), computeCollapsedEndBorder(), | 1257 *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(), |
| 1229 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()}; | 1258 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()); |
| 1230 | 1259 |
| 1231 bool changed = false; | 1260 bool changed = false; |
| 1232 if (!newValues.startBorder.isVisible() && !newValues.endBorder.isVisible() && | 1261 if (!newValues.startBorder().isVisible() && |
| 1233 !newValues.beforeBorder.isVisible() && | 1262 !newValues.endBorder().isVisible() && |
| 1234 !newValues.afterBorder.isVisible()) { | 1263 !newValues.beforeBorder().isVisible() && |
| 1264 !newValues.afterBorder().isVisible()) { |
| 1235 changed = !!m_collapsedBorderValues; | 1265 changed = !!m_collapsedBorderValues; |
| 1236 m_collapsedBorderValues = nullptr; | 1266 m_collapsedBorderValues = nullptr; |
| 1237 } else if (!m_collapsedBorderValues) { | 1267 } else if (!m_collapsedBorderValues) { |
| 1238 changed = true; | 1268 changed = true; |
| 1239 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues(newValues)); | 1269 m_collapsedBorderValues = wrapUnique(new CollapsedBorderValues( |
| 1270 *table(), newValues.startBorder(), newValues.endBorder(), |
| 1271 newValues.beforeBorder(), newValues.afterBorder())); |
| 1240 } else { | 1272 } else { |
| 1241 // We check visuallyEquals so that the table cell is invalidated only if a c
hanged | 1273 // We check visuallyEquals so that the table cell is invalidated only if a |
| 1242 // collapsed border is visible in the first place. | 1274 // changed collapsed border is visible in the first place. |
| 1243 changed = !m_collapsedBorderValues->startBorder.visuallyEquals( | 1275 changed = !m_collapsedBorderValues->startBorder().visuallyEquals( |
| 1244 newValues.startBorder) || | 1276 newValues.startBorder()) || |
| 1245 !m_collapsedBorderValues->endBorder.visuallyEquals( | 1277 !m_collapsedBorderValues->endBorder().visuallyEquals( |
| 1246 newValues.endBorder) || | 1278 newValues.endBorder()) || |
| 1247 !m_collapsedBorderValues->beforeBorder.visuallyEquals( | 1279 !m_collapsedBorderValues->beforeBorder().visuallyEquals( |
| 1248 newValues.beforeBorder) || | 1280 newValues.beforeBorder()) || |
| 1249 !m_collapsedBorderValues->afterBorder.visuallyEquals( | 1281 !m_collapsedBorderValues->afterBorder().visuallyEquals( |
| 1250 newValues.afterBorder); | 1282 newValues.afterBorder()); |
| 1251 if (changed) | 1283 if (changed) |
| 1252 *m_collapsedBorderValues = newValues; | 1284 m_collapsedBorderValues->setCollapsedBorderValues(newValues); |
| 1253 } | 1285 } |
| 1254 | 1286 |
| 1255 // If collapsed borders changed, invalidate the cell's display item client on
the table's backing. | 1287 // If collapsed borders changed, invalidate the cell's display item client on
the table's backing. |
| 1256 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders onl
y. | 1288 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders onl
y. |
| 1257 if (changed) | 1289 if (changed) |
| 1258 ObjectPaintInvalidator(*table()) | 1290 ObjectPaintInvalidator(*table()) |
| 1259 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 1291 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| 1260 *this, PaintInvalidationStyleChange); | 1292 *this, PaintInvalidationStyleChange); |
| 1261 | 1293 |
| 1262 addBorderStyle(borderValues, newValues.startBorder); | 1294 addBorderStyle(borderValues, newValues.startBorder()); |
| 1263 addBorderStyle(borderValues, newValues.endBorder); | 1295 addBorderStyle(borderValues, newValues.endBorder()); |
| 1264 addBorderStyle(borderValues, newValues.beforeBorder); | 1296 addBorderStyle(borderValues, newValues.beforeBorder()); |
| 1265 addBorderStyle(borderValues, newValues.afterBorder); | 1297 addBorderStyle(borderValues, newValues.afterBorder()); |
| 1266 } | 1298 } |
| 1267 | 1299 |
| 1268 void LayoutTableCell::sortBorderValues( | 1300 void LayoutTableCell::sortBorderValues( |
| 1269 LayoutTable::CollapsedBorderValues& borderValues) { | 1301 LayoutTable::CollapsedBorderValues& borderValues) { |
| 1270 std::sort(borderValues.begin(), borderValues.end(), compareBorders); | 1302 std::sort(borderValues.begin(), borderValues.end(), compareBorders); |
| 1271 } | 1303 } |
| 1272 | 1304 |
| 1273 void LayoutTableCell::paintBoxDecorationBackground( | 1305 void LayoutTableCell::paintBoxDecorationBackground( |
| 1274 const PaintInfo& paintInfo, | 1306 const PaintInfo& paintInfo, |
| 1275 const LayoutPoint& paintOffset) const { | 1307 const LayoutPoint& paintOffset) const { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 | 1368 |
| 1337 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1369 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| 1338 const LayoutRect& localRect) const { | 1370 const LayoutRect& localRect) const { |
| 1339 // If this object has layer, the area of collapsed borders should be transpare
nt | 1371 // If this object has layer, the area of collapsed borders should be transpare
nt |
| 1340 // to expose the collapsed borders painted on the underlying layer. | 1372 // to expose the collapsed borders painted on the underlying layer. |
| 1341 if (hasLayer() && table()->collapseBorders()) | 1373 if (hasLayer() && table()->collapseBorders()) |
| 1342 return false; | 1374 return false; |
| 1343 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1375 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| 1344 } | 1376 } |
| 1345 | 1377 |
| 1378 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const { |
| 1379 // In certain cases such as collapsed borders for composited table cells we |
| 1380 // paint content for the cell into the table graphics layer backing and so |
| 1381 // must use the table's visual rect. |
| 1382 return (hasLayer() && layer()->compositingState() != NotComposited) || |
| 1383 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
| 1384 } |
| 1385 |
| 1386 void LayoutTableCell::invalidateDisplayItemClients( |
| 1387 PaintInvalidationReason reason) const { |
| 1388 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) { |
| 1389 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( |
| 1390 *m_collapsedBorderValues, reason); |
| 1391 } |
| 1392 LayoutBlockFlow::invalidateDisplayItemClients(reason); |
| 1393 } |
| 1394 |
| 1346 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1395 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| 1347 // is what current results reflect. We'd like to clean up the results to dump | 1396 // is what current results reflect. We'd like to clean up the results to dump |
| 1348 // both the outer box and the intrinsic padding so that both bits of | 1397 // both the outer box and the intrinsic padding so that both bits of |
| 1349 // information are captured by the results. | 1398 // information are captured by the results. |
| 1350 LayoutRect LayoutTableCell::debugRect() const { | 1399 LayoutRect LayoutTableCell::debugRect() const { |
| 1351 LayoutRect rect = LayoutRect( | 1400 LayoutRect rect = LayoutRect( |
| 1352 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1401 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
| 1353 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1402 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
| 1354 | 1403 |
| 1355 LayoutBlock* cb = containingBlock(); | 1404 LayoutBlock* cb = containingBlock(); |
| 1356 if (cb) | 1405 if (cb) |
| 1357 cb->adjustChildDebugRect(rect); | 1406 cb->adjustChildDebugRect(rect); |
| 1358 | 1407 |
| 1359 return rect; | 1408 return rect; |
| 1360 } | 1409 } |
| 1361 | 1410 |
| 1362 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1411 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
| 1363 r.move(0, -intrinsicPaddingBefore()); | 1412 r.move(0, -intrinsicPaddingBefore()); |
| 1364 } | 1413 } |
| 1365 | 1414 |
| 1366 } // namespace blink | 1415 } // namespace blink |
| OLD | NEW |