Bug 1337781 - Force Flash to be windowless on Linux, r?jimm draft
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 08 Feb 2017 09:35:28 -0500
changeset 481913 3eedf5fb41738be98a903a85ecc84bb57f7238c9
parent 480508 3a95aa4246653a7863914ffec032897d13359fb0
child 481915 0405267c670903503cb71151f767230528d8382a
push id44956
push userbsmedberg@mozilla.com
push dateFri, 10 Feb 2017 19:33:27 +0000
reviewersjimm
bugs1337781
milestone54.0a1
Bug 1337781 - Force Flash to be windowless on Linux, r?jimm MozReview-Commit-ID: KuSqj0FwAXg
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -2685,16 +2685,37 @@ PluginModuleParent::AccumulateModuleInit
         GetPluginDetails();
     }
     Telemetry::Accumulate(Telemetry::BLOCKED_ON_PLUGIN_MODULE_INIT_MS,
                           GetHistogramKey(),
                           static_cast<uint32_t>(mTimeBlocked.ToMilliseconds()));
     mTimeBlocked = TimeDuration();
 }
 
+#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+static void
+ForceWindowless(InfallibleTArray<nsCString>& names,
+                InfallibleTArray<nsCString>& values)
+{
+    nsCaseInsensitiveUTF8StringArrayComparator comparator;
+    NS_NAMED_LITERAL_CSTRING(wmodeAttributeName, "wmode");
+    NS_NAMED_LITERAL_CSTRING(opaqueAttributeValue, "opaque");
+    auto wmodeAttributeIndex =
+        names.IndexOf(wmodeAttributeName, 0, comparator);
+    if (wmodeAttributeIndex != names.NoIndex) {
+        if (!values[wmodeAttributeIndex].EqualsLiteral("transparent")) {
+            values[wmodeAttributeIndex].Assign(opaqueAttributeValue);
+        }
+    } else {
+        names.AppendElement(wmodeAttributeName);
+        values.AppendElement(opaqueAttributeValue);
+    }
+}
+#endif // windows or linux
+
 nsresult
 PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
                                     uint16_t mode,
                                     InfallibleTArray<nsCString>& names,
                                     InfallibleTArray<nsCString>& values,
                                     NPSavedData* saved, NPError* error)
 {
     MOZ_ASSERT(names.Length() == values.Length());
@@ -2736,29 +2757,21 @@ PluginModuleParent::NPP_NewInternal(NPMI
         // For 64-bit builds force windowless if the flash library doesn't support
         // async rendering regardless of sandbox level.
         if (!supportsAsyncRender) {
 #else
         // For 32-bit builds force windowless if the flash library doesn't support
         // async rendering and the sandbox level is 2 or greater.
         if (!supportsAsyncRender && mSandboxLevel >= 2) {
 #endif
-           NS_NAMED_LITERAL_CSTRING(wmodeAttributeName, "wmode");
-           NS_NAMED_LITERAL_CSTRING(opaqueAttributeValue, "opaque");
-           auto wmodeAttributeIndex =
-               names.IndexOf(wmodeAttributeName, 0, comparator);
-           if (wmodeAttributeIndex != names.NoIndex) {
-               if (!values[wmodeAttributeIndex].EqualsLiteral("transparent")) {
-                   values[wmodeAttributeIndex].Assign(opaqueAttributeValue);
-               }
-           } else {
-               names.AppendElement(wmodeAttributeName);
-               values.AppendElement(opaqueAttributeValue);
-           }
+            ForceWindowless(names, values);
         }
+#elif defined(MOZ_WIDGET_GTK)
+        // We no longer support windowed mode on Linux.
+        ForceWindowless(names, values);
 #endif
     }
 
     // Release the surrogate reference that was in pdata
     RefPtr<PluginAsyncSurrogate> surrogate(
         dont_AddRef(PluginAsyncSurrogate::Cast(instance)));
     // Now replace it with the instance
     instance->pdata = static_cast<PluginDataResolver*>(parentInstance);