| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef TableGridCell_h |
| 6 #define TableGridCell_h |
| 7 |
| 8 #include "platform/wtf/Allocator.h" |
| 9 #include "platform/wtf/Vector.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class LayoutTableCell; |
| 14 |
| 15 // TableGridCell represents a single unit in the table grid. |
| 16 // - Without rowspan and colspan, TableGridCells and LayoutTableCells have 1:1 |
| 17 // relationship. |
| 18 // - A LayoutTableCell spanning multiple rows or effective columns can cover |
| 19 // multiple TableGridCells. |
| 20 // - Multiple LayoutTableCells can span into the same TableGridCell, e.g. |
| 21 // <tr><td>A</td><td rowspan="2">B</td></tr> |
| 22 // <tr><td colspan="2">C></td></tr> |
| 23 // both LayoutTableCell B and C cover the TableGridCell at (1,1). |
| 24 |
| 25 class TableGridCell { |
| 26 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 27 |
| 28 public: |
| 29 // We can't inline the constructor and destructor because cells_ needs full |
| 30 // definition of LayoutTableCell, and we can't include LayoutTableCell.h |
| 31 // from this file due to circular includes. |
| 32 TableGridCell(); |
| 33 ~TableGridCell(); |
| 34 |
| 35 // This is the LayoutTableCell covering this TableGridCell that is on top of |
| 36 // the others (aka the last LayoutTableCell in DOM order for this |
| 37 // TableGridCell). |
| 38 // |
| 39 // The concept of a primary cell is dubious at most as it doesn't correspond |
| 40 // to a DOM or rendering concept. Also callers should be careful about |
| 41 // assumptions about it. For example, even though the primary cell is visibly |
| 42 // the top most, it is not guaranteed to be the only one visible for this |
| 43 // unit due to different visual overflow rectangles. |
| 44 LayoutTableCell* PrimaryCell() { |
| 45 return HasCells() ? cells_.back() : nullptr; |
| 46 } |
| 47 const LayoutTableCell* PrimaryCell() const { |
| 48 return const_cast<TableGridCell*>(this)->PrimaryCell(); |
| 49 } |
| 50 |
| 51 bool HasCells() const { return cells_.size() > 0; } |
| 52 |
| 53 Vector<LayoutTableCell*, 1>& Cells() { return cells_; } |
| 54 const Vector<LayoutTableCell*, 1>& Cells() const { return cells_; } |
| 55 |
| 56 bool InColSpan() const { return in_col_span_; } |
| 57 void SetInColSpan(bool in_col_span) { in_col_span_ = in_col_span; } |
| 58 |
| 59 private: |
| 60 // All LayoutTableCells covering this TableGridCell. |
| 61 // Due to colspan / rowpsan, it is possible to have overlapping cells |
| 62 // (see class comment about an example). |
| 63 // This Vector is sorted in DOM order. |
| 64 Vector<LayoutTableCell*, 1> cells_; |
| 65 |
| 66 // True for columns after the first in a colspan. |
| 67 bool in_col_span_ = false; |
| 68 }; |
| 69 |
| 70 } // namespace blink |
| 71 |
| 72 #endif // TableGridCell_h |
| OLD | NEW |