summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/FixedTableLayout.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/rendering/FixedTableLayout.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/rendering/FixedTableLayout.cpp')
-rw-r--r--WebCore/rendering/FixedTableLayout.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/WebCore/rendering/FixedTableLayout.cpp b/WebCore/rendering/FixedTableLayout.cpp
index 3e71365..1dc66a9 100644
--- a/WebCore/rendering/FixedTableLayout.cpp
+++ b/WebCore/rendering/FixedTableLayout.cpp
@@ -210,6 +210,7 @@ void FixedTableLayout::layout()
Vector<int> calcWidth(nEffCols, 0);
int numAuto = 0;
+ int autoSpan = 0;
int totalFixedWidth = 0;
int totalPercentWidth = 0;
int totalRawPercent = 0;
@@ -226,10 +227,13 @@ void FixedTableLayout::layout()
calcWidth[i] = m_width[i].calcValue(tableWidth);
totalPercentWidth += calcWidth[i];
totalRawPercent += m_width[i].rawValue();
- } else if (m_width[i].isAuto())
+ } else if (m_width[i].isAuto()) {
numAuto++;
+ autoSpan += m_table->spanOfEffCol(i);
+ }
}
+ int hspacing = m_table->hBorderSpacing();
int totalWidth = totalFixedWidth + totalPercentWidth;
if (!numAuto || totalWidth > tableWidth) {
// If there are no auto columns, or if the total is too wide, take
@@ -258,16 +262,19 @@ void FixedTableLayout::layout()
}
} else {
// Divide the remaining width among the auto columns.
- int remainingWidth = tableWidth - totalFixedWidth - totalPercentWidth;
+ int remainingWidth = tableWidth - totalFixedWidth - totalPercentWidth - hspacing * (autoSpan - numAuto);
int lastAuto = 0;
for (int i = 0; i < nEffCols; i++) {
if (m_width[i].isAuto()) {
- calcWidth[i] = remainingWidth / numAuto;
- remainingWidth -= calcWidth[i];
+ int span = m_table->spanOfEffCol(i);
+ int w = remainingWidth * span / autoSpan;
+ calcWidth[i] = w + hspacing * (span - 1);
+ remainingWidth -= w;
if (!remainingWidth)
break;
lastAuto = i;
numAuto--;
+ autoSpan -= span;
}
}
// Last one gets the remainder.
@@ -285,16 +292,18 @@ void FixedTableLayout::layout()
remainingWidth -= w;
calcWidth[--total] += w;
}
- calcWidth[nEffCols - 1] += remainingWidth;
+ if (nEffCols > 0)
+ calcWidth[nEffCols - 1] += remainingWidth;
}
int pos = 0;
- int hspacing = m_table->hBorderSpacing();
for (int i = 0; i < nEffCols; i++) {
m_table->columnPositions()[i] = pos;
pos += calcWidth[i] + hspacing;
}
- m_table->columnPositions()[m_table->columnPositions().size() - 1] = pos;
+ int colPositionsSize = m_table->columnPositions().size();
+ if (colPositionsSize > 0)
+ m_table->columnPositions()[colPositionsSize - 1] = pos;
}
} // namespace WebCore