Title: [125917] trunk
Revision
125917
Author
[email protected]
Date
2012-08-17 11:31:56 -0700 (Fri, 17 Aug 2012)

Log Message

ASSERTION FAILED: allocatedMaxLogicalWidth <= cellMaxLogicalWidth : int WebCore::AutoTableLayout::calcEffectiveLogicalWidth()
https://bugs.webkit.org/show_bug.cgi?id=92471

Patch by Arpita Bahuguna <[email protected]> on 2012-08-17
Reviewed by Julien Chaffraix.

Source/WebCore:

The assert occurs due to the float based computations causing a floating
point rounding error between allocatedMaxLogicalWidth and cellMaxLogicalWidth.

Test: fast/table/assert-autotablelayout-maxlogicalwidth.html

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
Converting float based calculations for computing max logical width to int based;
similar to the calculations for min logical width.

LayoutTests:

* fast/table/assert-autotablelayout-maxlogicalwidth-expected.txt: Added.
* fast/table/assert-autotablelayout-maxlogicalwidth.html: Added.
Added a testcase for verifying that the assert in AutoTableLayout::calcEffectiveLogicalWidth()
for allocatedMaxLogicalWidth coming greater than cellMaxLogicalWidth, does not occur.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125916 => 125917)


--- trunk/LayoutTests/ChangeLog	2012-08-17 18:27:17 UTC (rev 125916)
+++ trunk/LayoutTests/ChangeLog	2012-08-17 18:31:56 UTC (rev 125917)
@@ -1,3 +1,15 @@
+2012-08-17  Arpita Bahuguna  <[email protected]>
+
+        ASSERTION FAILED: allocatedMaxLogicalWidth <= cellMaxLogicalWidth : int WebCore::AutoTableLayout::calcEffectiveLogicalWidth()
+        https://bugs.webkit.org/show_bug.cgi?id=92471
+
+        Reviewed by Julien Chaffraix.
+
+        * fast/table/assert-autotablelayout-maxlogicalwidth-expected.txt: Added.
+        * fast/table/assert-autotablelayout-maxlogicalwidth.html: Added.
+        Added a testcase for verifying that the assert in AutoTableLayout::calcEffectiveLogicalWidth()
+        for allocatedMaxLogicalWidth coming greater than cellMaxLogicalWidth, does not occur.
+
 2012-08-17  Adrienne Walker  <[email protected]>
 
         [chromium] Mark context-menu.html as failing on Chromium Mac

Added: trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth-expected.txt (0 => 125917)


--- trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth-expected.txt	2012-08-17 18:31:56 UTC (rev 125917)
@@ -0,0 +1,5 @@
+Test for Bugzilla Bug 92471: ASSERTION FAILED: allocatedMaxLogicalWidth <= cellMaxLogicalWidth : int WebCore::AutoTableLayout::calcEffectiveLogicalWidth().
+
+The following test passes if there is no assert or crash.
+
+

Added: trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth.html (0 => 125917)


--- trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/assert-autotablelayout-maxlogicalwidth.html	2012-08-17 18:31:56 UTC (rev 125917)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+    <style>
+        .percent td { width: 1%; }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+    </script>
+    <p>Test for Bugzilla <a href="" 92471</a>: ASSERTION FAILED: allocatedMaxLogicalWidth <= cellMaxLogicalWidth : int WebCore::AutoTableLayout::calcEffectiveLogicalWidth().</p>
+    <p>The following test passes if there is no assert or crash.</p>
+    <table>
+    <tr>
+        <td colspan="7" style="padding: 0;" width="479">
+            <div style="position: relative; width: 479px;" ></div>
+        </td>
+    </tr>
+    <tr class="percent">
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>
+        <td></td>		
+        <td></td>		
+    </tr>
+    </table>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (125916 => 125917)


--- trunk/Source/WebCore/ChangeLog	2012-08-17 18:27:17 UTC (rev 125916)
+++ trunk/Source/WebCore/ChangeLog	2012-08-17 18:31:56 UTC (rev 125917)
@@ -1,3 +1,20 @@
+2012-08-17  Arpita Bahuguna  <[email protected]>
+
+        ASSERTION FAILED: allocatedMaxLogicalWidth <= cellMaxLogicalWidth : int WebCore::AutoTableLayout::calcEffectiveLogicalWidth()
+        https://bugs.webkit.org/show_bug.cgi?id=92471
+
+        Reviewed by Julien Chaffraix.
+
+        The assert occurs due to the float based computations causing a floating
+        point rounding error between allocatedMaxLogicalWidth and cellMaxLogicalWidth.
+
+        Test: fast/table/assert-autotablelayout-maxlogicalwidth.html
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::calcEffectiveLogicalWidth):
+        Converting float based calculations for computing max logical width to int based;
+        similar to the calculations for min logical width.
+
 2012-08-17  John J. Barton  <[email protected]>
 
         Web Inspector: Add //@ sourceURL to test-runner evals

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (125916 => 125917)


--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2012-08-17 18:27:17 UTC (rev 125916)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2012-08-17 18:31:56 UTC (rev 125917)
@@ -277,7 +277,7 @@
  */
 int AutoTableLayout::calcEffectiveLogicalWidth()
 {
-    float maxLogicalWidth = 0;
+    int maxLogicalWidth = 0;
 
     size_t nEffCols = m_layoutStruct.size();
     int spacingInRowDirection = m_table->hBorderSpacing();
@@ -302,10 +302,10 @@
         unsigned effCol = m_table->colToEffCol(cell->col());
         size_t lastCol = effCol;
         int cellMinLogicalWidth = cell->minPreferredLogicalWidth() + spacingInRowDirection;
-        float cellMaxLogicalWidth = cell->maxPreferredLogicalWidth() + spacingInRowDirection;
+        int cellMaxLogicalWidth = cell->maxPreferredLogicalWidth() + spacingInRowDirection;
         float totalPercent = 0;
         int spanMinLogicalWidth = 0;
-        float spanMaxLogicalWidth = 0;
+        int spanMaxLogicalWidth = 0;
         bool allColsArePercent = true;
         bool allColsAreFixed = true;
         bool haveAuto = false;
@@ -361,11 +361,11 @@
                 // can't satify this condition, treat as variable
                 cellLogicalWidth = Length();
             } else {
-                maxLogicalWidth = max(maxLogicalWidth, static_cast<float>(max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100  / cellLogicalWidth.percent()));
+                maxLogicalWidth = max(maxLogicalWidth, static_cast<int>(max(spanMaxLogicalWidth, cellMaxLogicalWidth) * 100  / cellLogicalWidth.percent()));
 
                 // all non percent columns in the span get percent values to sum up correctly.
                 float percentMissing = cellLogicalWidth.percent() - totalPercent;
-                float totalWidth = 0;
+                int totalWidth = 0;
                 for (unsigned pos = effCol; pos < lastCol; ++pos) {
                     if (!m_layoutStruct[pos].effectiveLogicalWidth.isPercent())
                         totalWidth += m_layoutStruct[pos].effectiveMaxLogicalWidth;
@@ -397,13 +397,13 @@
             } else if (allColsArePercent) {
                 // In this case, we just split the colspan's min amd max widths following the percentage.
                 int allocatedMinLogicalWidth = 0;
-                float allocatedMaxLogicalWidth = 0;
+                int allocatedMaxLogicalWidth = 0;
                 for (unsigned pos = effCol; pos < lastCol; ++pos) {
                     ASSERT(m_layoutStruct[pos].logicalWidth.isPercent() || m_layoutStruct[pos].effectiveLogicalWidth.isPercent());
                     // |allColsArePercent| means that either the logicalWidth *or* the effectiveLogicalWidth are percents, handle both of them here.
                     float percent = m_layoutStruct[pos].logicalWidth.isPercent() ? m_layoutStruct[pos].logicalWidth.percent() : m_layoutStruct[pos].effectiveLogicalWidth.percent();
                     int columnMinLogicalWidth = static_cast<int>(percent * cellMinLogicalWidth / totalPercent);
-                    float columnMaxLogicalWidth = percent * cellMaxLogicalWidth / totalPercent;
+                    int columnMaxLogicalWidth = static_cast<int>(percent * cellMaxLogicalWidth / totalPercent);
                     m_layoutStruct[pos].effectiveMinLogicalWidth = max(m_layoutStruct[pos].effectiveMinLogicalWidth, columnMinLogicalWidth);
                     m_layoutStruct[pos].effectiveMaxLogicalWidth = columnMaxLogicalWidth;
                     allocatedMinLogicalWidth += columnMinLogicalWidth;
@@ -414,7 +414,7 @@
                 cellMinLogicalWidth -= allocatedMinLogicalWidth;
                 cellMaxLogicalWidth -= allocatedMaxLogicalWidth;
             } else {
-                float remainingMaxLogicalWidth = spanMaxLogicalWidth;
+                int remainingMaxLogicalWidth = spanMaxLogicalWidth;
                 int remainingMinLogicalWidth = spanMinLogicalWidth;
                 
                 // Give min to variable first, to fixed second, and to others third.
@@ -462,7 +462,7 @@
     }
     m_effectiveLogicalWidthDirty = false;
 
-    return static_cast<int>(min(maxLogicalWidth, INT_MAX / 2.0f));
+    return min(maxLogicalWidth, INT_MAX / 2);
 }
 
 /* gets all cells that originate in a column and have a cellspan > 1
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to