| 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, 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // FIXME: calc() on tables should be handled consistently wi
th other lengths. See bug: https://crbug.com/382725 | 83 // FIXME: calc() on tables should be handled consistently wi
th other lengths. See bug: https://crbug.com/382725 |
| 84 if (cellLogicalWidth.isCalculated()) | 84 if (cellLogicalWidth.isCalculated()) |
| 85 cellLogicalWidth = Length(); // Make it Auto | 85 cellLogicalWidth = Length(); // Make it Auto |
| 86 if (cellLogicalWidth.value() > cCellMaxWidth) | 86 if (cellLogicalWidth.value() > cCellMaxWidth) |
| 87 cellLogicalWidth.setValue(cCellMaxWidth); | 87 cellLogicalWidth.setValue(cCellMaxWidth); |
| 88 if (cellLogicalWidth.isNegative()) | 88 if (cellLogicalWidth.isNegative()) |
| 89 cellLogicalWidth.setValue(0); | 89 cellLogicalWidth.setValue(0); |
| 90 switch (cellLogicalWidth.type()) { | 90 switch (cellLogicalWidth.type()) { |
| 91 case Fixed: | 91 case Fixed: |
| 92 // ignore width=0 | 92 // ignore width=0 |
| 93 if (cellLogicalWidth.isPositive() && !columnLayout.logic
alWidth.hasPercent()) { | 93 if (cellLogicalWidth.isPositive() && !columnLayout.logic
alWidth.isPercentOrCalc()) { |
| 94 int logicalWidth = cell->adjustBorderBoxLogicalWidth
ForBoxSizing(cellLogicalWidth.value()).toInt(); | 94 int logicalWidth = cell->adjustBorderBoxLogicalWidth
ForBoxSizing(cellLogicalWidth.value()).toInt(); |
| 95 if (columnLayout.logicalWidth.isFixed()) { | 95 if (columnLayout.logicalWidth.isFixed()) { |
| 96 // Nav/IE weirdness | 96 // Nav/IE weirdness |
| 97 if ((logicalWidth > columnLayout.logicalWidth.va
lue()) | 97 if ((logicalWidth > columnLayout.logicalWidth.va
lue()) |
| 98 || ((columnLayout.logicalWidth.value() == lo
gicalWidth) && (maxContributor == cell))) { | 98 || ((columnLayout.logicalWidth.value() == lo
gicalWidth) && (maxContributor == cell))) { |
| 99 columnLayout.logicalWidth.setValue(Fixed, lo
gicalWidth); | 99 columnLayout.logicalWidth.setValue(Fixed, lo
gicalWidth); |
| 100 fixedContributor = cell; | 100 fixedContributor = cell; |
| 101 } | 101 } |
| 102 } else { | 102 } else { |
| 103 columnLayout.logicalWidth.setValue(Fixed, logica
lWidth); | 103 columnLayout.logicalWidth.setValue(Fixed, logica
lWidth); |
| 104 fixedContributor = cell; | 104 fixedContributor = cell; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 break; | 107 break; |
| 108 case Percent: | 108 case Percent: |
| 109 m_hasPercent = true; | 109 m_hasPercent = true; |
| 110 // TODO(alancutter): Make this work correctly for calc l
engths. | 110 // TODO(alancutter): Make this work correctly for calc l
engths. |
| 111 if (cellLogicalWidth.isPositive() && (!columnLayout.logi
calWidth.hasPercent() || cellLogicalWidth.value() > columnLayout.logicalWidth.va
lue())) | 111 if (cellLogicalWidth.isPositive() && (!columnLayout.logi
calWidth.isPercentOrCalc() || cellLogicalWidth.value() > columnLayout.logicalWid
th.value())) |
| 112 columnLayout.logicalWidth = cellLogicalWidth; | 112 columnLayout.logicalWidth = cellLogicalWidth; |
| 113 break; | 113 break; |
| 114 default: | 114 default: |
| 115 break; | 115 break; |
| 116 } | 116 } |
| 117 } else if (!effCol || section->primaryCellAt(i, effCol - 1) != c
ell) { | 117 } else if (!effCol || section->primaryCellAt(i, effCol - 1) != c
ell) { |
| 118 // If a cell originates in this spanning column ensure we ha
ve a min/max width of at least 1px for it. | 118 // If a cell originates in this spanning column ensure we ha
ve a min/max width of at least 1px for it. |
| 119 columnLayout.minLogicalWidth = std::max<int>(columnLayout.mi
nLogicalWidth, cell->maxPreferredLogicalWidth() ? 1 : 0); | 119 columnLayout.minLogicalWidth = std::max<int>(columnLayout.mi
nLogicalWidth, cell->maxPreferredLogicalWidth() ? 1 : 0); |
| 120 | 120 |
| 121 // This spanning cell originates in this column. Insert the
cell into spanning cells list. | 121 // This spanning cell originates in this column. Insert the
cell into spanning cells list. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 150 unsigned currentColumn = 0; | 150 unsigned currentColumn = 0; |
| 151 for (LayoutTableCol* column = m_table->firstColumn(); column; column = colum
n->nextColumn()) { | 151 for (LayoutTableCol* column = m_table->firstColumn(); column; column = colum
n->nextColumn()) { |
| 152 if (column->isTableColumnGroupWithColumnChildren()) { | 152 if (column->isTableColumnGroupWithColumnChildren()) { |
| 153 groupLogicalWidth = column->style()->logicalWidth(); | 153 groupLogicalWidth = column->style()->logicalWidth(); |
| 154 } else { | 154 } else { |
| 155 Length colLogicalWidth = column->style()->logicalWidth(); | 155 Length colLogicalWidth = column->style()->logicalWidth(); |
| 156 // FIXME: calc() on tables should be handled consistently with other
lengths. See bug: https://crbug.com/382725 | 156 // FIXME: calc() on tables should be handled consistently with other
lengths. See bug: https://crbug.com/382725 |
| 157 if (colLogicalWidth.isCalculated() || colLogicalWidth.isAuto()) | 157 if (colLogicalWidth.isCalculated() || colLogicalWidth.isAuto()) |
| 158 colLogicalWidth = groupLogicalWidth; | 158 colLogicalWidth = groupLogicalWidth; |
| 159 // TODO(alancutter): Make this work correctly for calc lengths. | 159 // TODO(alancutter): Make this work correctly for calc lengths. |
| 160 if ((colLogicalWidth.isFixed() || colLogicalWidth.hasPercent()) && c
olLogicalWidth.isZero()) | 160 if ((colLogicalWidth.isFixed() || colLogicalWidth.isPercentOrCalc())
&& colLogicalWidth.isZero()) |
| 161 colLogicalWidth = Length(); | 161 colLogicalWidth = Length(); |
| 162 unsigned effCol = m_table->absoluteColumnToEffectiveColumn(currentCo
lumn); | 162 unsigned effCol = m_table->absoluteColumnToEffectiveColumn(currentCo
lumn); |
| 163 unsigned span = column->span(); | 163 unsigned span = column->span(); |
| 164 if (!colLogicalWidth.isAuto() && span == 1 && effCol < nEffCols && m
_table->spanOfEffectiveColumn(effCol) == 1) { | 164 if (!colLogicalWidth.isAuto() && span == 1 && effCol < nEffCols && m
_table->spanOfEffectiveColumn(effCol) == 1) { |
| 165 m_layoutStruct[effCol].logicalWidth = colLogicalWidth; | 165 m_layoutStruct[effCol].logicalWidth = colLogicalWidth; |
| 166 if (colLogicalWidth.isFixed() && m_layoutStruct[effCol].maxLogic
alWidth < colLogicalWidth.value()) | 166 if (colLogicalWidth.isFixed() && m_layoutStruct[effCol].maxLogic
alWidth < colLogicalWidth.value()) |
| 167 m_layoutStruct[effCol].maxLogicalWidth = colLogicalWidth.val
ue(); | 167 m_layoutStruct[effCol].maxLogicalWidth = colLogicalWidth.val
ue(); |
| 168 } | 168 } |
| 169 currentColumn += span; | 169 currentColumn += span; |
| 170 } | 170 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 196 static bool shouldScaleColumnsForSelf(LayoutTable* table) | 196 static bool shouldScaleColumnsForSelf(LayoutTable* table) |
| 197 { | 197 { |
| 198 // Normally, scale all columns to satisfy this from CSS2.2: | 198 // Normally, scale all columns to satisfy this from CSS2.2: |
| 199 // "A percentage value for a column width is relative to the table width. | 199 // "A percentage value for a column width is relative to the table width. |
| 200 // If the table has 'width: auto', a percentage represents a constraint on t
he column's width" | 200 // If the table has 'width: auto', a percentage represents a constraint on t
he column's width" |
| 201 | 201 |
| 202 // A special case. If this table is not fixed width and contained inside | 202 // A special case. If this table is not fixed width and contained inside |
| 203 // a cell, then don't bloat the maxwidth by examining percentage growth. | 203 // a cell, then don't bloat the maxwidth by examining percentage growth. |
| 204 while (true) { | 204 while (true) { |
| 205 Length tw = table->style()->width(); | 205 Length tw = table->style()->width(); |
| 206 if ((!tw.isAuto() && !tw.hasPercent()) || table->isOutOfFlowPositioned()
) | 206 if ((!tw.isAuto() && !tw.isPercentOrCalc()) || table->isOutOfFlowPositio
ned()) |
| 207 return true; | 207 return true; |
| 208 LayoutBlock* cb = table->containingBlock(); | 208 LayoutBlock* cb = table->containingBlock(); |
| 209 | 209 |
| 210 while (!cb->isLayoutView() && !cb->isTableCell() | 210 while (!cb->isLayoutView() && !cb->isTableCell() |
| 211 && cb->style()->width().isAuto() && !cb->isOutOfFlowPositioned()) | 211 && cb->style()->width().isAuto() && !cb->isOutOfFlowPositioned()) |
| 212 cb = cb->containingBlock(); | 212 cb = cb->containingBlock(); |
| 213 | 213 |
| 214 // TODO(dgrogan): Should the second clause check for isFixed() instead? | 214 // TODO(dgrogan): Should the second clause check for isFixed() instead? |
| 215 if (!cb->isTableCell() | 215 if (!cb->isTableCell() |
| 216 || (!cb->style()->width().isAuto() && !cb->style()->width().hasPerce
nt())) | 216 || (!cb->style()->width().isAuto() && !cb->style()->width().isPercen
tOrCalc())) |
| 217 return true; | 217 return true; |
| 218 | 218 |
| 219 LayoutTableCell* cell = toLayoutTableCell(cb); | 219 LayoutTableCell* cell = toLayoutTableCell(cb); |
| 220 table = cell->table(); | 220 table = cell->table(); |
| 221 if (cell->colSpan() > 1 || table->isLogicalWidthAuto()) | 221 if (cell->colSpan() > 1 || table->isLogicalWidthAuto()) |
| 222 return false; | 222 return false; |
| 223 } | 223 } |
| 224 NOTREACHED(); | 224 NOTREACHED(); |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 240 | 240 |
| 241 // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two
places below to avoid division by zero. | 241 // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two
places below to avoid division by zero. |
| 242 // FIXME: Handle the 0% cases properly. | 242 // FIXME: Handle the 0% cases properly. |
| 243 const float epsilon = 1 / 128.0f; | 243 const float epsilon = 1 / 128.0f; |
| 244 | 244 |
| 245 float remainingPercent = 100; | 245 float remainingPercent = 100; |
| 246 for (size_t i = 0; i < m_layoutStruct.size(); ++i) { | 246 for (size_t i = 0; i < m_layoutStruct.size(); ++i) { |
| 247 minWidth += m_layoutStruct[i].effectiveMinLogicalWidth; | 247 minWidth += m_layoutStruct[i].effectiveMinLogicalWidth; |
| 248 maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth; | 248 maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth; |
| 249 if (scaleColumnsForSelf) { | 249 if (scaleColumnsForSelf) { |
| 250 if (m_layoutStruct[i].effectiveLogicalWidth.hasPercent()) { | 250 if (m_layoutStruct[i].effectiveLogicalWidth.isPercentOrCalc()) { |
| 251 float percent = std::min(static_cast<float>(m_layoutStruct[i].ef
fectiveLogicalWidth.percent()), remainingPercent); | 251 float percent = std::min(static_cast<float>(m_layoutStruct[i].ef
fectiveLogicalWidth.percent()), remainingPercent); |
| 252 float logicalWidth = static_cast<float>(m_layoutStruct[i].effect
iveMaxLogicalWidth) * 100 / std::max(percent, epsilon); | 252 float logicalWidth = static_cast<float>(m_layoutStruct[i].effect
iveMaxLogicalWidth) * 100 / std::max(percent, epsilon); |
| 253 maxPercent = std::max(logicalWidth, maxPercent); | 253 maxPercent = std::max(logicalWidth, maxPercent); |
| 254 remainingPercent -= percent; | 254 remainingPercent -= percent; |
| 255 } else { | 255 } else { |
| 256 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; | 256 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 // fall through | 352 // fall through |
| 353 default: | 353 default: |
| 354 // If the column is a percentage width, do not let the spanning
cell overwrite the | 354 // If the column is a percentage width, do not let the spanning
cell overwrite the |
| 355 // width value. This caused a mis-layout on amazon.com. | 355 // width value. This caused a mis-layout on amazon.com. |
| 356 // Sample snippet: | 356 // Sample snippet: |
| 357 // <table border=2 width=100%>< | 357 // <table border=2 width=100%>< |
| 358 // <tr><td>1</td><td colspan=2>2-3</tr> | 358 // <tr><td>1</td><td colspan=2>2-3</tr> |
| 359 // <tr><td>1</td><td colspan=2 width=100%>2-3</td></tr> | 359 // <tr><td>1</td><td colspan=2 width=100%>2-3</td></tr> |
| 360 // </table> | 360 // </table> |
| 361 // TODO(alancutter): Make this work correctly for calc lengths. | 361 // TODO(alancutter): Make this work correctly for calc lengths. |
| 362 if (!columnLayout.effectiveLogicalWidth.hasPercent()) { | 362 if (!columnLayout.effectiveLogicalWidth.isPercentOrCalc()) { |
| 363 columnLayout.effectiveLogicalWidth = Length(); | 363 columnLayout.effectiveLogicalWidth = Length(); |
| 364 allColsArePercent = false; | 364 allColsArePercent = false; |
| 365 } else { | 365 } else { |
| 366 totalPercent += columnLayout.effectiveLogicalWidth.percent()
; | 366 totalPercent += columnLayout.effectiveLogicalWidth.percent()
; |
| 367 } | 367 } |
| 368 allColsAreFixed = false; | 368 allColsAreFixed = false; |
| 369 } | 369 } |
| 370 if (!columnLayout.emptyCellsOnly) | 370 if (!columnLayout.emptyCellsOnly) |
| 371 spanHasEmptyCellsOnly = false; | 371 spanHasEmptyCellsOnly = false; |
| 372 span -= m_table->spanOfEffectiveColumn(lastCol); | 372 span -= m_table->spanOfEffectiveColumn(lastCol); |
| 373 spanMinLogicalWidth += columnLayout.effectiveMinLogicalWidth; | 373 spanMinLogicalWidth += columnLayout.effectiveMinLogicalWidth; |
| 374 spanMaxLogicalWidth += columnLayout.effectiveMaxLogicalWidth; | 374 spanMaxLogicalWidth += columnLayout.effectiveMaxLogicalWidth; |
| 375 lastCol++; | 375 lastCol++; |
| 376 cellMinLogicalWidth -= spacingInRowDirection; | 376 cellMinLogicalWidth -= spacingInRowDirection; |
| 377 cellMaxLogicalWidth -= spacingInRowDirection; | 377 cellMaxLogicalWidth -= spacingInRowDirection; |
| 378 } | 378 } |
| 379 | 379 |
| 380 // adjust table max width if needed | 380 // adjust table max width if needed |
| 381 if (cellLogicalWidth.hasPercent()) { | 381 if (cellLogicalWidth.isPercentOrCalc()) { |
| 382 if (totalPercent > cellLogicalWidth.percent() || allColsArePercent)
{ | 382 if (totalPercent > cellLogicalWidth.percent() || allColsArePercent)
{ |
| 383 // can't satify this condition, treat as variable | 383 // can't satify this condition, treat as variable |
| 384 cellLogicalWidth = Length(); | 384 cellLogicalWidth = Length(); |
| 385 } else { | 385 } else { |
| 386 maxLogicalWidth = std::max(maxLogicalWidth, static_cast<int>(std
::max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100 / cellLogicalWidth.percen
t())); | 386 maxLogicalWidth = std::max(maxLogicalWidth, static_cast<int>(std
::max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100 / cellLogicalWidth.percen
t())); |
| 387 | 387 |
| 388 // all non percent columns in the span get percent values to sum
up correctly. | 388 // all non percent columns in the span get percent values to sum
up correctly. |
| 389 float percentMissing = cellLogicalWidth.percent() - totalPercent
; | 389 float percentMissing = cellLogicalWidth.percent() - totalPercent
; |
| 390 int totalWidth = 0; | 390 int totalWidth = 0; |
| 391 for (unsigned pos = effCol; pos < lastCol; ++pos) { | 391 for (unsigned pos = effCol; pos < lastCol; ++pos) { |
| 392 if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent()) | 392 if (!m_layoutStruct[pos].effectiveLogicalWidth.isPercentOrCa
lc()) |
| 393 totalWidth += m_layoutStruct[pos].clampedEffectiveMaxLog
icalWidth(); | 393 totalWidth += m_layoutStruct[pos].clampedEffectiveMaxLog
icalWidth(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 for (unsigned pos = effCol; pos < lastCol && totalWidth > 0; ++p
os) { | 396 for (unsigned pos = effCol; pos < lastCol && totalWidth > 0; ++p
os) { |
| 397 if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent())
{ | 397 if (!m_layoutStruct[pos].effectiveLogicalWidth.isPercentOrCa
lc()) { |
| 398 float percent = percentMissing * static_cast<float>(m_la
youtStruct[pos].effectiveMaxLogicalWidth) / totalWidth; | 398 float percent = percentMissing * static_cast<float>(m_la
youtStruct[pos].effectiveMaxLogicalWidth) / totalWidth; |
| 399 totalWidth -= m_layoutStruct[pos].clampedEffectiveMaxLog
icalWidth(); | 399 totalWidth -= m_layoutStruct[pos].clampedEffectiveMaxLog
icalWidth(); |
| 400 percentMissing -= percent; | 400 percentMissing -= percent; |
| 401 if (percent > 0) | 401 if (percent > 0) |
| 402 m_layoutStruct[pos].effectiveLogicalWidth.setValue(P
ercent, percent); | 402 m_layoutStruct[pos].effectiveLogicalWidth.setValue(P
ercent, percent); |
| 403 else | 403 else |
| 404 m_layoutStruct[pos].effectiveLogicalWidth = Length()
; | 404 m_layoutStruct[pos].effectiveLogicalWidth = Length()
; |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 // make sure minWidth and maxWidth of the spanning cell are honoured | 410 // make sure minWidth and maxWidth of the spanning cell are honoured |
| 411 if (cellMinLogicalWidth > spanMinLogicalWidth) { | 411 if (cellMinLogicalWidth > spanMinLogicalWidth) { |
| 412 if (allColsAreFixed) { | 412 if (allColsAreFixed) { |
| 413 for (unsigned pos = effCol; fixedWidth > 0 && pos < lastCol; ++p
os) { | 413 for (unsigned pos = effCol; fixedWidth > 0 && pos < lastCol; ++p
os) { |
| 414 int cellLogicalWidth = std::max(m_layoutStruct[pos].effectiv
eMinLogicalWidth, static_cast<int>(cellMinLogicalWidth * m_layoutStruct[pos].log
icalWidth.value() / fixedWidth)); | 414 int cellLogicalWidth = std::max(m_layoutStruct[pos].effectiv
eMinLogicalWidth, static_cast<int>(cellMinLogicalWidth * m_layoutStruct[pos].log
icalWidth.value() / fixedWidth)); |
| 415 fixedWidth -= m_layoutStruct[pos].logicalWidth.value(); | 415 fixedWidth -= m_layoutStruct[pos].logicalWidth.value(); |
| 416 cellMinLogicalWidth -= cellLogicalWidth; | 416 cellMinLogicalWidth -= cellLogicalWidth; |
| 417 m_layoutStruct[pos].effectiveMinLogicalWidth = cellLogicalWi
dth; | 417 m_layoutStruct[pos].effectiveMinLogicalWidth = cellLogicalWi
dth; |
| 418 } | 418 } |
| 419 } else if (allColsArePercent) { | 419 } else if (allColsArePercent) { |
| 420 // In this case, we just split the colspan's min amd max widths
following the percentage. | 420 // In this case, we just split the colspan's min amd max widths
following the percentage. |
| 421 int allocatedMinLogicalWidth = 0; | 421 int allocatedMinLogicalWidth = 0; |
| 422 int allocatedMaxLogicalWidth = 0; | 422 int allocatedMaxLogicalWidth = 0; |
| 423 for (unsigned pos = effCol; pos < lastCol; ++pos) { | 423 for (unsigned pos = effCol; pos < lastCol; ++pos) { |
| 424 // TODO(alancutter): Make this work correctly for calc lengt
hs. | 424 // TODO(alancutter): Make this work correctly for calc lengt
hs. |
| 425 ASSERT(m_layoutStruct[pos].logicalWidth.hasPercent() || m_la
youtStruct[pos].effectiveLogicalWidth.hasPercent()); | 425 DCHECK(m_layoutStruct[pos].logicalWidth.isPercentOrCalc() ||
m_layoutStruct[pos].effectiveLogicalWidth.isPercentOrCalc()); |
| 426 // |allColsArePercent| means that either the logicalWidth *o
r* the effectiveLogicalWidth are percents, handle both of them here. | 426 // |allColsArePercent| means that either the logicalWidth *o
r* the effectiveLogicalWidth are percents, handle both of them here. |
| 427 float percent = m_layoutStruct[pos].logicalWidth.hasPercent(
) ? m_layoutStruct[pos].logicalWidth.percent() : m_layoutStruct[pos].effectiveLo
gicalWidth.percent(); | 427 float percent = m_layoutStruct[pos].logicalWidth.isPercentOr
Calc() ? m_layoutStruct[pos].logicalWidth.percent() : m_layoutStruct[pos].effect
iveLogicalWidth.percent(); |
| 428 int columnMinLogicalWidth = static_cast<int>(percent * cellM
inLogicalWidth / totalPercent); | 428 int columnMinLogicalWidth = static_cast<int>(percent * cellM
inLogicalWidth / totalPercent); |
| 429 int columnMaxLogicalWidth = static_cast<int>(percent * cellM
axLogicalWidth / totalPercent); | 429 int columnMaxLogicalWidth = static_cast<int>(percent * cellM
axLogicalWidth / totalPercent); |
| 430 m_layoutStruct[pos].effectiveMinLogicalWidth = std::max(m_la
youtStruct[pos].effectiveMinLogicalWidth, columnMinLogicalWidth); | 430 m_layoutStruct[pos].effectiveMinLogicalWidth = std::max(m_la
youtStruct[pos].effectiveMinLogicalWidth, columnMinLogicalWidth); |
| 431 m_layoutStruct[pos].effectiveMaxLogicalWidth = columnMaxLogi
calWidth; | 431 m_layoutStruct[pos].effectiveMaxLogicalWidth = columnMaxLogi
calWidth; |
| 432 allocatedMinLogicalWidth += columnMinLogicalWidth; | 432 allocatedMinLogicalWidth += columnMinLogicalWidth; |
| 433 allocatedMaxLogicalWidth += columnMaxLogicalWidth; | 433 allocatedMaxLogicalWidth += columnMaxLogicalWidth; |
| 434 } | 434 } |
| 435 ASSERT(allocatedMinLogicalWidth <= cellMinLogicalWidth); | 435 ASSERT(allocatedMinLogicalWidth <= cellMinLogicalWidth); |
| 436 ASSERT(allocatedMaxLogicalWidth <= cellMaxLogicalWidth); | 436 ASSERT(allocatedMaxLogicalWidth <= cellMaxLogicalWidth); |
| 437 cellMinLogicalWidth -= allocatedMinLogicalWidth; | 437 cellMinLogicalWidth -= allocatedMinLogicalWidth; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 457 int colMinLogicalWidth = std::max<int>(m_layoutStruct[po
s].effectiveMinLogicalWidth, static_cast<int>(remainingMaxLogicalWidth ? cellMin
LogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth)
/ remainingMaxLogicalWidth : cellMinLogicalWidth)); | 457 int colMinLogicalWidth = std::max<int>(m_layoutStruct[po
s].effectiveMinLogicalWidth, static_cast<int>(remainingMaxLogicalWidth ? cellMin
LogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth)
/ remainingMaxLogicalWidth : cellMinLogicalWidth)); |
| 458 colMinLogicalWidth = std::min<int>(m_layoutStruct[pos].e
ffectiveMinLogicalWidth + (cellMinLogicalWidth - remainingMinLogicalWidth), colM
inLogicalWidth); | 458 colMinLogicalWidth = std::min<int>(m_layoutStruct[pos].e
ffectiveMinLogicalWidth + (cellMinLogicalWidth - remainingMinLogicalWidth), colM
inLogicalWidth); |
| 459 remainingMaxLogicalWidth -= m_layoutStruct[pos].effectiv
eMaxLogicalWidth; | 459 remainingMaxLogicalWidth -= m_layoutStruct[pos].effectiv
eMaxLogicalWidth; |
| 460 remainingMinLogicalWidth -= m_layoutStruct[pos].effectiv
eMinLogicalWidth; | 460 remainingMinLogicalWidth -= m_layoutStruct[pos].effectiv
eMinLogicalWidth; |
| 461 cellMinLogicalWidth -= colMinLogicalWidth; | 461 cellMinLogicalWidth -= colMinLogicalWidth; |
| 462 m_layoutStruct[pos].effectiveMinLogicalWidth = colMinLog
icalWidth; | 462 m_layoutStruct[pos].effectiveMinLogicalWidth = colMinLog
icalWidth; |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 if (!cellLogicalWidth.hasPercent()) { | 467 if (!cellLogicalWidth.isPercentOrCalc()) { |
| 468 if (cellMaxLogicalWidth > spanMaxLogicalWidth) { | 468 if (cellMaxLogicalWidth > spanMaxLogicalWidth) { |
| 469 for (unsigned pos = effCol; spanMaxLogicalWidth >= 0 && pos < la
stCol; ++pos) { | 469 for (unsigned pos = effCol; spanMaxLogicalWidth >= 0 && pos < la
stCol; ++pos) { |
| 470 int colMaxLogicalWidth = std::max(m_layoutStruct[pos].effect
iveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth *
static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogic
alWidth : cellMaxLogicalWidth)); | 470 int colMaxLogicalWidth = std::max(m_layoutStruct[pos].effect
iveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth *
static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogic
alWidth : cellMaxLogicalWidth)); |
| 471 spanMaxLogicalWidth -= m_layoutStruct[pos].effectiveMaxLogic
alWidth; | 471 spanMaxLogicalWidth -= m_layoutStruct[pos].effectiveMaxLogic
alWidth; |
| 472 cellMaxLogicalWidth -= colMaxLogicalWidth; | 472 cellMaxLogicalWidth -= colMaxLogicalWidth; |
| 473 m_layoutStruct[pos].effectiveMaxLogicalWidth = colMaxLogical
Width; | 473 m_layoutStruct[pos].effectiveMaxLogicalWidth = colMaxLogical
Width; |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 } else { | 476 } else { |
| 477 for (unsigned pos = effCol; pos < lastCol; ++pos) | 477 for (unsigned pos = effCol; pos < lastCol; ++pos) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 break; | 571 break; |
| 572 default: | 572 default: |
| 573 break; | 573 break; |
| 574 } | 574 } |
| 575 } | 575 } |
| 576 | 576 |
| 577 // allocate width to percent cols | 577 // allocate width to percent cols |
| 578 if (available > 0 && havePercent) { | 578 if (available > 0 && havePercent) { |
| 579 for (size_t i = 0; i < nEffCols; ++i) { | 579 for (size_t i = 0; i < nEffCols; ++i) { |
| 580 Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth; | 580 Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth; |
| 581 if (logicalWidth.hasPercent()) { | 581 if (logicalWidth.isPercentOrCalc()) { |
| 582 int cellLogicalWidth = std::max<int>(m_layoutStruct[i].effective
MinLogicalWidth, | 582 int cellLogicalWidth = std::max<int>(m_layoutStruct[i].effective
MinLogicalWidth, |
| 583 minimumValueForLength(logicalWidth, LayoutUnit(tableLogicalW
idth)).toInt()); | 583 minimumValueForLength(logicalWidth, LayoutUnit(tableLogicalW
idth)).toInt()); |
| 584 available += m_layoutStruct[i].computedLogicalWidth - cellLogica
lWidth; | 584 available += m_layoutStruct[i].computedLogicalWidth - cellLogica
lWidth; |
| 585 m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth; | 585 m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth; |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 if (totalPercent > 100) { | 588 if (totalPercent > 100) { |
| 589 // remove overallocated space from the last columns | 589 // remove overallocated space from the last columns |
| 590 int excess = tableLogicalWidth * (totalPercent - 100) / 100; | 590 int excess = tableLogicalWidth * (totalPercent - 100) / 100; |
| 591 for (unsigned i = nEffCols; i; ) { | 591 for (unsigned i = nEffCols; i; ) { |
| 592 --i; | 592 --i; |
| 593 if (m_layoutStruct[i].effectiveLogicalWidth.hasPercent()) { | 593 if (m_layoutStruct[i].effectiveLogicalWidth.isPercentOrCalc()) { |
| 594 int cellLogicalWidth = m_layoutStruct[i].computedLogicalWidt
h; | 594 int cellLogicalWidth = m_layoutStruct[i].computedLogicalWidt
h; |
| 595 int reduction = std::min(cellLogicalWidth, excess); | 595 int reduction = std::min(cellLogicalWidth, excess); |
| 596 // the lines below might look inconsistent, but that's the w
ay it's handled in mozilla | 596 // the lines below might look inconsistent, but that's the w
ay it's handled in mozilla |
| 597 excess -= reduction; | 597 excess -= reduction; |
| 598 int newLogicalWidth = std::max<int>(m_layoutStruct[i].effect
iveMinLogicalWidth, cellLogicalWidth - reduction); | 598 int newLogicalWidth = std::max<int>(m_layoutStruct[i].effect
iveMinLogicalWidth, cellLogicalWidth - reduction); |
| 599 available += cellLogicalWidth - newLogicalWidth; | 599 available += cellLogicalWidth - newLogicalWidth; |
| 600 m_layoutStruct[i].computedLogicalWidth = newLogicalWidth; | 600 m_layoutStruct[i].computedLogicalWidth = newLogicalWidth; |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 } | 603 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 int reduce = available * minMaxDiff / logicalWidthBeyondMin; | 715 int reduce = available * minMaxDiff / logicalWidthBeyondMin; |
| 716 m_layoutStruct[i].computedLogicalWidth += reduce; | 716 m_layoutStruct[i].computedLogicalWidth += reduce; |
| 717 available -= reduce; | 717 available -= reduce; |
| 718 logicalWidthBeyondMin -= minMaxDiff; | 718 logicalWidthBeyondMin -= minMaxDiff; |
| 719 if (available >= 0) | 719 if (available >= 0) |
| 720 break; | 720 break; |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 } // namespace blink | 724 } // namespace blink |
| OLD | NEW |