dom/plugins/base/nsPluginNativeWindowQt.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:expandtab:shiftwidth=2:tabstop=2:
michael@0 3 */
michael@0 4 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 /**
michael@0 9 * This file is the Qt implementation of plugin native window.
michael@0 10 */
michael@0 11
michael@0 12 #include "nsDebug.h"
michael@0 13 #include "nsPluginNativeWindow.h"
michael@0 14 #include "npapi.h"
michael@0 15
michael@0 16 /**
michael@0 17 * Qt implementation of plugin window
michael@0 18 */
michael@0 19 class nsPluginNativeWindowQt : public nsPluginNativeWindow
michael@0 20 {
michael@0 21 public:
michael@0 22 nsPluginNativeWindowQt();
michael@0 23 virtual ~nsPluginNativeWindowQt();
michael@0 24
michael@0 25 virtual nsresult CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance);
michael@0 26 private:
michael@0 27
michael@0 28 NPSetWindowCallbackStruct mWsInfo;
michael@0 29 };
michael@0 30
michael@0 31 nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow()
michael@0 32 {
michael@0 33 //Initialize member variables
michael@0 34 #ifdef DEBUG
michael@0 35 fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this);
michael@0 36 #endif
michael@0 37 window = nullptr;
michael@0 38 x = 0;
michael@0 39 y = 0;
michael@0 40 width = 0;
michael@0 41 height = 0;
michael@0 42 memset(&clipRect, 0, sizeof(clipRect));
michael@0 43 ws_info = &mWsInfo;
michael@0 44 type = NPWindowTypeWindow;
michael@0 45 mWsInfo.type = 0;
michael@0 46 #if defined(MOZ_X11)
michael@0 47 mWsInfo.display = nullptr;
michael@0 48 mWsInfo.visual = nullptr;
michael@0 49 mWsInfo.colormap = 0;
michael@0 50 mWsInfo.depth = 0;
michael@0 51 #endif
michael@0 52 }
michael@0 53
michael@0 54 nsPluginNativeWindowQt::~nsPluginNativeWindowQt()
michael@0 55 {
michael@0 56 #ifdef DEBUG
michael@0 57 fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this);
michael@0 58 #endif
michael@0 59 }
michael@0 60
michael@0 61 nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow)
michael@0 62 {
michael@0 63 NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
michael@0 64 *aPluginNativeWindow = new nsPluginNativeWindowQt();
michael@0 65 return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
michael@0 66 }
michael@0 67
michael@0 68 nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)
michael@0 69 {
michael@0 70 NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
michael@0 71 nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow;
michael@0 72 delete p;
michael@0 73 return NS_OK;
michael@0 74 }
michael@0 75
michael@0 76 nsresult nsPluginNativeWindowQt::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance)
michael@0 77 {
michael@0 78 if (aPluginInstance) {
michael@0 79 if (type == NPWindowTypeWindow) {
michael@0 80 return NS_ERROR_FAILURE;
michael@0 81 } // NPWindowTypeWindow
michael@0 82 aPluginInstance->SetWindow(this);
michael@0 83 }
michael@0 84 else if (mPluginInstance)
michael@0 85 mPluginInstance->SetWindow(nullptr);
michael@0 86
michael@0 87 SetPluginInstance(aPluginInstance);
michael@0 88 return NS_OK;
michael@0 89 }

mercurial