faster paint tree traversal

David Hyatt hyatt at apple.com
Wed Feb 11 09:49:55 CET 2004


Here's my cut at a merge.  I had to do things a bit differently for 
tables because of the collapsed border code in RenderTableCell's paint 
method.  I made a non-virtual paintObject method for RenderBlock so 
that I could basically leave RenderBlock and RenderTableCell the way 
they were.

See also what I did for RenderReplaced/Widget/Image to avoid code 
duplication (adding a shouldPaint method to RenderReplaced).

I noticed in your patch that you replaced

_y + _h

with

r.bottom()

If I'm reading the Qt docs correctly, I think this is going to 
introduce a 1 pixel error, since a 16px high rectangle at a ypos of 0 
would have a bottom ypos point of 15 (not 16).

In my merge, for now, I simply did a straight substitution of the 
rect's y() method for _y and the rect's height() method for _h.  It's 
too late in the evening for me to attempt to get the math right on all 
the < and > :)

Anyway, here's the patch:

-------------- next part --------------
Index: khtml/rendering/render_block.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_block.cpp,v
retrieving revision 1.95
diff -u -p -r1.95 khtml/rendering/render_block.cpp
--- khtml/rendering/render_block.cpp	2004/02/11 03:33:50	1.95
+++ khtml/rendering/render_block.cpp	2004/02/11 08:43:32
@@ -1147,7 +1147,7 @@ void RenderBlock::repaintObjectsBeforeLa
     }
 }
 
-void RenderBlock::paint(QPainter* p, int _x, int _y, int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderBlock::paint(PaintInfo& i, int _tx, int _ty)
 {
     _tx += m_x;
     _ty += m_y;
@@ -1166,31 +1166,27 @@ void RenderBlock::paint(QPainter* p, int
         if (m_firstLineBox && m_firstLineBox->topOverflow() < 0)
             yPos += m_firstLineBox->topOverflow();
         
-        int os = 2*maximalOutlineSize(paintAction);
-        if( (yPos >= _y + _h + os) || (_ty + h <= _y - os))
+        int os = 2*maximalOutlineSize(i.phase);
+        if( (yPos >= i.r.y() + i.r.height() + os) || (_ty + h <= i.r.y() - os))
             return;
     }
 
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    return RenderBlock::paintObject(i, _tx, _ty);
 }
 
-void RenderBlock::paintObject(QPainter *p, int _x, int _y,
-                              int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderBlock::paintObject(PaintInfo& i, int _tx, int _ty)
 {
+    PaintAction paintAction = i.phase;
 
-#ifdef DEBUG_LAYOUT
-    //    kdDebug( 6040 ) << renderName() << "(RenderBlock) " << this << " ::paintObject() w/h = (" << width() << "/" << height() << ")" << endl;
-#endif
-
     // If we're a repositioned run-in, don't paint background/borders.
     bool inlineFlow = isInlineFlow();
-    bool isPrinting = (p->device()->devType() == QInternal::Printer);
+    bool isPrinting = (i.p->device()->devType() == QInternal::Printer);
 
     // 1. paint background, borders etc
     if (!inlineFlow &&
         (paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground) &&
         shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE) {
-        paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+        paintBoxDecorations(i, _tx, _ty);
     }
 
     // We're done.  We don't bother painting any children.
@@ -1199,8 +1195,9 @@ void RenderBlock::paintObject(QPainter *
     // We don't paint our own background, but we do let the kids paint their backgrounds.
     if (paintAction == PaintActionChildBackgrounds)
         paintAction = PaintActionChildBackground;
+    PaintInfo paintInfo(i.p, i.r, paintAction);
     
-    paintLineBoxBackgroundBorder(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    paintLineBoxBackgroundBorder(paintInfo, _tx, _ty);
 
     // 2. paint contents
     int scrolledX = _tx;
@@ -1210,32 +1207,33 @@ void RenderBlock::paintObject(QPainter *
     for (RenderObject *child = firstChild(); child; child = child->nextSibling()) {        
         // Check for page-break-before: always, and if it's set, break and bail.
         if (isPrinting && !childrenInline() && child->style()->pageBreakBefore() == PBALWAYS &&
-            inRootBlockContext() && (_ty + child->yPos()) > _y && (_ty + child->yPos()) < _y + _h) {
+            inRootBlockContext() && (_ty + child->yPos()) > i.r.y() && 
+            (_ty + child->yPos()) < i.r.y() + i.r.height()) {
             canvas()->setBestTruncatedAt(_ty + child->yPos(), this, true);
             return;
         }
         
         if (!child->layer() && !child->isFloating())
-            child->paint(p, _x, _y, _w, _h, scrolledX, scrolledY, paintAction);
+            child->paint(paintInfo, scrolledX, scrolledY);
         
         // Check for page-break-after: always, and if it's set, break and bail.
         if (isPrinting && !childrenInline() && child->style()->pageBreakAfter() == PBALWAYS && 
-            inRootBlockContext() && (_ty + child->yPos() + child->height()) > _y && 
-            (_ty + child->yPos() + child->height()) < _y + _h) {
+            inRootBlockContext() && (_ty + child->yPos() + child->height()) > i.r.y() && 
+            (_ty + child->yPos() + child->height()) < i.r.y() + i.r.height()) {
             canvas()->setBestTruncatedAt(_ty + child->yPos() + child->height() + child->collapsedMarginBottom(), this, true);
             return;
         }
     }
-    paintLineBoxDecorations(p, _x, _y, _w, _h, scrolledX, scrolledY, paintAction);
+    paintLineBoxDecorations(paintInfo, scrolledX, scrolledY);
     
     // 3. paint floats.
     if (!inlineFlow && (paintAction == PaintActionFloat || paintAction == PaintActionSelection))
-        paintFloats(p, _x, _y, _w, _h, scrolledX, scrolledY, paintAction == PaintActionSelection);
+        paintFloats(paintInfo, scrolledX, scrolledY, paintAction == PaintActionSelection);
 
     // 4. paint outline.
     if (!inlineFlow && paintAction == PaintActionOutline && 
         style()->outlineWidth() && style()->visibility() == VISIBLE)
-        paintOutline(p, _tx, _ty, width(), height(), style());
+        paintOutline(i.p, _tx, _ty, width(), height(), style());
 
     // 5. paint caret.
     /*
@@ -1248,7 +1246,7 @@ void RenderBlock::paintObject(QPainter *
         NodeImpl *baseNode = s.baseNode();
         RenderObject *renderer = baseNode ? baseNode->renderer() : 0;
         if (renderer && renderer->containingBlock() == this && baseNode->isContentEditable()) {
-            document()->part()->paintCaret(p, QRect(_x, _y, _w, _h));
+            document()->part()->paintCaret(i.p, i.r);
         }
     }
     
@@ -1256,17 +1254,16 @@ void RenderBlock::paintObject(QPainter *
 #ifdef BOX_DEBUG
     if ( style() && style()->visibility() == VISIBLE ) {
         if(isAnonymous())
-            outlineBox(p, _tx, _ty, "green");
+            outlineBox(i.p, _tx, _ty, "green");
         if(isFloating())
-            outlineBox(p, _tx, _ty, "yellow");
+            outlineBox(i.p, _tx, _ty, "yellow");
         else
-            outlineBox(p, _tx, _ty);
+            outlineBox(i.p, _tx, _ty);
     }
 #endif
 }
 
-void RenderBlock::paintFloats(QPainter *p, int _x, int _y,
-                              int _w, int _h, int _tx, int _ty, bool paintSelection)
+void RenderBlock::paintFloats(PaintInfo& i, int _tx, int _ty, bool paintSelection)
 {
     if (!m_floatingObjects)
         return;
@@ -1276,33 +1273,19 @@ void RenderBlock::paintFloats(QPainter *
     for ( ; (r = it.current()); ++it) {
         // Only paint the object if our noPaint flag isn't set.
         if (!r->noPaint && !r->node->layer()) {
-            if (paintSelection) {
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionSelection);
-            }
-            else {
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionElementBackground);
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionChildBackgrounds);
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionFloat);
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionForeground);
-                r->node->paint(p, _x, _y, _w, _h,
-                               _tx + r->left - r->node->xPos() + r->node->marginLeft(),
-                               _ty + r->startY - r->node->yPos() + r->node->marginTop(),
-                               PaintActionOutline);
+            PaintInfo info(i.p, i.r, paintSelection ? PaintActionSelection : PaintActionElementBackground);
+            int tx = _tx + r->left - r->node->xPos() + r->node->marginLeft();
+            int ty = _ty + r->startY - r->node->yPos() + r->node->marginTop();
+            r->node->paint(info, tx, ty);
+            if (!paintSelection) {
+                info.phase = PaintActionChildBackgrounds;
+                r->node->paint(info, tx, ty);
+                info.phase = PaintActionFloat;
+                r->node->paint(info, tx, ty);
+                info.phase = PaintActionForeground;
+                r->node->paint(info, tx, ty);
+                info.phase = PaintActionOutline;
+                r->node->paint(info, tx, ty);
             }
         }
     }
Index: khtml/rendering/render_block.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_block.h,v
retrieving revision 1.30
diff -u -p -r1.30 khtml/rendering/render_block.h
--- khtml/rendering/render_block.h	2004/01/26 21:56:41	1.30
+++ khtml/rendering/render_block.h	2004/02/11 08:43:32
@@ -120,13 +120,9 @@ public:
     void computeVerticalPositionsForLine(InlineFlowBox* lineBox);
     // end bidi.cpp functions
     
-    virtual void paint(QPainter *, int x, int y, int w, int h,
-                       int tx, int ty, PaintAction paintAction);
-    virtual void paintObject(QPainter *, int x, int y, int w, int h,
-                             int tx, int ty, PaintAction paintAction);
-    void paintFloats(QPainter *p, int _x, int _y,
-                     int _w, int _h, int _tx, int _ty, bool paintSelection = false);
-    
+    virtual void paint(PaintInfo& i, int tx, int ty);
+    void paintObject(PaintInfo& i, int tx, int ty);
+    void paintFloats(PaintInfo& i, int _tx, int _ty, bool paintSelection = false);
 
     void insertFloatingObject(RenderObject *o);
     void removeFloatingObject(RenderObject *o);
Index: khtml/rendering/render_box.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_box.cpp,v
retrieving revision 1.109
diff -u -p -r1.109 khtml/rendering/render_box.cpp
--- khtml/rendering/render_box.cpp	2004/01/27 10:01:55	1.109
+++ khtml/rendering/render_box.cpp	2004/02/11 08:43:34
@@ -180,23 +180,17 @@ int RenderBox::height() const
 
 // --------------------- painting stuff -------------------------------
 
-void RenderBox::paint(QPainter *p, int _x, int _y, int _w, int _h,
-                      int _tx, int _ty, PaintAction paintAction)
+void RenderBox::paint(PaintInfo& i, int _tx, int _ty)
 {
     _tx += m_x;
     _ty += m_y;
 
-    // default implementation. Just pass things through to the children
-    RenderObject *child = firstChild();
-    while(child != 0)
-    {
-        child->paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-        child = child->nextSibling();
-    }
+    // default implementation. Just pass paint through to the children
+    for (RenderObject* child = firstChild(); child; child = child->nextSibling())
+        child->paint(i, _tx, _ty);
 }
 
-void RenderBox::paintRootBoxDecorations(QPainter *p,int, int _y,
-                                        int, int _h, int _tx, int _ty)
+void RenderBox::paintRootBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     //kdDebug( 6040 ) << renderName() << "::paintBoxDecorations()" << _tx << "/" << _ty << endl;
     QColor c = style()->backgroundColor();
@@ -255,38 +249,37 @@ void RenderBox::paintRootBoxDecorations(
 
     int bx = _tx - marginLeft();
     int by = _ty - marginTop();
-    int bw = QMAX(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
-    int bh = QMAX(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh);
+    int bw = kMax(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
+    int bh = kMax(h + marginTop() + marginBottom() + borderTop() + borderBottom(), rh);
 
     // CSS2 14.2:
     // " The background of the box generated by the root element covers the entire canvas."
     // hence, paint the background even in the margin areas (unlike for every other element!)
     // I just love these little inconsistencies .. :-( (Dirk)
-    int my = QMAX(by,_y);
+    int my = kMax(by, i.r.y());
 
-    paintBackground(p, c, bg, my, _h, bx, by, bw, bh);
+    paintBackground(i.p, c, bg, my, i.r.height(), bx, by, bw, bh);
 
     if (style()->hasBorder() && style()->display() != INLINE)
-        paintBorder( p, _tx, _ty, w, h, style() );
+        paintBorder( i.p, _tx, _ty, w, h, style() );
 }
 
-void RenderBox::paintBoxDecorations(QPainter *p,int _x, int _y,
-                                    int _w, int _h, int _tx, int _ty)
+void RenderBox::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     //kdDebug( 6040 ) << renderName() << "::paintDecorations()" << endl;
     if (isRoot())
-        return paintRootBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+        return paintRootBoxDecorations(i, _tx, _ty);
     
     int w = width();
     int h = height() + borderTopExtra() + borderBottomExtra();
     _ty -= borderTopExtra();
 
-    int my = QMAX(_ty,_y);
+    int my = kMax(_ty, i.r.y());
     int mh;
-    if (_ty<_y)
-        mh= QMAX(0,h-(_y-_ty));
+    if (_ty < i.r.y())
+        mh= kMax(0, h - (i.r.y() - _ty));
     else
-        mh = QMIN(_h,h);
+        mh = kMin(i.r.height(), h);
 
     // The <body> only paints its background if the root element has defined a background
     // independent of the body.  Go through the DOM to get to the root element's render object,
@@ -294,10 +287,10 @@ void RenderBox::paintBoxDecorations(QPai
     if (!isBody()
         || element()->getDocument()->documentElement()->renderer()->style()->backgroundColor().isValid()
         || element()->getDocument()->documentElement()->renderer()->style()->backgroundImage())
-        paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
+        paintBackground(i.p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
    
     if (style()->hasBorder())
-        paintBorder(p, _tx, _ty, w, h, style());
+        paintBorder(i.p, _tx, _ty, w, h, style());
 }
 
 void RenderBox::paintBackground(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph, int _tx, int _ty, int w, int height)
Index: khtml/rendering/render_box.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_box.h,v
retrieving revision 1.36
diff -u -p -r1.36 khtml/rendering/render_box.h
--- khtml/rendering/render_box.h	2004/01/26 21:56:41	1.36
+++ khtml/rendering/render_box.h	2004/02/11 08:43:34
@@ -48,8 +48,7 @@ public:
     virtual const char *renderName() const { return "RenderBox"; }
 
     virtual void setStyle(RenderStyle *style);
-    virtual void paint(QPainter *p, int _x, int _y, int _w, int _h,
-                       int _tx, int _ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int _tx, int _ty);
 
     virtual void detach();
     
@@ -130,10 +129,8 @@ public:
     virtual void setStaticY(int staticY);
 
 protected:
-    virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty);
-    void paintRootBoxDecorations(QPainter *p,int, int _y,
-                                 int, int _h, int _tx, int _ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
+    void paintRootBoxDecorations(PaintInfo& i, int _tx, int _ty);
 
     void paintBackground(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph, int _tx, int _ty, int w, int h);
     void outlineBox(QPainter *p, int _tx, int _ty, const char *color = "red");
Index: khtml/rendering/render_br.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_br.h,v
retrieving revision 1.8
diff -u -p -r1.8 khtml/rendering/render_br.h
--- khtml/rendering/render_br.h	2004/02/04 22:22:13	1.8
+++ khtml/rendering/render_br.h	2004/02/11 08:43:34
@@ -38,9 +38,8 @@ public:
 
     virtual const char *renderName() const { return "RenderBR"; }
 
-    virtual void paint( QPainter *, int, int, int, int, int, int, int) {}
-    virtual void paintObject( QPainter *, int, int, int, int, int, int, int) {}
-
+    virtual void paint(PaintInfo&, int, int) {}
+    
     virtual void position(InlineBox* box, int from, int len, bool reverse);
     virtual unsigned int width(unsigned int, unsigned int, const Font *) const { return 0; }
     virtual unsigned int width( unsigned int, unsigned int, bool) const { return 0; }
Index: khtml/rendering/render_canvas.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_canvas.cpp,v
retrieving revision 1.16
diff -u -p -r1.16 khtml/rendering/render_canvas.cpp
--- khtml/rendering/render_canvas.cpp	2003/12/13 00:23:54	1.16
+++ khtml/rendering/render_canvas.cpp	2004/02/11 08:43:35
@@ -196,32 +196,21 @@ bool RenderCanvas::absolutePosition(int 
     return true;
 }
 
-void RenderCanvas::paint(QPainter *p, int _x, int _y, int _w, int _h, int _tx, int _ty,
-                       PaintAction paintAction)
+void RenderCanvas::paint(PaintInfo& i, int _tx, int _ty)
 {
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-}
-
-void RenderCanvas::paintObject(QPainter *p, int _x, int _y,
-                             int _w, int _h, int _tx, int _ty, PaintAction paintAction)
-{
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << renderName() << "(RenderCanvas) " << this << " ::paintObject() w/h = (" << width() << "/" << height() << ")" << endl;
 #endif
     // 1. paint background, borders etc
-    if (paintAction == PaintActionElementBackground) {
-        paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+    if (i.phase == PaintActionElementBackground) {
+        paintBoxDecorations(i, _tx, _ty);
         return;
     }
     
     // 2. paint contents
-    RenderObject *child = firstChild();
-    while(child != 0) {
-        if(!child->layer() && !child->isFloating()) {
-            child->paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-        }
-        child = child->nextSibling();
-    }
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
+        if (!child->layer() && !child->isFloating())
+            child->paint(i, _tx, _ty);
 
     if (m_view)
     {
@@ -230,17 +219,15 @@ void RenderCanvas::paintObject(QPainter 
     }
     
     // 3. paint floats.
-    if (paintAction == PaintActionFloat)
-        paintFloats(p, _x, _y, _w, _h, _tx, _ty);
+    if (i.phase == PaintActionFloat)
+        paintFloats(i, _tx, _ty);
         
 #ifdef BOX_DEBUG
-    outlineBox(p, _tx, _ty);
+    outlineBox(i.p, _tx, _ty);
 #endif
-
 }
 
-void RenderCanvas::paintBoxDecorations(QPainter *p,int _x, int _y,
-                                       int _w, int _h, int _tx, int _ty)
+void RenderCanvas::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     // Check to see if we are enclosed by a transparent layer.  If so, we cannot blit
     // when scrolling, and we need to use slow repaints.
@@ -260,7 +247,8 @@ void RenderCanvas::paintBoxDecorations(Q
     if (elt)
         view()->useSlowRepaints(); // The parent must show behind the child.
     else
-        p->fillRect(_x,_y,_w,_h, view()->palette().active().color(QColorGroup::Base));
+        i.p->fillRect(i.r.x(), i.r.y(), i.r.width(), i.r.height(), 
+                    view()->palette().active().color(QColorGroup::Base));
 }
 
 void RenderCanvas::repaintViewRectangle(const QRect& ur, bool immediate)
Index: khtml/rendering/render_canvas.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_canvas.h,v
retrieving revision 1.6
diff -u -p -r1.6 khtml/rendering/render_canvas.h
--- khtml/rendering/render_canvas.h	2003/12/13 00:23:54	1.6
+++ khtml/rendering/render_canvas.h	2004/02/11 08:43:35
@@ -56,13 +56,8 @@ public:
     virtual void computeAbsoluteRepaintRect(QRect& r, bool f=false);
     virtual void repaintViewRectangle(const QRect& r, bool immediate = false);
     
-    virtual void paint(QPainter *, int x, int y, int w, int h, int tx, int ty,
-                       PaintAction paintAction);
-    void paintObject(QPainter *p, int _x, int _y,
-                     int _w, int _h, int _tx, int _ty, PaintAction paintAction);
-
-    virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty);
+    virtual void paint(PaintInfo& i, int tx, int ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
     
     virtual void setSelection(RenderObject *s, int sp, RenderObject *e, int ep);
     virtual void clearSelection(bool doRepaint=true);
Index: khtml/rendering/render_flow.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_flow.cpp,v
retrieving revision 1.122
diff -u -p -r1.122 khtml/rendering/render_flow.cpp
--- khtml/rendering/render_flow.cpp	2004/02/04 21:33:12	1.122
+++ khtml/rendering/render_flow.cpp	2004/02/11 08:43:35
@@ -197,18 +197,17 @@ InlineBox* RenderFlow::createInlineBox(b
     return flowBox;
 }
 
-void RenderFlow::paintLineBoxBackgroundBorder(QPainter *p, int _x, int _y,
-                                int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderFlow::paintLineBoxBackgroundBorder(PaintInfo& i, int _tx, int _ty)
 {
     if (!firstLineBox())
         return;
-    
-    if (style()->visibility() == VISIBLE && paintAction == PaintActionForeground) {
+ 
+    if (style()->visibility() == VISIBLE && i.phase == PaintActionForeground) {
         // We can check the first box and last box and avoid painting if we don't
         // intersect.
         int yPos = _ty + firstLineBox()->yPos();
         int h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
-        if( (yPos >= _y + _h) || (yPos + h <= _y))
+        if( (yPos >= i.r.y() + i.r.height()) || (yPos + h <= i.r.y()))
             return;
 
         // See if our boxes intersect with the dirty rect.  If so, then we paint
@@ -218,20 +217,19 @@ void RenderFlow::paintLineBoxBackgroundB
         for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
             yPos = _ty + curr->yPos();
             h = curr->height();
-            if ((yPos < _y + _h) && (yPos + h > _y))
-                curr->paintBackgroundAndBorder(p, _x, _y, _w, _h, _tx, _ty, xOffsetWithinLineBoxes);
+            if ((yPos < i.r.y() + i.r.height()) && (yPos + h > i.r.y()))
+                curr->paintBackgroundAndBorder(i, _tx, _ty, xOffsetWithinLineBoxes);
             xOffsetWithinLineBoxes += curr->width();
         }
     }
 }
 
-void RenderFlow::paintLineBoxDecorations(QPainter *p, int _x, int _y,
-                                         int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderFlow::paintLineBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     if (!firstLineBox())
         return;
 
-    if (style()->visibility() == VISIBLE && paintAction == PaintActionForeground) {
+    if (style()->visibility() == VISIBLE && i.phase == PaintActionForeground) {
         // We only paint line box decorations in strict or almost strict mode.
         // Otherwise we let the InlineTextBoxes paint their own decorations.
         if (style()->htmlHacks())
@@ -241,7 +239,7 @@ void RenderFlow::paintLineBoxDecorations
         // intersect.
         int yPos = _ty + firstLineBox()->yPos();;
         int h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
-        if( (yPos >= _y + _h) || (yPos + h <= _y))
+        if( (yPos >= i.r.y() + i.r.height()) || (yPos + h <= i.r.y()))
             return;
 
         // See if our boxes intersect with the dirty rect.  If so, then we paint
@@ -250,8 +248,8 @@ void RenderFlow::paintLineBoxDecorations
         for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
             yPos = _ty + curr->yPos();
             h = curr->height();
-            if ((yPos < _y + _h) && (yPos + h > _y))
-                curr->paintDecorations(p, _x, _y, _w, _h, _tx, _ty);
+            if ((yPos < i.r.y() + i.r.height()) && (yPos + h > i.r.y()))
+                curr->paintDecorations(i, _tx, _ty);
         }
     }
 }
Index: khtml/rendering/render_flow.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_flow.h,v
retrieving revision 1.49
diff -u -p -r1.49 khtml/rendering/render_flow.h
--- khtml/rendering/render_flow.h	2004/02/04 22:22:13	1.49
+++ khtml/rendering/render_flow.h	2004/02/11 08:43:36
@@ -66,10 +66,8 @@ public:
 
     virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox);
 
-    void paintLineBoxBackgroundBorder(QPainter *p, int _x, int _y,
-                        int _w, int _h, int _tx, int _ty, PaintAction paintAction);
-    void paintLineBoxDecorations(QPainter *p, int _x, int _y,
-                                 int _w, int _h, int _tx, int _ty, PaintAction paintAction);
+    void paintLineBoxBackgroundBorder(PaintInfo& i, int _tx, int _ty);
+    void paintLineBoxDecorations(PaintInfo& i, int _tx, int _ty);
 
     virtual QRect getAbsoluteRepaintRect();
     
Index: khtml/rendering/render_form.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_form.cpp,v
retrieving revision 1.77
diff -u -p -r1.77 khtml/rendering/render_form.cpp
--- khtml/rendering/render_form.cpp	2004/02/08 02:44:07	1.77
+++ khtml/rendering/render_form.cpp	2004/02/11 08:43:37
@@ -712,8 +712,7 @@ RenderObject* RenderFieldset::findLegend
     return 0;
 }
 
-void RenderFieldset::paintBoxDecorations(QPainter *p,int _x, int _y,
-                                         int _w, int _h, int _tx, int _ty)
+void RenderFieldset::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     //kdDebug( 6040 ) << renderName() << "::paintDecorations()" << endl;
 
@@ -721,20 +720,20 @@ void RenderFieldset::paintBoxDecorations
     int h = height() + borderTopExtra() + borderBottomExtra();
     RenderObject* legend = findLegend();
     if (!legend)
-        return RenderBlock::paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+        return RenderBlock::paintBoxDecorations(i, _tx, _ty);
 
     int yOff = (legend->yPos() > 0) ? 0 : (legend->height()-borderTop())/2;
     h -= yOff;
     _ty += yOff - borderTopExtra();
 
-    int my = QMAX(_ty,_y);
-    int end = QMIN( _y + _h,  _ty + h );
+    int my = kMax(_ty, i.r.y());
+    int end = kMin(i.r.y() + i.r.height(),  _ty + h);
     int mh = end - my;
 
-    paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
+    paintBackground(i.p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
 
     if (style()->hasBorder())
-        paintBorderMinusLegend(p, _tx, _ty, w, h, style(), legend->xPos(), legend->width());
+        paintBorderMinusLegend(i.p, _tx, _ty, w, h, style(), legend->xPos(), legend->width());
 }
 
 void RenderFieldset::paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w, int h,
Index: khtml/rendering/render_form.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_form.h,v
retrieving revision 1.36
diff -u -p -r1.36 khtml/rendering/render_form.h
--- khtml/rendering/render_form.h	2004/01/27 01:37:56	1.36
+++ khtml/rendering/render_form.h	2004/02/11 08:43:38
@@ -298,8 +298,7 @@ public:
     virtual void setStyle(RenderStyle* _style);
     
 protected:
-    virtual void paintBoxDecorations(QPainter *p,int, int _y,
-                                     int, int _h, int _tx, int _ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
     void paintBorderMinusLegend(QPainter *p, int _tx, int _ty, int w,
                                 int h, const RenderStyle *style, int lx, int lw);
     RenderObject* findLegend();
Index: khtml/rendering/render_image.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_image.cpp,v
retrieving revision 1.50
diff -u -p -r1.50 khtml/rendering/render_image.cpp
--- khtml/rendering/render_image.cpp	2004/01/26 21:56:41	1.50
+++ khtml/rendering/render_image.cpp	2004/02/11 08:43:39
@@ -206,17 +206,24 @@ QColor RenderImage::selectionTintColor(Q
 }
 #endif
 
-void RenderImage::paintObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, int /*_h*/, int _tx, int _ty, PaintAction paintAction)
+void RenderImage::paint(PaintInfo& i, int _tx, int _ty)
 {
-    if (paintAction == PaintActionOutline && style()->outlineWidth() && style()->visibility() == VISIBLE)
+    if (!shouldPaint(i, _tx, _ty)) return;
+    
+    if (shouldPaintBackgroundOrBorder() && i.phase != PaintActionOutline) 
+        paintBoxDecorations(i, _tx, _ty);
+
+    QPainter* p = i.p;
+    
+    if (i.phase == PaintActionOutline && style()->outlineWidth() && style()->visibility() == VISIBLE)
         paintOutline(p, _tx, _ty, width(), height(), style());
     
-    if (paintAction != PaintActionForeground && paintAction != PaintActionSelection)
+    if (i.phase != PaintActionForeground && i.phase != PaintActionSelection)
         return;
 
 #if APPLE_CHANGES
     bool drawSelectionTint = selectionState() != SelectionNone;
-    if (paintAction == PaintActionSelection) {
+    if (i.phase == PaintActionSelection) {
         if (selectionState() == SelectionNone) {
             return;
         }
@@ -237,9 +244,9 @@ void RenderImage::paintObject(QPainter *
     //kdDebug( 6040 ) << "    contents (" << contentWidth << "/" << contentHeight << ") border=" << borderLeft() << " padding=" << paddingLeft() << endl;
     if ( pix.isNull() || berrorPic)
     {
-        if (paintAction == PaintActionSelection) {
+        if (i.phase == PaintActionSelection)
             return;
-        }
+
         if(cWidth > 2 && cHeight > 2)
         {
 #if APPLE_CHANGES
Index: khtml/rendering/render_image.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_image.h,v
retrieving revision 1.17
diff -u -p -r1.17 khtml/rendering/render_image.h
--- khtml/rendering/render_image.h	2003/11/11 00:00:54	1.17
+++ khtml/rendering/render_image.h	2004/02/11 08:43:39
@@ -48,7 +48,7 @@ public:
 
     virtual bool isImage() const { return true; }
     
-    virtual void paintObject( QPainter *p, int /*x*/, int /*y*/, int /*w*/, int /*h*/, int tx, int ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     virtual void layout();
 
Index: khtml/rendering/render_inline.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_inline.cpp,v
retrieving revision 1.31
diff -u -p -r1.31 khtml/rendering/render_inline.cpp
--- khtml/rendering/render_inline.cpp	2004/02/10 20:52:12	1.31
+++ khtml/rendering/render_inline.cpp	2004/02/11 08:43:39
@@ -257,52 +257,35 @@ void RenderInline::splitFlow(RenderObjec
     block->setNeedsLayoutAndMinMaxRecalc();
 }
 
-void RenderInline::paint(QPainter *p, int _x, int _y, int _w, int _h,
-                      int _tx, int _ty, PaintAction paintAction)
+void RenderInline::paint(PaintInfo& i, int _tx, int _ty)
 {
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-}
-
-void RenderInline::paintObject(QPainter *p, int _x, int _y,
-                             int _w, int _h, int _tx, int _ty, PaintAction paintAction)
-{
 #ifdef DEBUG_LAYOUT
     //    kdDebug( 6040 ) << renderName() << "(RenderInline) " << this << " ::paintObject() w/h = (" << width() << "/" << height() << ")" << endl;
 #endif
-
-    // If we have an inline root, it has to call the special root box decoration painting
-    // function.
-    if (isRoot() &&
-        (paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground) &&
-        shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE) {
-        paintRootBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
-    }
     
     // We're done.  We don't bother painting any children.
-    if (paintAction == PaintActionElementBackground)
+    if (i.phase == PaintActionElementBackground)
         return;
+    
     // We don't paint our own background, but we do let the kids paint their backgrounds.
-    if (paintAction == PaintActionChildBackgrounds)
-        paintAction = PaintActionChildBackground;
+    PaintInfo paintInfo(i.p, i.r, i.phase);
+    if (i.phase == PaintActionChildBackgrounds)
+        paintInfo.phase = PaintActionChildBackground;
 
-    paintLineBoxBackgroundBorder(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    paintLineBoxBackgroundBorder(paintInfo, _tx, _ty);
     
-    RenderObject *child = firstChild();
-    while(child != 0)
-    {
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
         if(!child->layer() && !child->isFloating())
-            child->paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-        child = child->nextSibling();
-    }
+            child->paint(paintInfo, _tx, _ty);
 
-    paintLineBoxDecorations(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-    if (style()->visibility() == VISIBLE && paintAction == PaintActionOutline) {
+    paintLineBoxDecorations(paintInfo, _tx, _ty);
+    if (style()->visibility() == VISIBLE && paintInfo.phase == PaintActionOutline) {
 #if APPLE_CHANGES
         if (style()->outlineStyleIsAuto())
-            paintFocusRing(p, _tx, _ty);
+            paintFocusRing(paintInfo.p, _tx, _ty);
         else
 #endif
-        paintOutlines(p, _tx, _ty);
+        paintOutlines(paintInfo.p, _tx, _ty);
     }
 }
 
Index: khtml/rendering/render_inline.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_inline.h,v
retrieving revision 1.16
diff -u -p -r1.16 khtml/rendering/render_inline.h
--- khtml/rendering/render_inline.h	2003/12/17 23:48:53	1.16
+++ khtml/rendering/render_inline.h	2004/02/11 08:43:40
@@ -53,10 +53,7 @@ public:
 
     virtual void layout() {} // Do nothing for layout()
     
-    virtual void paint(QPainter *, int x, int y, int w, int h,
-                       int tx, int ty, PaintAction paintAction);
-    virtual void paintObject(QPainter *, int x, int y, int w, int h,
-                             int tx, int ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     virtual bool nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
                              HitTestAction hitTestAction = HitTestAll, bool inside=false);
Index: khtml/rendering/render_layer.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_layer.cpp,v
retrieving revision 1.65
diff -u -p -r1.65 khtml/rendering/render_layer.cpp
--- khtml/rendering/render_layer.cpp	2004/02/08 02:44:07	1.65
+++ khtml/rendering/render_layer.cpp	2004/02/11 08:43:41
@@ -753,11 +753,8 @@ RenderLayer::paintLayer(RenderLayer* roo
         setClip(p, paintDirtyRect, damageRect);
 
         // Paint the background.
-        renderer()->paint(p, damageRect.x(), damageRect.y(),
-                            damageRect.width(), damageRect.height(),
-                            x - renderer()->xPos(), y - renderer()->yPos(),
-                            PaintActionElementBackground);
-        
+        RenderObject::PaintInfo info = RenderObject::PaintInfo(p, damageRect, PaintActionElementBackground);
+        renderer()->paint(info, x - renderer()->xPos(), y - renderer()->yPos());        
 #if APPLE_CHANGES
         // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with
         // z-index.  We paint after we painted the background/border, so that the scrollbars will
@@ -788,23 +785,18 @@ RenderLayer::paintLayer(RenderLayer* roo
         // Set up the clip used when painting our children.
         setClip(p, paintDirtyRect, clipRectToApply);
 
-        if (selectionOnly)
-            renderer()->paint(p, clipRectToApply.x(), clipRectToApply.y(),
-                              clipRectToApply.width(), clipRectToApply.height(),
-                              x - renderer()->xPos(), y - renderer()->yPos(), PaintActionSelection);
-        else {
-            renderer()->paint(p, clipRectToApply.x(), clipRectToApply.y(),
-                              clipRectToApply.width(), clipRectToApply.height(),
-                              x - renderer()->xPos(), y - renderer()->yPos(), PaintActionChildBackgrounds);
-            renderer()->paint(p, clipRectToApply.x(), clipRectToApply.y(),
-                              clipRectToApply.width(), clipRectToApply.height(),
-                              x - renderer()->xPos(), y - renderer()->yPos(), PaintActionFloat);
-            renderer()->paint(p, clipRectToApply.x(), clipRectToApply.y(),
-                              clipRectToApply.width(), clipRectToApply.height(),
-                              x - renderer()->xPos(), y - renderer()->yPos(), PaintActionForeground);
-            renderer()->paint(p, clipRectToApply.x(), clipRectToApply.y(),
-                              clipRectToApply.width(), clipRectToApply.height(),
-                              x - renderer()->xPos(), y - renderer()->yPos(), PaintActionOutline);
+        int tx = x - renderer()->xPos();
+        int ty = y - renderer()->yPos();
+        RenderObject::PaintInfo info(p, clipRectToApply, 
+                                     selectionOnly ? PaintActionSelection : PaintActionChildBackgrounds);
+        renderer()->paint(info, tx, ty);
+        if (!selectionOnly) {
+            info.phase = PaintActionFloat;
+            renderer()->paint(info, tx, ty);
+            info.phase = PaintActionForeground;
+            renderer()->paint(info, tx, ty);
+            info.phase = PaintActionOutline;
+            renderer()->paint(info, tx, ty);
         }
 
         // Now restore our clip.
Index: khtml/rendering/render_line.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_line.cpp,v
retrieving revision 1.15
diff -u -p -r1.15 khtml/rendering/render_line.cpp
--- khtml/rendering/render_line.cpp	2004/01/27 10:01:55	1.15
+++ khtml/rendering/render_line.cpp	2004/02/11 08:43:43
@@ -507,8 +507,7 @@ void InlineFlowBox::shrinkBoxesWithNoTex
     }
 }
 
-void InlineFlowBox::paintBackgroundAndBorder(QPainter *p, int _x, int _y,
-                                             int _w, int _h, int _tx, int _ty, int xOffsetOnLine)
+void InlineFlowBox::paintBackgroundAndBorder(RenderObject::PaintInfo& i, int _tx, int _ty, int xOffsetOnLine)
 {
     // Move x/y to our coordinates.
     _tx += m_x;
@@ -517,13 +516,15 @@ void InlineFlowBox::paintBackgroundAndBo
     int w = width();
     int h = height();
 
-    int my = QMAX(_ty,_y);
+    int my = kMax(_ty, i.r.y());
     int mh;
-    if (_ty<_y)
-        mh= QMAX(0,h-(_y-_ty));
+    if (_ty < i.r.y())
+        mh= kMax(0, h - (i.r.y() - _ty));
     else
-        mh = QMIN(_h,h);
+        mh = kMin(i.r.height(), h);
 
+    QPainter* p = i.p;
+    
     // You can use p::first-line to specify a background. If so, the root line boxes for
     // a line may actually have to paint a background.
     RenderStyle* styleToUse = object()->style(m_firstLine);
@@ -583,11 +584,11 @@ static bool shouldDrawDecoration(RenderO
     return shouldDraw;
 }
 
-void InlineFlowBox::paintDecorations(QPainter *p, int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty)
+void InlineFlowBox::paintDecorations(RenderObject::PaintInfo& i, int _tx, int _ty)
 {
     // Now paint our text decorations. We only do this if we aren't in quirks mode (i.e., in
     // almost-strict mode or strict mode).
+    QPainter* p = i.p;
     _tx += m_x;
     _ty += m_y;
     RenderStyle* styleToUse = object()->style(m_firstLine);
Index: khtml/rendering/render_line.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_line.h,v
retrieving revision 1.7
diff -u -p -r1.7 khtml/rendering/render_line.h
--- khtml/rendering/render_line.h	2004/01/27 10:01:55	1.7
+++ khtml/rendering/render_line.h	2004/02/11 08:43:43
@@ -142,10 +142,8 @@ public:
     void setNextLineBox(InlineRunBox* n) { m_nextLine = n; }
     void setPreviousLineBox(InlineRunBox* p) { m_prevLine = p; }
 
-    virtual void paintBackgroundAndBorder(QPainter *p, int _x, int _y,
-                       int _w, int _h, int _tx, int _ty, int xOffsetOnLine) {};
-    virtual void paintDecorations(QPainter *p, int _x, int _y,
-                       int _w, int _h, int _tx, int _ty) {};
+    virtual void paintBackgroundAndBorder(RenderObject::PaintInfo& i, int _tx, int _ty, int xOffsetOnLine) {};
+    virtual void paintDecorations(RenderObject::PaintInfo& i, int _tx, int _ty) {};
     
 protected:
     InlineRunBox* m_prevLine;  // The previous box that also uses our RenderObject
@@ -188,10 +186,8 @@ public:
             m_hasTextChildren = true;
     }
 
-    virtual void paintBackgroundAndBorder(QPainter *p, int _x, int _y,
-                       int _w, int _h, int _tx, int _ty, int xOffsetOnLine);
-    virtual void paintDecorations(QPainter *p, int _x, int _y,
-                       int _w, int _h, int _tx, int _ty);
+    virtual void paintBackgroundAndBorder(RenderObject::PaintInfo& i, int _tx, int _ty, int xOffsetOnLine);
+    virtual void paintDecorations(RenderObject::PaintInfo& i, int _tx, int _ty);
     
     int marginBorderPaddingLeft();
     int marginBorderPaddingRight();
Index: khtml/rendering/render_list.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_list.cpp,v
retrieving revision 1.51
diff -u -p -r1.51 khtml/rendering/render_list.cpp
--- khtml/rendering/render_list.cpp	2004/02/10 20:52:12	1.51
+++ khtml/rendering/render_list.cpp	2004/02/11 08:43:44
@@ -271,26 +271,17 @@ void RenderListItem::layout( )
     RenderBlock::layout();
 }
 
-void RenderListItem::paint(QPainter *p, int _x, int _y, int _w, int _h,
-                           int _tx, int _ty, PaintAction paintAction)
+void RenderListItem::paint(PaintInfo& i, int _tx, int _ty)
 {
-    if ( !m_height )
+    if (!m_height)
         return;
 
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << nodeName().string() << "(LI)::paint()" << endl;
 #endif
-    RenderBlock::paint(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    RenderBlock::paint(i, _tx, _ty);
 }
 
-void RenderListItem::paintObject(QPainter *p, int _x, int _y,
-                                    int _w, int _h, int _tx, int _ty, PaintAction paintAction)
-{
-    // ### this should scale with the font size in the body... possible?
-    //m_marker->printIcon(p, _tx, _ty);
-    RenderBlock::paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-}
-
 QRect RenderListItem::getAbsoluteRepaintRect()
 {
     QRect result = RenderBlock::getAbsoluteRepaintRect();
@@ -359,10 +350,9 @@ void RenderListMarker::setStyle(RenderSt
 }
 
 
-void RenderListMarker::paint(QPainter *p, int _x, int _y, int _w, int _h,
-                             int _tx, int _ty, PaintAction paintAction)
+void RenderListMarker::paint(PaintInfo& i, int _tx, int _ty)
 {
-    if (paintAction != PaintActionForeground)
+    if (i.phase != PaintActionForeground)
         return;
     
     if (style()->visibility() != VISIBLE)  return;
@@ -370,23 +360,17 @@ void RenderListMarker::paint(QPainter *p
     _tx += m_x;
     _ty += m_y;
 
-    if((_ty > _y + _h) || (_ty + m_height < _y))
+    if ((_ty > i.r.y() + i.r.height()) || (_ty + m_height < i.r.y()))
         return;
-
-    if(shouldPaintBackgroundOrBorder()) 
-        paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
 
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-}
-
-void RenderListMarker::paintObject(QPainter *p, int, int _y,
-                                    int, int _h, int _tx, int _ty, PaintAction paintAction)
-{
-    if (style()->visibility() != VISIBLE) return;
+    if (shouldPaintBackgroundOrBorder()) 
+        paintBoxDecorations(i, _tx, _ty);
 
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << nodeName().string() << "(ListMarker)::paintObject(" << _tx << ", " << _ty << ")" << endl;
 #endif
+
+    QPainter* p = i.p;
     p->setFont(style()->font());
     const QFontMetrics fm = p->fontMetrics();
     int offset = fm.ascent()*2/3;
@@ -421,12 +405,12 @@ void RenderListMarker::paintObject(QPain
     bool isPrinting = (p->device()->devType() == QInternal::Printer);
     if (isPrinting)
     {
-        if (_ty < _y)
+        if (_ty < i.r.y())
         {
             // This has been printed already we suppose.
             return;
         }
-        if (_ty + m_height + paddingBottom() + borderBottom() >= _y+_h)
+        if (_ty + m_height + paddingBottom() + borderBottom() >= i.r.y() + i.r.height())
         {
             RenderCanvas *rootObj = canvas();
             if (_ty < rootObj->truncatedAt())
Index: khtml/rendering/render_list.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_list.h,v
retrieving revision 1.19
diff -u -p -r1.19 khtml/rendering/render_list.h
--- khtml/rendering/render_list.h	2003/10/07 04:43:23	1.19
+++ khtml/rendering/render_list.h	2004/02/11 08:43:44
@@ -48,10 +48,7 @@ public:
     // so the marker gets to layout itself. Only needed for
     // list-style-position: inside
 
-    virtual void paint(QPainter *p, int x, int y, int w, int h,
-                       int xoff, int yoff, PaintAction paintAction);
-    virtual void paintObject(QPainter *p, int x, int y, int w, int h,
-                             int xoff, int yoff, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int xoff, int yoff);
     virtual void layout( );
     virtual void calcMinMaxWidth();
 
@@ -98,10 +95,7 @@ public:
     void setValue( long v ) { predefVal = v; }
     void calcListValue();
     
-    virtual void paint(QPainter *p, int x, int y, int w, int h,
-                       int xoff, int yoff, PaintAction paintAction);
-    virtual void paintObject(QPainter *p, int x, int y, int w, int h,
-                       int xoff, int yoff, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int xoff, int yoff);
 
     virtual void layout( );
     virtual void calcMinMaxWidth();
Index: khtml/rendering/render_object.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_object.cpp,v
retrieving revision 1.131
diff -u -p -r1.131 khtml/rendering/render_object.cpp
--- khtml/rendering/render_object.cpp	2004/02/11 01:44:55	1.131
+++ khtml/rendering/render_object.cpp	2004/02/11 08:43:46
@@ -1122,10 +1122,8 @@ void RenderObject::paintOutline(QPainter
 
 }
 
-void RenderObject::paint(QPainter *p, int x, int y, int w, int h, int tx, int ty,
-                         PaintAction paintAction)
+void RenderObject::paint(PaintInfo& i, int tx, int ty)
 {
-    paintObject(p, x, y, w, h, tx, ty, paintAction);
 }
 
 void RenderObject::repaint(bool immediate)
Index: khtml/rendering/render_object.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_object.h,v
retrieving revision 1.102
diff -u -p -r1.102 khtml/rendering/render_object.h
--- khtml/rendering/render_object.h	2004/01/30 19:12:55	1.102
+++ khtml/rendering/render_object.h	2004/02/11 08:43:47
@@ -338,18 +338,19 @@ public:
      * Paint the object and its children, clipped by (x|y|w|h).
      * (tx|ty) is the calculated position of the parent
      */
-    virtual void paint(QPainter *p, int x, int y, int w, int h, int tx, int ty, 
-                       PaintAction paintAction);
-
-    virtual void paintObject( QPainter */*p*/, int /*x*/, int /*y*/,
-                              int /*w*/, int /*h*/, int /*tx*/, int /*ty*/,
-                              PaintAction paintAction /*paintAction*/) {}
+    struct PaintInfo {
+        PaintInfo(QPainter* _p, const QRect& _r, PaintAction _phase)
+        : p(_p), r(_r), phase(_phase) {}
+        QPainter* p;
+        QRect     r;
+        PaintAction phase;
+    };
+    virtual void paint(PaintInfo& i, int tx, int ty);
     void paintBorder(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style, bool begin=true, bool end=true);
     void paintOutline(QPainter *p, int _tx, int _ty, int w, int h, const RenderStyle* style);
 
     // RenderBox implements this.
-    virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty) {};
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty) {};
 
     virtual void paintBackgroundExtended(QPainter *p, const QColor &c, CachedImage *bg, int clipy, int cliph,
                                          int _tx, int _ty, int w, int height,
Index: khtml/rendering/render_replaced.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_replaced.cpp,v
retrieving revision 1.53
diff -u -p -r1.53 khtml/rendering/render_replaced.cpp
--- khtml/rendering/render_replaced.cpp	2004/01/23 18:55:45	1.53
+++ khtml/rendering/render_replaced.cpp	2004/02/11 08:43:48
@@ -53,29 +53,25 @@ RenderReplaced::RenderReplaced(DOM::Node
     m_intrinsicHeight = 150;
 }
 
-void RenderReplaced::paint(QPainter *p, int _x, int _y, int _w, int _h,
-                           int _tx, int _ty, PaintAction paintAction)
+bool RenderReplaced::shouldPaint(PaintInfo& i, int _tx, int _ty)
 {
-    if (paintAction != PaintActionForeground && paintAction != PaintActionOutline && paintAction != PaintActionSelection)
-        return;
+    if (i.phase != PaintActionForeground && i.phase != PaintActionOutline && i.phase != PaintActionSelection)
+        return false;
         
     // if we're invisible or haven't received a layout yet, then just bail.
-    if (style()->visibility() != VISIBLE || m_y <=  -500000)  return;
+    if (style()->visibility() != VISIBLE || m_y <=  -500000)  return false;
 
     _tx += m_x;
     _ty += m_y;
 
     // Early exit if the element touches the edges.
-    int os = 2*maximalOutlineSize(paintAction);
-    if((_tx >= _x + _w + os) || (_tx + m_width <= _x - os))
-        return;
-    if((_ty >= _y + _h + os) || (_ty + m_height <= _y - os))
-        return;
+    int os = 2*maximalOutlineSize(i.phase);
+    if ((_tx >= i.r.x() + i.r.width() + os) || (_tx + m_width <= i.r.x() - os))
+        return false;
+    if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + m_height <= i.r.y() - os))
+        return false;
 
-    if(shouldPaintBackgroundOrBorder() && paintAction != PaintActionOutline) 
-        paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
-
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    return true;
 }
 
 void RenderReplaced::calcMinMaxWidth()
@@ -272,11 +268,15 @@ void RenderWidget::setStyle(RenderStyle 
     }
 }
 
-void RenderWidget::paintObject(QPainter *p, int x, int y, int width, int height, int _tx, int _ty,
-                               PaintAction paintAction)
+void RenderWidget::paint(PaintInfo& i, int _tx, int _ty)
 {
+    if (!shouldPaint(i, _tx, _ty)) return;
+
+    if (shouldPaintBackgroundOrBorder() && i.phase != PaintActionOutline) 
+        paintBoxDecorations(i, _tx, _ty);
+
 #if APPLE_CHANGES
-    if (!m_widget || !m_view || paintAction != PaintActionForeground ||
+    if (!m_widget || !m_view || i.phase != PaintActionForeground ||
         style()->visibility() != VISIBLE)
         return;
 
@@ -290,10 +290,10 @@ void RenderWidget::paintObject(QPainter 
     
     // Tell the widget to paint now.  This is the only time the widget is allowed
     // to paint itself.  That way it will composite properly with z-indexed layers.
-    m_widget->paint(p, QRect(x, y, width, height));
+    m_widget->paint(i.p, i.r);
     
 #else
-    if (!m_widget || !m_view || paintAction != PaintActionForeground)
+    if (!m_widget || !m_view || i.phase != PaintActionForeground)
         return;
     
     if (style()->visibility() != VISIBLE) {
@@ -327,8 +327,8 @@ void RenderWidget::paintObject(QPainter 
 	    }
 // 	    qDebug("calculated yNew=%d", yNew);
 	}
-	yNew = QMIN( yNew, yPos + m_height - childh );
-	yNew = QMAX( yNew, yPos );
+	yNew = kMin( yNew, yPos + m_height - childh );
+	yNew = kMax( yNew, yPos );
 	if ( yNew != childy || xNew != childx ) {
 	    if ( vw->contentsHeight() < yNew - yPos + childh )
 		vw->resizeContents( vw->contentsWidth(), yNew - yPos + childh );
Index: khtml/rendering/render_replaced.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_replaced.h,v
retrieving revision 1.19
diff -u -p -r1.19 khtml/rendering/render_replaced.h
--- khtml/rendering/render_replaced.h	2004/01/23 18:55:45	1.19
+++ khtml/rendering/render_replaced.h	2004/02/11 08:43:48
@@ -41,10 +41,8 @@ public:
 
     virtual void calcMinMaxWidth();
 
-    virtual void paint(QPainter *, int x, int y, int w, int h,
-                       int tx, int ty, PaintAction paintAction);
-    virtual void paintObject(QPainter *p, int x, int y, int w, int h, int tx, int ty,
-                             PaintAction paintAction) = 0;
+    bool shouldPaint(PaintInfo& i, int _tx, int _ty);
+    virtual void paint(PaintInfo& i, int _tx, int _ty) = 0;
 
     virtual short intrinsicWidth() const { return m_intrinsicWidth; }
     virtual int intrinsicHeight() const { return m_intrinsicHeight; }
@@ -72,8 +70,7 @@ public:
 
     virtual void setStyle(RenderStyle *style);
 
-    virtual void paintObject(QPainter *p, int x, int y, int w, int h, int tx, int ty,
-                             PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     virtual bool isWidget() const { return true; };
 
Index: khtml/rendering/render_table.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_table.cpp,v
retrieving revision 1.93
diff -u -p -r1.93 khtml/rendering/render_table.cpp
--- khtml/rendering/render_table.cpp	2004/02/10 20:52:12	1.93
+++ khtml/rendering/render_table.cpp	2004/02/11 08:43:51
@@ -402,8 +402,7 @@ void RenderTable::setCellWidths()
     }
 }
 
-void RenderTable::paint( QPainter *p, int _x, int _y,
-                                  int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderTable::paint(PaintInfo& i, int _tx, int _ty)
 {
     if (needsLayout())
         return;
@@ -411,14 +410,16 @@ void RenderTable::paint( QPainter *p, in
     _tx += xPos();
     _ty += yPos();
 
+    PaintAction paintAction = i.phase;
+    
 #ifdef TABLE_PRINT
     kdDebug( 6040 ) << "RenderTable::paint() w/h = (" << width() << "/" << height() << ")" << endl;
 #endif
     if (!overhangingContents() && !isRelPositioned() && !isPositioned())
     {
         int os = 2*maximalOutlineSize(paintAction);
-        if((_ty >= _y + _h + os) || (_ty + height() <= _y - os)) return;
-        if((_tx >= _x + _w + os) || (_tx + width() <= _x - os)) return;
+        if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + height() <= i.r.y() - os)) return;
+        if ((_tx >= i.r.x() + i.r.width() + os) || (_tx + width() <= i.r.x() - os)) return;
     }
 
 #ifdef TABLE_PRINT
@@ -427,7 +428,7 @@ void RenderTable::paint( QPainter *p, in
 
     if ((paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground)
         && shouldPaintBackgroundOrBorder() && style()->visibility() == VISIBLE)
-        paintBoxDecorations(p, _x, _y, _w, _h, _tx, _ty);
+        paintBoxDecorations(i, _tx, _ty);
 
     // We're done.  We don't bother painting any children.
     if (paintAction == PaintActionElementBackground)
@@ -435,13 +436,11 @@ void RenderTable::paint( QPainter *p, in
     // We don't paint our own background, but we do let the kids paint their backgrounds.
     if (paintAction == PaintActionChildBackgrounds)
         paintAction = PaintActionChildBackground;
+    PaintInfo paintInfo(i.p, i.r, paintAction);
     
-    RenderObject *child = firstChild();
-    while( child ) {
-	if ( child->isTableSection() || child == tCaption )
-	    child->paint( p, _x, _y, _w, _h, _tx, _ty, paintAction );
-	child = child->nextSibling();
-    }
+    for (RenderObject *child = firstChild(); child; child = child->nextSibling())
+        if (child->isTableSection() || child == tCaption)
+	    child->paint(paintInfo, _tx, _ty);
 
     if (collapseBorders() && 
         (paintAction == PaintActionElementBackground || paintAction == PaintActionChildBackground)
@@ -452,38 +451,37 @@ void RenderTable::paint( QPainter *p, in
         QPtrList<CollapsedBorderValue> borderStyles;
         borderStyles.setAutoDelete(true);
         collectBorders(borderStyles);
+        paintInfo.phase = PaintActionCollapsedTableBorders;
         for (uint i = 0; i < borderStyles.count(); i++) {
             m_currentBorder = borderStyles.at(i);
-            for (child = firstChild(); child; child = child->nextSibling()) {
+            for (RenderObject* child = firstChild(); child; child = child->nextSibling())
                 if (child->isTableSection())
-                    child->paint(p, _x, _y, _w, _h, _tx, _ty, PaintActionCollapsedTableBorders);
-            }
+                    child->paint(paintInfo, _tx, _ty);
         }
     }
         
 #ifdef BOX_DEBUG
-    outlineBox(p, _tx, _ty, "blue");
+    outlineBox(i.p, _tx, _ty, "blue");
 #endif
 }
 
-void RenderTable::paintBoxDecorations(QPainter *p,int _x, int _y,
-                                      int _w, int _h, int _tx, int _ty)
+void RenderTable::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     int w = width();
     int h = height() + borderTopExtra() + borderBottomExtra();
     _ty -= borderTopExtra();
     
-    int my = kMax(_ty,_y);
+    int my = kMax(_ty, i.r.y());
     int mh;
-    if (_ty<_y)
-        mh= kMax(0,h-(_y-_ty));
+    if (_ty < i.r.y())
+        mh= kMax(0, h - (i.r.y() - _ty));
     else
-        mh = kMin(_h,h);
+        mh = kMin(i.r.height(), h);
     
-    paintBackground(p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
+    paintBackground(i.p, style()->backgroundColor(), style()->backgroundImage(), my, mh, _tx, _ty, w, h);
     
     if (style()->hasBorder() && !collapseBorders())
-        paintBorder(p, _tx, _ty, w, h, style());
+        paintBorder(i.p, _tx, _ty, w, h, style());
 }
 
 void RenderTable::calcMinMaxWidth()
@@ -1379,8 +1377,7 @@ int RenderTableSection::layoutRows( int 
 }
 
 
-void RenderTableSection::paint( QPainter *p, int x, int y, int w, int h,
-				int tx, int ty, PaintAction paintAction)
+void RenderTableSection::paint(PaintInfo& i, int tx, int ty)
 {
     unsigned int totalRows = grid.size();
     unsigned int totalCols = table()->columns.size();
@@ -1390,6 +1387,9 @@ void RenderTableSection::paint( QPainter
 
     // check which rows and cols are visible and only paint these
     // ### fixme: could use a binary search here
+    PaintAction paintAction = i.phase;
+    int x = i.r.x(); int y = i.r.y(); int w = i.r.width(); int h = i.r.height();
+
     int os = 2*maximalOutlineSize(paintAction);
     unsigned int startrow = 0;
     unsigned int endrow = totalRows;
@@ -1431,7 +1431,7 @@ void RenderTableSection::paint( QPainter
 #ifdef TABLE_PRINT
 		kdDebug( 6040 ) << "painting cell " << r << "/" << c << endl;
 #endif
-		cell->paint( p, x, y, w, h, tx, ty, paintAction);
+		cell->paint(i, tx, ty);
 	    }
 	}
     }
@@ -2061,28 +2061,24 @@ static void outlineBox(QPainter *p, int 
 }
 #endif
 
-void RenderTableCell::paint(QPainter *p, int _x, int _y,
-                                       int _w, int _h, int _tx, int _ty, PaintAction paintAction)
+void RenderTableCell::paint(PaintInfo& i, int _tx, int _ty)
 {
 
 #ifdef TABLE_PRINT
     kdDebug( 6040 ) << renderName() << "(RenderTableCell)::paint() w/h = (" << width() << "/" << height() << ")" << " _y/_h=" << _y << "/" << _h << endl;
 #endif
 
-    if (needsLayout()) return;
-
     _tx += m_x;
     _ty += m_y + _topExtra;
 
     // check if we need to do anything at all...
-    int os = 2*maximalOutlineSize(paintAction);
-    if(!overhangingContents() && ((_ty-_topExtra >= _y + _h + os)
-        || (_ty + m_height + _bottomExtra <= _y - os))) return;
-
-    paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
+    int os = 2*maximalOutlineSize(i.phase);
+    if (!overhangingContents() && ((_ty - _topExtra >= i.r.y() + i.r.height() + os)
+                                   || (_ty + m_height + _bottomExtra <= i.r.y() - os))) return;
+    RenderBlock::paintObject(i, _tx, _ty);
 
 #ifdef BOX_DEBUG
-    ::outlineBox( p, _tx, _ty - _topExtra, width(), height() + borderTopExtra() + borderBottomExtra());
+    ::outlineBox( i.p, _tx, _ty - _topExtra, width(), height() + borderTopExtra() + borderBottomExtra());
 #endif
 }
 
@@ -2236,22 +2232,8 @@ QRect RenderTableCell::getAbsoluteRepain
     computeAbsoluteRepaintRect(r);
     return r;
 }
-
-void RenderTableCell::paintObject(QPainter* p, int _x, int _y, int _w, int _h,
-                                  int _tx, int _ty, PaintAction paintAction)
-{
-    if (paintAction == PaintActionCollapsedTableBorders && style()->visibility() == VISIBLE) {
-        int w = width();
-        int h = height() + borderTopExtra() + borderBottomExtra();
-        _ty -= borderTopExtra();
-        paintCollapsedBorder(p, _tx, _ty, w, h);
-    }
-    else
-        RenderBlock::paintObject(p, _x, _y, _w, _h, _tx, _ty, paintAction);
-}
 
-void RenderTableCell::paintBoxDecorations(QPainter *p,int, int _y,
-                                          int, int _h, int _tx, int _ty)
+void RenderTableCell::paintBoxDecorations(PaintInfo& i, int _tx, int _ty)
 {
     RenderTable* tableElt = table();
     if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
@@ -2300,15 +2282,15 @@ void RenderTableCell::paintBoxDecoration
 	}
     }
 
-    int my = QMAX(_ty,_y);
-    int end = QMIN( _y + _h,  _ty + h );
+    int my = kMax(_ty, i.r.y());
+    int end = kMin(i.r.y() + i.r.height(), _ty + h);
     int mh = end - my;
 
     if ( bg || c.isValid() )
-	paintBackground(p, c, bg, my, mh, _tx, _ty, w, h);
+	paintBackground(i.p, c, bg, my, mh, _tx, _ty, w, h);
 
     if (style()->hasBorder() && !tableElt->collapseBorders())
-        paintBorder(p, _tx, _ty, w, h, style());
+        paintBorder(i.p, _tx, _ty, w, h, style());
 }
 
 
Index: khtml/rendering/render_table.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_table.h,v
retrieving revision 1.33
diff -u -p -r1.33 khtml/rendering/render_table.h
--- khtml/rendering/render_table.h	2004/01/07 01:15:20	1.33
+++ khtml/rendering/render_table.h	2004/02/11 08:43:51
@@ -104,10 +104,8 @@ public:
     virtual int overflowHeight(bool includeInterior=true) const { return height(); }
     virtual int overflowWidth(bool includeInterior=true) const { return width(); }
     virtual void addChild(RenderObject *child, RenderObject *beforeChild = 0);
-    virtual void paint( QPainter *, int x, int y, int w, int h,
-                        int tx, int ty, PaintAction paintAction);
-    virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty);
+    virtual void paint(PaintInfo& i, int tx, int ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
     virtual void layout();
     virtual void calcMinMaxWidth();
     virtual void close();
@@ -251,8 +249,7 @@ public:
 	return (*(grid[row].row))[col];
     }
 
-    virtual void paint( QPainter *, int x, int y, int w, int h,
-                        int tx, int ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     int numRows() const { return grid.size(); }
     int getBaseline(int row) {return grid[row].baseLine;}
@@ -365,8 +362,7 @@ public:
     int getCellPercentageHeight() const;
     void setCellPercentageHeight(int h);
     
-    virtual void paint( QPainter* p, int x, int y,
-                        int w, int h, int tx, int ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     void paintCollapsedBorder(QPainter* p, int x, int y, int w, int h);
     
@@ -390,14 +386,10 @@ public:
     virtual void dump(QTextStream *stream, QString ind = "") const;
 #endif
 
-    virtual void paintObject(QPainter *, int x, int y, int w, int h,
-                             int tx, int ty, PaintAction paintAction);
-    
     virtual QRect getAbsoluteRepaintRect();
     
 protected:
-    virtual void paintBoxDecorations(QPainter *p,int _x, int _y,
-                                     int _w, int _h, int _tx, int _ty);
+    virtual void paintBoxDecorations(PaintInfo& i, int _tx, int _ty);
     
     short _row;
     short _col;
Index: khtml/rendering/render_text.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_text.cpp,v
retrieving revision 1.108
diff -u -p -r1.108 khtml/rendering/render_text.cpp
--- khtml/rendering/render_text.cpp	2004/02/04 21:33:12	1.108
+++ khtml/rendering/render_text.cpp	2004/02/11 08:43:53
@@ -532,9 +532,18 @@ correctedTextColor(QColor textColor, QCo
     return textColor.light();
 }
 
-void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
-                             int tx, int ty, PaintAction paintAction)
+void RenderText::paint(PaintInfo& i, int tx, int ty)
 {
+    if (i.phase != PaintActionForeground && i.phase != PaintActionSelection)
+        return;
+    
+    if (style()->visibility() != VISIBLE || !firstTextBox())
+        return;
+    
+    if (ty + firstTextBox()->yPos() > i.r.y() + i.r.height()) return;
+    if (ty + lastTextBox()->yPos() + lastTextBox()->height() < i.r.y()) return;
+    
+    QPainter* p = i.p;
     RenderStyle* pseudoStyle = style(true);
     if (pseudoStyle == style()) pseudoStyle = 0;
     int d = style()->textDecorationsInEffect();
@@ -542,7 +551,7 @@ void RenderText::paintObject(QPainter *p
     
     // Walk forward until we hit the first line that needs to be painted.
     InlineTextBox* s = firstTextBox();
-    for (; s && !s->checkVerticalPoint(y, ty, h); s = s->nextTextBox());
+    for (; s && !s->checkVerticalPoint(i.r.y(), ty, i.r.height()); s = s->nextTextBox());
     if (!s) return;
     
     // Now calculate startPos and endPos, for painting selection.
@@ -568,7 +577,7 @@ void RenderText::paintObject(QPainter *p
 #if APPLE_CHANGES
     // Do one pass for the selection, then another for the rest.
     bool haveSelection = startPos != endPos && !isPrinting && selectionState() != SelectionNone;
-    if (!haveSelection && paintAction == PaintActionSelection) {
+    if (!haveSelection && i.phase == PaintActionSelection) {
         // When only painting the selection, don't bother to paint if there is none.
         return;
     }
@@ -576,7 +585,7 @@ void RenderText::paintObject(QPainter *p
     InlineTextBox* startBox = s;
     for (int pass = 0; pass < (haveSelection ? 2 : 1); pass++) {
         s = startBox;
-        bool drawSelectionBackground = haveSelection && pass == 0 && paintAction != PaintActionSelection;
+        bool drawSelectionBackground = haveSelection && pass == 0 && i.phase != PaintActionSelection;
         bool drawText = !haveSelection || pass == 1;
 #endif
 
@@ -586,13 +595,13 @@ void RenderText::paintObject(QPainter *p
         if (isPrinting)
         {
             // FIXME: Need to understand what this section is doing.
-            if (ty+s->m_y < y)
+            if (ty+s->m_y < i.r.y())
             {
                // This has been printed already we suppose.
                continue;
             }
 
-            if (ty+s->m_y+s->height() > y+h)
+            if (ty+s->m_y+s->height() > i.r.y() + i.r.height())
             {
                RenderCanvas* canvasObj = canvas();
                if (ty+s->m_y < canvasObj->truncatedAt())
@@ -638,7 +647,7 @@ void RenderText::paintObject(QPainter *p
 #endif
         
         if (s->m_len > 0) {
-            bool paintSelectedTextOnly = (paintAction == PaintActionSelection);
+            bool paintSelectedTextOnly = (i.phase == PaintActionSelection);
             bool paintSelectedTextSeparately = false; // Whether or not we have to do multiple paints.  Only
                                            // necessary when a custom ::selection foreground color is applied.
             QColor selectionColor = p->pen().color();
@@ -737,7 +746,7 @@ void RenderText::paintObject(QPainter *p
             } 
         }
         
-        if (d != TDNONE && paintAction == PaintActionForeground &&
+        if (d != TDNONE && i.phase == PaintActionForeground &&
             style()->htmlHacks()) {
             p->setPen(_style->color());
             s->paintDecoration(p, tx, ty, d);
@@ -775,29 +784,11 @@ void RenderText::paintObject(QPainter *p
         }
 #endif
 
-    } while (((s = s->nextTextBox()) != 0) && s->checkVerticalPoint(y, ty, h));
+    } while (((s = s->nextTextBox()) != 0) && s->checkVerticalPoint(i.r.y(), ty, i.r.height()));
 
 #if APPLE_CHANGES
     } // end of for loop
 #endif
-}
-
-void RenderText::paint(QPainter *p, int x, int y, int w, int h,
-                       int tx, int ty, PaintAction paintAction)
-{
-    if (paintAction != PaintActionForeground && paintAction != PaintActionSelection)
-        return;
-    
-    if (style()->visibility() != VISIBLE)
-        return;
-
-    if (!firstTextBox())
-        return;
-    
-    if (ty + firstTextBox()->yPos() > y + h) return;
-    if (ty + lastTextBox()->yPos() + lastTextBox()->height() < y ) return;
-
-    paintObject(p, x, y, w, h, tx, ty, paintAction);
 }
 
 #ifdef APPLE_CHANGES
Index: khtml/rendering/render_text.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_text.h,v
retrieving revision 1.47
diff -u -p -r1.47 khtml/rendering/render_text.h
--- khtml/rendering/render_text.h	2004/01/30 19:12:55	1.47
+++ khtml/rendering/render_text.h	2004/02/11 08:43:53
@@ -116,10 +116,7 @@ public:
 
     virtual void setStyle(RenderStyle *style);
     
-    virtual void paint(QPainter *, int x, int y, int w, int h,
-                       int tx, int ty, PaintAction paintAction);
-    virtual void paintObject(QPainter *, int x, int y, int w, int h,
-                             int tx, int ty, PaintAction paintAction);
+    virtual void paint(PaintInfo& i, int tx, int ty);
 
     void deleteTextBoxes();
     virtual void detach();
-------------- next part --------------


dave


On Feb 10, 2004, at 9:15 PM, Dirk Mueller wrote:

> On Wednesday 11 February 2004 06:14, Dirk Mueller wrote:
>
>> attach my diff for RenderTableCell and RenderTable::paint() as 
>> reference,
>> they work fine for me this way (not extensively tested yet though).
>
> sigh.
>
> <rendertable.diff>_______________________________________________
> Khtml-devel at kde.org
> https://mail.kde.org/mailman/listinfo/khtml-devel


More information about the Khtml-devel mailing list