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

Side by Side Diff: third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp

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) 2002 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org)
3 * (C) 2002 Dirk Mueller (mueller@kde.org) 3 * (C) 2002 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License. 9 * version 2 of the License.
10 * 10 *
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (child->IsLayoutTableCol()) { 48 if (child->IsLayoutTableCol()) {
49 // LayoutTableCols don't have the concept of preferred logical width, but 49 // LayoutTableCols don't have the concept of preferred logical width, but
50 // we need to clear their dirty bits so that if we call 50 // we need to clear their dirty bits so that if we call
51 // setPreferredWidthsDirty(true) on a col or one of its descendants, we'll 51 // setPreferredWidthsDirty(true) on a col or one of its descendants, we'll
52 // mark it's ancestors as dirty. 52 // mark it's ancestors as dirty.
53 ToLayoutTableCol(child)->ClearPreferredLogicalWidthsDirtyBits(); 53 ToLayoutTableCol(child)->ClearPreferredLogicalWidthsDirtyBits();
54 } else if (child->IsTableSection()) { 54 } else if (child->IsTableSection()) {
55 LayoutTableSection* section = ToLayoutTableSection(child); 55 LayoutTableSection* section = ToLayoutTableSection(child);
56 unsigned num_rows = section->NumRows(); 56 unsigned num_rows = section->NumRows();
57 for (unsigned i = 0; i < num_rows; i++) { 57 for (unsigned i = 0; i < num_rows; i++) {
58 if (eff_col >= section->NumCols(i)) 58 if (eff_col >= section->NumEffectiveColumns(i))
59 continue; 59 continue;
60 auto& grid_cell = section->GridCellAt(i, eff_col); 60 auto& grid_cell = section->GridCellAt(i, eff_col);
61 LayoutTableCell* cell = grid_cell.PrimaryCell(); 61 LayoutTableCell* cell = grid_cell.PrimaryCell();
62 62
63 if (grid_cell.InColSpan() || !cell) 63 if (grid_cell.InColSpan() || !cell)
64 continue; 64 continue;
65 column_layout.column_has_no_cells = false; 65 column_layout.column_has_no_cells = false;
66 66
67 if (cell->MaxPreferredLogicalWidth()) 67 if (cell->MaxPreferredLogicalWidth())
68 column_layout.empty_cells_only = false; 68 column_layout.empty_cells_only = false;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 unsigned n_eff_cols = table_->NumEffectiveColumns(); 163 unsigned n_eff_cols = table_->NumEffectiveColumns();
164 layout_struct_.resize(n_eff_cols); 164 layout_struct_.resize(n_eff_cols);
165 layout_struct_.Fill(Layout()); 165 layout_struct_.Fill(Layout());
166 span_cells_.Fill(0); 166 span_cells_.Fill(0);
167 167
168 Length group_logical_width; 168 Length group_logical_width;
169 unsigned current_column = 0; 169 unsigned current_column = 0;
170 for (LayoutTableCol* column = table_->FirstColumn(); column; 170 for (LayoutTableCol* column = table_->FirstColumn(); column;
171 column = column->NextColumn()) { 171 column = column->NextColumn()) {
172 if (column->IsTableColumnGroupWithColumnChildren()) { 172 if (!column->IsInnermost()) {
173 group_logical_width = column->Style()->LogicalWidth(); 173 group_logical_width = column->Style()->LogicalWidth();
174 } else { 174 } else {
175 Length col_logical_width = column->Style()->LogicalWidth(); 175 Length col_logical_width = column->Style()->LogicalWidth();
176 // FIXME: calc() on tables should be handled consistently with other 176 // FIXME: calc() on tables should be handled consistently with other
177 // lengths. See bug: https://crbug.com/382725 177 // lengths. See bug: https://crbug.com/382725
178 if (col_logical_width.IsCalculated() || col_logical_width.IsAuto()) 178 if (col_logical_width.IsCalculated() || col_logical_width.IsAuto())
179 col_logical_width = group_logical_width; 179 col_logical_width = group_logical_width;
180 // TODO(alancutter): Make this work correctly for calc lengths. 180 // TODO(alancutter): Make this work correctly for calc lengths.
181 if ((col_logical_width.IsFixed() || 181 if ((col_logical_width.IsFixed() ||
182 col_logical_width.IsPercentOrCalc()) && 182 col_logical_width.IsPercentOrCalc()) &&
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 break; 359 break;
360 360
361 unsigned span = cell->ColSpan(); 361 unsigned span = cell->ColSpan();
362 362
363 Length cell_logical_width = cell->StyleOrColLogicalWidth(); 363 Length cell_logical_width = cell->StyleOrColLogicalWidth();
364 // FIXME: calc() on tables should be handled consistently with other 364 // FIXME: calc() on tables should be handled consistently with other
365 // lengths. See bug: https://crbug.com/382725 365 // lengths. See bug: https://crbug.com/382725
366 if (cell_logical_width.IsZero() || cell_logical_width.IsCalculated()) 366 if (cell_logical_width.IsZero() || cell_logical_width.IsCalculated())
367 cell_logical_width = Length(); // Make it Auto 367 cell_logical_width = Length(); // Make it Auto
368 368
369 unsigned eff_col = 369 unsigned eff_col = cell->EffectiveColumnIndex();
370 table_->AbsoluteColumnToEffectiveColumn(cell->AbsoluteColumnIndex());
371 size_t last_col = eff_col; 370 size_t last_col = eff_col;
372 int cell_min_logical_width = 371 int cell_min_logical_width =
373 (cell->MinPreferredLogicalWidth() + spacing_in_row_direction).ToInt(); 372 (cell->MinPreferredLogicalWidth() + spacing_in_row_direction).ToInt();
374 int cell_max_logical_width = 373 int cell_max_logical_width =
375 (cell->MaxPreferredLogicalWidth() + spacing_in_row_direction).ToInt(); 374 (cell->MaxPreferredLogicalWidth() + spacing_in_row_direction).ToInt();
376 float total_percent = 0; 375 float total_percent = 0;
377 int span_min_logical_width = 0; 376 int span_min_logical_width = 0;
378 int span_max_logical_width = 0; 377 int span_max_logical_width = 0;
379 bool all_cols_are_percent = true; 378 bool all_cols_are_percent = true;
380 bool all_cols_are_fixed = true; 379 bool all_cols_are_fixed = true;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 int reduce = available * min_max_diff / logical_width_beyond_min; 872 int reduce = available * min_max_diff / logical_width_beyond_min;
874 layout_struct_[i].computed_logical_width += reduce; 873 layout_struct_[i].computed_logical_width += reduce;
875 available -= reduce; 874 available -= reduce;
876 logical_width_beyond_min -= min_max_diff; 875 logical_width_beyond_min -= min_max_diff;
877 if (available >= 0) 876 if (available >= 0)
878 break; 877 break;
879 } 878 }
880 } 879 }
881 } 880 }
882 } // namespace blink 881 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698