| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 spanInCurrentEffectiveColumn = span; | 111 spanInCurrentEffectiveColumn = span; |
| 112 } else { | 112 } else { |
| 113 if (span < m_table->spanOfEffectiveColumn(currentEffectiveColumn
)) { | 113 if (span < m_table->spanOfEffectiveColumn(currentEffectiveColumn
)) { |
| 114 m_table->splitEffectiveColumn(currentEffectiveColumn, span); | 114 m_table->splitEffectiveColumn(currentEffectiveColumn, span); |
| 115 nEffCols++; | 115 nEffCols++; |
| 116 m_width.append(Length()); | 116 m_width.append(Length()); |
| 117 } | 117 } |
| 118 spanInCurrentEffectiveColumn = m_table->spanOfEffectiveColumn(cu
rrentEffectiveColumn); | 118 spanInCurrentEffectiveColumn = m_table->spanOfEffectiveColumn(cu
rrentEffectiveColumn); |
| 119 } | 119 } |
| 120 // TODO(alancutter): Make this work correctly for calc lengths. | 120 // TODO(alancutter): Make this work correctly for calc lengths. |
| 121 if ((colStyleLogicalWidth.isFixed() || colStyleLogicalWidth.hasPerce
nt()) && colStyleLogicalWidth.isPositive()) { | 121 if ((colStyleLogicalWidth.isFixed() || colStyleLogicalWidth.isPercen
tOrCalc()) && colStyleLogicalWidth.isPositive()) { |
| 122 m_width[currentEffectiveColumn] = colStyleLogicalWidth; | 122 m_width[currentEffectiveColumn] = colStyleLogicalWidth; |
| 123 m_width[currentEffectiveColumn] *= spanInCurrentEffectiveColumn; | 123 m_width[currentEffectiveColumn] *= spanInCurrentEffectiveColumn; |
| 124 usedWidth += effectiveColWidth * spanInCurrentEffectiveColumn; | 124 usedWidth += effectiveColWidth * spanInCurrentEffectiveColumn; |
| 125 } | 125 } |
| 126 span -= spanInCurrentEffectiveColumn; | 126 span -= spanInCurrentEffectiveColumn; |
| 127 currentEffectiveColumn++; | 127 currentEffectiveColumn++; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Iterate over the first row in case some are unspecified. | 131 // Iterate over the first row in case some are unspecified. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 <table style="background-color:blue"><tr><td> | 192 <table style="background-color:blue"><tr><td> |
| 193 <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> |
| 194 Content | 194 Content |
| 195 </td></tr></table> | 195 </td></tr></table> |
| 196 </td></tr></table> | 196 </td></tr></table> |
| 197 </td></tr></table> | 197 </td></tr></table> |
| 198 */ | 198 */ |
| 199 // 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. |
| 200 // 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 |
| 201 // widths be infinite. | 201 // widths be infinite. |
| 202 if (m_table->style()->logicalWidth().hasPercent() && maxWidth < tableMaxWidt
h) | 202 if (m_table->style()->logicalWidth().isPercentOrCalc() && maxWidth < tableMa
xWidth) |
| 203 maxWidth = LayoutUnit(tableMaxWidth); | 203 maxWidth = LayoutUnit(tableMaxWidth); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void TableLayoutAlgorithmFixed::layout() | 206 void TableLayoutAlgorithmFixed::layout() |
| 207 { | 207 { |
| 208 int tableLogicalWidth = (m_table->logicalWidth() - m_table->bordersPaddingAn
dSpacingInRowDirection()).toInt(); | 208 int tableLogicalWidth = (m_table->logicalWidth() - m_table->bordersPaddingAn
dSpacingInRowDirection()).toInt(); |
| 209 unsigned nEffCols = m_table->numEffectiveColumns(); | 209 unsigned nEffCols = m_table->numEffectiveColumns(); |
| 210 | 210 |
| 211 // 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. |
| 212 // 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. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 225 float totalPercent = 0; | 225 float totalPercent = 0; |
| 226 | 226 |
| 227 // Compute requirements and try to satisfy fixed and percent widths. | 227 // Compute requirements and try to satisfy fixed and percent widths. |
| 228 // Percentages are of the table's width, so for example | 228 // Percentages are of the table's width, so for example |
| 229 // 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 |
| 230 // 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). |
| 231 for (unsigned i = 0; i < nEffCols; i++) { | 231 for (unsigned i = 0; i < nEffCols; i++) { |
| 232 if (m_width[i].isFixed()) { | 232 if (m_width[i].isFixed()) { |
| 233 calcWidth[i] = m_width[i].value(); | 233 calcWidth[i] = m_width[i].value(); |
| 234 totalFixedWidth += calcWidth[i]; | 234 totalFixedWidth += calcWidth[i]; |
| 235 } else if (m_width[i].hasPercent()) { | 235 } else if (m_width[i].isPercentOrCalc()) { |
| 236 // TODO(alancutter): Make this work correctly for calc lengths. | 236 // TODO(alancutter): Make this work correctly for calc lengths. |
| 237 calcWidth[i] = valueForLength(m_width[i], LayoutUnit(tableLogicalWid
th)).toInt(); | 237 calcWidth[i] = valueForLength(m_width[i], LayoutUnit(tableLogicalWid
th)).toInt(); |
| 238 totalPercentWidth += calcWidth[i]; | 238 totalPercentWidth += calcWidth[i]; |
| 239 totalPercent += m_width[i].percent(); | 239 totalPercent += m_width[i].percent(); |
| 240 } else if (m_width[i].isAuto()) { | 240 } else if (m_width[i].isAuto()) { |
| 241 numAuto++; | 241 numAuto++; |
| 242 autoSpan += m_table->spanOfEffectiveColumn(i); | 242 autoSpan += m_table->spanOfEffectiveColumn(i); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 256 if (m_width[i].isFixed()) { | 256 if (m_width[i].isFixed()) { |
| 257 calcWidth[i] = calcWidth[i] * tableLogicalWidth / totalW
idth; | 257 calcWidth[i] = calcWidth[i] * tableLogicalWidth / totalW
idth; |
| 258 totalFixedWidth += calcWidth[i]; | 258 totalFixedWidth += calcWidth[i]; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 if (totalPercent) { | 262 if (totalPercent) { |
| 263 totalPercentWidth = 0; | 263 totalPercentWidth = 0; |
| 264 for (unsigned i = 0; i < nEffCols; i++) { | 264 for (unsigned i = 0; i < nEffCols; i++) { |
| 265 // TODO(alancutter): Make this work correctly for calc lengt
hs. | 265 // TODO(alancutter): Make this work correctly for calc lengt
hs. |
| 266 if (m_width[i].hasPercent()) { | 266 if (m_width[i].isPercentOrCalc()) { |
| 267 calcWidth[i] = m_width[i].percent() * (tableLogicalWidth
- totalFixedWidth) / totalPercent; | 267 calcWidth[i] = m_width[i].percent() * (tableLogicalWidth
- totalFixedWidth) / totalPercent; |
| 268 totalPercentWidth += calcWidth[i]; | 268 totalPercentWidth += calcWidth[i]; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 totalWidth = totalFixedWidth + totalPercentWidth; | 272 totalWidth = totalFixedWidth + totalPercentWidth; |
| 273 } | 273 } |
| 274 } else { | 274 } else { |
| 275 // Divide the remaining width among the auto columns. | 275 // Divide the remaining width among the auto columns. |
| 276 ASSERT(autoSpan >= numAuto); | 276 ASSERT(autoSpan >= numAuto); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // When switching table layout algorithm, we need to dirty the preferred | 324 // When switching table layout algorithm, we need to dirty the preferred |
| 325 // logical widths as we cleared the bits without computing them. | 325 // logical widths as we cleared the bits without computing them. |
| 326 // (see calcWidthArray above.) This optimization is preferred to always | 326 // (see calcWidthArray above.) This optimization is preferred to always |
| 327 // computing the logical widths we never intended to use. | 327 // computing the logical widths we never intended to use. |
| 328 m_table->recalcSectionsIfNeeded(); | 328 m_table->recalcSectionsIfNeeded(); |
| 329 for (LayoutTableSection* section = m_table->topNonEmptySection(); section; s
ection = m_table->sectionBelow(section)) | 329 for (LayoutTableSection* section = m_table->topNonEmptySection(); section; s
ection = m_table->sectionBelow(section)) |
| 330 section->markAllCellsWidthsDirtyAndOrNeedsLayout(LayoutTableSection::Mar
kDirtyOnly); | 330 section->markAllCellsWidthsDirtyAndOrNeedsLayout(LayoutTableSection::Mar
kDirtyOnly); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace blink | 333 } // namespace blink |
| OLD | NEW |