当前位置: 首页>>代码示例>>C++>>正文


C++ nsRefPtr::GetPlugin方法代码示例

本文整理汇总了C++中nsRefPtr::GetPlugin方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRefPtr::GetPlugin方法的具体用法?C++ nsRefPtr::GetPlugin怎么用?C++ nsRefPtr::GetPlugin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsRefPtr的用法示例。


在下文中一共展示了nsRefPtr::GetPlugin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CallSetWindow

nsresult nsPluginNativeWindowGtk::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("nsPluginNativeWindowGtk: NPPVpluginNeedsXEmbed=%d\n", needsXEmbed);
#endif

                bool isOOPPlugin = aPluginInstance->GetPlugin()->GetLibrary()->IsOOP();
                if (needsXEmbed || isOOPPlugin) {
                    bool enableXtFocus = !needsXEmbed;
                    rv = CreateXEmbedWindow(enableXtFocus);
                }
                else {
#if (MOZ_WIDGET_GTK == 2)
                    rv = CreateXtWindow();
#else
                    return NS_ERROR_FAILURE;
#endif
                }

                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.
            SetAllocation();
            // Need to reset "window" each time as nsPluginFrame::DidReflow sets it
            // to the ancestor window.
#if (MOZ_WIDGET_GTK == 2)
            if (GTK_IS_XTBIN(mSocketWidget)) {
                // Point the NPWindow structures window to the actual X window
                SetWindow(GTK_XTBIN(mSocketWidget)->xtwindow);
            }
            else { // XEmbed or OOP&Xt
                SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget)));
            }
#else
            // Gtk3 supports only OOP by GtkSocket
            SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget)));
#endif

#ifdef DEBUG
            printf("nsPluginNativeWindowGtk: call SetWindow with xid=%p\n", (void *)window);
#endif
        } // NPWindowTypeWindow
        aPluginInstance->SetWindow(this);
    }
    else if (mPluginInstance)
        mPluginInstance->SetWindow(nullptr);

    SetPluginInstance(aPluginInstance);
    return NS_OK;
}
开发者ID:,项目名称:,代码行数:75,代码来源:


注:本文中的nsRefPtr::GetPlugin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。