1 /* 2 * Copyright (C) 2006 Dirk Mueller <mueller (at) kde.org> 3 * Copyright (C) 2006 Zack Rusin <zack (at) kde.org> 4 * Copyright (C) 2006 George Staikos <staikos (at) kde.org> 5 * Copyright (C) 2006 Simon Hausmann <hausmann (at) kde.org> 6 * Copyright (C) 2006 Rob Buis <buis (at) kde.org> 7 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann (at) kde.org> 8 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2008 Collabora Ltd. All rights reserved. 10 * Copyright (C) 2008 Eric Seidel <eric (at) webkit.org> 11 * 12 * All rights reserved. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. 22 * 23 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 31 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #include "config.h" 37 #include "ScriptController.h" 38 39 #include "Bridge.h" 40 #include "DOMWindow.h" 41 #include "PluginView.h" 42 #include "qt_instance.h" 43 #include "runtime_root.h" 44 45 #include <QWidget> 46 47 namespace WebCore { 48 49 PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(WebCore::Widget* widget) 50 { 51 if (widget->isPluginView()) { 52 PluginView* pluginView = static_cast<PluginView*>(widget); 53 return pluginView->bindingInstance(); 54 } 55 56 QWidget* platformWidget = widget->platformWidget(); 57 if (!platformWidget) 58 return 0; 59 return JSC::Bindings::QtInstance::getQtInstance(platformWidget, bindingRootObject(), QScriptEngine::QtOwnership); 60 } 61 62 } 63 // vim: ts=4 sw=4 et 64