Commit 80844874 authored by hyatt's avatar hyatt
Browse files

Rewrite cellpadding to not use the style system at all and

	to make table cells just get the padding from the table
	itself (overriding style).

        * khtml/html/html_tableimpl.cpp:
        (HTMLTableElementImpl::HTMLTableElementImpl):
        (HTMLTableElementImpl::attach):
        (HTMLTableElementImpl::parseAttribute):
        (HTMLTableCellElementImpl::init):
        * khtml/html/html_tableimpl.h:
        * khtml/rendering/bidi.cpp:
        (RenderFlow::layoutInlineChildren):
        * khtml/rendering/render_box.cpp:
        (RenderBox::contentWidth):
        (RenderBox::contentHeight):
        * khtml/rendering/render_flow.cpp:
        (RenderFlow::layoutBlockChildren):
        (RenderFlow::leftOffset):
        (RenderFlow::rightOffset):
        (RenderFlow::calcMinMaxWidth):
        * khtml/rendering/render_object.h:
        * khtml/rendering/render_table.cpp:
        (RenderTable::RenderTable):
        (RenderTableCell::paddingTop):
        (RenderTableCell::paddingBottom):
        (RenderTableCell::paddingLeft):
        (RenderTableCell::paddingRight):
        * khtml/rendering/render_table.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2657 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 28b09116
2002-11-13 David Hyatt <hyatt@apple.com>
Rewrite cellpadding to not use the style system at all and
to make table cells just get the padding from the table
itself (overriding style).
* khtml/html/html_tableimpl.cpp:
(HTMLTableElementImpl::HTMLTableElementImpl):
(HTMLTableElementImpl::attach):
(HTMLTableElementImpl::parseAttribute):
(HTMLTableCellElementImpl::init):
* khtml/html/html_tableimpl.h:
* khtml/rendering/bidi.cpp:
(RenderFlow::layoutInlineChildren):
* khtml/rendering/render_box.cpp:
(RenderBox::contentWidth):
(RenderBox::contentHeight):
* khtml/rendering/render_flow.cpp:
(RenderFlow::layoutBlockChildren):
(RenderFlow::leftOffset):
(RenderFlow::rightOffset):
(RenderFlow::calcMinMaxWidth):
* khtml/rendering/render_object.h:
* khtml/rendering/render_table.cpp:
(RenderTable::RenderTable):
(RenderTableCell::paddingTop):
(RenderTableCell::paddingBottom):
(RenderTableCell::paddingLeft):
(RenderTableCell::paddingRight):
* khtml/rendering/render_table.h:
2002-11-13 Ken Kocienda <kocienda@apple.com>
 
Bump WebCore cache to 4 MB (was 1 MB).
......
2002-11-13 David Hyatt <hyatt@apple.com>
Rewrite cellpadding to not use the style system at all and
to make table cells just get the padding from the table
itself (overriding style).
* khtml/html/html_tableimpl.cpp:
(HTMLTableElementImpl::HTMLTableElementImpl):
(HTMLTableElementImpl::attach):
(HTMLTableElementImpl::parseAttribute):
(HTMLTableCellElementImpl::init):
* khtml/html/html_tableimpl.h:
* khtml/rendering/bidi.cpp:
(RenderFlow::layoutInlineChildren):
* khtml/rendering/render_box.cpp:
(RenderBox::contentWidth):
(RenderBox::contentHeight):
* khtml/rendering/render_flow.cpp:
(RenderFlow::layoutBlockChildren):
(RenderFlow::leftOffset):
(RenderFlow::rightOffset):
(RenderFlow::calcMinMaxWidth):
* khtml/rendering/render_object.h:
* khtml/rendering/render_table.cpp:
(RenderTable::RenderTable):
(RenderTableCell::paddingTop):
(RenderTableCell::paddingBottom):
(RenderTableCell::paddingLeft):
(RenderTableCell::paddingRight):
* khtml/rendering/render_table.h:
2002-11-13 Ken Kocienda <kocienda@apple.com>
 
Bump WebCore cache to 4 MB (was 1 MB).
......
2002-11-13 David Hyatt <hyatt@apple.com>
Rewrite cellpadding to not use the style system at all and
to make table cells just get the padding from the table
itself (overriding style).
* khtml/html/html_tableimpl.cpp:
(HTMLTableElementImpl::HTMLTableElementImpl):
(HTMLTableElementImpl::attach):
(HTMLTableElementImpl::parseAttribute):
(HTMLTableCellElementImpl::init):
* khtml/html/html_tableimpl.h:
* khtml/rendering/bidi.cpp:
(RenderFlow::layoutInlineChildren):
* khtml/rendering/render_box.cpp:
(RenderBox::contentWidth):
(RenderBox::contentHeight):
* khtml/rendering/render_flow.cpp:
(RenderFlow::layoutBlockChildren):
(RenderFlow::leftOffset):
(RenderFlow::rightOffset):
(RenderFlow::calcMinMaxWidth):
* khtml/rendering/render_object.h:
* khtml/rendering/render_table.cpp:
(RenderTable::RenderTable):
(RenderTableCell::paddingTop):
(RenderTableCell::paddingBottom):
(RenderTableCell::paddingLeft):
(RenderTableCell::paddingRight):
* khtml/rendering/render_table.h:
2002-11-13 Ken Kocienda <kocienda@apple.com>
 
Bump WebCore cache to 4 MB (was 1 MB).
......
......@@ -56,6 +56,8 @@ HTMLTableElementImpl::HTMLTableElementImpl(DocumentPtr *doc)
rules = None;
frame = Void;
m_cellPadding = -1;
incremental = false;
m_noBorder = true;
m_solid = false;
......@@ -84,7 +86,12 @@ void HTMLTableElementImpl::attach()
}
}
return HTMLElementImpl::attach();
HTMLElementImpl::attach();
if (m_render && m_render->isTable()) {
RenderTable* table = static_cast<RenderTable*>(m_render);
table->setCellPadding(m_cellPadding);
}
}
NodeImpl* HTMLTableElementImpl::setCaption( HTMLTableCaptionElementImpl *c )
......@@ -415,9 +422,13 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
break;
case ATTR_CELLPADDING:
if (!attr->value().isEmpty())
cellPadding = attr->value();
else // XXXdwh Need to update all cells to remove the padding property.
cellPadding = "";
m_cellPadding = attr->value().toInt();
else
m_cellPadding = -1;
if (m_render && m_render->isTable()) {
RenderTable* table = static_cast<RenderTable*>(m_render);
table->setCellPadding(m_cellPadding);
}
break;
case ATTR_COLS:
{
......@@ -744,13 +755,6 @@ void HTMLTableCellElementImpl::init()
if (!m_solid)
addCSSProperty(CSS_PROP_BORDER_COLOR, "inherit");
}
if (!table->cellPadding.isEmpty()) {
addCSSLength(CSS_PROP_PADDING_TOP, table->cellPadding);
addCSSLength(CSS_PROP_PADDING_LEFT, table->cellPadding);
addCSSLength(CSS_PROP_PADDING_BOTTOM, table->cellPadding);
addCSSLength(CSS_PROP_PADDING_RIGHT, table->cellPadding);
}
}
}
......
......@@ -101,6 +101,8 @@ public:
virtual void init();
int cellPadding() { return m_cellPadding; }
protected:
HTMLTableSectionElementImpl *head;
HTMLTableSectionElementImpl *foot;
......@@ -110,7 +112,7 @@ protected:
Frame frame;
Rules rules;
DOMString cellPadding;
int m_cellPadding;
bool incremental : 1;
bool m_noBorder : 1;
......
......@@ -995,7 +995,7 @@ void RenderFlow::layoutInlineChildren()
int toAdd = style()->borderBottomWidth();
m_height = style()->borderTopWidth();
if(style()->hasPadding())
if(hasPadding())
{
m_height += paddingTop();
toAdd += paddingBottom();
......
......@@ -106,7 +106,7 @@ void RenderBox::detach(RenderArena* renderArena)
short RenderBox::contentWidth() const
{
short w = m_width - style()->borderLeftWidth() - style()->borderRightWidth();
if(style()->hasPadding())
if (hasPadding())
w -= paddingLeft() + paddingRight();
//kdDebug( 6040 ) << "RenderBox::contentWidth(2) = " << w << endl;
......@@ -116,7 +116,7 @@ short RenderBox::contentWidth() const
int RenderBox::contentHeight() const
{
int h = m_height - style()->borderTopWidth() - style()->borderBottomWidth();
if(style()->hasPadding())
if (hasPadding())
h -= paddingTop() + paddingBottom();
return h;
......
......@@ -361,7 +361,7 @@ void RenderFlow::layoutBlockChildren( bool relayoutChildren )
m_height += borderTop();
toAdd += borderBottom();
}
if(style()->hasPadding())
if (hasPadding())
{
xPos += paddingLeft();
m_height += paddingTop();
......@@ -881,9 +881,9 @@ RenderFlow::leftOffset() const
{
int left = 0;
if(style()->hasBorder())
if (style()->hasBorder())
left += borderLeft();
if(style()->hasPadding())
if (hasPadding())
left += paddingLeft();
if ( firstLine && style()->direction() == LTR ) {
......@@ -925,9 +925,9 @@ RenderFlow::rightOffset() const
{
int right = m_width;
if(style()->hasBorder())
if (style()->hasBorder())
right -= borderRight();
if(style()->hasPadding())
if (hasPadding())
right -= paddingRight();
if ( firstLine && style()->direction() == RTL ) {
......@@ -1563,7 +1563,7 @@ void RenderFlow::calcMinMaxWidth()
int toAdd = 0;
if(style()->hasBorder())
toAdd = borderLeft() + borderRight();
if(style()->hasPadding())
if (hasPadding())
toAdd += paddingLeft() + paddingRight();
m_minWidth += toAdd;
......
......@@ -407,11 +407,13 @@ public:
virtual short marginLeft() const { return 0; }
virtual short marginRight() const { return 0; }
int paddingTop() const;
int paddingBottom() const;
int paddingLeft() const;
int paddingRight() const;
// Virtual since table cells override
virtual int paddingTop() const;
virtual int paddingBottom() const;
virtual int paddingLeft() const;
virtual int paddingRight() const;
virtual bool hasPadding() const { return style()->hasPadding(); }
int borderTop() const { return style()->borderTopWidth(); }
int borderBottom() const { return style()->borderBottomWidth(); }
int borderLeft() const { return style()->borderLeftWidth(); }
......
......@@ -78,6 +78,8 @@ RenderTable::RenderTable(DOM::NodeImpl* node)
rules = None;
frame = Void;
m_cellPadding = -1;
row = 0;
col = 0;
......@@ -2138,6 +2140,33 @@ void RenderTableCell::close()
#endif
}
int RenderTableCell::paddingTop() const
{
if (m_table && m_table->cellPadding() != -1)
return m_table->cellPadding();
return RenderFlow::paddingTop();
}
int RenderTableCell::paddingBottom() const
{
if (m_table && m_table->cellPadding() != -1)
return m_table->cellPadding();
return RenderFlow::paddingBottom();
}
int RenderTableCell::paddingLeft() const
{
if (m_table && m_table->cellPadding() != -1)
return m_table->cellPadding();
return RenderFlow::paddingLeft();
}
int RenderTableCell::paddingRight() const
{
if (m_table && m_table->cellPadding() != -1)
return m_table->cellPadding();
return RenderFlow::paddingRight();
}
void RenderTableCell::repaintRectangle(int x, int y, int w, int h, bool f)
{
......
......@@ -114,6 +114,9 @@ public:
virtual void setCellWidths( );
int cellPadding() { return m_cellPadding; }
void setCellPadding(int cellPadding) { m_cellPadding = cellPadding; }
int getBaseline(int row) {return rowInfo[row].baseline;}
virtual void position(int x, int y, int from, int len, int width, bool reverse, bool firstLine, int);
......@@ -253,6 +256,8 @@ protected:
Frame frame;
Rules rules;
int m_cellPadding;
RenderTableCol *_oldColElem;
int _currentCol; // keeps track of current col for col/colgroup stuff
int spacing;
......@@ -375,7 +380,17 @@ public:
virtual void setWidth( int width );
virtual void setStyle( RenderStyle *style );
virtual void repaint();
virtual int paddingTop() const;
virtual int paddingBottom() const;
virtual int paddingLeft() const;
virtual int paddingRight() const;
virtual bool hasPadding() const {
if (m_table && m_table->cellPadding() != -1)
return true;
return style()->hasPadding();
}
virtual void updateFromElement();
void setRowHeight(int h) { rowHeight = h; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment