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 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 Loading... | |
| 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 (<tbody>), header | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
Would it make sense to be more CSS-centric and les
Julien - ping for review
2015/09/04 14:36:16
Yes and amended to talk about display values inste
| |
| 71 // group (<thead>) and footer group (<tfoot>). | |
| 72 // | |
| 73 // The object holds the internal representation of the rows (m_grid). See | |
| 74 // recalccells() below for some extra explanation. | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
recalcCells().
Julien - ping for review
2015/09/04 14:36:16
Fixed.
| |
| 75 // | |
| 76 // A lot of the complexity in this class is related to handling rowspan, colspan | |
| 77 // or just non-regular tables. | |
| 78 // | |
| 79 // Example of rowspan / colspan leading to overlapping cells (rowspan and | |
| 80 // colspan are overlapping): | |
| 81 // <table> | |
| 82 // <tr> | |
| 83 // <td>first row</td> | |
| 84 // <td rowspan="2">rowspan</td> | |
| 85 // </tr> | |
| 86 // <tr> | |
| 87 // <td colspan="2">colspan</td> | |
| 88 // </tr> | |
| 89 // </table> | |
| 90 // | |
| 91 // Example of non-regular table (missing one cell in the first row): | |
| 92 // <!DOCTYPE html> | |
| 93 // <table> | |
| 94 // <tr><td>First row only child.</td></tr> | |
| 95 // <tr> | |
| 96 // <td>Second row first child</td> | |
| 97 // <td>Second row second child</td> | |
| 98 // </tr> | |
| 99 // </table> | |
| 70 class CORE_EXPORT LayoutTableSection final : public LayoutBox { | 100 class CORE_EXPORT LayoutTableSection final : public LayoutBox { |
| 71 public: | 101 public: |
| 72 LayoutTableSection(Element*); | 102 LayoutTableSection(Element*); |
| 73 ~LayoutTableSection() override; | 103 ~LayoutTableSection() override; |
| 74 | 104 |
| 75 LayoutTableRow* firstRow() const; | 105 LayoutTableRow* firstRow() const; |
| 76 LayoutTableRow* lastRow() const; | 106 LayoutTableRow* lastRow() const; |
| 77 | 107 |
| 78 const LayoutObjectChildList* children() const { return &m_children; } | 108 const LayoutObjectChildList* children() const { return &m_children; } |
| 79 LayoutObjectChildList* children() { return &m_children; } | 109 LayoutObjectChildList* children() { return &m_children; } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 int calcInlineDirectionOuterBorder(InlineBorderSide) const; | 222 int calcInlineDirectionOuterBorder(InlineBorderSide) const; |
| 193 void recalcOuterBorder(); | 223 void recalcOuterBorder(); |
| 194 | 224 |
| 195 int outerBorderBefore() const { return m_outerBorderBefore; } | 225 int outerBorderBefore() const { return m_outerBorderBefore; } |
| 196 int outerBorderAfter() const { return m_outerBorderAfter; } | 226 int outerBorderAfter() const { return m_outerBorderAfter; } |
| 197 int outerBorderStart() const { return m_outerBorderStart; } | 227 int outerBorderStart() const { return m_outerBorderStart; } |
| 198 int outerBorderEnd() const { return m_outerBorderEnd; } | 228 int outerBorderEnd() const { return m_outerBorderEnd; } |
| 199 | 229 |
| 200 unsigned numRows() const { return m_grid.size(); } | 230 unsigned numRows() const { return m_grid.size(); } |
| 201 unsigned numColumns() const; | 231 unsigned numColumns() const; |
| 232 | |
| 233 // recalccells() is used when we are not sure about the section's structure | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
recalcCells(). Shall I mail you a new Shift key? ;
Julien - ping for review
2015/09/04 14:36:16
How about a new pinky instead? Or better coffee? :
| |
| 234 // and want to do an expensive (but safe) reconstruction of m_grid from | |
| 235 // scratch. | |
| 236 // An example of this is inserting a new cell in the middle of an existing | |
| 237 // row or removing a row. | |
| 238 // | |
| 239 // Accessing m_grid when this flag is set is UNSAFE as pointers can be | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
"this flag" is not declared at this point.
Julien - ping for review
2015/09/04 14:36:16
s/this flag/m_needsCellRecalc
| |
| 240 // leaving dangling. Thus care should be taken in the code to check | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
"left dangling"?
Julien - ping for review
2015/09/04 14:36:16
Doh', fixed!
| |
| 241 // m_needsCellRecalc before accessing m_grid. | |
| 202 void recalcCells(); | 242 void recalcCells(); |
| 203 void recalcCellsIfNeeded() | 243 void recalcCellsIfNeeded() |
| 204 { | 244 { |
| 205 if (m_needsCellRecalc) | 245 if (m_needsCellRecalc) |
| 206 recalcCells(); | 246 recalcCells(); |
| 207 } | 247 } |
| 208 | 248 |
| 209 bool needsCellRecalc() const { return m_needsCellRecalc; } | 249 bool needsCellRecalc() const { return m_needsCellRecalc; } |
| 210 void setNeedsCellRecalc(); | 250 void setNeedsCellRecalc(); |
| 211 | 251 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 | 326 |
| 287 // These two functions take a rectangle as input that has been flipped by lo gicalRectForWritingModeAndDirection. | 327 // 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. | 328 // The returned span of rows or columns is end-exclusive, and empty if start ==end. |
| 289 CellSpan spannedRows(const LayoutRect& flippedRect) const; | 329 CellSpan spannedRows(const LayoutRect& flippedRect) const; |
| 290 CellSpan spannedColumns(const LayoutRect& flippedRect) const; | 330 CellSpan spannedColumns(const LayoutRect& flippedRect) const; |
| 291 | 331 |
| 292 void setLogicalPositionForCell(LayoutTableCell*, unsigned effectiveColumn) c onst; | 332 void setLogicalPositionForCell(LayoutTableCell*, unsigned effectiveColumn) c onst; |
| 293 | 333 |
| 294 LayoutObjectChildList m_children; | 334 LayoutObjectChildList m_children; |
| 295 | 335 |
| 336 // The representation of the rows. | |
|
mstensho (USE GERRIT)
2015/09/04 13:06:53
and their cells.
Julien - ping for review
2015/09/04 14:36:16
Amended:
// The representation of the rows and th
| |
| 296 Vector<RowStruct> m_grid; | 337 Vector<RowStruct> m_grid; |
| 338 | |
| 339 // The logical offset of each row from the top of the section. | |
| 340 // | |
| 341 // Note that this Vector has one more entry than the number of rows so that | |
| 342 // we can keep track of the final size of the section | |
| 343 // (m_rowPos[m_grid.size() + 1]). | |
| 344 // | |
| 345 // To know a row's height at |rowIndex|, use the formula: | |
| 346 // m_rowPos[rowIndex + 1] - m_rowPos[rowIndex] | |
| 297 Vector<int> m_rowPos; | 347 Vector<int> m_rowPos; |
| 298 | 348 |
| 299 // the current insertion position | 349 // The current insertion position in the grid. |
| 350 // The position is used when inserting a new cell into the section to | |
| 351 // know where it should be inserted and expand our internal structure. | |
| 352 // | |
| 353 // The reason for them is that we process cells as we discover them | |
| 354 // during parsing or during recalcCells (ie in DOM order). This means | |
| 355 // that we can discover changes in the structure later (e.g. due to | |
| 356 // colspans, extra cells, ...). | |
| 357 // | |
| 358 // Do not use outside of recalcCells and addChild. | |
| 300 unsigned m_cCol; | 359 unsigned m_cCol; |
| 301 unsigned m_cRow; | 360 unsigned m_cRow; |
| 302 | 361 |
| 303 int m_outerBorderStart; | 362 int m_outerBorderStart; |
| 304 int m_outerBorderEnd; | 363 int m_outerBorderEnd; |
| 305 int m_outerBorderBefore; | 364 int m_outerBorderBefore; |
| 306 int m_outerBorderAfter; | 365 int m_outerBorderAfter; |
| 307 | 366 |
| 308 bool m_needsCellRecalc; | 367 bool m_needsCellRecalc; |
| 309 | 368 |
| 310 // This HashSet holds the overflowing cells for faster painting. | 369 // This HashSet holds the overflowing cells for faster painting. |
| 311 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it wi ll be empty | 370 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it wi ll be empty |
| 312 // and m_forceSlowPaintPathWithOverflowingCell will be set to save memory. | 371 // and m_forceSlowPaintPathWithOverflowingCell will be set to save memory. |
| 313 HashSet<LayoutTableCell*> m_overflowingCells; | 372 HashSet<LayoutTableCell*> m_overflowingCells; |
| 314 bool m_forceSlowPaintPathWithOverflowingCell; | 373 bool m_forceSlowPaintPathWithOverflowingCell; |
| 315 | 374 |
| 316 bool m_hasMultipleCellLevels; | 375 bool m_hasMultipleCellLevels; |
| 317 | 376 |
| 318 // This map holds the collapsed border values for cells with collapsed borde rs. | 377 // 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. | 378 // It is held at LayoutTableSection level to spare memory consumption by tab le cells. |
| 320 using CellsCollapsedBordersMap = HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>; | 379 using CellsCollapsedBordersMap = HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>; |
| 321 CellsCollapsedBordersMap m_cellsCollapsedBorders; | 380 CellsCollapsedBordersMap m_cellsCollapsedBorders; |
| 322 }; | 381 }; |
| 323 | 382 |
| 324 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); | 383 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); |
| 325 | 384 |
| 326 } // namespace blink | 385 } // namespace blink |
| 327 | 386 |
| 328 #endif // LayoutTableSection_h | 387 #endif // LayoutTableSection_h |
| OLD | NEW |