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

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

Issue 2616463003: Reference table via the cell for collapsed border display item client (Closed)
Patch Set: Avoid copy constructor Created 3 years, 11 months 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 m_cellWidthChanged(false), 62 m_cellWidthChanged(false),
63 m_intrinsicPaddingBefore(0), 63 m_intrinsicPaddingBefore(0),
64 m_intrinsicPaddingAfter(0) { 64 m_intrinsicPaddingAfter(0) {
65 // We only update the flags when notified of DOM changes in 65 // We only update the flags when notified of DOM changes in
66 // colSpanOrRowSpanChanged() so we need to set their initial values here in 66 // colSpanOrRowSpanChanged() so we need to set their initial values here in
67 // case something asks for colSpan()/rowSpan() before then. 67 // case something asks for colSpan()/rowSpan() before then.
68 updateColAndRowSpanFlags(); 68 updateColAndRowSpanFlags();
69 } 69 }
70 70
71 LayoutTableCell::CollapsedBorderValues::CollapsedBorderValues( 71 LayoutTableCell::CollapsedBorderValues::CollapsedBorderValues(
72 const LayoutTable& layoutTable, 72 const LayoutTableCell& layoutTableCell,
73 const CollapsedBorderValue& startBorder, 73 const CollapsedBorderValue& startBorder,
74 const CollapsedBorderValue& endBorder, 74 const CollapsedBorderValue& endBorder,
75 const CollapsedBorderValue& beforeBorder, 75 const CollapsedBorderValue& beforeBorder,
76 const CollapsedBorderValue& afterBorder) 76 const CollapsedBorderValue& afterBorder)
77 : m_layoutTable(layoutTable), 77 : m_layoutTableCell(layoutTableCell),
78 m_startBorder(startBorder), 78 m_startBorder(startBorder),
79 m_endBorder(endBorder), 79 m_endBorder(endBorder),
80 m_beforeBorder(beforeBorder), 80 m_beforeBorder(beforeBorder),
81 m_afterBorder(afterBorder) {} 81 m_afterBorder(afterBorder) {}
82 82
83 void LayoutTableCell::CollapsedBorderValues::setCollapsedBorderValues( 83 void LayoutTableCell::CollapsedBorderValues::setCollapsedBorderValues(
84 const CollapsedBorderValues& other) { 84 const CollapsedBorderValues& other) {
85 m_startBorder = other.startBorder(); 85 m_startBorder = other.startBorder();
86 m_endBorder = other.endBorder(); 86 m_endBorder = other.endBorder();
87 m_beforeBorder = other.beforeBorder(); 87 m_beforeBorder = other.beforeBorder();
88 m_afterBorder = other.afterBorder(); 88 m_afterBorder = other.afterBorder();
89 } 89 }
90 90
91 String LayoutTableCell::CollapsedBorderValues::debugName() const { 91 String LayoutTableCell::CollapsedBorderValues::debugName() const {
92 return "CollapsedBorderValues"; 92 return "CollapsedBorderValues";
93 } 93 }
94 94
95 LayoutRect LayoutTableCell::CollapsedBorderValues::visualRect() const { 95 LayoutRect LayoutTableCell::CollapsedBorderValues::visualRect() const {
96 return m_layoutTable.visualRect(); 96 return m_layoutTableCell.table()->visualRect();
97 } 97 }
98 98
99 void LayoutTableCell::willBeRemovedFromTree() { 99 void LayoutTableCell::willBeRemovedFromTree() {
100 LayoutBlockFlow::willBeRemovedFromTree(); 100 LayoutBlockFlow::willBeRemovedFromTree();
101 101
102 section()->setNeedsCellRecalc(); 102 section()->setNeedsCellRecalc();
103 103
104 // When borders collapse, removing a cell can affect the the width of 104 // When borders collapse, removing a cell can affect the the width of
105 // neighboring cells. 105 // neighboring cells.
106 LayoutTable* enclosingTable = table(); 106 LayoutTable* enclosingTable = table();
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 for (size_t i = 0; i < count; ++i) { 1314 for (size_t i = 0; i < count; ++i) {
1315 if (borderValues[i].isSameIgnoringColor(borderValue)) 1315 if (borderValues[i].isSameIgnoringColor(borderValue))
1316 return; 1316 return;
1317 } 1317 }
1318 borderValues.append(borderValue); 1318 borderValues.append(borderValue);
1319 } 1319 }
1320 1320
1321 void LayoutTableCell::collectBorderValues( 1321 void LayoutTableCell::collectBorderValues(
1322 LayoutTable::CollapsedBorderValues& borderValues) { 1322 LayoutTable::CollapsedBorderValues& borderValues) {
1323 CollapsedBorderValues newValues( 1323 CollapsedBorderValues newValues(
1324 *table(), computeCollapsedStartBorder(), computeCollapsedEndBorder(), 1324 *this, computeCollapsedStartBorder(), computeCollapsedEndBorder(),
1325 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder()); 1325 computeCollapsedBeforeBorder(), computeCollapsedAfterBorder());
1326 1326
1327 bool changed = false; 1327 bool changed = false;
1328 if (!newValues.startBorder().isVisible() && 1328 if (!newValues.startBorder().isVisible() &&
1329 !newValues.endBorder().isVisible() && 1329 !newValues.endBorder().isVisible() &&
1330 !newValues.beforeBorder().isVisible() && 1330 !newValues.beforeBorder().isVisible() &&
1331 !newValues.afterBorder().isVisible()) { 1331 !newValues.afterBorder().isVisible()) {
1332 changed = !!m_collapsedBorderValues; 1332 changed = !!m_collapsedBorderValues;
1333 m_collapsedBorderValues = nullptr; 1333 m_collapsedBorderValues = nullptr;
1334 } else if (!m_collapsedBorderValues) { 1334 } else if (!m_collapsedBorderValues) {
1335 changed = true; 1335 changed = true;
1336 m_collapsedBorderValues = WTF::wrapUnique(new CollapsedBorderValues( 1336 m_collapsedBorderValues = WTF::wrapUnique(new CollapsedBorderValues(
1337 *table(), newValues.startBorder(), newValues.endBorder(), 1337 *this, newValues.startBorder(), newValues.endBorder(),
1338 newValues.beforeBorder(), newValues.afterBorder())); 1338 newValues.beforeBorder(), newValues.afterBorder()));
1339 } else { 1339 } else {
1340 // We check visuallyEquals so that the table cell is invalidated only if a 1340 // We check visuallyEquals so that the table cell is invalidated only if a
1341 // changed collapsed border is visible in the first place. 1341 // changed collapsed border is visible in the first place.
1342 changed = !m_collapsedBorderValues->startBorder().visuallyEquals( 1342 changed = !m_collapsedBorderValues->startBorder().visuallyEquals(
1343 newValues.startBorder()) || 1343 newValues.startBorder()) ||
1344 !m_collapsedBorderValues->endBorder().visuallyEquals( 1344 !m_collapsedBorderValues->endBorder().visuallyEquals(
1345 newValues.endBorder()) || 1345 newValues.endBorder()) ||
1346 !m_collapsedBorderValues->beforeBorder().visuallyEquals( 1346 !m_collapsedBorderValues->beforeBorder().visuallyEquals(
1347 newValues.beforeBorder()) || 1347 newValues.beforeBorder()) ||
1348 !m_collapsedBorderValues->afterBorder().visuallyEquals( 1348 !m_collapsedBorderValues->afterBorder().visuallyEquals(
1349 newValues.afterBorder()); 1349 newValues.afterBorder());
1350 if (changed) 1350 if (changed)
1351 m_collapsedBorderValues->setCollapsedBorderValues(newValues); 1351 m_collapsedBorderValues->setCollapsedBorderValues(newValues);
1352 } 1352 }
1353 1353
1354 // If collapsed borders changed, invalidate the cell's display item client on 1354 // If collapsed borders changed, invalidate the cell's display item client on
1355 // the table's backing. 1355 // the table's backing.
1356 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders 1356 // TODO(crbug.com/451090#c5): Need a way to invalidate/repaint the borders
1357 // only. 1357 // only.
1358 if (changed) 1358 if (changed) {
1359 ObjectPaintInvalidator(*table()) 1359 ObjectPaintInvalidator(*table())
1360 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( 1360 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
1361 *this, PaintInvalidationStyleChange); 1361 *this, PaintInvalidationStyleChange);
1362 }
1362 1363
1363 addBorderStyle(borderValues, newValues.startBorder()); 1364 addBorderStyle(borderValues, newValues.startBorder());
1364 addBorderStyle(borderValues, newValues.endBorder()); 1365 addBorderStyle(borderValues, newValues.endBorder());
1365 addBorderStyle(borderValues, newValues.beforeBorder()); 1366 addBorderStyle(borderValues, newValues.beforeBorder());
1366 addBorderStyle(borderValues, newValues.afterBorder()); 1367 addBorderStyle(borderValues, newValues.afterBorder());
1367 } 1368 }
1368 1369
1369 void LayoutTableCell::sortBorderValues( 1370 void LayoutTableCell::sortBorderValues(
1370 LayoutTable::CollapsedBorderValues& borderValues) { 1371 LayoutTable::CollapsedBorderValues& borderValues) {
1371 std::sort(borderValues.begin(), borderValues.end(), compareBorders); 1372 std::sort(borderValues.begin(), borderValues.end(), compareBorders);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 } 1492 }
1492 1493
1493 bool LayoutTableCell::hasLineIfEmpty() const { 1494 bool LayoutTableCell::hasLineIfEmpty() const {
1494 if (node() && hasEditableStyle(*node())) 1495 if (node() && hasEditableStyle(*node()))
1495 return true; 1496 return true;
1496 1497
1497 return LayoutBlock::hasLineIfEmpty(); 1498 return LayoutBlock::hasLineIfEmpty();
1498 } 1499 }
1499 1500
1500 } // namespace blink 1501 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698