khtml Library API Documentation

render_html.cpp

00001 
00023 #include "rendering/render_html.h"
00024 #include "rendering/render_root.h"
00025 #include "html/html_elementimpl.h"
00026 
00027 #include "khtmlview.h"
00028 
00029 #include <kdebug.h>
00030 
00031 using namespace khtml;
00032 
00033 RenderHtml::RenderHtml(DOM::HTMLElementImpl* node)
00034     : RenderFlow(node)
00035 {
00036 }
00037 
00038 RenderHtml::~RenderHtml()
00039 {
00040 }
00041 
00042 void RenderHtml::setStyle(RenderStyle *style)
00043 {
00044     RenderFlow::setStyle(style);
00045     setSpecialObjects(true);
00046 }
00047 
00048 void RenderHtml::paint(QPainter *p, int _x, int _y, int _w, int _h, int _tx, int _ty)
00049 {
00050     _tx += m_x;
00051     _ty += m_y;
00052 
00053     //kdDebug(0) << "html:paint " << _tx << "/" << _ty << endl;
00054     paintObject(p, _x, _y, _w, _h, _tx, _ty);
00055 }
00056 
00057 void RenderHtml::paintBoxDecorations(QPainter *p,int, int _y,
00058                                        int, int _h, int _tx, int _ty)
00059 {
00060     //kdDebug( 6040 ) << renderName() << "::paintDecorations()" << _tx << "/" << _ty << endl;
00061 
00062     QColor c = style()->backgroundColor();
00063     CachedImage *bg = style()->backgroundImage();
00064 
00065     if( firstChild() ) {
00066         if( !c.isValid() )
00067             c = firstChild()->style()->backgroundColor();
00068         if( !bg )
00069             bg = firstChild()->style()->backgroundImage();
00070         if( !c.isValid() && root()->view())
00071             c = root()->view()->palette().active().color(QColorGroup::Base);
00072     }
00073 
00074     int w = width();
00075     int h = height();
00076 
00077 //    kdDebug(0) << "width = " << w <<endl;
00078 
00079     int rw;
00080     if (root()->view())
00081         rw=root()->view()->contentsWidth();
00082     else
00083         rw=root()->width();
00084 
00085 //    kdDebug(0) << "rw = " << rw <<endl;
00086 
00087     int bx = _tx - marginLeft();
00088     int by = _ty - marginTop();
00089     int bw = QMAX(w + marginLeft() + marginRight() + borderLeft() + borderRight(), rw);
00090     int bh = QMAX(h + marginTop() + marginBottom() + borderTop() + borderBottom(), parent()->height());
00091 
00092     // CSS2 14.2:
00093     // " The background of the box generated by the root element covers the entire canvas."
00094     // hence, paint the background even in the margin areas (unlike for every other element!)
00095     // I just love these little inconsistencies .. :-( (Dirk)
00096     int my = QMAX(by,_y);
00097 
00098     paintBackground(p, c, bg, my, _h, bx, by, bw, bh);
00099 
00100     if(style()->hasBorder())
00101         paintBorder( p, _tx, _ty, w, h, style() );
00102 }
00103 
00104 void RenderHtml::repaint()
00105 {
00106     RenderObject *cb = containingBlock();
00107     if(cb != this)
00108         cb->repaint();
00109 }
00110 
00111 void RenderHtml::layout()
00112 {
00113     RenderFlow::layout();
00114 
00115     //kdDebug(0) << renderName() << " height = " << m_height << endl;
00116     int lp = lowestPosition();
00117     // margins of Html element can only be fixed, right?
00118     int margins  = style()->marginTop().isFixed() ? style()->marginTop().value() : 0;
00119         margins += style()->marginBottom().isFixed() ? style()->marginBottom().value() : 0;
00120 
00121     if( m_height + margins < lp )
00122         m_height = lp - margins;
00123 
00124     //kdDebug(0) << "docHeight = " << m_height << endl;
00125 }
00126 
00127 short RenderHtml::containingBlockWidth() const
00128 {
00129     if (root()->view())
00130         return root()->view()->visibleWidth();
00131     else
00132         return RenderFlow::containingBlockWidth();
00133 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:36 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001