Title: [111118] trunk
Revision
111118
Author
[email protected]
Date
2012-03-17 03:48:41 -0700 (Sat, 17 Mar 2012)

Log Message

CSS 2.1 failure: fixed-table-layout-013 and fixed-table-layout-015 fail
https://bugs.webkit.org/show_bug.cgi?id=78027

Reviewed by Julien Chaffraix.

Source/WebCore:

Both of these test the (slightly implicit) rule that width set on column-groups cannot
affect the width of columns in a fixed layout table: http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout
FF, Opera and IE all pass these two tests.

Tests: css2.1/20110323/fixed-table-layout-013.htm
       css2.1/20110323/fixed-table-layout-015.htm
       fast/table/fixed-table-layout-toggle-colwidth.html

* rendering/FixedTableLayout.cpp:
(WebCore::nextCol): A helper function for finding the next column along.
(WebCore::FixedTableLayout::calcWidthArray): Ignore width specified by column groups.
* rendering/RenderTableCol.h:
(WebCore::RenderTableCol::isTableColGroup): Convenience function for identifying column groups.

LayoutTests:

* css2.1/20110323/fixed-table-layout-013-expected.html: Added.
* css2.1/20110323/fixed-table-layout-013.htm: Added.
* css2.1/20110323/fixed-table-layout-015-expected.html: Added.
* css2.1/20110323/fixed-table-layout-015.htm: Added.
* fast/table/fixed-table-layout-toggle-colwidth-expected.txt: Added.
* fast/table/fixed-table-layout-toggle-colwidth.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (111117 => 111118)


--- trunk/LayoutTests/ChangeLog	2012-03-17 07:45:16 UTC (rev 111117)
+++ trunk/LayoutTests/ChangeLog	2012-03-17 10:48:41 UTC (rev 111118)
@@ -1,3 +1,17 @@
+2012-03-15  Robert Hogan  <[email protected]>
+
+        CSS 2.1 failure: fixed-table-layout-013 and fixed-table-layout-015 fail
+        https://bugs.webkit.org/show_bug.cgi?id=78027
+
+        Reviewed by Julien Chaffraix.
+
+        * css2.1/20110323/fixed-table-layout-013-expected.html: Added.
+        * css2.1/20110323/fixed-table-layout-013.htm: Added.
+        * css2.1/20110323/fixed-table-layout-015-expected.html: Added.
+        * css2.1/20110323/fixed-table-layout-015.htm: Added.
+        * fast/table/fixed-table-layout-toggle-colwidth-expected.txt: Added.
+        * fast/table/fixed-table-layout-toggle-colwidth.html: Added.
+
 2012-03-16  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Unreviewed gardening after r111110.

Added: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013-expected.html (0 => 111118)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013-expected.html	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Reference Result</title>
+        <style type="text/css">
+            table
+            {
+                border-collapse: collapse;
+                table-layout: fixed;
+                width: 200px;
+            }
+            #cell
+            {
+                background: black;
+                width: 100px;
+            }
+            #div1
+            {
+                background: blue;
+                width: 100px;
+            }
+            #div1, #cell
+            {
+                height: 1em;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the boxes below are the same width.</p>
+        <table>
+            <tr>
+                <td id="cell"></td>
+                <td></td>
+           </tr>
+        </table>
+        <div id="div1"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013-expected.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm (0 => 111118)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Fixed table layout - specified column-group width</title>
+        <link rel="author" title="Microsoft" href=""
+        <link rel="help" href=""
+        <meta name="flags" content="">
+        <meta name="assert" content="Specified column-group width is ignored in fixed table layout.">
+        <style type="text/css">
+            table
+            {
+                border-collapse: collapse;
+                table-layout: fixed;
+                width: 200px;
+            }
+            #colgroup
+            {
+                width: 50px;
+            }
+            #cell
+            {
+                background: black;
+            }
+            #div1
+            {
+                background: blue;
+                width: 100px;
+            }
+            #div1, #cell
+            {
+                height: 1em;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the boxes below are the same width.</p>
+        <table>
+            <colgroup id="colgroup">
+                <col>
+            </colgroup>
+            <colgroup>
+                <col>
+            </colgroup>
+            <tr>
+                <td id="cell"></td>
+                <td></td>
+           </tr>
+        </table>
+        <div id="div1"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015-expected.html (0 => 111118)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015-expected.html	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015-expected.html	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,42 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Reference Result</title>
+        <style type="text/css">
+            table
+            {
+                border-spacing: 0;
+                table-layout: fixed;
+                width: 200px;
+            }
+            #cell
+            {
+                background: black;
+                width: 100px;
+            }
+            td
+            {
+                padding: 0;
+            }
+            #div1
+            {
+                background: blue;
+                width: 100px;
+            }
+            #div1, td
+            {
+                height: 1em;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the boxes below are the same width.</p>
+        <table>
+            <tr>
+                <td id="cell"></td>
+                <td></td>
+            </tr>
+        </table>
+        <div id="div1"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015-expected.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm (0 => 111118)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,56 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <title>CSS Test: Fixed table layout - specified cell width overrides specified column-group width</title>
+        <link rel="author" title="Microsoft" href=""
+        <link rel="help" href=""
+        <meta name="flags" content="">
+        <meta name="assert" content="A column that has both a cell width and column-group width specified will use its cell specified width.">
+        <style type="text/css">
+            table
+            {
+                border-spacing: 0;
+                table-layout: fixed;
+                width: 200px;
+            }
+            #colgroup
+            {
+                width: 75px;
+            }
+            #cell
+            {
+                background: black;
+                width: 100px;
+            }
+            td
+            {
+                padding: 0;
+            }
+            #div1
+            {
+                background: blue;
+                width: 100px;
+            }
+            #div1, td
+            {
+                height: 1em;
+            }
+        </style>
+    </head>
+    <body>
+        <p>Test passes if the boxes below are the same width.</p>
+        <table>
+            <colgroup id="colgroup">
+                <col>
+            </colgroup>
+            <colgroup>
+                <col>
+            </colgroup>
+            <tr>
+                <td id="cell"></td>
+                <td></td>
+            </tr>
+        </table>
+        <div id="div1"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth-expected.txt (0 => 111118)


--- trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth-expected.txt	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,4 @@
+Cell width was 48px
+Cell width is 98px
+PASSED: Cell changed width
+
Property changes on: trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth.html (0 => 111118)


--- trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth.html	                        (rev 0)
+++ trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth.html	2012-03-17 10:48:41 UTC (rev 111118)
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+    <head>
+        <style type="text/css">
+            table
+            {
+                border-collapse: collapse;
+                table-layout: fixed;
+                width: 200px;
+            }
+            #cell
+            {
+                background: black;
+            }
+            #div1
+            {
+                background: blue;
+                width: 100px;
+            }
+            #div1, #cell
+            {
+                height: 1em;
+            }
+        </style>
+        <script>
+            if (window.layoutTestController) {
+                layoutTestController.dumpAsText();
+                layoutTestController.waitUntilDone();
+            }
+            function log(msg)
+            {
+                var console = document.getElementById('console');
+                console.appendChild(document.createTextNode(msg));
+                console.appendChild(document.createElement('br'));
+            }
+            function toggleWidth()
+            {
+                var col = document.getElementById('colgroup').children[0];
+                var oldCellWidth = getComputedStyle(document.getElementById('cell')).width;
+                col.style.width = "100px";
+                var newCellWidth = getComputedStyle(document.getElementById('cell')).width;
+
+                log("Cell width was " + oldCellWidth);
+                log("Cell width is " + newCellWidth);
+                if (oldCellWidth != newCellWidth)
+                    log("PASSED: Cell changed width");
+                else
+                    log("FAILED: Cell did not change width");
+                layoutTestController.notifyDone();
+            }
+        </script>
+    </head>
+    <body _onload_="toggleWidth();">
+        <table id="table">
+            <colgroup id="colgroup">
+                <col style="width: 50px">
+                <col>
+            </colgroup>
+            <tr>
+                <td id="cell"></td>
+                <td></td>
+           </tr>
+        </table>
+        <div id="div1"></div>
+        <p id="console"></p>
+    </body>
+</html>
+
Property changes on: trunk/LayoutTests/fast/table/fixed-table-layout-toggle-colwidth.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (111117 => 111118)


--- trunk/Source/WebCore/ChangeLog	2012-03-17 07:45:16 UTC (rev 111117)
+++ trunk/Source/WebCore/ChangeLog	2012-03-17 10:48:41 UTC (rev 111118)
@@ -1,3 +1,24 @@
+2012-02-07  Robert Hogan  <[email protected]>
+
+        CSS 2.1 failure: fixed-table-layout-013 and fixed-table-layout-015 fail
+        https://bugs.webkit.org/show_bug.cgi?id=78027
+
+        Reviewed by Julien Chaffraix.
+
+        Both of these test the (slightly implicit) rule that width set on column-groups cannot
+        affect the width of columns in a fixed layout table: http://www.w3.org/TR/CSS21/tables.html#fixed-table-layout
+        FF, Opera and IE all pass these two tests.
+
+        Tests: css2.1/20110323/fixed-table-layout-013.htm
+               css2.1/20110323/fixed-table-layout-015.htm
+               fast/table/fixed-table-layout-toggle-colwidth.html
+
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::nextCol): A helper function for finding the next column along.
+        (WebCore::FixedTableLayout::calcWidthArray): Ignore width specified by column groups.
+        * rendering/RenderTableCol.h:
+        (WebCore::RenderTableCol::isTableColGroup): Convenience function for identifying column groups.
+
 2012-03-16  Leo Yang  <[email protected]>
 
         [BlackBerry] Add BlackBerry to NavigatorBase.cpp

Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (111117 => 111118)


--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2012-03-17 07:45:16 UTC (rev 111117)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2012-03-17 10:48:41 UTC (rev 111118)
@@ -77,65 +77,68 @@
 {
 }
 
+static RenderObject* nextCol(RenderObject* child)
+{
+    // If child is a colgroup, the next col is the colgroup's first child col.
+    if (RenderObject* next = child->firstChild())
+        return next;
+    // Otherwise it's the next col along.
+    if (RenderObject* next = child->nextSibling())
+        return next;
+    // Failing that, the child is the last col in a colgroup, so the next col is the next col/colgroup after its colgroup.
+    if (child->parent()->isTableCol())
+        return child->parent()->nextSibling();
+    return 0;
+}
+
 int FixedTableLayout::calcWidthArray(int)
 {
     int usedWidth = 0;
 
     // iterate over all <col> elements
-    RenderObject* child = m_table->firstChild();
     unsigned nEffCols = m_table->numEffCols();
     m_width.resize(nEffCols);
     m_width.fill(Length(Auto));
 
     unsigned currentEffectiveColumn = 0;
-    Length grpWidth;
-    while (child && child->isTableCol()) {
+    for (RenderObject* child = m_table->firstChild();child && child->isTableCol(); child = nextCol(child)) {
+
+        // Width specified by column-groups does not affect column width in fixed layout tables
         RenderTableCol* col = toRenderTableCol(child);
-        if (col->firstChild())
-            grpWidth = col->style()->logicalWidth();
-        else {
-            Length w = col->style()->logicalWidth();
-            if (w.isAuto())
-                w = grpWidth;
-            int effWidth = 0;
-            if (w.isFixed() && w.value() > 0)
-                effWidth = w.value();
+        col->computePreferredLogicalWidths();
 
-            unsigned span = col->span();
-            while (span) {
-                unsigned spanInCurrentEffectiveColumn;
-                if (currentEffectiveColumn >= nEffCols) {
-                    m_table->appendColumn(span);
+        if (col->isTableColGroup())
+            continue;
+
+        Length colStyleLogicalWidth = col->style()->logicalWidth();
+        int effectiveColWidth = 0;
+        if (colStyleLogicalWidth.isFixed() && colStyleLogicalWidth.value() > 0)
+            effectiveColWidth = colStyleLogicalWidth.value();
+
+        unsigned span = col->span();
+        while (span) {
+            unsigned spanInCurrentEffectiveColumn;
+            if (currentEffectiveColumn >= nEffCols) {
+                m_table->appendColumn(span);
+                nEffCols++;
+                m_width.append(Length());
+                spanInCurrentEffectiveColumn = span;
+            } else {
+                if (span < m_table->spanOfEffCol(currentEffectiveColumn)) {
+                    m_table->splitColumn(currentEffectiveColumn, span);
                     nEffCols++;
                     m_width.append(Length());
-                    spanInCurrentEffectiveColumn = span;
-                } else {
-                    if (span < m_table->spanOfEffCol(currentEffectiveColumn)) {
-                        m_table->splitColumn(currentEffectiveColumn, span);
-                        nEffCols++;
-                        m_width.append(Length());
-                    }
-                    spanInCurrentEffectiveColumn = m_table->spanOfEffCol(currentEffectiveColumn);
                 }
-                if ((w.isFixed() || w.isPercent()) && w.isPositive()) {
-                    m_width[currentEffectiveColumn] = w;
-                    m_width[currentEffectiveColumn] *= spanInCurrentEffectiveColumn;
-                    usedWidth += effWidth * spanInCurrentEffectiveColumn;
-                }
-                span -= spanInCurrentEffectiveColumn;
-                currentEffectiveColumn++;
+                spanInCurrentEffectiveColumn = m_table->spanOfEffCol(currentEffectiveColumn);
             }
+            if ((colStyleLogicalWidth.isFixed() || colStyleLogicalWidth.isPercent()) && colStyleLogicalWidth.isPositive()) {
+                m_width[currentEffectiveColumn] = colStyleLogicalWidth;
+                m_width[currentEffectiveColumn] *= spanInCurrentEffectiveColumn;
+                usedWidth += effectiveColWidth * spanInCurrentEffectiveColumn;
+            }
+            span -= spanInCurrentEffectiveColumn;
+            currentEffectiveColumn++;
         }
-        col->computePreferredLogicalWidths();
-
-        RenderObject* next = child->firstChild();
-        if (!next)
-            next = child->nextSibling();
-        if (!next && child->parent()->isTableCol()) {
-            next = child->parent()->nextSibling();
-            grpWidth = Length();
-        }
-        child = next;
     }
 
     // Iterate over the first row in case some are unspecified.
@@ -143,7 +146,7 @@
     if (section) {
         unsigned cCol = 0;
         RenderObject* firstRow = section->firstChild();
-        child = firstRow->firstChild();
+        RenderObject* child = firstRow->firstChild();
         while (child) {
             if (child->isTableCell()) {
                 RenderTableCell* cell = toRenderTableCell(child);
@@ -152,9 +155,9 @@
 
                 Length w = cell->styleOrColLogicalWidth();
                 unsigned span = cell->colSpan();
-                int effWidth = 0;
+                int effectiveColWidth = 0;
                 if (w.isFixed() && w.isPositive())
-                    effWidth = w.value();
+                    effectiveColWidth = w.value();
                 
                 unsigned usedSpan = 0;
                 unsigned i = 0;
@@ -164,7 +167,7 @@
                     if (m_width[cCol + i].isAuto() && w.type() != Auto) {
                         m_width[cCol + i] = w;
                         m_width[cCol + i] *= eSpan / span;
-                        usedWidth += effWidth * eSpan / span;
+                        usedWidth += effectiveColWidth * eSpan / span;
                     }
                     usedSpan += eSpan;
                     i++;

Modified: trunk/Source/WebCore/rendering/RenderTableCol.h (111117 => 111118)


--- trunk/Source/WebCore/rendering/RenderTableCol.h	2012-03-17 07:45:16 UTC (rev 111117)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h	2012-03-17 10:48:41 UTC (rev 111118)
@@ -43,7 +43,7 @@
 
     unsigned span() const { return m_span; }
     void setSpan(unsigned span) { m_span = span; }
-
+    bool isTableColGroup() { return firstChild() ? true : false; }
 private:
     virtual RenderObjectChildList* virtualChildren() { return children(); }
     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to