1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/base/nsPluginNativeWindowQt.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:expandtab:shiftwidth=2:tabstop=2: 1.6 + */ 1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.10 + 1.11 +/** 1.12 + * This file is the Qt implementation of plugin native window. 1.13 + */ 1.14 + 1.15 +#include "nsDebug.h" 1.16 +#include "nsPluginNativeWindow.h" 1.17 +#include "npapi.h" 1.18 + 1.19 +/** 1.20 + * Qt implementation of plugin window 1.21 + */ 1.22 +class nsPluginNativeWindowQt : public nsPluginNativeWindow 1.23 +{ 1.24 +public: 1.25 + nsPluginNativeWindowQt(); 1.26 + virtual ~nsPluginNativeWindowQt(); 1.27 + 1.28 + virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance); 1.29 +private: 1.30 + 1.31 + NPSetWindowCallbackStruct mWsInfo; 1.32 +}; 1.33 + 1.34 +nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow() 1.35 +{ 1.36 + //Initialize member variables 1.37 +#ifdef DEBUG 1.38 + fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this); 1.39 +#endif 1.40 + window = nullptr; 1.41 + x = 0; 1.42 + y = 0; 1.43 + width = 0; 1.44 + height = 0; 1.45 + memset(&clipRect, 0, sizeof(clipRect)); 1.46 + ws_info = &mWsInfo; 1.47 + type = NPWindowTypeWindow; 1.48 + mWsInfo.type = 0; 1.49 +#if defined(MOZ_X11) 1.50 + mWsInfo.display = nullptr; 1.51 + mWsInfo.visual = nullptr; 1.52 + mWsInfo.colormap = 0; 1.53 + mWsInfo.depth = 0; 1.54 +#endif 1.55 +} 1.56 + 1.57 +nsPluginNativeWindowQt::~nsPluginNativeWindowQt() 1.58 +{ 1.59 +#ifdef DEBUG 1.60 + fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this); 1.61 +#endif 1.62 +} 1.63 + 1.64 +nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow) 1.65 +{ 1.66 + NS_ENSURE_ARG_POINTER(aPluginNativeWindow); 1.67 + *aPluginNativeWindow = new nsPluginNativeWindowQt(); 1.68 + return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY; 1.69 +} 1.70 + 1.71 +nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) 1.72 +{ 1.73 + NS_ENSURE_ARG_POINTER(aPluginNativeWindow); 1.74 + nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow; 1.75 + delete p; 1.76 + return NS_OK; 1.77 +} 1.78 + 1.79 +nsresult nsPluginNativeWindowQt::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) 1.80 +{ 1.81 + if (aPluginInstance) { 1.82 + if (type == NPWindowTypeWindow) { 1.83 + return NS_ERROR_FAILURE; 1.84 + } // NPWindowTypeWindow 1.85 + aPluginInstance->SetWindow(this); 1.86 + } 1.87 + else if (mPluginInstance) 1.88 + mPluginInstance->SetWindow(nullptr); 1.89 + 1.90 + SetPluginInstance(aPluginInstance); 1.91 + return NS_OK; 1.92 +}