summaryrefslogtreecommitdiffstats
path: root/dom/plugins/ipc/PluginMessageUtils.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/plugins/ipc/PluginMessageUtils.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/ipc/PluginMessageUtils.cpp')
-rw-r--r--dom/plugins/ipc/PluginMessageUtils.cpp155
1 files changed, 155 insertions, 0 deletions
diff --git a/dom/plugins/ipc/PluginMessageUtils.cpp b/dom/plugins/ipc/PluginMessageUtils.cpp
new file mode 100644
index 000000000..47653fe6e
--- /dev/null
+++ b/dom/plugins/ipc/PluginMessageUtils.cpp
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- */
+/* vim: set sw=2 ts=8 et tw=80 : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "PluginMessageUtils.h"
+#include "nsIRunnable.h"
+#include "nsThreadUtils.h"
+
+#include "PluginInstanceParent.h"
+#include "PluginInstanceChild.h"
+#include "PluginScriptableObjectParent.h"
+#include "PluginScriptableObjectChild.h"
+
+using std::string;
+
+using mozilla::ipc::MessageChannel;
+
+namespace {
+
+class DeferNPObjectReleaseRunnable : public mozilla::Runnable
+{
+public:
+ DeferNPObjectReleaseRunnable(const NPNetscapeFuncs* f, NPObject* o)
+ : mFuncs(f)
+ , mObject(o)
+ {
+ NS_ASSERTION(o, "no release null objects");
+ }
+
+ NS_IMETHOD Run();
+
+private:
+ const NPNetscapeFuncs* mFuncs;
+ NPObject* mObject;
+};
+
+NS_IMETHODIMP
+DeferNPObjectReleaseRunnable::Run()
+{
+ mFuncs->releaseobject(mObject);
+ return NS_OK;
+}
+
+} // namespace
+
+namespace mozilla {
+namespace plugins {
+
+NPRemoteWindow::NPRemoteWindow() :
+ window(0), x(0), y(0), width(0), height(0), type(NPWindowTypeDrawable)
+#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
+ , visualID(0)
+ , colormap(0)
+#endif /* XP_UNIX */
+#if defined(XP_MACOSX)
+ ,contentsScaleFactor(1.0)
+#endif
+{
+ clipRect.top = 0;
+ clipRect.left = 0;
+ clipRect.bottom = 0;
+ clipRect.right = 0;
+}
+
+ipc::RacyInterruptPolicy
+MediateRace(const MessageChannel::MessageInfo& parent,
+ const MessageChannel::MessageInfo& child)
+{
+ switch (parent.type()) {
+ case PPluginInstance::Msg_Paint__ID:
+ case PPluginInstance::Msg_NPP_SetWindow__ID:
+ case PPluginInstance::Msg_NPP_HandleEvent_Shmem__ID:
+ case PPluginInstance::Msg_NPP_HandleEvent_IOSurface__ID:
+ // our code relies on the frame list not changing during paints and
+ // reflows
+ return ipc::RIPParentWins;
+
+ default:
+ return ipc::RIPChildWins;
+ }
+}
+
+#if defined(OS_LINUX)
+static string
+ReplaceAll(const string& haystack, const string& needle, const string& with)
+{
+ string munged = haystack;
+ string::size_type i = 0;
+
+ while (string::npos != (i = munged.find(needle, i))) {
+ munged.replace(i, needle.length(), with);
+ i += with.length();
+ }
+
+ return munged;
+}
+#endif
+
+string
+MungePluginDsoPath(const string& path)
+{
+#if defined(OS_LINUX)
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=519601
+ return ReplaceAll(path, "netscape", "netsc@pe");
+#else
+ return path;
+#endif
+}
+
+string
+UnmungePluginDsoPath(const string& munged)
+{
+#if defined(OS_LINUX)
+ return ReplaceAll(munged, "netsc@pe", "netscape");
+#else
+ return munged;
+#endif
+}
+
+
+LogModule*
+GetPluginLog()
+{
+ static LazyLogModule sLog("IPCPlugins");
+ return sLog;
+}
+
+void
+DeferNPObjectLastRelease(const NPNetscapeFuncs* f, NPObject* o)
+{
+ if (!o)
+ return;
+
+ if (o->referenceCount > 1) {
+ f->releaseobject(o);
+ return;
+ }
+
+ NS_DispatchToCurrentThread(new DeferNPObjectReleaseRunnable(f, o));
+}
+
+void DeferNPVariantLastRelease(const NPNetscapeFuncs* f, NPVariant* v)
+{
+ if (!NPVARIANT_IS_OBJECT(*v)) {
+ f->releasevariantvalue(v);
+ return;
+ }
+ DeferNPObjectLastRelease(f, v->value.objectValue);
+ VOID_TO_NPVARIANT(*v);
+}
+
+} // namespace plugins
+} // namespace mozilla