Bug 50235 - padding attribute for style definitions in tables ignored
Summary: padding attribute for style definitions in tables ignored
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml renderer (show other bugs)
Version: 4.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-05 15:29 UTC by Melchior Franz
Modified: 2005-03-08 12:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Melchior Franz 2002-11-05 15:29:26 UTC
Version:           4.0 (using KDE 3.0.9)
Compiler:          gcc version 3.2
OS:          Linux (i686) release 2.4.19

Since a while khtml ignores the padding style given to a whole table.

The same example code also exposes another problem: khtml wrongly(?)
interprets the newline after the <td>-contents as space.

mozilla renders the example file "correctly" (i.e. like I think
it *should* be rendered  ;-)

m.




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Test</title>
    </head>
    <body>
        <table style="background-color: red; padding: 20px">
            <tr>
                <td>
                    padding 20px
                </td>
            </tr>
        </table>
        <br>
        <table style="background-color: green; padding: 0px">
            <tr>
                <td>
                    padding 0px
                </td>
            </tr>
        </table>
    </body>
</html>
Comment 1 Marc Mutz 2003-07-20 00:31:18 UTC
I can confirm this. padding work on other elements, though, most notably <div>. 
Comment 2 Stephan Kulow 2003-10-29 12:54:48 UTC
the test case is rendered exactly as in IE6, mozilla adds indeed padding pixels. I'm not
sure what's supposed to happen ;(
Comment 3 Stephan Kulow 2003-10-29 13:00:03 UTC
JFYI: this is the way it works:

<table style="background-color: red">
 <tr>
 <td style="padding: 20px">
 padding 20px
 </td>
 </tr>
 </table>
Comment 4 Daniel Arnold 2005-02-25 17:26:34 UTC
I can reproduce this bug with Konqueror from KDE 3.3.2a. So it is still there.
Comment 5 Thiago Macieira 2005-02-26 02:33:44 UTC
3.3.2 isn't the newest version anymore. But it's still present in HEAD 20050213.
Comment 6 Allan Sandfeld 2005-03-08 12:23:16 UTC
CVS commit by carewolf: 

Respect padding in tables. Merged from WebCore
BUG: 50235, 90711


  M +9 -1      ChangeLog   1.397
  M +6 -11     html/html_tableimpl.cpp   1.190
  M +11 -9     rendering/render_table.cpp   1.277
  M +6 -5      rendering/render_table.h   1.113
  M +4 -4      rendering/table_layout.cpp   1.41


--- kdelibs/khtml/html/html_tableimpl.cpp  #1.189:1.190
@@ -455,17 +455,12 @@ void HTMLTableElementImpl::parseAttribut
         break;
     case ATTR_CELLPADDING:
-        if (!attr->value().isEmpty()) {
-            addCSSLength(CSS_PROP_PADDING_TOP, attr->value(), true);
-            addCSSLength(CSS_PROP_PADDING_LEFT, attr->value(), true);
-            addCSSLength(CSS_PROP_PADDING_BOTTOM, attr->value(), true);
-            addCSSLength(CSS_PROP_PADDING_RIGHT, attr->value(), true);
+        if (!attr->value().isEmpty())
             padding = kMax( 0, attr->value().toInt() );
-        }
-        else {
-            removeCSSProperty(CSS_PROP_PADDING_TOP);
-            removeCSSProperty(CSS_PROP_PADDING_LEFT);
-            removeCSSProperty(CSS_PROP_PADDING_BOTTOM);
-            removeCSSProperty(CSS_PROP_PADDING_RIGHT);
+        else
             padding = 1;
+        if (m_render && m_render->isTable()) {
+            static_cast<RenderTable *>(m_render)->setCellPadding(padding);
+            if (!m_render->needsLayout())
+                m_render->setNeedsLayout(true);
         }
         break;

--- kdelibs/khtml/ChangeLog  #1.396:1.397
@@ -1,2 +1,10 @@
+2005-03-04  Allan Sandfeld Jensen <kde@carewolf.com>
+
+        Merge table padding from WebCore
+
+        * html/html_tableimpl.cpp: CELLPADDING should not set normal padding
+        * rendering/render_table.cpp: Respect padding
+        * rendering/render_table.h: bordersAndSpacing() -> bordersPaddingAndSpacing()
+
 2005-03-04  Germain Garand  <germain@ebooksfrance.org>
 
@@ -15,5 +23,5 @@
         * ecma/kjs_dom.cpp (getValueProperty/putValueProperty):
         Mozilla/IE strict compatibility: document.documentElement.scroll{Top,Left}
-        concern the canvas, not the root block. 
+        concern the canvas, not the root block.
         Cf. http://www.quirksmode.org/viewport/compatibility.html
 

--- kdelibs/khtml/rendering/render_table.cpp  #1.276:1.277
@@ -296,6 +296,6 @@ void RenderTable::layout()
     }
 
-    int bpTop = borderTop();
-    int bpBottom = borderBottom();
+    int bpTop = borderTop() + (collapseBorders() ? 0 : paddingTop());
+    int bpBottom = borderBottom() + (collapseBorders() ? 0 : paddingBottom());
 
     m_height += bpTop;
@@ -327,4 +327,6 @@ void RenderTable::layout()
     }
     int bl = borderLeft();
+    if (!collapseBorders())
+        bl += paddingLeft();
 
     // position the table sections

--- kdelibs/khtml/rendering/render_table.h  #1.112:1.113
@@ -161,6 +161,7 @@ public:
     }
 
-    int bordersAndSpacing() const {
-        return borderLeft() + borderRight() + (numEffCols()+1) * borderHSpacing();
+    int bordersPaddingAndSpacing() const {
+        return borderLeft() + borderRight() +
+               (collapseBorders() ? 0 : (paddingLeft() + paddingRight() + (numEffCols()+1) * borderHSpacing()));
     }
 

--- kdelibs/khtml/rendering/table_layout.cpp  #1.40:1.41
@@ -233,5 +233,5 @@ void FixedTableLayout::calcMinMaxWidth()
     // unlimited.
 
-    int bs = table->bordersAndSpacing();
+    int bs = table->bordersPaddingAndSpacing();
     int tableWidth = table->style()->width().isFixed() ? table->style()->width().value() - bs : 0;
 
@@ -258,5 +258,5 @@ void FixedTableLayout::calcMinMaxWidth()
 void FixedTableLayout::layout()
 {
-    int tableWidth = table->width() - table->bordersAndSpacing();
+    int tableWidth = table->width() - table->bordersPaddingAndSpacing();
     int available = tableWidth;
     int nEffCols = table->numEffCols();
@@ -597,5 +597,5 @@ void AutoTableLayout::calcMinMaxWidth()
     maxWidth = kMax( maxWidth, spanMaxWidth );
 
-    int bs = table->bordersAndSpacing();
+    int bs = table->bordersPaddingAndSpacing();
     minWidth += bs;
     maxWidth += bs;
@@ -850,5 +850,5 @@ void AutoTableLayout::layout()
 {
     // table layout based on the values collected in the layout structure.
-    int tableWidth = table->width() - table->bordersAndSpacing();
+    int tableWidth = table->width() - table->bordersPaddingAndSpacing();
     int available = tableWidth;
     int nEffCols = table->numEffCols();