2 * This file is part of the html renderer for KDE.
4 * Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "rendering/render_body.h"
23 #include "rendering/render_canvas.h"
24 #include "html/html_baseimpl.h"
25 #include "xml/dom_docimpl.h"
26 #include "khtmlview.h"
33 using namespace khtml
;
36 RenderBody::RenderBody(HTMLBodyElementImpl
* element
)
37 : RenderBlock(element
)
39 scrollbarsStyled
= false;
42 RenderBody::~RenderBody()
46 void RenderBody::setStyle(RenderStyle
* style
)
48 RenderBlock::setStyle(style
);
49 document()->setTextColor( style
->color() );
50 scrollbarsStyled
= false;
53 void RenderBody::paintBoxDecorations(PaintInfo
& paintInfo
, int _tx
, int _ty
)
55 //kDebug( 6040 ) << renderName() << "::paintDecorations()";
57 const BackgroundLayer
*bgLayer
= 0;
59 if( parent()->style()->hasBackground() ) {
60 // the root element already has a non-transparent background of its own
61 // so we must fork our own. (CSS2.1 - 14.2 ยง4)
62 bgColor
= style()->backgroundColor();
63 bgLayer
= style()->backgroundLayers();
67 int h
= height() + borderTopExtra() + borderBottomExtra();
68 _ty
-= borderTopExtra();
69 QRect cr
= QRect(_tx
, _ty
, w
, h
).intersected(paintInfo
.r
);
71 paintAllBackgrounds(paintInfo
.p
, bgColor
, bgLayer
, cr
, _tx
, _ty
, w
, h
);
73 if(style()->hasBorder())
74 paintBorder( paintInfo
.p
, _tx
, _ty
, w
, h
, style() );
78 void RenderBody::repaint(Priority p
)
80 RenderObject
*cb
= containingBlock();
85 void RenderBody::layout()
87 // in quirk mode, we'll need to have our margins determined
88 // for percentage height calculations
89 if (style()->htmlHacks())
91 RenderBlock::layout();
93 if (!scrollbarsStyled
)
95 RenderCanvas
* canvas
= this->canvas();
98 canvas
->view()->horizontalScrollBar()->setPalette(style()->palette());
99 canvas
->view()->verticalScrollBar()->setPalette(style()->palette());
101 scrollbarsStyled
=true;
105 int RenderBody::availableHeight() const
107 int h
= RenderBlock::availableHeight();
109 if( style()->marginTop().isFixed() )
110 h
-= style()->marginTop().value();
111 if( style()->marginBottom().isFixed() )
112 h
-= style()->marginBottom().value();