#include "render_body.h"
#include "render_canvas.h"
#include "html/html_baseimpl.h"
#include "xml/dom_docimpl.h"
#include "khtmlview.h"
#include <kglobal.h>
#include <kdebug.h>
using namespace khtml;
using namespace DOM;
RenderBody::RenderBody(HTMLBodyElementImpl* element)
: RenderBlock(element)
{
scrollbarsStyled = false;
}
RenderBody::~RenderBody()
{
}
void RenderBody::setStyle(RenderStyle* style)
{
style->setDisplay(BLOCK); RenderBlock::setStyle(style);
element()->getDocument()->setTextColor( style->color() );
scrollbarsStyled = false;
}
void RenderBody::paintBoxDecorations(QPainter *p,int, int _y,
int, int _h, int _tx, int _ty)
{
QColor c;
CachedImage *bg = 0;
if (parent()->style()->backgroundColor().isValid() || parent()->style()->backgroundImage()) {
c = style()->backgroundColor();
bg = style()->backgroundImage();
}
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
_ty -= borderTopExtra();
int my = QMAX(_ty,_y);
int mh;
if (_ty<_y)
mh=QMAX(0,h-(_y-_ty));
else
mh = QMIN(_h,h);
paintBackground(p, c, bg, my, mh, _tx, _ty, w, h);
if(style()->hasBorder())
paintBorder(p, _tx, _ty, w, h, style());
}
void RenderBody::repaint(bool immediate)
{
RenderObject *cb = containingBlock();
if(cb != this)
cb->repaint(immediate);
}
void RenderBody::layout()
{
RenderBlock::layout();
#if !APPLE_CHANGES
if (!scrollbarsStyled)
{
if (root()->view())
{
root()->view()->horizontalScrollBar()->setPalette(style()->palette());
root()->view()->verticalScrollBar()->setPalette(style()->palette());
}
scrollbarsStyled=true;
}
#endif
}
int RenderBody::availableHeight() const
{
int h = RenderBlock::availableHeight();
if( style()->marginTop().isFixed() )
h -= style()->marginTop().value;
if( style()->marginBottom().isFixed() )
h -= style()->marginBottom().value;
return kMax(0, h);
}