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

Side by Side Diff: Source/core/layout/LayoutTableSection.h

Issue 1319453009: Start adding some documentation to LayoutTable (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated after yummy, yummy review! Created 5 years, 3 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
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, 2009, 2013 Apple Inc. All rights reserv ed. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2013 Apple Inc. All rights reserv ed.
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void ensureConsistency(const unsigned); 60 void ensureConsistency(const unsigned);
61 61
62 private: 62 private:
63 unsigned m_start; 63 unsigned m_start;
64 unsigned m_end; 64 unsigned m_end;
65 }; 65 };
66 66
67 class LayoutTableCell; 67 class LayoutTableCell;
68 class LayoutTableRow; 68 class LayoutTableRow;
69 69
70 // LayoutTableSection is used to represent table row group (display:
71 // table-row-group), header group (display: table-header-group) and footer group
72 // (display: table-footer-group).
73 //
74 // The object holds the internal representation of the rows (m_grid). See
75 // recalcCells() below for some extra explanation.
76 //
77 // A lot of the complexity in this class is related to handling rowspan, colspan
78 // or just non-regular tables.
79 //
80 // Example of rowspan / colspan leading to overlapping cells (rowspan and
81 // colspan are overlapping):
82 // <table>
83 // <tr>
84 // <td>first row</td>
85 // <td rowspan="2">rowspan</td>
86 // </tr>
87 // <tr>
88 // <td colspan="2">colspan</td>
89 // </tr>
90 // </table>
91 //
92 // Example of non-regular table (missing one cell in the first row):
93 // <!DOCTYPE html>
94 // <table>
95 // <tr><td>First row only child.</td></tr>
96 // <tr>
97 // <td>Second row first child</td>
98 // <td>Second row second child</td>
99 // </tr>
100 // </table>
70 class CORE_EXPORT LayoutTableSection final : public LayoutBox { 101 class CORE_EXPORT LayoutTableSection final : public LayoutBox {
71 public: 102 public:
72 LayoutTableSection(Element*); 103 LayoutTableSection(Element*);
73 ~LayoutTableSection() override; 104 ~LayoutTableSection() override;
74 105
75 LayoutTableRow* firstRow() const; 106 LayoutTableRow* firstRow() const;
76 LayoutTableRow* lastRow() const; 107 LayoutTableRow* lastRow() const;
77 108
78 const LayoutObjectChildList* children() const { return &m_children; } 109 const LayoutObjectChildList* children() const { return &m_children; }
79 LayoutObjectChildList* children() { return &m_children; } 110 LayoutObjectChildList* children() { return &m_children; }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int calcInlineDirectionOuterBorder(InlineBorderSide) const; 223 int calcInlineDirectionOuterBorder(InlineBorderSide) const;
193 void recalcOuterBorder(); 224 void recalcOuterBorder();
194 225
195 int outerBorderBefore() const { return m_outerBorderBefore; } 226 int outerBorderBefore() const { return m_outerBorderBefore; }
196 int outerBorderAfter() const { return m_outerBorderAfter; } 227 int outerBorderAfter() const { return m_outerBorderAfter; }
197 int outerBorderStart() const { return m_outerBorderStart; } 228 int outerBorderStart() const { return m_outerBorderStart; }
198 int outerBorderEnd() const { return m_outerBorderEnd; } 229 int outerBorderEnd() const { return m_outerBorderEnd; }
199 230
200 unsigned numRows() const { return m_grid.size(); } 231 unsigned numRows() const { return m_grid.size(); }
201 unsigned numColumns() const; 232 unsigned numColumns() const;
233
234 // recalcCells() is used when we are not sure about the section's structure
235 // and want to do an expensive (but safe) reconstruction of m_grid from
236 // scratch.
237 // An example of this is inserting a new cell in the middle of an existing
238 // row or removing a row.
239 //
240 // Accessing m_grid when m_needsCellRecalc is set is UNSAFE as pointers can
241 // be left dangling. Thus care should be taken in the code to check
242 // m_needsCellRecalc before accessing m_grid.
202 void recalcCells(); 243 void recalcCells();
203 void recalcCellsIfNeeded() 244 void recalcCellsIfNeeded()
204 { 245 {
205 if (m_needsCellRecalc) 246 if (m_needsCellRecalc)
206 recalcCells(); 247 recalcCells();
207 } 248 }
208 249
209 bool needsCellRecalc() const { return m_needsCellRecalc; } 250 bool needsCellRecalc() const { return m_needsCellRecalc; }
210 void setNeedsCellRecalc(); 251 void setNeedsCellRecalc();
211 252
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 327
287 // These two functions take a rectangle as input that has been flipped by lo gicalRectForWritingModeAndDirection. 328 // These two functions take a rectangle as input that has been flipped by lo gicalRectForWritingModeAndDirection.
288 // The returned span of rows or columns is end-exclusive, and empty if start ==end. 329 // The returned span of rows or columns is end-exclusive, and empty if start ==end.
289 CellSpan spannedRows(const LayoutRect& flippedRect) const; 330 CellSpan spannedRows(const LayoutRect& flippedRect) const;
290 CellSpan spannedColumns(const LayoutRect& flippedRect) const; 331 CellSpan spannedColumns(const LayoutRect& flippedRect) const;
291 332
292 void setLogicalPositionForCell(LayoutTableCell*, unsigned effectiveColumn) c onst; 333 void setLogicalPositionForCell(LayoutTableCell*, unsigned effectiveColumn) c onst;
293 334
294 LayoutObjectChildList m_children; 335 LayoutObjectChildList m_children;
295 336
337 // The representation of the rows and their cells (CellStruct).
296 Vector<RowStruct> m_grid; 338 Vector<RowStruct> m_grid;
339
340 // The logical offset of each row from the top of the section.
341 //
342 // Note that this Vector has one more entry than the number of rows so that
343 // we can keep track of the final size of the section
344 // (m_rowPos[m_grid.size() + 1]).
345 //
346 // To know a row's height at |rowIndex|, use the formula:
347 // m_rowPos[rowIndex + 1] - m_rowPos[rowIndex]
297 Vector<int> m_rowPos; 348 Vector<int> m_rowPos;
298 349
299 // the current insertion position 350 // The current insertion position in the grid.
351 // The position is used when inserting a new cell into the section to
352 // know where it should be inserted and expand our internal structure.
353 //
354 // The reason for them is that we process cells as we discover them
355 // during parsing or during recalcCells (ie in DOM order). This means
356 // that we can discover changes in the structure later (e.g. due to
357 // colspans, extra cells, ...).
358 //
359 // Do not use outside of recalcCells and addChild.
300 unsigned m_cCol; 360 unsigned m_cCol;
301 unsigned m_cRow; 361 unsigned m_cRow;
302 362
303 int m_outerBorderStart; 363 int m_outerBorderStart;
304 int m_outerBorderEnd; 364 int m_outerBorderEnd;
305 int m_outerBorderBefore; 365 int m_outerBorderBefore;
306 int m_outerBorderAfter; 366 int m_outerBorderAfter;
307 367
308 bool m_needsCellRecalc; 368 bool m_needsCellRecalc;
309 369
310 // This HashSet holds the overflowing cells for faster painting. 370 // This HashSet holds the overflowing cells for faster painting.
311 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it wi ll be empty 371 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it wi ll be empty
312 // and m_forceSlowPaintPathWithOverflowingCell will be set to save memory. 372 // and m_forceSlowPaintPathWithOverflowingCell will be set to save memory.
313 HashSet<LayoutTableCell*> m_overflowingCells; 373 HashSet<LayoutTableCell*> m_overflowingCells;
314 bool m_forceSlowPaintPathWithOverflowingCell; 374 bool m_forceSlowPaintPathWithOverflowingCell;
315 375
316 bool m_hasMultipleCellLevels; 376 bool m_hasMultipleCellLevels;
317 377
318 // This map holds the collapsed border values for cells with collapsed borde rs. 378 // This map holds the collapsed border values for cells with collapsed borde rs.
319 // It is held at LayoutTableSection level to spare memory consumption by tab le cells. 379 // It is held at LayoutTableSection level to spare memory consumption by tab le cells.
320 using CellsCollapsedBordersMap = HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>; 380 using CellsCollapsedBordersMap = HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>;
321 CellsCollapsedBordersMap m_cellsCollapsedBorders; 381 CellsCollapsedBordersMap m_cellsCollapsedBorders;
322 }; 382 };
323 383
324 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); 384 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection());
325 385
326 } // namespace blink 386 } // namespace blink
327 387
328 #endif // LayoutTableSection_h 388 #endif // LayoutTableSection_h
OLDNEW
« Source/core/layout/LayoutTable.h ('K') | « Source/core/layout/LayoutTable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698