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

Unified Diff: third_party/WebKit/Source/core/layout/TableGridCell.h

Issue 2884533002: Extract LayoutTableSection::CellStruct to a standalone class TableGridCell (Closed)
Patch Set: - Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/TableGridCell.h
diff --git a/third_party/WebKit/Source/core/layout/TableGridCell.h b/third_party/WebKit/Source/core/layout/TableGridCell.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b0b8a551e0c3505db47006612ccd6ef8d1da5be
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/TableGridCell.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TableGridCell_h
+#define TableGridCell_h
+
+#include "platform/wtf/Allocator.h"
+#include "platform/wtf/Vector.h"
+
+namespace blink {
+
+class LayoutTableCell;
+
+// TableGridCell represents a single unit in the table grid.
+// - Without rowspan and colspan, TableGridCells and LayoutTableCells have 1:1
+// relationship.
+// - A LayoutTableCell spanning multiple rows or effective columns can cover
+// multiple TableGridCells.
+// - Multiple LayoutTableCells can span into the same TableGridCell, e.g.
+// <tr><td>A</td><td rowspan="2">B</td></tr>
+// <tr><td colspan="2">C></td></tr>
+// both LayoutTableCell B and C cover the TableGridCell at (1,1).
+
+class TableGridCell {
+ DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+
+ public:
+ // We can't inline the constructor and destructor because cells_ needs full
+ // definition of LayoutTableCell, and we can't include LayoutTableCell.h
+ // from this file due to circular includes.
+ TableGridCell();
+ ~TableGridCell();
+
+ // This is the LayoutTableCell covering this TableGridCell that is on top of
+ // the others (aka the last LayoutTableCell in DOM order for this
+ // TableGridCell).
+ //
+ // The concept of a primary cell is dubious at most as it doesn't correspond
+ // to a DOM or rendering concept. Also callers should be careful about
+ // assumptions about it. For example, even though the primary cell is visibly
+ // the top most, it is not guaranteed to be the only one visible for this
+ // unit due to different visual overflow rectangles.
+ LayoutTableCell* PrimaryCell() {
+ return HasCells() ? cells_.back() : nullptr;
+ }
+ const LayoutTableCell* PrimaryCell() const {
+ return const_cast<TableGridCell*>(this)->PrimaryCell();
+ }
+
+ bool HasCells() const { return cells_.size() > 0; }
+
+ Vector<LayoutTableCell*, 1>& Cells() { return cells_; }
+ const Vector<LayoutTableCell*, 1>& Cells() const { return cells_; }
+
+ bool InColSpan() const { return in_col_span_; }
+ void SetInColSpan(bool in_col_span) { in_col_span_ = in_col_span; }
+
+ private:
+ // All LayoutTableCells covering this TableGridCell.
+ // Due to colspan / rowpsan, it is possible to have overlapping cells
+ // (see class comment about an example).
+ // This Vector is sorted in DOM order.
+ Vector<LayoutTableCell*, 1> cells_;
+
+ // True for columns after the first in a colspan.
+ bool in_col_span_ = false;
+};
+
+} // namespace blink
+
+#endif // TableGridCell_h
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableSection.cpp ('k') | third_party/WebKit/Source/core/layout/TableGridCell.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698