diff options
author | Steve Block <steveblock@google.com> | 2011-06-08 08:26:01 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-08 08:26:01 -0700 |
commit | 3742ac093d35d923c81693096ab6671e9b147700 (patch) | |
tree | c2add9100f789dad45ef1ec5328bddde02c47a4c /Source/WebCore/rendering/AutoTableLayout.cpp | |
parent | 901401d90459bc22580842455d4588b9a697514d (diff) | |
parent | e5926f4a0d6adc9ad4a75824129f117181953560 (diff) | |
download | external_webkit-3742ac093d35d923c81693096ab6671e9b147700.zip external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.gz external_webkit-3742ac093d35d923c81693096ab6671e9b147700.tar.bz2 |
Merge changes I55c6d71a,Ifb3277d4,Ia1b847a2,I7ba9cf3f,Ida2b2a8a,I1280ec90,I72f818d5,I2e3b588b,I9a4e6289,Ia724c78b,Icd8612c8,Ie31b15d7,Ie125edae,I77941a88,I89dae78b,I3516e5ca,I1a4c17b5,I2c4ecc1a,I9c8e6537,Ifac13115,Ie1f80e09,Ia541ed77,I60ce9d78
* changes:
Merge WebKit at r82507: Update ThirdPartyProject.prop
Merge WebKit at r82507: Cherry-pick change r88166 to add INSPECTOR guards to ScriptProfiler
Merge WebKit at r82507: Work around a V8 bug
Merge WebKit at r82507: JNIType renamed to JavaType
Merge WebKit at r82507: IconDatabaseClient interface expanded
Merge WebKit at r82507: Don't use new loss-free code path in HTMLCanvasElement::toDataURL()
Merge WebKit at r82507: IcondDatabaseBase::iconForPageURL() renamed
Merge WebKit at r82507: IconDatabaseBase::Open() signature changed
Merge WebKit at r82507: Node::isContentEditable() renamed
Merge WebKit at r82507: Use icon database through IconDatabaseBase
Merge WebKit at r82507: toInputElement() is now a member of Node
Merge WebKit at r82507: FrameLoaderClient::objectContentType() signature changed
Merge WebKit at r82507: StringImpl::computeHash() removed
Merge WebKit at r82507: Stub out FontPlatformData::setOrientation()
Merge WebKit at r82507: Path::strokeBoundingRect() is now const
Merge WebKit at r82507: Add missing UnusedParam.h include in ApplicationCacheGroup.cpp
Merge WebKit at r82507: Continue to use Android's version of FontPlatformData.h
Merge WebKit at r82507: Update signature of FontCustomPlatformData::fontPlatformData()
Merge WebKit at r82507: Fix conflicts due to JNI refactoring
Merge WebKit at r82507: Fix conflicts due to new StorageTracker
Merge WebKit at r82507: Fix conflicts
Merge WebKit at r82507: Fix makefiles
Merge WebKit at r82507: Initial merge by git
Diffstat (limited to 'Source/WebCore/rendering/AutoTableLayout.cpp')
-rw-r--r-- | Source/WebCore/rendering/AutoTableLayout.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/Source/WebCore/rendering/AutoTableLayout.cpp b/Source/WebCore/rendering/AutoTableLayout.cpp index 9775ec5..4eef95f 100644 --- a/Source/WebCore/rendering/AutoTableLayout.cpp +++ b/Source/WebCore/rendering/AutoTableLayout.cpp @@ -81,8 +81,8 @@ void AutoTableLayout::recalcColumn(int effCol) Length cellLogicalWidth = cell->styleOrColLogicalWidth(); // FIXME: What is this arbitrary value? - if (cellLogicalWidth.rawValue() > 32760) - cellLogicalWidth.setRawValue(32760); + if (cellLogicalWidth.value() > 32760) + cellLogicalWidth.setValue(32760); if (cellLogicalWidth.isNegative()) cellLogicalWidth.setValue(0); switch (cellLogicalWidth.type()) { @@ -105,13 +105,13 @@ void AutoTableLayout::recalcColumn(int effCol) break; case Percent: m_hasPercent = true; - if (cellLogicalWidth.isPositive() && (!columnLayout.logicalWidth.isPercent() || cellLogicalWidth.rawValue() > columnLayout.logicalWidth.rawValue())) + if (cellLogicalWidth.isPositive() && (!columnLayout.logicalWidth.isPercent() || cellLogicalWidth.value() > columnLayout.logicalWidth.value())) columnLayout.logicalWidth = cellLogicalWidth; break; case Relative: // FIXME: Need to understand this case and whether it makes sense to compare values // which are not necessarily of the same type. - if (cellLogicalWidth.isAuto() || (cellLogicalWidth.isRelative() && cellLogicalWidth.value() > columnLayout.logicalWidth.rawValue())) + if (cellLogicalWidth.isAuto() || (cellLogicalWidth.isRelative() && cellLogicalWidth.value() > columnLayout.logicalWidth.value())) columnLayout.logicalWidth = cellLogicalWidth; default: break; @@ -232,16 +232,16 @@ void AutoTableLayout::computePreferredLogicalWidths(int& minWidth, int& maxWidth // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two places below to avoid division by zero. // FIXME: Handle the 0% cases properly. - const int epsilon = 1; + const float epsilon = 1 / 128.0f; - int remainingPercent = 100 * percentScaleFactor; + float remainingPercent = 100; for (size_t i = 0; i < m_layoutStruct.size(); ++i) { minWidth += m_layoutStruct[i].effectiveMinLogicalWidth; maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth; if (scaleColumns) { if (m_layoutStruct[i].effectiveLogicalWidth.isPercent()) { - int percent = min(m_layoutStruct[i].effectiveLogicalWidth.rawValue(), remainingPercent); - float logicalWidth = static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) * 100 * percentScaleFactor / max(percent, epsilon); + float percent = min(static_cast<float>(m_layoutStruct[i].effectiveLogicalWidth.percent()), remainingPercent); + float logicalWidth = static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) * 100 / max(percent, epsilon); maxPercent = max(logicalWidth, maxPercent); remainingPercent -= percent; } else @@ -250,7 +250,7 @@ void AutoTableLayout::computePreferredLogicalWidths(int& minWidth, int& maxWidth } if (scaleColumns) { - maxNonPercent = maxNonPercent * 100 * percentScaleFactor / max(remainingPercent, epsilon); + maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon); maxWidth = max(maxWidth, static_cast<int>(min(maxNonPercent, INT_MAX / 2.0f))); maxWidth = max(maxWidth, static_cast<int>(min(maxPercent, INT_MAX / 2.0f))); } @@ -266,6 +266,10 @@ void AutoTableLayout::computePreferredLogicalWidths(int& minWidth, int& maxWidth minWidth = max(minWidth, tableLogicalWidth.value()); maxWidth = minWidth; } + + // if there was no remaining percent, maxWidth is invalid. + if (!remainingPercent && maxNonPercent) + maxWidth = intMaxForLength; } /* @@ -300,7 +304,7 @@ int AutoTableLayout::calcEffectiveLogicalWidth() size_t lastCol = effCol; int cellMinLogicalWidth = cell->minPreferredLogicalWidth() + spacingInRowDirection; float cellMaxLogicalWidth = cell->maxPreferredLogicalWidth() + spacingInRowDirection; - int totalPercent = 0; + float totalPercent = 0; int spanMinLogicalWidth = 0; float spanMaxLogicalWidth = 0; bool allColsArePercent = true; @@ -312,7 +316,7 @@ int AutoTableLayout::calcEffectiveLogicalWidth() Layout& columnLayout = m_layoutStruct[lastCol]; switch (columnLayout.logicalWidth.type()) { case Percent: - totalPercent += columnLayout.logicalWidth.rawValue(); + totalPercent += columnLayout.logicalWidth.percent(); allColsAreFixed = false; break; case Fixed: @@ -339,7 +343,7 @@ int AutoTableLayout::calcEffectiveLogicalWidth() columnLayout.effectiveLogicalWidth = Length(); allColsArePercent = false; } else - totalPercent += columnLayout.effectiveLogicalWidth.rawValue(); + totalPercent += columnLayout.effectiveLogicalWidth.percent(); allColsAreFixed = false; } if (!columnLayout.emptyCellsOnly) @@ -354,14 +358,14 @@ int AutoTableLayout::calcEffectiveLogicalWidth() // adjust table max width if needed if (cellLogicalWidth.isPercent()) { - if (totalPercent > cellLogicalWidth.rawValue() || allColsArePercent) { + if (totalPercent > cellLogicalWidth.percent() || allColsArePercent) { // can't satify this condition, treat as variable cellLogicalWidth = Length(); } else { - maxLogicalWidth = max(maxLogicalWidth, max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100 * percentScaleFactor / cellLogicalWidth.rawValue()); + maxLogicalWidth = max(maxLogicalWidth, static_cast<float>(max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100 / cellLogicalWidth.percent())); // all non percent columns in the span get percent values to sum up correctly. - int percentMissing = cellLogicalWidth.rawValue() - totalPercent; + float percentMissing = cellLogicalWidth.percent() - totalPercent; float totalWidth = 0; for (unsigned pos = effCol; pos < lastCol; ++pos) { if (!m_layoutStruct[pos].effectiveLogicalWidth.isPercent()) @@ -370,11 +374,11 @@ int AutoTableLayout::calcEffectiveLogicalWidth() for (unsigned pos = effCol; pos < lastCol && totalWidth > 0; ++pos) { if (!m_layoutStruct[pos].effectiveLogicalWidth.isPercent()) { - int percent = static_cast<int>(percentMissing * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / totalWidth); + float percent = percentMissing * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / totalWidth; totalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth; percentMissing -= percent; if (percent > 0) - m_layoutStruct[pos].effectiveLogicalWidth.setRawValue(Percent, percent); + m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent); else m_layoutStruct[pos].effectiveLogicalWidth = Length(); } @@ -495,7 +499,7 @@ void AutoTableLayout::layout() int numFixed = 0; float totalAuto = 0; float totalFixed = 0; - int totalPercent = 0; + float totalPercent = 0; int allocAuto = 0; unsigned numAutoEmptyCellsOnly = 0; @@ -508,7 +512,7 @@ void AutoTableLayout::layout() switch (logicalWidth.type()) { case Percent: havePercent = true; - totalPercent += logicalWidth.rawValue(); + totalPercent += logicalWidth.percent(); break; case Relative: totalRelative += logicalWidth.value(); @@ -542,9 +546,9 @@ void AutoTableLayout::layout() m_layoutStruct[i].computedLogicalWidth = cellLogicalWidth; } } - if (totalPercent > 100 * percentScaleFactor) { + if (totalPercent > 100) { // remove overallocated space from the last columns - int excess = tableLogicalWidth * (totalPercent - 100 * percentScaleFactor) / (100 * percentScaleFactor); + int excess = tableLogicalWidth * (totalPercent - 100) / 100; for (int i = nEffCols - 1; i >= 0; --i) { if (m_layoutStruct[i].effectiveLogicalWidth.isPercent()) { int cellLogicalWidth = m_layoutStruct[i].computedLogicalWidth; @@ -611,13 +615,13 @@ void AutoTableLayout::layout() } // spread over percent colums - if (available > 0 && m_hasPercent && totalPercent < 100 * percentScaleFactor) { + if (available > 0 && m_hasPercent && totalPercent < 100) { for (size_t i = 0; i < nEffCols; ++i) { Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth; if (logicalWidth.isPercent()) { - int cellLogicalWidth = available * logicalWidth.rawValue() / totalPercent; + int cellLogicalWidth = available * logicalWidth.percent() / totalPercent; available -= cellLogicalWidth; - totalPercent -= logicalWidth.rawValue(); + totalPercent -= logicalWidth.percent(); m_layoutStruct[i].computedLogicalWidth += cellLogicalWidth; if (!available || !totalPercent) break; |