1/* 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 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24#include "config.h" 25#include "RenderPart.h" 26 27#include "Frame.h" 28#include "FrameView.h" 29#include "HTMLFrameElementBase.h" 30#include "PluginViewBase.h" 31#include "RenderView.h" 32 33namespace WebCore { 34 35RenderPart::RenderPart(Element* node) 36 : RenderWidget(node) 37{ 38 setInline(false); 39} 40 41RenderPart::~RenderPart() 42{ 43 clearWidget(); 44} 45 46void RenderPart::setWidget(PassRefPtr<Widget> widget) 47{ 48 if (widget == this->widget()) 49 return; 50 51 RenderWidget::setWidget(widget); 52 53 // make sure the scrollbars are set correctly for restore 54 // ### find better fix 55 viewCleared(); 56} 57 58void RenderPart::viewCleared() 59{ 60} 61 62#if USE(ACCELERATED_COMPOSITING) 63bool RenderPart::requiresLayer() const 64{ 65 if (RenderWidget::requiresLayer()) 66 return true; 67 68 return requiresAcceleratedCompositing(); 69} 70 71bool RenderPart::requiresAcceleratedCompositing() const 72{ 73 // There are two general cases in which we can return true. First, if this is a plugin 74 // renderer and the plugin has a layer, then we need a layer. Second, if this is 75 // a renderer with a contentDocument and that document needs a layer, then we need 76 // a layer. 77 if (widget() && widget()->isPluginViewBase() && static_cast<PluginViewBase*>(widget())->platformLayer()) 78 return true; 79 80 if (!node() || !node()->isFrameOwnerElement()) 81 return false; 82 83#if PLATFORM(ANDROID) 84 // FIXME: Upstream this to webkit.org 85 // https://bugs.webkit.org/show_bug.cgi?id=52655 86 if (style()->visibility() != VISIBLE) 87 return false; 88#endif 89 90 HTMLFrameOwnerElement* element = static_cast<HTMLFrameOwnerElement*>(node()); 91 if (Document* contentDocument = element->contentDocument()) { 92 if (RenderView* view = contentDocument->renderView()) 93 return view->usesCompositing(); 94 } 95 96 return false; 97} 98#endif 99 100} 101