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

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

Issue 2884573002: Replace LayoutTableCell::AbsoluteColumnIndex() with EffectiveColumnIndex()
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 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 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // Returns the primary cell at (row, effectiveColumn) if the cell exists and 186 // Returns the primary cell at (row, effectiveColumn) if the cell exists and
187 // originates from (instead of spanning into) the grid slot, or nullptr. 187 // originates from (instead of spanning into) the grid slot, or nullptr.
188 LayoutTableCell* OriginatingCellAt(unsigned row, unsigned effective_column); 188 LayoutTableCell* OriginatingCellAt(unsigned row, unsigned effective_column);
189 const LayoutTableCell* OriginatingCellAt(unsigned row, 189 const LayoutTableCell* OriginatingCellAt(unsigned row,
190 unsigned effective_column) const { 190 unsigned effective_column) const {
191 return const_cast<LayoutTableSection*>(this)->OriginatingCellAt( 191 return const_cast<LayoutTableSection*>(this)->OriginatingCellAt(
192 row, effective_column); 192 row, effective_column);
193 } 193 }
194 194
195 unsigned NumCols(unsigned row) const { return grid_[row].grid_cells.size(); } 195 unsigned NumEffectiveColumns(unsigned row) const {
196 return grid_[row].grid_cells.size();
197 }
196 198
197 // Returns null for cells with a rowspan that exceed the last row. Possibly 199 // Returns null for cells with a rowspan that exceed the last row. Possibly
198 // others. 200 // others.
199 LayoutTableRow* RowLayoutObjectAt(unsigned row) { return grid_[row].row; } 201 LayoutTableRow* RowLayoutObjectAt(unsigned row) { return grid_[row].row; }
200 const LayoutTableRow* RowLayoutObjectAt(unsigned row) const { 202 const LayoutTableRow* RowLayoutObjectAt(unsigned row) const {
201 return grid_[row].row; 203 return grid_[row].row;
202 } 204 }
203 205
204 void AppendEffectiveColumn(unsigned pos); 206 void AppendEffectiveColumn(unsigned pos);
205 void SplitEffectiveColumn(unsigned pos, unsigned first); 207 void SplitEffectiveColumn(unsigned pos, unsigned first);
206 208
207 enum BlockBorderSide { kBorderBefore, kBorderAfter }; 209 enum BlockBorderSide { kBorderBefore, kBorderAfter };
208 int CalcBlockDirectionOuterBorder(BlockBorderSide) const; 210 int CalcBlockDirectionOuterBorder(BlockBorderSide) const;
209 enum InlineBorderSide { kBorderStart, kBorderEnd }; 211 enum InlineBorderSide { kBorderStart, kBorderEnd };
210 int CalcInlineDirectionOuterBorder(InlineBorderSide) const; 212 int CalcInlineDirectionOuterBorder(InlineBorderSide) const;
211 void RecalcOuterBorder(); 213 void RecalcOuterBorder();
212 214
213 int OuterBorderBefore() const { return outer_border_before_; } 215 int OuterBorderBefore() const { return outer_border_before_; }
214 int OuterBorderAfter() const { return outer_border_after_; } 216 int OuterBorderAfter() const { return outer_border_after_; }
215 int OuterBorderStart() const { return outer_border_start_; } 217 int OuterBorderStart() const { return outer_border_start_; }
216 int OuterBorderEnd() const { return outer_border_end_; } 218 int OuterBorderEnd() const { return outer_border_end_; }
217 219
218 unsigned NumRows() const { 220 unsigned NumRows() const {
219 DCHECK(!NeedsCellRecalc()); 221 DCHECK(!NeedsCellRecalc());
220 return grid_.size(); 222 return grid_.size();
221 } 223 }
222 unsigned NumEffectiveColumns() const; 224 // This is slow. Use Table()->NumEffectiveColumns() instead if possible.
225 unsigned MaxNumEffectiveColumnsOfRows() const;
223 226
224 // recalcCells() is used when we are not sure about the section's structure 227 // recalcCells() is used when we are not sure about the section's structure
225 // and want to do an expensive (but safe) reconstruction of m_grid from 228 // and want to do an expensive (but safe) reconstruction of m_grid from
226 // scratch. 229 // scratch.
227 // An example of this is inserting a new cell in the middle of an existing 230 // An example of this is inserting a new cell in the middle of an existing
228 // row or removing a row. 231 // row or removing a row.
229 // 232 //
230 // Accessing m_grid when m_needsCellRecalc is set is UNSAFE as pointers can 233 // Accessing m_grid when m_needsCellRecalc is set is UNSAFE as pointers can
231 // be left dangling. Thus care should be taken in the code to check 234 // be left dangling. Thus care should be taken in the code to check
232 // m_needsCellRecalc before accessing m_grid. 235 // m_needsCellRecalc before accessing m_grid.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 int BorderSpacingForRow(unsigned row) const { 324 int BorderSpacingForRow(unsigned row) const {
322 return grid_[row].row ? Table()->VBorderSpacing() : 0; 325 return grid_[row].row ? Table()->VBorderSpacing() : 0;
323 } 326 }
324 327
325 void EnsureRows(unsigned num_rows) { 328 void EnsureRows(unsigned num_rows) {
326 if (num_rows > grid_.size()) 329 if (num_rows > grid_.size())
327 grid_.Grow(num_rows); 330 grid_.Grow(num_rows);
328 } 331 }
329 332
330 void EnsureCols(unsigned row_index, unsigned num_cols) { 333 void EnsureCols(unsigned row_index, unsigned num_cols) {
331 if (num_cols > this->NumCols(row_index)) 334 if (num_cols > grid_[row_index].grid_cells.size())
332 grid_[row_index].grid_cells.Grow(num_cols); 335 grid_[row_index].grid_cells.Grow(num_cols);
333 } 336 }
334 337
335 bool RowHasOnlySpanningCells(unsigned); 338 bool RowHasOnlySpanningCells(unsigned);
336 unsigned CalcRowHeightHavingOnlySpanningCells(unsigned, 339 unsigned CalcRowHeightHavingOnlySpanningCells(unsigned,
337 int&, 340 int&,
338 unsigned, 341 unsigned,
339 unsigned&, 342 unsigned&,
340 Vector<int>&); 343 Vector<int>&);
341 void UpdateRowsHeightHavingOnlySpanningCells(LayoutTableCell*, 344 void UpdateRowsHeightHavingOnlySpanningCells(LayoutTableCell*,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 458
456 // Whether any cell spans multiple rows or cols. 459 // Whether any cell spans multiple rows or cols.
457 bool has_spanning_cells_; 460 bool has_spanning_cells_;
458 }; 461 };
459 462
460 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, IsTableSection()); 463 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, IsTableSection());
461 464
462 } // namespace blink 465 } // namespace blink
463 466
464 #endif // LayoutTableSection_h 467 #endif // LayoutTableSection_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCol.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutTableSection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698