Title: [107970] trunk
Revision
107970
Author
rob...@webkit.org
Date
2012-02-16 12:40:20 -0800 (Thu, 16 Feb 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

* 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107969 => 107970)


--- trunk/LayoutTests/ChangeLog	2012-02-16 20:32:43 UTC (rev 107969)
+++ trunk/LayoutTests/ChangeLog	2012-02-16 20:40:20 UTC (rev 107970)
@@ -1,3 +1,15 @@
+2012-02-07  Robert Hogan  <rob...@webkit.org>
+
+        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.
+
 2012-02-16  Tony Chang  <t...@chromium.org>
 
         [chromium] Unreviewed, tests passing after the fix in r107874.

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


--- 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-02-16 20:40:20 UTC (rev 107970)
@@ -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 => 107970)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-013.htm	2012-02-16 20:40:20 UTC (rev 107970)
@@ -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 => 107970)


--- 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-02-16 20:40:20 UTC (rev 107970)
@@ -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 => 107970)


--- trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm	                        (rev 0)
+++ trunk/LayoutTests/css2.1/20110323/fixed-table-layout-015.htm	2012-02-16 20:40:20 UTC (rev 107970)
@@ -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

Modified: trunk/Source/WebCore/ChangeLog (107969 => 107970)


--- trunk/Source/WebCore/ChangeLog	2012-02-16 20:32:43 UTC (rev 107969)
+++ trunk/Source/WebCore/ChangeLog	2012-02-16 20:40:20 UTC (rev 107970)
@@ -1,3 +1,23 @@
+2012-02-07  Robert Hogan  <rob...@webkit.org>
+
+        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
+
+        * 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-02-16  Philippe Normand  <pnorm...@igalia.com>
 
         Unreviewed, rolling out r107941.

Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (107969 => 107970)


--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2012-02-16 20:32:43 UTC (rev 107969)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2012-02-16 20:40:20 UTC (rev 107970)
@@ -77,6 +77,20 @@
 {
 }
 
+static RenderObject* findNextCol(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;
@@ -88,54 +102,43 @@
     m_width.fill(Length(Auto));
 
     unsigned currentEffectiveColumn = 0;
-    Length grpWidth;
-    while (child && child->isTableCol()) {
+    for (; child && child->isTableCol(); child = findNextCol(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();
+        if (col->isColGroup())
+            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);
+        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.
@@ -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 (107969 => 107970)


--- trunk/Source/WebCore/rendering/RenderTableCol.h	2012-02-16 20:32:43 UTC (rev 107969)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h	2012-02-16 20:40:20 UTC (rev 107970)
@@ -43,7 +43,7 @@
 
     unsigned span() const { return m_span; }
     void setSpan(unsigned span) { m_span = span; }
-
+    bool isColGroup() { return firstChild(); }
 private:
     virtual RenderObjectChildList* virtualChildren() { return children(); }
     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to