Bug 1338172 part B - remove the ancient carbon detection on Mac which is no longer used, r=jimm
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 08 Feb 2017 14:27:49 -0500
changeset 344845 d209d88c5e203ae93f46c11df49ef49a7c3dac21
parent 344844 21643634694ece74eba865eb086da336fedf9ba2
child 344846 74cabd7a09b6c5da67c994ef33dd0dc2363ea9ea
push id37969
push userkwierso@gmail.com
push dateSat, 25 Feb 2017 00:59:33 +0000
treeherderautoland@23bd8be8d881 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1338172
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1338172 part B - remove the ancient carbon detection on Mac which is no longer used, r=jimm MozReview-Commit-ID: 9UEAfPHg7fP
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsNPAPIPluginInstance.h
dom/plugins/ipc/PPluginInstance.ipdl
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginInstanceParent.h
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1573,59 +1573,16 @@ nsNPAPIPluginInstance::FinalizeAsyncSurf
 void
 nsNPAPIPluginInstance::SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed)
 {
   if (mOwner) {
     mOwner->SetCurrentAsyncSurface(surface, changed);
   }
 }
 
-class CarbonEventModelFailureEvent : public Runnable {
-public:
-  nsCOMPtr<nsIContent> mContent;
-
-  explicit CarbonEventModelFailureEvent(nsIContent* aContent)
-    : mContent(aContent)
-  {}
-
-  ~CarbonEventModelFailureEvent() {}
-
-  NS_IMETHOD Run();
-};
-
-NS_IMETHODIMP
-CarbonEventModelFailureEvent::Run()
-{
-  nsString type = NS_LITERAL_STRING("npapi-carbon-event-model-failure");
-  nsContentUtils::DispatchTrustedEvent(mContent->GetComposedDoc(), mContent,
-                                       type, true, true);
-  return NS_OK;
-}
-
-void
-nsNPAPIPluginInstance::CarbonNPAPIFailure()
-{
-  nsCOMPtr<nsIDOMElement> element;
-  GetDOMElement(getter_AddRefs(element));
-  if (!element) {
-    return;
-  }
-
-  nsCOMPtr<nsIContent> content(do_QueryInterface(element));
-  if (!content) {
-    return;
-  }
-
-  nsCOMPtr<nsIRunnable> e = new CarbonEventModelFailureEvent(content);
-  nsresult rv = NS_DispatchToCurrentThread(e);
-  if (NS_FAILED(rv)) {
-    NS_WARNING("Failed to dispatch CarbonEventModelFailureEvent.");
-  }
-}
-
 static bool
 GetJavaVersionFromMimetype(nsPluginTag* pluginTag, nsCString& version)
 {
   for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); ++i) {
     nsCString type = pluginTag->MimeTypes()[i];
     nsAutoCString jpi("application/x-java-applet;jpi-version=");
 
     int32_t idx = type.Find(jpi, false, 0, -1);
--- a/dom/plugins/base/nsNPAPIPluginInstance.h
+++ b/dom/plugins/base/nsNPAPIPluginInstance.h
@@ -297,20 +297,16 @@ public:
 
   void URLRedirectResponse(void* notifyData, NPBool allow);
 
   NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
                            void *initData, NPAsyncSurface *surface);
   NPError FinalizeAsyncSurface(NPAsyncSurface *surface);
   void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed);
 
-  // Called when the instance fails to instantiate beceause the Carbon
-  // event model is not supported.
-  void CarbonNPAPIFailure();
-
   // Returns the contents scale factor of the screen the plugin is drawn on.
   double GetContentsScaleFactor();
 
   // Returns the css zoom factor of the document the plugin is drawn on.
   float GetCSSZoomFactor();
 
   nsresult GetRunID(uint32_t *aRunID);
 
--- a/dom/plugins/ipc/PPluginInstance.ipdl
+++ b/dom/plugins/ipc/PPluginInstance.ipdl
@@ -257,21 +257,16 @@ parent:
     returns (nsCString username, nsCString password, NPError result);
 
   intr NPN_ConvertPoint(double sourceX, bool ignoreDestX, double sourceY, bool ignoreDestY, NPCoordinateSpace sourceSpace,
                        NPCoordinateSpace destSpace)
     returns (double destX, double destY, bool result);
 
   async RedrawPlugin();
 
-  // Send notification that a plugin tried to negotiate Carbon NPAPI so that
-  // users can be notified that restarting the browser in i386 mode may allow
-  // them to use the plugin.
-  sync NegotiatedCarbon();
-
   // Notifies the parent of its NPP_New result code.
   async AsyncNPP_NewResult(NPError aResult);
 
   // Sends a native window to be adopted by the native window that would be
   // returned by NPN_GetValue_NPNVnetscapeWindow. Only used on Windows.
   async SetNetscapeWindowAsParent(NativeWindowHandle childWindow);
 
   sync GetCompositionString(uint32_t aType)
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -257,35 +257,19 @@ PluginInstanceChild::DoNPP_New()
     NPP npp = GetNPP();
 
     NPError rv = mPluginIface->newp((char*)NullableStringGet(mMimeType), npp,
                                     NP_EMBED, argc, argn.get(), argv.get(), 0);
     if (NPERR_NO_ERROR != rv) {
         return rv;
     }
 
-    Initialize();
-
-#if defined(XP_MACOSX) && defined(__i386__)
-    // If an i386 Mac OS X plugin has selected the Carbon event model then
-    // we have to fail. We do not support putting Carbon event model plugins
-    // out of process. Note that Carbon is the default model so out of process
-    // plugins need to actively negotiate something else in order to work
-    // out of process.
-    if (EventModel() == NPEventModelCarbon) {
-      // Send notification that a plugin tried to negotiate Carbon NPAPI so that
-      // users can be notified that restarting the browser in i386 mode may allow
-      // them to use the plugin.
-      SendNegotiatedCarbon();
-
-      // Fail to instantiate.
-      rv = NPERR_MODULE_LOAD_FAILED_ERROR;
-    }
-#endif
-
+    if (!Initialize()) {
+        rv = NPERR_MODULE_LOAD_FAILED_ERROR;
+    }
     return rv;
 }
 
 int
 PluginInstanceChild::GetQuirks()
 {
     return PluginModuleChild::GetChrome()->GetQuirks();
 }
@@ -382,22 +366,24 @@ PluginInstanceChild::NPN_GetValue(NPNVar
 #if defined(MOZ_X11)
     case NPNVToolkit:
         *((NPNToolkitType*)aValue) = NPNVGtk2;
         return NPERR_NO_ERROR;
 
     case NPNVxDisplay:
         if (!mWsInfo.display) {
             // We are called before Initialize() so we have to call it now.
-           Initialize();
+           if (!Initialize()) {
+               return NPERR_GENERIC_ERROR;
+           }
            NS_ASSERTION(mWsInfo.display, "We should have a valid display!");
         }
         *(void **)aValue = mWsInfo.display;
         return NPERR_NO_ERROR;
-    
+
 #elif defined(OS_WIN)
     case NPNVToolkit:
         return NPERR_GENERIC_ERROR;
 #endif
     case NPNVprivateModeBool: {
         bool v = false;
         NPError result;
         if (!CallNPN_GetValue_NPNVprivateModeBool(&v, &result)) {
@@ -1423,17 +1409,17 @@ PluginInstanceChild::AnswerNPP_SetWindow
 bool
 PluginInstanceChild::Initialize()
 {
 #ifdef MOZ_WIDGET_GTK
     NPError rv;
 
     if (mWsInfo.display) {
         // Already initialized
-        return false;
+        return true;
     }
 
     // Request for windowless plugins is set in newp(), before this call.
     if (mWindow.type == NPWindowTypeWindow) {
         AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(&mXEmbed, &rv);
 
         // Set up Xt loop for windowed plugins without XEmbed support
         if (!mXEmbed) {
@@ -1443,17 +1429,28 @@ PluginInstanceChild::Initialize()
 
     // Use default GTK display for XEmbed and windowless plugins
     if (mXEmbed || mWindow.type != NPWindowTypeWindow) {
         mWsInfo.display = DefaultXDisplay();
     }
     else {
         mWsInfo.display = xt_client_get_display();
     }
-#endif 
+#endif
+
+#if defined(XP_MACOSX) && defined(__i386__)
+    // If an i386 Mac OS X plugin has selected the Carbon event model then
+    // we have to fail. We do not support putting Carbon event model plugins
+    // out of process. Note that Carbon is the default model so out of process
+    // plugins need to actively negotiate something else in order to work
+    // out of process.
+    if (EventModel() == NPEventModelCarbon) {
+        return false;
+    }
+#endif
 
     return true;
 }
 
 mozilla::ipc::IPCResult
 PluginInstanceChild::RecvHandledWindowedPluginKeyEvent(
                        const NativeEventData& aKeyEventData,
                        const bool& aIsConsumed)
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -2081,27 +2081,16 @@ PluginInstanceParent::RecvRedrawPlugin()
     if (!inst) {
         return IPC_FAIL_NO_REASON(this);
     }
 
     inst->RedrawPlugin();
     return IPC_OK();
 }
 
-mozilla::ipc::IPCResult
-PluginInstanceParent::RecvNegotiatedCarbon()
-{
-    nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
-    if (!inst) {
-        return IPC_FAIL_NO_REASON(this);
-    }
-    inst->CarbonNPAPIFailure();
-    return IPC_OK();
-}
-
 nsPluginInstanceOwner*
 PluginInstanceParent::GetOwner()
 {
     nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
     if (!inst) {
         return nullptr;
     }
     return inst->GetOwner();
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -247,19 +247,16 @@ public:
                            double *destX,
                            double *destY,
                            bool *result) override;
 
     virtual mozilla::ipc::IPCResult
     RecvRedrawPlugin() override;
 
     virtual mozilla::ipc::IPCResult
-    RecvNegotiatedCarbon() override;
-
-    virtual mozilla::ipc::IPCResult
     RecvAsyncNPP_NewResult(const NPError& aResult) override;
 
     virtual mozilla::ipc::IPCResult
     RecvSetNetscapeWindowAsParent(const NativeWindowHandle& childWindow) override;
 
     NPError NPP_SetWindow(const NPWindow* aWindow);
 
     NPError NPP_GetValue(NPPVariable variable, void* retval);