KJS::Bindings::Instance* Frame::createScriptInstanceForWidget(WebCore::Widget* widget) { QWidget* nativeWidget = widget->nativeWidget(); if (!nativeWidget) return 0; return KJS::Bindings::Instance::createBindingForLanguageInstance(KJS::Bindings::Instance::QtLanguage, nativeWidget, bindingRootObject()); }
NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement* plugin) { JSObject* object = jsObjectForPluginElement(plugin); if (!object) return _NPN_CreateNoScriptObject(); // Wrap the JSObject in an NPObject return _NPN_CreateScriptObject(0, object, bindingRootObject()); }
PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(WebCore::Widget* widget) { if (widget->isPluginView()) { PluginView* pluginView = static_cast<PluginView*>(widget); return pluginView->bindingInstance(); } QWidget* platformWidget = widget->platformWidget(); if (!platformWidget) return 0; return JSC::Bindings::QtInstance::getQtInstance(platformWidget, bindingRootObject(), QScriptEngine::QtOwnership); }
PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(WebCore::Widget* widget) { if (!widget->isPluginView()) return 0; if (widget->isNPAPIPlugin()) return static_cast<PluginView*>(widget)->bindingInstance(); QWidget* nativeWidget = widget->nativeWidget(); if (!nativeWidget) return 0; return JSC::Bindings::QtInstance::create(nativeWidget, bindingRootObject()); }
NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement* plugin) { // Can't create NPObjects when JavaScript is disabled if (!isEnabled()) return _NPN_CreateNoScriptObject(); // Create a JSObject bound to this element JSLock lock(false); ExecState* exec = globalObject()->globalExec(); JSValue* jsElementValue = toJS(exec, plugin); if (!jsElementValue || !jsElementValue->isObject()) return _NPN_CreateNoScriptObject(); // Wrap the JSObject in an NPObject return _NPN_CreateScriptObject(0, jsElementValue->getObject(), bindingRootObject()); }
NPObject* ScriptController::windowScriptNPObject() { if (!m_windowScriptNPObject) { if (canExecuteScripts(NotAboutToExecuteScript)) { // JavaScript is enabled, so there is a JavaScript window object. // Return an NPObject bound to the window object. JSC::JSLock lock(SilenceAssertionsOnly); JSObject* win = windowShell(pluginWorld())->window(); ASSERT(win); Bindings::RootObject* root = bindingRootObject(); m_windowScriptNPObject = _NPN_CreateScriptObject(0, win, root); } else { // JavaScript is not enabled, so we cannot bind the NPObject to the JavaScript window object. // Instead, we create an NPObject of a different class, one which is not bound to a JavaScript object. m_windowScriptNPObject = _NPN_CreateNoScriptObject(); } } return m_windowScriptNPObject; }
NPObject* ScriptController::windowScriptNPObject() { if (!m_windowScriptNPObject) { if (isEnabled()) { // JavaScript is enabled, so there is a JavaScript window object. // Return an NPObject bound to the window object. JSC::JSLock lock(false); JSObject* win = windowShell()->window(); ASSERT(win); Bindings::RootObject* root = bindingRootObject(); m_windowScriptNPObject = _NPN_CreateScriptObject(0, win, root); } else { // JavaScript is not enabled, so we cannot bind the NPObject to the JavaScript window object. // Instead, we create an NPObject of a different class, one which is not bound to a JavaScript object. m_windowScriptNPObject = _NPN_CreateNoScriptObject(); } } return m_windowScriptNPObject; }