OLD | NEW |
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, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. |
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // in case we later call setPreferredLogicalWidthsDirty() on it later. | 170 // in case we later call setPreferredLogicalWidthsDirty() on it later. |
171 if (cell->preferredLogicalWidthsDirty()) | 171 if (cell->preferredLogicalWidthsDirty()) |
172 cell->clearPreferredLogicalWidthsDirty(); | 172 cell->clearPreferredLogicalWidthsDirty(); |
173 } | 173 } |
174 | 174 |
175 return usedWidth; | 175 return usedWidth; |
176 } | 176 } |
177 | 177 |
178 void TableLayoutAlgorithmFixed::computeIntrinsicLogicalWidths(LayoutUnit& minWid
th, LayoutUnit& maxWidth) | 178 void TableLayoutAlgorithmFixed::computeIntrinsicLogicalWidths(LayoutUnit& minWid
th, LayoutUnit& maxWidth) |
179 { | 179 { |
180 minWidth = maxWidth = calcWidthArray(); | 180 minWidth = maxWidth = LayoutUnit(calcWidthArray()); |
181 } | 181 } |
182 | 182 |
183 void TableLayoutAlgorithmFixed::applyPreferredLogicalWidthQuirks(LayoutUnit& min
Width, LayoutUnit& maxWidth) const | 183 void TableLayoutAlgorithmFixed::applyPreferredLogicalWidthQuirks(LayoutUnit& min
Width, LayoutUnit& maxWidth) const |
184 { | 184 { |
185 Length tableLogicalWidth = m_table->style()->logicalWidth(); | 185 Length tableLogicalWidth = m_table->style()->logicalWidth(); |
186 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) | 186 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) { |
187 minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - m_t
able->bordersPaddingAndSpacingInRowDirection()); | 187 minWidth = maxWidth = LayoutUnit(max(minWidth, LayoutUnit(tableLogicalWi
dth.value() - m_table->bordersPaddingAndSpacingInRowDirection())).floor()); |
| 188 } |
188 | 189 |
189 /* | 190 /* |
190 <table style="width:100%; background-color:red"><tr><td> | 191 <table style="width:100%; background-color:red"><tr><td> |
191 <table style="background-color:blue"><tr><td> | 192 <table style="background-color:blue"><tr><td> |
192 <table style="width:100%; background-color:green; table-layout:f
ixed"><tr><td> | 193 <table style="width:100%; background-color:green; table-layout:f
ixed"><tr><td> |
193 Content | 194 Content |
194 </td></tr></table> | 195 </td></tr></table> |
195 </td></tr></table> | 196 </td></tr></table> |
196 </td></tr></table> | 197 </td></tr></table> |
197 */ | 198 */ |
198 // In this example, the two inner tables should be as large as the outer tab
le. | 199 // In this example, the two inner tables should be as large as the outer tab
le. |
199 // We can achieve this effect by making the maxwidth of fixed tables with pe
rcentage | 200 // We can achieve this effect by making the maxwidth of fixed tables with pe
rcentage |
200 // widths be infinite. | 201 // widths be infinite. |
201 if (m_table->style()->logicalWidth().hasPercent() && maxWidth < tableMaxWidt
h) | 202 if (m_table->style()->logicalWidth().hasPercent() && maxWidth < tableMaxWidt
h) |
202 maxWidth = tableMaxWidth; | 203 maxWidth = LayoutUnit(tableMaxWidth); |
203 } | 204 } |
204 | 205 |
205 void TableLayoutAlgorithmFixed::layout() | 206 void TableLayoutAlgorithmFixed::layout() |
206 { | 207 { |
207 int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAnd
SpacingInRowDirection(); | 208 int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAnd
SpacingInRowDirection(); |
208 unsigned nEffCols = m_table->numEffCols(); | 209 unsigned nEffCols = m_table->numEffCols(); |
209 | 210 |
210 // FIXME: It is possible to be called without having properly updated our in
ternal representation. | 211 // FIXME: It is possible to be called without having properly updated our in
ternal representation. |
211 // This means that our preferred logical widths were not recomputed as expec
ted. | 212 // This means that our preferred logical widths were not recomputed as expec
ted. |
212 if (nEffCols != m_width.size()) { | 213 if (nEffCols != m_width.size()) { |
(...skipping 13 matching lines...) Expand all Loading... |
226 // Compute requirements and try to satisfy fixed and percent widths. | 227 // Compute requirements and try to satisfy fixed and percent widths. |
227 // Percentages are of the table's width, so for example | 228 // Percentages are of the table's width, so for example |
228 // for a table width of 100px with columns (40px, 10%), the 10% compute | 229 // for a table width of 100px with columns (40px, 10%), the 10% compute |
229 // to 10px here, and will scale up to 20px in the final (80px, 20px). | 230 // to 10px here, and will scale up to 20px in the final (80px, 20px). |
230 for (unsigned i = 0; i < nEffCols; i++) { | 231 for (unsigned i = 0; i < nEffCols; i++) { |
231 if (m_width[i].isFixed()) { | 232 if (m_width[i].isFixed()) { |
232 calcWidth[i] = m_width[i].value(); | 233 calcWidth[i] = m_width[i].value(); |
233 totalFixedWidth += calcWidth[i]; | 234 totalFixedWidth += calcWidth[i]; |
234 } else if (m_width[i].hasPercent()) { | 235 } else if (m_width[i].hasPercent()) { |
235 // TODO(alancutter): Make this work correctly for calc lengths. | 236 // TODO(alancutter): Make this work correctly for calc lengths. |
236 calcWidth[i] = valueForLength(m_width[i], tableLogicalWidth); | 237 calcWidth[i] = valueForLength(m_width[i], LayoutUnit(tableLogicalWid
th)); |
237 totalPercentWidth += calcWidth[i]; | 238 totalPercentWidth += calcWidth[i]; |
238 totalPercent += m_width[i].percent(); | 239 totalPercent += m_width[i].percent(); |
239 } else if (m_width[i].isAuto()) { | 240 } else if (m_width[i].isAuto()) { |
240 numAuto++; | 241 numAuto++; |
241 autoSpan += m_table->spanOfEffCol(i); | 242 autoSpan += m_table->spanOfEffCol(i); |
242 } | 243 } |
243 } | 244 } |
244 | 245 |
245 int hspacing = m_table->hBorderSpacing(); | 246 int hspacing = m_table->hBorderSpacing(); |
246 int totalWidth = totalFixedWidth + totalPercentWidth; | 247 int totalWidth = totalFixedWidth + totalPercentWidth; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 LayoutTableRow* row = section->rowLayoutObjectAt(i); | 331 LayoutTableRow* row = section->rowLayoutObjectAt(i); |
331 if (!row) | 332 if (!row) |
332 continue; | 333 continue; |
333 for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) | 334 for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) |
334 cell->setPreferredLogicalWidthsDirty(); | 335 cell->setPreferredLogicalWidthsDirty(); |
335 } | 336 } |
336 } | 337 } |
337 } | 338 } |
338 | 339 |
339 } // namespace blink | 340 } // namespace blink |
OLD | NEW |