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, 2009, 2013 Apple Inc. All rights | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2013 Apple Inc. All rights |
| 8 * reserved. | 8 * 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 // This Vector is sorted in DOM order. | 134 // This Vector is sorted in DOM order. |
| 135 Vector<LayoutTableCell*, 1> cells; | 135 Vector<LayoutTableCell*, 1> cells; |
| 136 bool inColSpan; // true for columns after the first in a colspan | 136 bool inColSpan; // true for columns after the first in a colspan |
| 137 | 137 |
| 138 CellStruct(); | 138 CellStruct(); |
| 139 ~CellStruct(); | 139 ~CellStruct(); |
| 140 | 140 |
| 141 // This is the cell in the grid "slot" that is on top of the others | 141 // This is the cell in the grid "slot" that is on top of the others |
| 142 // (aka the last cell in DOM order for this slot). | 142 // (aka the last cell in DOM order for this slot). |
| 143 // | 143 // |
| 144 // This is the cell originating from this slot if it exists. | 144 // Multiple grid slots can have the same primary cell if the cell spans |
| 145 // into the grid slots. The slot having the smallest row index and | |
| 146 // smallest effective column index is the originating slot of the cell. | |
| 145 // | 147 // |
| 146 // The concept of a primary cell is dubious at most as it doesn't | 148 // The concept of a primary cell is dubious at most as it doesn't |
| 147 // correspond to a DOM or rendering concept. Also callers should be | 149 // correspond to a DOM or rendering concept. Also callers should be |
| 148 // careful about assumptions about it. For example, even though the | 150 // careful about assumptions about it. For example, even though the |
| 149 // primary cell is visibly the top most, it is not guaranteed to be | 151 // primary cell is visibly the top most, it is not guaranteed to be |
| 150 // the only one visible for this slot due to different visual | 152 // the only one visible for this slot due to different visual |
| 151 // overflow rectangles. | 153 // overflow rectangles. |
| 152 LayoutTableCell* primaryCell() { | 154 LayoutTableCell* primaryCell() { |
| 153 return hasCells() ? cells[cells.size() - 1] : 0; | 155 return hasCells() ? cells[cells.size() - 1] : 0; |
| 154 } | 156 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 if (effectiveColumn >= rowVector.size()) | 224 if (effectiveColumn >= rowVector.size()) |
| 223 return nullptr; | 225 return nullptr; |
| 224 return rowVector[effectiveColumn].primaryCell(); | 226 return rowVector[effectiveColumn].primaryCell(); |
| 225 } | 227 } |
| 226 const LayoutTableCell* primaryCellAt(unsigned row, | 228 const LayoutTableCell* primaryCellAt(unsigned row, |
| 227 unsigned effectiveColumn) const { | 229 unsigned effectiveColumn) const { |
| 228 return const_cast<LayoutTableSection*>(this)->primaryCellAt( | 230 return const_cast<LayoutTableSection*>(this)->primaryCellAt( |
| 229 row, effectiveColumn); | 231 row, effectiveColumn); |
| 230 } | 232 } |
| 231 | 233 |
| 234 // Returns the primary cell at (row, effectiveColumn) if the cell exists and | |
| 235 // originates from (instead of spanning into) the grid slot, or nullptr. | |
| 236 LayoutTableCell* originatingCellAt(unsigned row, unsigned effectiveColumn) { | |
|
wkorman
2017/03/29 18:12:33
Do these methods have to be implemented in header?
Xianzhu
2017/03/29 18:44:41
Done.
| |
| 237 LayoutTableCell* cell = primaryCellAt(row, effectiveColumn); | |
| 238 if ((!row || primaryCellAt(row - 1, effectiveColumn) != cell) && | |
| 239 (!effectiveColumn || primaryCellAt(row, effectiveColumn - 1) != cell)) | |
| 240 return cell; | |
| 241 return nullptr; | |
| 242 } | |
| 243 const LayoutTableCell* originatingCellAt(unsigned row, | |
| 244 unsigned effectiveColumn) const { | |
| 245 return const_cast<LayoutTableSection*>(this)->originatingCellAt( | |
|
wkorman
2017/03/29 18:12:33
Why do we need the const_cast and the separate met
Xianzhu
2017/03/29 18:44:41
This follows the strict-const style which is used
Xianzhu
2017/03/29 18:49:12
As only the const version is used, I will remove t
| |
| 246 row, effectiveColumn); | |
| 247 } | |
| 248 | |
| 232 unsigned numCols(unsigned row) const { return m_grid[row].row.size(); } | 249 unsigned numCols(unsigned row) const { return m_grid[row].row.size(); } |
| 233 | 250 |
| 234 // Returns null for cells with a rowspan that exceed the last row. Possibly | 251 // Returns null for cells with a rowspan that exceed the last row. Possibly |
| 235 // others. | 252 // others. |
| 236 LayoutTableRow* rowLayoutObjectAt(unsigned row) { | 253 LayoutTableRow* rowLayoutObjectAt(unsigned row) { |
| 237 return m_grid[row].rowLayoutObject; | 254 return m_grid[row].rowLayoutObject; |
| 238 } | 255 } |
| 239 const LayoutTableRow* rowLayoutObjectAt(unsigned row) const { | 256 const LayoutTableRow* rowLayoutObjectAt(unsigned row) const { |
| 240 return m_grid[row].rowLayoutObject; | 257 return m_grid[row].rowLayoutObject; |
| 241 } | 258 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 const LayoutObject* parent) const override { | 310 const LayoutObject* parent) const override { |
| 294 return createAnonymousWithParent(parent); | 311 return createAnonymousWithParent(parent); |
| 295 } | 312 } |
| 296 | 313 |
| 297 void paint(const PaintInfo&, const LayoutPoint&) const override; | 314 void paint(const PaintInfo&, const LayoutPoint&) const override; |
| 298 | 315 |
| 299 // Flip the rect so it aligns with the coordinates used by the rowPos and | 316 // Flip the rect so it aligns with the coordinates used by the rowPos and |
| 300 // columnPos vectors. | 317 // columnPos vectors. |
| 301 LayoutRect logicalRectForWritingModeAndDirection(const LayoutRect&) const; | 318 LayoutRect logicalRectForWritingModeAndDirection(const LayoutRect&) const; |
| 302 | 319 |
| 320 // Returns a row or column span covering all grid slots from each of which | |
| 321 // a primary cell intersecting visualRect originates. | |
|
wkorman
2017/03/29 18:12:33
|visualRect|
Xianzhu
2017/03/29 18:44:41
Done.
| |
| 303 CellSpan dirtiedRows(const LayoutRect& visualRect) const; | 322 CellSpan dirtiedRows(const LayoutRect& visualRect) const; |
| 304 CellSpan dirtiedEffectiveColumns(const LayoutRect& visualRect) const; | 323 CellSpan dirtiedEffectiveColumns(const LayoutRect& visualRect) const; |
| 324 | |
| 305 const HashSet<LayoutTableCell*>& overflowingCells() const { | 325 const HashSet<LayoutTableCell*>& overflowingCells() const { |
| 306 return m_overflowingCells; | 326 return m_overflowingCells; |
| 307 } | 327 } |
| 308 bool hasMultipleCellLevels() const { return m_hasMultipleCellLevels; } | 328 bool hasMultipleCellLevels() const { return m_hasMultipleCellLevels; } |
| 309 | 329 |
| 310 const char* name() const override { return "LayoutTableSection"; } | 330 const char* name() const override { return "LayoutTableSection"; } |
| 311 | 331 |
| 312 // Whether a section has opaque background depends on many factors, e.g. | 332 // Whether a section has opaque background depends on many factors, e.g. |
| 313 // border spacing, border collapsing, missing cells, etc. For simplicity, | 333 // border spacing, border collapsing, missing cells, etc. For simplicity, |
| 314 // just conservatively assume all table sections are not opaque. | 334 // just conservatively assume all table sections are not opaque. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 // memory. | 488 // memory. |
| 469 HashSet<LayoutTableCell*> m_overflowingCells; | 489 HashSet<LayoutTableCell*> m_overflowingCells; |
| 470 bool m_forceSlowPaintPathWithOverflowingCell; | 490 bool m_forceSlowPaintPathWithOverflowingCell; |
| 471 | 491 |
| 472 // This boolean tracks if we have cells overlapping due to rowspan / colspan | 492 // This boolean tracks if we have cells overlapping due to rowspan / colspan |
| 473 // (see class comment above about when it could appear). | 493 // (see class comment above about when it could appear). |
| 474 // | 494 // |
| 475 // The use is to disable a painting optimization where we just paint the | 495 // The use is to disable a painting optimization where we just paint the |
| 476 // invalidated cells. | 496 // invalidated cells. |
| 477 bool m_hasMultipleCellLevels; | 497 bool m_hasMultipleCellLevels; |
| 498 | |
| 499 // This is set if there is any cell spanning multiple rows or cols. | |
|
wkorman
2017/03/29 18:12:33
Slight rephrase for clarity, something like, "Whet
Xianzhu
2017/03/29 18:44:41
Done.
| |
| 500 bool m_hasSpanningCells; | |
| 478 }; | 501 }; |
| 479 | 502 |
| 480 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); | 503 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); |
| 481 | 504 |
| 482 } // namespace blink | 505 } // namespace blink |
| 483 | 506 |
| 484 #endif // LayoutTableSection_h | 507 #endif // LayoutTableSection_h |
| OLD | NEW |