2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
26 #include "RenderPart.h"
29 #include "FrameView.h"
30 #include "HTMLFrameElementBase.h"
31 #include "PluginViewBase.h"
32 #include "RenderSVGRoot.h"
33 #include "RenderView.h"
39 RenderPart::RenderPart(Element* node)
45 RenderPart::~RenderPart()
50 void RenderPart::setWidget(PassRefPtr<Widget> widget)
52 if (widget == this->widget())
55 RenderWidget::setWidget(widget);
57 // make sure the scrollbars are set correctly for restore
58 // ### find better fix
62 void RenderPart::viewCleared()
66 #if USE(ACCELERATED_COMPOSITING)
67 bool RenderPart::requiresLayer() const
69 if (RenderWidget::requiresLayer())
72 return requiresAcceleratedCompositing();
75 bool RenderPart::requiresAcceleratedCompositing() const
77 // There are two general cases in which we can return true. First, if this is a plugin
78 // renderer and the plugin has a layer, then we need a layer. Second, if this is
79 // a renderer with a contentDocument and that document needs a layer, then we need
81 if (widget() && widget()->isPluginViewBase() && static_cast<PluginViewBase*>(widget())->platformLayer())
84 if (!node() || !node()->isFrameOwnerElement())
87 HTMLFrameOwnerElement* element = static_cast<HTMLFrameOwnerElement*>(node());
88 if (Document* contentDocument = element->contentDocument()) {
89 if (RenderView* view = contentDocument->renderView())
90 return view->usesCompositing();
97 bool RenderPart::needsPreferredWidthsRecalculation() const
99 if (RenderWidget::needsPreferredWidthsRecalculation())
101 return embeddedContentBox();
104 RenderBox* RenderPart::embeddedContentBox() const
106 if (!node() || !widget() || !widget()->isFrameView())
108 return static_cast<FrameView*>(widget())->embeddedContentBox();