2
* This file is part of the KDE project.
4
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5
* (C) 2000 Simon Hausmann <hausmann@kde.org>
6
* (C) 2000 Stefan Schimanski (1Stein@gmx.de)
7
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Library General Public
11
* License as published by the Free Software Foundation; either
12
* version 2 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Library General Public License for more details.
19
* You should have received a copy of the GNU Library General Public License
20
* along with this library; see the file COPYING.LIB. If not, write to
21
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
* Boston, MA 02111-1307, USA.
26
#include "RenderPart.h"
30
#include "FrameTree.h"
31
#include "FrameView.h"
32
#include "HTMLFrameOwnerElement.h"
33
#include "HTMLNames.h"
38
using namespace HTMLNames;
40
RenderPart::RenderPart(HTMLFrameOwnerElement* node)
43
// init RenderObject attributes
47
RenderPart::~RenderPart()
49
// Since deref ends up calling setWidget back on us, need to make sure
50
// that widget is already 0 so it won't do any work.
51
Widget* widget = m_widget;
53
if (widget && widget->isFrameView())
54
static_cast<FrameView*>(widget)->deref();
59
void RenderPart::setWidget(Widget* widget)
61
if (widget != m_widget) {
62
if (widget && widget->isFrameView())
63
static_cast<FrameView*>(widget)->ref();
64
RenderWidget::setWidget(widget);
66
// make sure the scrollbars are set correctly for restore
67
// ### find better fix
72
void RenderPart::viewCleared()
76
void RenderPart::deleteWidget()
78
if (m_widget && m_widget->isFrameView())
79
static_cast<FrameView*>(m_widget)->deref();
84
// FIXME: This should not be necessary. Remove this once WebKit knows to properly schedule
85
// layouts using WebCore when objects resize.
86
void RenderPart::updateWidgetPosition()
91
int x, y, width, height;
92
absolutePosition(x, y);
93
x += borderLeft() + paddingLeft();
94
y += borderTop() + paddingTop();
95
width = m_width - borderLeft() - borderRight() - paddingLeft() - paddingRight();
96
height = m_height - borderTop() - borderBottom() - paddingTop() - paddingBottom();
97
IntRect newBounds(x,y,width,height);
98
bool boundsChanged = newBounds != m_widget->frameGeometry();
100
// The widget changed positions. Update the frame geometry.
101
RenderArena *arena = ref();
103
m_widget->setFrameGeometry(newBounds);
108
// if the frame bounds got changed, or if view needs layout (possibly indicating
109
// content size is wrong) we have to do a layout to set the right widget size
110
if (m_widget && m_widget->isFrameView()) {
111
FrameView* frameView = static_cast<FrameView*>(m_widget);
112
if (boundsChanged || frameView->needsLayout())