Warning, file /frameworks/khtml/src/rendering/render_body.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /** 0002 * This file is part of the html renderer for KDE. 0003 * 0004 * Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 #include "rendering/render_body.h" 0023 #include "rendering/render_canvas.h" 0024 #include "html/html_baseimpl.h" 0025 #include "xml/dom_docimpl.h" 0026 #include "khtmlview.h" 0027 0028 #include "khtml_debug.h" 0029 0030 #include <QScrollBar> 0031 0032 using namespace khtml; 0033 using namespace DOM; 0034 0035 RenderBody::RenderBody(HTMLBodyElementImpl *element) 0036 : RenderBlock(element) 0037 { 0038 scrollbarsStyled = false; 0039 } 0040 0041 RenderBody::~RenderBody() 0042 { 0043 } 0044 0045 void RenderBody::setStyle(RenderStyle *style) 0046 { 0047 RenderBlock::setStyle(style); 0048 document()->setTextColor(style->color()); 0049 scrollbarsStyled = false; 0050 } 0051 0052 void RenderBody::paintBoxDecorations(PaintInfo &paintInfo, int _tx, int _ty) 0053 { 0054 //qCDebug(KHTML_LOG) << renderName() << "::paintDecorations()"; 0055 QColor bgColor; 0056 const BackgroundLayer *bgLayer = nullptr; 0057 0058 if (parent()->style()->hasBackground()) { 0059 // the root element already has a non-transparent background of its own 0060 // so we must fork our own. (CSS2.1 - 14.2 ยง4) 0061 bgColor = style()->backgroundColor(); 0062 bgLayer = style()->backgroundLayers(); 0063 } 0064 0065 int w = width(); 0066 int h = height() + borderTopExtra() + borderBottomExtra(); 0067 _ty -= borderTopExtra(); 0068 QRect cr = QRect(_tx, _ty, w, h).intersected(paintInfo.r); 0069 0070 paintAllBackgrounds(paintInfo.p, bgColor, bgLayer, cr, _tx, _ty, w, h); 0071 0072 if (style()->hasBorder()) { 0073 paintBorder(paintInfo.p, _tx, _ty, w, h, style()); 0074 } 0075 0076 } 0077 0078 void RenderBody::repaint(Priority p) 0079 { 0080 RenderObject *cb = containingBlock(); 0081 if (cb) { 0082 cb->repaint(p); 0083 } 0084 } 0085 0086 void RenderBody::layout() 0087 { 0088 // in quirk mode, we'll need to have our margins determined 0089 // for percentage height calculations 0090 if (style()->htmlHacks()) { 0091 calcHeight(); 0092 } 0093 RenderBlock::layout(); 0094 0095 if (!scrollbarsStyled) { 0096 RenderCanvas *canvas = this->canvas(); 0097 if (canvas->view()) { 0098 canvas->view()->horizontalScrollBar()->setPalette(style()->palette()); 0099 canvas->view()->verticalScrollBar()->setPalette(style()->palette()); 0100 } 0101 scrollbarsStyled = true; 0102 } 0103 } 0104 0105 int RenderBody::availableHeight() const 0106 { 0107 int h = RenderBlock::availableHeight(); 0108 0109 if (style()->marginTop().isFixed()) { 0110 h -= style()->marginTop().value(); 0111 } 0112 if (style()->marginBottom().isFixed()) { 0113 h -= style()->marginBottom().value(); 0114 } 0115 0116 return qMax(0, h); 0117 }