nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { if (aPluginInstance) { if (type == NPWindowTypeWindow) { if (!mSocketWidget) { nsresult rv; PRBool needXEmbed = PR_FALSE; rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed); // If the call returned an error code make sure we still use our default value. if (NS_FAILED(rv)) { needXEmbed = PR_FALSE; } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif if (needXEmbed) { rv = CreateXEmbedWindow(); } else { rv = CreateXtWindow(); } if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } } if (!mSocketWidget) { return NS_ERROR_FAILURE; } // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if (GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // NPWindowTypeWindow aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) { if(aPluginInstance) { if (type == nsPluginWindowType_Window) { nsresult rv; if(!mSocketWidget) { PRBool needXEmbed = PR_FALSE; if (CanGetValueFromPlugin(aPluginInstance)) { rv = aPluginInstance->GetValue ((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &needXEmbed); #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif } nsresult rv; if(needXEmbed) { #ifdef MOZ_COMPOSITED_PLUGINS rv = CreateXCompositedWindow(); #else rv = CreateXEmbedWindow(); #endif } else { rv = CreateXtWindow(); } if(NS_FAILED(rv)) return NS_ERROR_FAILURE; } if(!mSocketWidget) return NS_ERROR_FAILURE; // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if(GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (nsPluginPort *)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // nsPluginWindowType_Window aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }
void PluginView::setNPWindowIfNeeded() { if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow) return; // If the plugin didn't load sucessfully, no point in calling setwindow if (m_status != PluginStatusLoadedSuccessfully) return; // On Unix, only call plugin's setwindow if it's full-page or windowed if (m_mode != NP_FULL && m_mode != NP_EMBED) return; // Check if the platformPluginWidget still exists if (m_isWindowed && !platformPluginWidget()) return; if (m_clipRect.isEmpty()) { // If width or height are null, set the clipRect to null, // indicating that the plugin is not visible/scrolled out. m_npWindow.clipRect.left = 0; m_npWindow.clipRect.right = 0; m_npWindow.clipRect.top = 0; m_npWindow.clipRect.bottom = 0; } else { // Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window. m_npWindow.clipRect.left = m_npWindow.x + m_clipRect.x(); m_npWindow.clipRect.top = m_npWindow.y + m_clipRect.y(); m_npWindow.clipRect.right = m_npWindow.x + m_clipRect.x() + m_clipRect.width(); m_npWindow.clipRect.bottom = m_npWindow.y + m_clipRect.y() + m_clipRect.height(); } // FLASH WORKAROUND: Only set initially. Multiple calls to // setNPWindow() cause the plugin to crash in windowed mode. if (!m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce) || !m_isWindowed || m_npWindow.width == static_cast<uint32_t>(-1) || m_npWindow.height == static_cast<uint32_t>(-1)) { m_npWindow.width = m_windowRect.width(); m_npWindow.height = m_windowRect.height(); } PluginView::setCurrentPluginView(this); JSC::JSLock::DropAllLocks dropAllLocks(JSDOMWindowBase::commonVM()); setCallingPlugin(true); m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); setCallingPlugin(false); PluginView::setCurrentPluginView(0); if (!m_isWindowed) return; #if PLATFORM(GTK) // GtkXtBin will call gtk_widget_size_allocate, so we don't need to do it here. if (!m_needsXEmbed) { gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y()); gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height()); return; } m_delayedAllocation = m_windowRect; updateWidgetAllocationAndClip(); #endif }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { if (aPluginInstance) { if (type == NPWindowTypeWindow) { if (!mSocketWidget) { nsresult rv; // The documentation on the types for many variables in NP(N|P)_GetValue // is vague. Often boolean values are NPBool (1 byte), but // https://developer.mozilla.org/en/XEmbed_Extension_for_Mozilla_Plugins // treats NPPVpluginNeedsXEmbed as PRBool (int), and // on x86/32-bit, flash stores to this using |movl 0x1,&needsXEmbed|. // thus we can't use NPBool for needsXEmbed, or the three bytes above // it on the stack would get clobbered. so protect with the larger bool. int needsXEmbed = 0; rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needsXEmbed); // If the call returned an error code make sure we still use our default value. if (NS_FAILED(rv)) { needsXEmbed = 0; } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needsXEmbed); #endif if (needsXEmbed) { rv = CreateXEmbedWindow(); } else { rv = CreateXtWindow(); } if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } } if (!mSocketWidget) { return NS_ERROR_FAILURE; } // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if (GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // NPWindowTypeWindow aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }