KHtml

render_body.cpp
1 /**
2  * This file is part of the html renderer for KDE.
3  *
4  * Copyright (C) 2000-2003 Lars Knoll ([email protected])
5  *
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.
10  *
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.
15  *
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.
20  *
21  */
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"
27 
28 #include "khtml_debug.h"
29 
30 #include <QScrollBar>
31 
32 using namespace khtml;
33 using namespace DOM;
34 
35 RenderBody::RenderBody(HTMLBodyElementImpl *element)
36  : RenderBlock(element)
37 {
38  scrollbarsStyled = false;
39 }
40 
41 RenderBody::~RenderBody()
42 {
43 }
44 
45 void RenderBody::setStyle(RenderStyle *style)
46 {
47  RenderBlock::setStyle(style);
48  document()->setTextColor(style->color());
49  scrollbarsStyled = false;
50 }
51 
52 void RenderBody::paintBoxDecorations(PaintInfo &paintInfo, int _tx, int _ty)
53 {
54  //qCDebug(KHTML_LOG) << renderName() << "::paintDecorations()";
55  QColor bgColor;
56  const BackgroundLayer *bgLayer = nullptr;
57 
58  if (parent()->style()->hasBackground()) {
59  // the root element already has a non-transparent background of its own
60  // so we must fork our own. (CSS2.1 - 14.2 ยง4)
61  bgColor = style()->backgroundColor();
62  bgLayer = style()->backgroundLayers();
63  }
64 
65  int w = width();
66  int h = height() + borderTopExtra() + borderBottomExtra();
67  _ty -= borderTopExtra();
68  QRect cr = QRect(_tx, _ty, w, h).intersected(paintInfo.r);
69 
70  paintAllBackgrounds(paintInfo.p, bgColor, bgLayer, cr, _tx, _ty, w, h);
71 
72  if (style()->hasBorder()) {
73  paintBorder(paintInfo.p, _tx, _ty, w, h, style());
74  }
75 
76 }
77 
78 void RenderBody::repaint(Priority p)
79 {
80  RenderObject *cb = containingBlock();
81  if (cb) {
82  cb->repaint(p);
83  }
84 }
85 
86 void RenderBody::layout()
87 {
88  // in quirk mode, we'll need to have our margins determined
89  // for percentage height calculations
90  if (style()->htmlHacks()) {
91  calcHeight();
92  }
93  RenderBlock::layout();
94 
95  if (!scrollbarsStyled) {
96  RenderCanvas *canvas = this->canvas();
97  if (canvas->view()) {
98  canvas->view()->horizontalScrollBar()->setPalette(style()->palette());
99  canvas->view()->verticalScrollBar()->setPalette(style()->palette());
100  }
101  scrollbarsStyled = true;
102  }
103 }
104 
105 int RenderBody::availableHeight() const
106 {
107  int h = RenderBlock::availableHeight();
108 
109  if (style()->marginTop().isFixed()) {
110  h -= style()->marginTop().value();
111  }
112  if (style()->marginBottom().isFixed()) {
113  h -= style()->marginBottom().value();
114  }
115 
116  return qMax(0, h);
117 }
This file is part of the HTML rendering engine for KDE.
QRect intersected(const QRect &rectangle) const const
This library provides a full-featured HTML parser and widget.
Base Class for all rendering tree objects.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.