Bug 598397: Remove support for Carbon NPAPI. r=smichaud
authorJosh Aas <joshmoz@gmail.com>
Mon, 15 Oct 2012 08:38:34 -0400
changeset 110403 faa749453ea4da994daf9bd3630bb3d229c4d691
parent 110402 22d51507ec021c0362e80e339370769578194642
child 110404 01d9b64351f4b5820c682bd6e79a5bda14e80ed2
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewerssmichaud
bugs598397
milestone19.0a1
Bug 598397: Remove support for Carbon NPAPI. r=smichaud
dom/plugins/base/nsIPluginInstanceOwner.idl
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/test/testplugin/nptest_macosx.mm
layout/generic/nsObjectFrame.cpp
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/cocoa/nsAppShell.mm
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/dom/plugins/base/nsIPluginInstanceOwner.idl
+++ b/dom/plugins/base/nsIPluginInstanceOwner.idl
@@ -14,17 +14,17 @@ interface nsIDocument;
 #include "nsNPAPIPluginInstance.h"
 class nsPluginEvent;
 %}
 
 [ptr] native nsNPAPIPluginInstancePtr(nsNPAPIPluginInstance);
 
 // Do not make this interface scriptable, because the virtual functions in C++
 // blocks will make script call the wrong functions.
-[uuid(CE1EE148-B201-4DC7-8A65-311143EA01BF)]
+[uuid(59BE4CA5-3CB0-40E6-A111-9A88C8477610)]
 interface nsIPluginInstanceOwner : nsISupports
 {
   /**
    * Let the owner know what its instance is
    */
   void setInstance(in nsNPAPIPluginInstancePtr aInstance);
 
   /**
@@ -106,20 +106,16 @@ interface nsIPluginInstanceOwner : nsISu
   virtual NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
                                    void *initData, NPAsyncSurface *surface) = 0;
   virtual NPError FinalizeAsyncSurface(NPAsyncSurface *surface) = 0;
   virtual void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed) = 0;
 %}
 
   void setEventModel(in int32_t eventModel);
 
-%{C++
-  virtual void SendIdleEvent() = 0;
-%}
-
   /**
    * Call NPP_SetWindow on the plugin.
    */
   void callSetWindow();
 
   /**
    * Get the contents scale factor for the screen the plugin is
    * drawn on.
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -2122,17 +2122,17 @@ NPError NP_CALLBACK
      *(NPBool*)result = nsCocoaFeatures::SupportCoreAnimationPlugins();
 
      return NPERR_NO_ERROR;
    }
 
 
 #ifndef NP_NO_CARBON
   case NPNVsupportsCarbonBool: {
-    *(NPBool*)result = true;
+    *(NPBool*)result = false;
 
     return NPERR_NO_ERROR;
   }
 #endif
   case NPNVsupportsCocoaBool: {
     *(NPBool*)result = true;
 
     return NPERR_NO_ERROR;
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -363,21 +363,16 @@ nsPluginHost::nsPluginHost()
 
   PR_LOG(nsPluginLogging::gNPNLog, PLUGIN_LOG_ALWAYS,("NPN Logging Active!\n"));
   PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_ALWAYS,("General Plugin Logging Active! (nsPluginHost::ctor)\n"));
   PR_LOG(nsPluginLogging::gNPPLog, PLUGIN_LOG_ALWAYS,("NPP Logging Active!\n"));
 
   PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHost::ctor\n"));
   PR_LogFlush();
 #endif
-
-#ifdef MAC_CARBON_PLUGINS
-  mVisiblePluginTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
-  mHiddenPluginTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
-#endif
 }
 
 nsPluginHost::~nsPluginHost()
 {
   PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHost::dtor\n"));
 
   UnloadPlugins();
   sInst = nullptr;
@@ -3805,84 +3800,18 @@ nsPluginHost::GetPluginTagForInstance(ns
     return NS_ERROR_FAILURE;
 
   *aPluginTag = TagForPlugin(plugin);
 
   NS_ADDREF(*aPluginTag);
   return NS_OK;
 }
 
-#ifdef MAC_CARBON_PLUGINS
-// Flash requires a minimum of 8 events per second to avoid audio skipping.
-// Since WebKit uses a hidden plugin event rate of 4 events per second Flash
-// uses a Carbon timer for WebKit which fires at 8 events per second.
-#define HIDDEN_PLUGIN_DELAY 125
-#define VISIBLE_PLUGIN_DELAY 20
-#endif
-
-void nsPluginHost::AddIdleTimeTarget(nsIPluginInstanceOwner* objectFrame, bool isVisible)
-{
-#ifdef MAC_CARBON_PLUGINS
-  nsTObserverArray<nsIPluginInstanceOwner*> *targetArray;
-  if (isVisible) {
-    targetArray = &mVisibleTimerTargets;
-  } else {
-    targetArray = &mHiddenTimerTargets;
-  }
-
-  if (targetArray->Contains(objectFrame)) {
-    return;
-  }
-
-  targetArray->AppendElement(objectFrame);
-  if (targetArray->Length() == 1) {
-    if (isVisible) {
-      mVisiblePluginTimer->InitWithCallback(this, VISIBLE_PLUGIN_DELAY, nsITimer::TYPE_REPEATING_SLACK);
-    } else {
-      mHiddenPluginTimer->InitWithCallback(this, HIDDEN_PLUGIN_DELAY, nsITimer::TYPE_REPEATING_SLACK);
-    }
-  }
-#endif
-}
-
-void nsPluginHost::RemoveIdleTimeTarget(nsIPluginInstanceOwner* objectFrame)
-{
-#ifdef MAC_CARBON_PLUGINS
-  bool visibleRemoved = mVisibleTimerTargets.RemoveElement(objectFrame);
-  if (visibleRemoved && mVisibleTimerTargets.IsEmpty()) {
-    mVisiblePluginTimer->Cancel();
-  }
-
-  bool hiddenRemoved = mHiddenTimerTargets.RemoveElement(objectFrame);
-  if (hiddenRemoved && mHiddenTimerTargets.IsEmpty()) {
-    mHiddenPluginTimer->Cancel();
-  }
-
-  NS_ASSERTION(!(hiddenRemoved && visibleRemoved), "Plugin instance received visible and hidden idle event notifications");
-#endif
-}
-
 NS_IMETHODIMP nsPluginHost::Notify(nsITimer* timer)
 {
-#ifdef MAC_CARBON_PLUGINS
-  if (timer == mVisiblePluginTimer) {
-    nsTObserverArray<nsIPluginInstanceOwner*>::ForwardIterator iter(mVisibleTimerTargets);
-    while (iter.HasMore()) {
-      iter.GetNext()->SendIdleEvent();
-    }
-    return NS_OK;
-  } else if (timer == mHiddenPluginTimer) {
-    nsTObserverArray<nsIPluginInstanceOwner*>::ForwardIterator iter(mHiddenTimerTargets);
-    while (iter.HasMore()) {
-      iter.GetNext()->SendIdleEvent();
-    }
-    return NS_OK;
-  }
-#endif
-
   nsRefPtr<nsPluginTag> pluginTag = mPlugins;
   while (pluginTag) {
     if (pluginTag->mUnloadTimer == timer) {
       if (!IsRunningPlugin(pluginTag)) {
         pluginTag->TryUnloadPlugin(false);
       }
       return NS_OK;
     }
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -33,20 +33,16 @@
 class nsNPAPIPlugin;
 class nsIComponentManager;
 class nsIFile;
 class nsIChannel;
 class nsPluginNativeWindow;
 class nsObjectLoadingContent;
 class nsPluginInstanceOwner;
 
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-#define MAC_CARBON_PLUGINS
-#endif
-
 class nsInvalidPluginTag : public nsISupports
 {
 public:
   nsInvalidPluginTag(const char* aFullPath, int64_t aLastModifiedTime = 0);
   virtual ~nsInvalidPluginTag();
   
   NS_DECL_ISUPPORTS
   
@@ -315,23 +311,16 @@ private:
 
   nsWeakPtr mCurrentDocument; // weak reference, we use it to id document only
 
   static nsIFile *sPluginTempDir;
 
   // We need to hold a global ptr to ourselves because we register for
   // two different CIDs for some reason...
   static nsPluginHost* sInst;
-
-#ifdef MAC_CARBON_PLUGINS
-  nsCOMPtr<nsITimer> mVisiblePluginTimer;
-  nsTObserverArray<nsIPluginInstanceOwner*> mVisibleTimerTargets;
-  nsCOMPtr<nsITimer> mHiddenPluginTimer;
-  nsTObserverArray<nsIPluginInstanceOwner*> mHiddenTimerTargets;
-#endif
 };
 
 class NS_STACK_CLASS PluginDestructionGuard : protected PRCList
 {
 public:
   PluginDestructionGuard(nsNPAPIPluginInstance *aInstance)
     : mInstance(aInstance)
   {
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -316,27 +316,24 @@ nsPluginInstanceOwner::nsPluginInstanceO
   mPluginDocumentActiveState = true;
   mNumCachedAttrs = 0;
   mNumCachedParams = 0;
   mCachedAttrParamNames = nullptr;
   mCachedAttrParamValues = nullptr;
 
 #ifdef XP_MACOSX
 #ifndef NP_NO_CARBON
+  // We don't support Carbon, but it is still the default model for i386 NPAPI.
   mEventModel = NPEventModelCarbon;
 #else
   mEventModel = NPEventModelCocoa;
 #endif
   mUseAsyncRendering = false;
 #endif
 
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-  mRegisteredScrollPositionListener = false;
-#endif
-
   mWaitingForPaint = false;
 
 #ifdef MOZ_WIDGET_ANDROID
   mFullScreen = false;
   mJavaView = nullptr;
 #endif
 }
 
@@ -346,20 +343,16 @@ nsPluginInstanceOwner::~nsPluginInstance
 
   if (mWaitingForPaint) {
     // We don't care when the event is dispatched as long as it's "soon",
     // since whoever needs it will be waiting for it.
     nsCOMPtr<nsIRunnable> event = new AsyncPaintWaitEvent(mContent, true);
     NS_DispatchToMainThread(event);
   }
 
-#ifdef MAC_CARBON_PLUGINS
-  CancelTimer();
-#endif
-
   mObjectFrame = nullptr;
 
   for (cnt = 0; cnt < (mNumCachedAttrs + 1 + mNumCachedParams); cnt++) {
     if (mCachedAttrParamNames && mCachedAttrParamNames[cnt]) {
       NS_Free(mCachedAttrParamNames[cnt]);
       mCachedAttrParamNames[cnt] = nullptr;
     }
 
@@ -762,27 +755,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 NS_IMETHODIMP nsPluginInstanceOwner::SetEventModel(int32_t eventModel)
 {
 #ifdef XP_MACOSX
-  NPEventModel newEventModel = static_cast<NPEventModel>(eventModel);
-#ifndef NP_NO_CARBON
-  bool eventModelChange = (mEventModel != newEventModel);
-  if (eventModelChange)
-    RemoveScrollPositionListener();
-#endif
-  mEventModel = static_cast<NPEventModel>(newEventModel);
-#ifndef NP_NO_CARBON
-  if (eventModelChange)
-    AddScrollPositionListener();
-#endif
+  mEventModel = static_cast<NPEventModel>(eventModel);
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 NPError nsPluginInstanceOwner::ShowNativeContextMenu(NPMenu* menu, void* event)
 {
@@ -1348,30 +1331,16 @@ nsresult nsPluginInstanceOwner::EnsureCa
     nextAttrParamIndex++;
   }
 
   return NS_OK;
 }
 
 #ifdef XP_MACOSX
 
-#ifndef NP_NO_CARBON
-static void InitializeEventRecord(EventRecord* event, ::Point* aMousePosition)
-{
-  memset(event, 0, sizeof(EventRecord));
-  if (aMousePosition) {
-    event->where = *aMousePosition;
-  } else {
-    ::GetGlobalMouse(&event->where);
-  }
-  event->when = ::TickCount();
-  event->modifiers = ::GetCurrentKeyModifiers();
-}
-#endif
-
 static void InitializeNPCocoaEvent(NPCocoaEvent* event)
 {
   memset(event, 0, sizeof(NPCocoaEvent));
 }
 
 NPDrawingModel nsPluginInstanceOwner::GetDrawingModel()
 {
 #ifndef NP_NO_QUICKDRAW
@@ -1590,29 +1559,16 @@ void* nsPluginInstanceOwner::SetPluginPo
 {
   if (!mPluginWindow)
     return nullptr;
   void* pluginPort = GetPluginPortFromWidget();
   if (!pluginPort)
     return nullptr;
   mPluginWindow->window = pluginPort;
 
-#ifndef NP_NO_CARBON
-  if (GetEventModel() == NPEventModelCarbon &&
-      GetDrawingModel() == NPDrawingModelCoreGraphics) {
-    NP_CGContext* windowCGPort = static_cast<NP_CGContext*>(mPluginWindow->window);
-    if ((windowCGPort->context != mCGPluginPortCopy.context) ||
-        (windowCGPort->window != mCGPluginPortCopy.window)) {
-      mCGPluginPortCopy.context = windowCGPort->context;
-      mCGPluginPortCopy.window = windowCGPort->window;
-      mPluginPortChanged = true;
-    }
-  }
-#endif
-
   return mPluginWindow->window;
 }
 
 void nsPluginInstanceOwner::BeginCGPaint()
 {
   ++mInCGPaintLevel;
 }
 
@@ -1645,64 +1601,16 @@ nsPluginInstanceOwner::GetEventloopNesti
   // we make sure we always tear the plugin down eventually.
   if (!currentLevel) {
     currentLevel++;
   }
 
   return currentLevel;
 }
 
-void nsPluginInstanceOwner::ScrollPositionWillChange(nscoord aX, nscoord aY)
-{
-#ifdef MAC_CARBON_PLUGINS
-  if (GetEventModel() != NPEventModelCarbon)
-    return;
-
-  CancelTimer();
-
-  if (mInstance) {
-    nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
-    if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
-      EventRecord scrollEvent;
-      InitializeEventRecord(&scrollEvent, nullptr);
-      scrollEvent.what = NPEventType_ScrollingBeginsEvent;
-
-      void* window = FixUpPluginWindow(ePluginPaintDisable);
-      if (window) {
-        mInstance->HandleEvent(&scrollEvent, nullptr);
-      }
-      pluginWidget->EndDrawPlugin();
-    }
-  }
-#endif
-}
-
-void nsPluginInstanceOwner::ScrollPositionDidChange(nscoord aX, nscoord aY)
-{
-#ifdef MAC_CARBON_PLUGINS
-  if (GetEventModel() != NPEventModelCarbon)
-    return;
-
-  if (mInstance) {
-    nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
-    if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
-      EventRecord scrollEvent;
-      InitializeEventRecord(&scrollEvent, nullptr);
-      scrollEvent.what = NPEventType_ScrollingEndsEvent;
-
-      void* window = FixUpPluginWindow(ePluginPaintEnable);
-      if (window) {
-        mInstance->HandleEvent(&scrollEvent, nullptr);
-      }
-      pluginWidget->EndDrawPlugin();
-    }
-  }
-#endif
-}
-
 #ifdef MOZ_WIDGET_ANDROID
 
 // Modified version of nsFrame::GetOffsetToCrossDoc that stops when it
 // hits an element with a displayport (or runs out of frames). This is
 // not really the right thing to do, but it's better than what was here before.
 static nsPoint
 GetOffsetRootContent(nsIFrame* aFrame)
 {
@@ -1933,45 +1841,16 @@ nsresult nsPluginInstanceOwner::Text(nsI
 
   return NS_OK;
 }
 #endif
 
 nsresult nsPluginInstanceOwner::ProcessKeyPress(nsIDOMEvent* aKeyEvent)
 {
 #ifdef XP_MACOSX
-#ifndef NP_NO_CARBON
-  if (GetEventModel() == NPEventModelCarbon) {
-    // KeyPress events are really synthesized keyDown events.
-    // Here we check the native message of the event so that
-    // we won't send the plugin two keyDown events.
-    nsEvent *theEvent = aKeyEvent->GetInternalNSEvent();
-    const EventRecord *ev;
-    if (theEvent &&
-        theEvent->message == NS_KEY_PRESS &&
-        (ev = (EventRecord*)(((nsGUIEvent*)theEvent)->pluginEvent)) &&
-        ev->what == keyDown)
-      return aKeyEvent->PreventDefault(); // consume event
-
-    // Nasty hack to avoid recursive event dispatching with Java. Java can
-    // dispatch key events to a TSM handler, which comes back and calls 
-    // [ChildView insertText:] on the cocoa widget, which sends a key
-    // event back down.
-    static bool sInKeyDispatch = false;
-
-    if (sInKeyDispatch)
-      return aKeyEvent->PreventDefault(); // consume event
-
-    sInKeyDispatch = true;
-    nsresult rv =  DispatchKeyToPlugin(aKeyEvent);
-    sInKeyDispatch = false;
-    return rv;
-  }
-#endif
-
   return DispatchKeyToPlugin(aKeyEvent);
 #else
   if (SendNativeEvents())
     DispatchKeyToPlugin(aKeyEvent);
 
   if (mInstance) {
     // If this event is going to the plugin, we want to kill it.
     // Not actually sending keypress to the plugin, since we didn't before.
@@ -2148,146 +2027,81 @@ nsEventStatus nsPluginInstanceOwner::Pro
 
   nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
   if (!pluginWidget || NS_FAILED(pluginWidget->StartDrawPlugin()))
     return nsEventStatus_eIgnore;
 
   NPEventModel eventModel = GetEventModel();
 
   // If we have to synthesize an event we'll use one of these.
-#ifndef NP_NO_CARBON
-  EventRecord synthCarbonEvent;
-#endif
   NPCocoaEvent synthCocoaEvent;
   void* event = anEvent.pluginEvent;
   nsPoint pt =
   nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
   mObjectFrame->GetContentRectRelativeToSelf().TopLeft();
   nsPresContext* presContext = mObjectFrame->PresContext();
   // Plugin event coordinates need to be translated from device pixels
   // into "display pixels" in HiDPI modes.
   double scaleFactor = 1.0;
   GetContentsScaleFactor(&scaleFactor);
   size_t intScaleFactor = ceil(scaleFactor);
   nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x) / intScaleFactor,
                   presContext->AppUnitsToDevPixels(pt.y) / intScaleFactor);
-#ifndef NP_NO_CARBON
-  nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
-  ::Point carbonPt = { static_cast<short>(ptPx.y + geckoScreenCoords.y / intScaleFactor),
-                       static_cast<short>(ptPx.x + geckoScreenCoords.x / intScaleFactor) };
-  if (eventModel == NPEventModelCarbon) {
-    if (event && anEvent.eventStructType == NS_MOUSE_EVENT) {
-      static_cast<EventRecord*>(event)->where = carbonPt;
-    }
-  }
-#endif
+
   if (!event) {
-#ifndef NP_NO_CARBON
-    if (eventModel == NPEventModelCarbon) {
-      InitializeEventRecord(&synthCarbonEvent, &carbonPt);
-    } else
-#endif
-    {
-      InitializeNPCocoaEvent(&synthCocoaEvent);
-    }
-    
+    InitializeNPCocoaEvent(&synthCocoaEvent);
     switch (anEvent.message) {
-      case NS_FOCUS_CONTENT:
-      case NS_BLUR_CONTENT:
-#ifndef NP_NO_CARBON
-        if (eventModel == NPEventModelCarbon) {
-          synthCarbonEvent.what = (anEvent.message == NS_FOCUS_CONTENT) ?
-          NPEventType_GetFocusEvent : NPEventType_LoseFocusEvent;
-          event = &synthCarbonEvent;
-        }
-#endif
-        break;
       case NS_MOUSE_MOVE:
       {
         // Ignore mouse-moved events that happen as part of a dragging
         // operation that started over another frame.  See bug 525078.
         nsRefPtr<nsFrameSelection> frameselection = mObjectFrame->GetFrameSelection();
         if (!frameselection->GetMouseDownState() ||
-            (nsIPresShell::GetCapturingContent() == mObjectFrame->GetContent())) {
-#ifndef NP_NO_CARBON
-          if (eventModel == NPEventModelCarbon) {
-            synthCarbonEvent.what = osEvt;
-            event = &synthCarbonEvent;
-          } else
-#endif
-          {
-            synthCocoaEvent.type = NPCocoaEventMouseMoved;
-            synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
-            synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
-            event = &synthCocoaEvent;
-          }
+          (nsIPresShell::GetCapturingContent() == mObjectFrame->GetContent())) {
+          synthCocoaEvent.type = NPCocoaEventMouseMoved;
+          synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
+          synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
+          event = &synthCocoaEvent;
         }
       }
         break;
       case NS_MOUSE_BUTTON_DOWN:
-#ifndef NP_NO_CARBON
-        if (eventModel == NPEventModelCarbon) {
-          synthCarbonEvent.what = mouseDown;
-          event = &synthCarbonEvent;
-        } else
-#endif
-        {
-          synthCocoaEvent.type = NPCocoaEventMouseDown;
-          synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
-          synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
-          event = &synthCocoaEvent;
-        }
+        synthCocoaEvent.type = NPCocoaEventMouseDown;
+        synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
+        synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
+        event = &synthCocoaEvent;
         break;
       case NS_MOUSE_BUTTON_UP:
         // If we're in a dragging operation that started over another frame,
-        // either ignore the mouse-up event (in the Carbon Event Model) or
         // convert it into a mouse-entered event (in the Cocoa Event Model).
         // See bug 525078.
         if ((static_cast<const nsMouseEvent&>(anEvent).button == nsMouseEvent::eLeftButton) &&
             (nsIPresShell::GetCapturingContent() != mObjectFrame->GetContent())) {
-          if (eventModel == NPEventModelCocoa) {
-            synthCocoaEvent.type = NPCocoaEventMouseEntered;
-            synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
-            synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
-            event = &synthCocoaEvent;
-          }
+          synthCocoaEvent.type = NPCocoaEventMouseEntered;
+          synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
+          synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
+          event = &synthCocoaEvent;
         } else {
-#ifndef NP_NO_CARBON
-          if (eventModel == NPEventModelCarbon) {
-            synthCarbonEvent.what = mouseUp;
-            event = &synthCarbonEvent;
-          } else
-#endif
-          {
-            synthCocoaEvent.type = NPCocoaEventMouseUp;
-            synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
-            synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
-            event = &synthCocoaEvent;
-          }
+          synthCocoaEvent.type = NPCocoaEventMouseUp;
+          synthCocoaEvent.data.mouse.pluginX = static_cast<double>(ptPx.x);
+          synthCocoaEvent.data.mouse.pluginY = static_cast<double>(ptPx.y);
+          event = &synthCocoaEvent;
         }
         break;
       default:
         break;
     }
 
     // If we still don't have an event, bail.
     if (!event) {
       pluginWidget->EndDrawPlugin();
       return nsEventStatus_eIgnore;
     }
   }
 
-#ifndef NP_NO_CARBON
-  // Work around an issue in the Flash plugin, which can cache a pointer
-  // to a doomed TSM document (one that belongs to a NSTSMInputContext)
-  // and try to activate it after it has been deleted. See bug 183313.
-  if (eventModel == NPEventModelCarbon && anEvent.message == NS_FOCUS_CONTENT)
-    ::DeactivateTSMDocument(::TSMGetActiveDocument());
-#endif
-
   int16_t response = kNPEventNotHandled;
   void* window = FixUpPluginWindow(ePluginPaintEnable);
   if (window || (eventModel == NPEventModelCocoa)) {
     mInstance->HandleEvent(event, &response);
   }
 
   if (eventModel == NPEventModelCocoa && response == kNPEventStartIME) {
     pluginWidget->StartComplexTextInputForCurrentEvent();
@@ -2750,20 +2564,16 @@ nsEventStatus nsPluginInstanceOwner::Pro
 }
 
 nsresult
 nsPluginInstanceOwner::Destroy()
 {
   if (mObjectFrame)
     mObjectFrame->SetInstanceOwner(nullptr);
 
-#ifdef MAC_CARBON_PLUGINS
-  // stop the timer explicitly to reduce reference count.
-  CancelTimer();
-#endif
 #ifdef XP_MACOSX
   RemoveFromCARefreshTimer();
   if (mColorProfile)
     ::CGColorSpaceRelease(mColorProfile);  
 #endif
 
   // unregister context menu listener
   if (mCXMenuListener) {
@@ -2831,30 +2641,17 @@ void nsPluginInstanceOwner::Paint(const 
     ::CGContextScaleCTM(cgContext, scaleFactor, scaleFactor);
     // Convert aDirtyRect from device pixels to "display pixels"
     // for HiDPI modes
     dirtyRectCopy.ScaleRoundOut(1.0 / scaleFactor);
   }
 
   nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
   if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
-#ifndef NP_NO_CARBON
-    void* window = FixUpPluginWindow(ePluginPaintEnable);
-    if (GetEventModel() == NPEventModelCarbon && window) {
-      EventRecord updateEvent;
-      InitializeEventRecord(&updateEvent, nullptr);
-      updateEvent.what = updateEvt;
-      updateEvent.message = UInt32(window);
-
-      mInstance->HandleEvent(&updateEvent, nullptr);
-    } else if (GetEventModel() == NPEventModelCocoa)
-#endif
-    {
-      DoCocoaEventDrawRect(dirtyRectCopy, cgContext);
-    }
+    DoCocoaEventDrawRect(dirtyRectCopy, cgContext);
     pluginWidget->EndDrawPlugin();
   }
 }
 
 void nsPluginInstanceOwner::DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext)
 {
   if (!mInstance || !mObjectFrame)
     return;
@@ -3173,60 +2970,16 @@ nsPluginInstanceOwner::Renderer::DrawWit
     exposeEvent.minor_code = 0;
 
     instance->HandleEvent(&pluginEvent, nullptr);
   }
   return NS_OK;
 }
 #endif
 
-void nsPluginInstanceOwner::SendIdleEvent()
-{
-#ifdef MAC_CARBON_PLUGINS
-  // validate the plugin clipping information by syncing the plugin window info to
-  // reflect the current widget location. This makes sure that everything is updated
-  // correctly in the event of scrolling in the window.
-  if (mInstance) {
-    nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
-    if (pluginWidget && NS_SUCCEEDED(pluginWidget->StartDrawPlugin())) {
-      void* window = FixUpPluginWindow(ePluginPaintEnable);
-      if (window) {
-        EventRecord idleEvent;
-        InitializeEventRecord(&idleEvent, nullptr);
-        idleEvent.what = nullEvent;
-
-        // give a bogus 'where' field of our null event when hidden, so Flash
-        // won't respond to mouse moves in other tabs, see bug 120875
-        if (!mWidgetVisible)
-          idleEvent.where.h = idleEvent.where.v = 20000;
-
-        mInstance->HandleEvent(&idleEvent, nullptr);
-      }
-
-      pluginWidget->EndDrawPlugin();
-    }
-  }
-#endif
-}
-
-#ifdef MAC_CARBON_PLUGINS
-void nsPluginInstanceOwner::StartTimer(bool isVisible)
-{
-  if (GetEventModel() != NPEventModelCarbon)
-    return;
-
-  mPluginHost->AddIdleTimeTarget(this, isVisible);
-}
-
-void nsPluginInstanceOwner::CancelTimer()
-{
-  mPluginHost->RemoveIdleTimeTarget(this);
-}
-#endif
-
 nsresult nsPluginInstanceOwner::Init(nsIContent* aContent)
 {
   mLastEventloopNestingLevel = GetEventloopNestingLevel();
 
   mContent = aContent;
 
   // Get a frame, don't reflow. If a reflow was necessary it should have been
   // done at a higher level than this (content).
@@ -3408,20 +3161,16 @@ NS_IMETHODIMP nsPluginInstanceOwner::Cre
     NS_NAMED_LITERAL_CSTRING(flash10Head, "Shockwave Flash 10.");
     mFlash10Quirks = StringBeginsWith(description, flash10Head);
 #endif
   } else if (mWidget) {
     // mPluginWindow->type is used in |GetPluginPort| so it must
     // be initialized first
     mPluginWindow->type = NPWindowTypeWindow;
     mPluginWindow->window = GetPluginPortFromWidget();
-#ifdef MAC_CARBON_PLUGINS
-    // start the idle timer.
-    StartTimer(true);
-#endif
     // tell the plugin window about the widget
     mPluginWindow->SetPluginWidget(mWidget);
     
     // tell the widget about the current plugin instance owner.
     nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
     if (pluginWidget) {
       pluginWidget->SetPluginInstanceOwner(this);
     }
@@ -3435,46 +3184,33 @@ NS_IMETHODIMP nsPluginInstanceOwner::Cre
 // Mac specific code to fix up the port location and clipping region
 #ifdef XP_MACOSX
 
 void* nsPluginInstanceOwner::FixUpPluginWindow(int32_t inPaintState)
 {
   if (!mWidget || !mPluginWindow || !mInstance || !mObjectFrame)
     return nullptr;
 
-  NPEventModel eventModel = GetEventModel();
-
   nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
   if (!pluginWidget)
     return nullptr;
 
   // If we've already set up a CGContext in nsObjectFrame::PaintPlugin(), we
   // don't want calls to SetPluginPortAndDetectChange() to step on our work.
-  void* pluginPort = nullptr;
-  if (mInCGPaintLevel > 0) {
-    pluginPort = mPluginWindow->window;
-  } else {
-    pluginPort = SetPluginPortAndDetectChange();
+  if (mInCGPaintLevel < 1) {
+    SetPluginPortAndDetectChange();
   }
 
-#ifdef MAC_CARBON_PLUGINS
-  if (eventModel == NPEventModelCarbon && !pluginPort)
-    return nullptr;
-#endif
-
   // We'll need the top-level Cocoa window for the Cocoa event model.
-  void* cocoaTopLevelWindow = nullptr;
-  if (eventModel == NPEventModelCocoa) {
-    nsIWidget* widget = mObjectFrame->GetNearestWidget();
-    if (!widget)
-      return nullptr;
-    cocoaTopLevelWindow = widget->GetNativeData(NS_NATIVE_WINDOW);
-    if (!cocoaTopLevelWindow)
-      return nullptr;
-  }
+  nsIWidget* widget = mObjectFrame->GetNearestWidget();
+  if (!widget)
+    return nullptr;
+  void *cocoaTopLevelWindow = widget->GetNativeData(NS_NATIVE_WINDOW);
+  if (!cocoaTopLevelWindow)
+    return nullptr;
 
   nsIntPoint pluginOrigin;
   nsIntRect widgetClip;
   bool widgetVisible;
   pluginWidget->GetPluginClipRect(widgetClip, pluginOrigin, widgetVisible);
   mWidgetVisible = widgetVisible;
 
   // printf("GetPluginClipRect returning visible %d\n", widgetVisible);
@@ -3482,24 +3218,17 @@ void* nsPluginInstanceOwner::FixUpPlugin
   // This would be a lot easier if we could use obj-c here,
   // but we can't. Since we have only nsIWidget and we can't
   // use its native widget (an obj-c object) we have to go
   // from the widget's screen coordinates to its window coords
   // instead of straight to window coords.
   nsIntPoint geckoScreenCoords = mWidget->WidgetToScreenOffset();
 
   nsRect windowRect;
-#ifndef NP_NO_CARBON
-  if (eventModel == NPEventModelCarbon) {
-    NS_NPAPI_CarbonWindowFrame(static_cast<WindowRef>(static_cast<NP_CGContext*>(pluginPort)->window), windowRect);
-  } else
-#endif
-  {
-    NS_NPAPI_CocoaWindowFrame(cocoaTopLevelWindow, windowRect);
-  }
+  NS_NPAPI_CocoaWindowFrame(cocoaTopLevelWindow, windowRect);
 
   double scaleFactor = 1.0;
   GetContentsScaleFactor(&scaleFactor);
   int intScaleFactor = ceil(scaleFactor);
 
   // Convert geckoScreenCoords from device pixels to "display pixels"
   // for HiDPI modes.
   mPluginWindow->x = geckoScreenCoords.x/intScaleFactor - windowRect.x;
@@ -3521,66 +3250,43 @@ void* nsPluginInstanceOwner::FixUpPlugin
     mPluginWindow->clipRect.right  = mPluginWindow->clipRect.left + widgetClip.width; 
   }
 
   // if the clip rect changed, call SetWindow()
   // (RealPlayer needs this to draw correctly)
   if (mPluginWindow->clipRect.left    != oldClipRect.left   ||
       mPluginWindow->clipRect.top     != oldClipRect.top    ||
       mPluginWindow->clipRect.right   != oldClipRect.right  ||
-      mPluginWindow->clipRect.bottom  != oldClipRect.bottom)
+      mPluginWindow->clipRect.bottom  != oldClipRect.bottom ||
+      mPluginPortChanged)
   {
     if (UseAsyncRendering()) {
       mInstance->AsyncSetWindow(mPluginWindow);
     }
     else {
       mPluginWindow->CallSetWindow(mInstance);
     }
     mPluginPortChanged = false;
-#ifdef MAC_CARBON_PLUGINS
-    // if the clipRect is of size 0, make the null timer fire less often
-    CancelTimer();
-    if (mPluginWindow->clipRect.left == mPluginWindow->clipRect.right ||
-        mPluginWindow->clipRect.top == mPluginWindow->clipRect.bottom) {
-      StartTimer(false);
-    }
-    else {
-      StartTimer(true);
-    }
-#endif
-  } else if (mPluginPortChanged) {
-    if (UseAsyncRendering()) {
-      mInstance->AsyncSetWindow(mPluginWindow);
-    }
-    else {
-      mPluginWindow->CallSetWindow(mInstance);
-    }
-    mPluginPortChanged = false;
   }
 
   // After the first NPP_SetWindow call we need to send an initial
   // top-level window focus event.
-  if (eventModel == NPEventModelCocoa && !mSentInitialTopLevelWindowEvent) {
+  if (!mSentInitialTopLevelWindowEvent) {
     // Set this before calling ProcessEvent to avoid endless recursion.
     mSentInitialTopLevelWindowEvent = true;
 
     nsPluginEvent pluginEvent(true, NS_PLUGIN_FOCUS_EVENT, nullptr);
     NPCocoaEvent cocoaEvent;
     InitializeNPCocoaEvent(&cocoaEvent);
     cocoaEvent.type = NPCocoaEventWindowFocusChanged;
     cocoaEvent.data.focus.hasFocus = NS_NPAPI_CocoaWindowIsMain(cocoaTopLevelWindow);
     pluginEvent.pluginEvent = &cocoaEvent;
     ProcessEvent(pluginEvent);
   }
 
-#ifdef MAC_CARBON_PLUGINS
-  if (GetDrawingModel() == NPDrawingModelCoreGraphics && eventModel == NPEventModelCarbon)
-    return static_cast<NP_CGContext*>(pluginPort)->window;
-#endif
-
   return nullptr;
 }
 
 void
 nsPluginInstanceOwner::HidePluginWindow()
 {
   if (!mPluginWindow || !mInstance) {
     return;
@@ -3684,48 +3390,16 @@ nsPluginInstanceOwner::CallSetWindow()
     } else {
       mInstance->SetWindow(mPluginWindow);
     }
   }
 
   return NS_OK;
 }
 
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-void nsPluginInstanceOwner::AddScrollPositionListener()
-{
-  // We need to register as a scroll position listener on every scrollable frame up to the top.
-  if (!mRegisteredScrollPositionListener && GetEventModel() == NPEventModelCarbon) {
-    for (nsIFrame* f = mObjectFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
-      nsIScrollableFrame* sf = do_QueryFrame(f);
-      if (sf) {
-        sf->AddScrollPositionListener(this);
-      }
-    }
-    mRegisteredScrollPositionListener = true;
-  }
-}
-
-void nsPluginInstanceOwner::RemoveScrollPositionListener()
-{
-  // Our frame is changing or going away, unregister for a scroll position listening.
-  // It's OK to unregister when we didn't register, so don't be strict about unregistering.
-  // Better to unregister when we didn't have to than to not unregister when we should.
-  if (mRegisteredScrollPositionListener) {
-    for (nsIFrame* f = mObjectFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
-      nsIScrollableFrame* sf = do_QueryFrame(f);
-      if (sf) {
-        sf->RemoveScrollPositionListener(this);
-      }
-    }
-    mRegisteredScrollPositionListener = false;
-  }
-}
-#endif
-
 NS_IMETHODIMP
 nsPluginInstanceOwner::GetContentsScaleFactor(double *result)
 {
   NS_ENSURE_ARG_POINTER(result);
   double scaleFactor = 1.0;
   // On Mac, device pixels need to be translated to (and from) "display pixels"
   // for plugins. On other platforms, plugin coordinates are always in device
   // pixels.
@@ -3768,21 +3442,16 @@ void nsPluginInstanceOwner::SetFrame(nsO
       }
       // Important! Unlock here otherwise SetCurrentImageInTransaction will deadlock with
       // our lock if we have a RemoteImage.
       autoLock.Unlock();
 #endif
       container->SetCurrentImageInTransaction(nullptr);
     }
 
-    // Scroll position listening is only required for Carbon event model plugins on Mac OS X.
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-    RemoveScrollPositionListener();
-#endif
-
     // Make sure the old frame isn't holding a reference to us.
     mObjectFrame->SetInstanceOwner(nullptr);
   }
 
   // Swap in the new frame (or no frame)
   mObjectFrame = aFrame;
 
   // Set up a new frame
@@ -3790,21 +3459,16 @@ void nsPluginInstanceOwner::SetFrame(nsO
     mObjectFrame->SetInstanceOwner(this);
     // Can only call PrepForDrawing on an object frame once. Don't do it here unless
     // widget creation is complete. Doesn't matter if we actually have a widget.
     if (mWidgetCreationComplete) {
       mObjectFrame->PrepForDrawing(mWidget);
     }
     mObjectFrame->FixupWindow(mObjectFrame->GetContentRectRelativeToSelf().Size());
     mObjectFrame->InvalidateFrame();
-
-    // Scroll position listening is only required for Carbon event model plugins on Mac OS X.
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-    AddScrollPositionListener();
-#endif
     
     nsFocusManager* fm = nsFocusManager::GetFocusManager();
     const nsIContent* content = aFrame->GetContent();
     if (fm && content) {
       mContentFocused = (content == fm->GetFocusedContent());
     }
   }
 }
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -8,17 +8,16 @@
 #define nsPluginInstanceOwner_h_
 
 #include "npapi.h"
 #include "nsCOMPtr.h"
 #include "nsIPluginInstanceOwner.h"
 #include "nsIPluginTagInfo.h"
 #include "nsIPrivacyTransitionObserver.h"
 #include "nsIDOMEventListener.h"
-#include "nsIScrollPositionListener.h"
 #include "nsPluginHost.h"
 #include "nsPluginNativeWindow.h"
 #include "nsWeakReference.h"
 #include "gfxRect.h"
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #include <ApplicationServices/ApplicationServices.h>
@@ -43,17 +42,16 @@ class gfxXlibSurface;
 #define INCL_PM
 #define INCL_GPI
 #include <os2.h>
 #endif
 
 class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
                               public nsIPluginTagInfo,
                               public nsIDOMEventListener,
-                              public nsIScrollPositionListener,
                               public nsIPrivacyTransitionObserver,
                               public nsSupportsWeakReference
 {
 public:
   nsPluginInstanceOwner();
   virtual ~nsPluginInstanceOwner();
   
   NS_DECL_ISUPPORTS
@@ -98,27 +96,17 @@ public:
   void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext);
 #elif defined(MOZ_X11) || defined(ANDROID)
   void Paint(gfxContext* aContext,
              const gfxRect& aFrameRect,
              const gfxRect& aDirtyRect);
 #elif defined(XP_OS2)
   void Paint(const nsRect& aDirtyRect, HPS aHPS);
 #endif
-  
-#ifdef MAC_CARBON_PLUGINS
-  void CancelTimer();
-  void StartTimer(bool isVisible);
-#endif
-  void SendIdleEvent();
-  
-  // nsIScrollPositionListener interface
-  virtual void ScrollPositionWillChange(nscoord aX, nscoord aY);
-  virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
-  
+
   //locals
   
   nsresult Init(nsIContent* aContent);
   
   void* GetPluginPortFromWidget();
   void ReleasePluginPort(void* pluginPort);
 
   nsEventStatus ProcessEvent(const nsGUIEvent & anEvent);
@@ -270,21 +258,16 @@ private:
 #ifdef MOZ_WIDGET_ANDROID
   gfxRect GetPluginRect();
   bool AddPluginView(const gfxRect& aRect = gfxRect(0, 0, 0, 0));
   void RemovePluginView();
 
   bool mFullScreen;
   void* mJavaView;
 #endif 
-
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-  void AddScrollPositionListener();
-  void RemoveScrollPositionListener();
-#endif
  
   nsPluginNativeWindow       *mPluginWindow;
   nsRefPtr<nsNPAPIPluginInstance> mInstance;
   nsObjectFrame              *mObjectFrame;
   nsIContent                 *mContent; // WEAK, content owns us
   nsCString                   mDocumentBase;
   char                       *mTagText;
   bool                        mWidgetCreationComplete;
@@ -312,19 +295,16 @@ private:
   bool                        mPluginPortChanged;
 #endif
 #ifdef MOZ_X11
   // Used with windowless plugins only, initialized in CreateWidget().
   bool                        mFlash10Quirks;
 #endif
   bool                        mPluginWindowVisible;
   bool                        mPluginDocumentActiveState;
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-  bool                        mRegisteredScrollPositionListener;
-#endif
 
   uint16_t          mNumCachedAttrs;
   uint16_t          mNumCachedParams;
   char              **mCachedAttrParamNames;
   char              **mCachedAttrParamValues;
   
 #ifdef XP_MACOSX
   NPEventModel mEventModel;
--- a/dom/plugins/test/testplugin/nptest_macosx.mm
+++ b/dom/plugins/test/testplugin/nptest_macosx.mm
@@ -64,30 +64,16 @@ pluginInstanceInit(InstanceData* instanc
   if ((NPN_GetValue(npp, NPNVsupportsCoreGraphicsBool, &supportsCoreGraphics) == NPERR_NO_ERROR) &&
       supportsCoreGraphics) {
     NPN_SetValue(npp, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics);
   } else {
     printf("CoreGraphics drawing model not supported, can't create a plugin instance.\n");
     return NPERR_INCOMPATIBLE_VERSION_ERROR;
   }
 
-#ifndef NP_NO_CARBON
-  // The test plugin will test using Carbon NPAPI if it is available. This
-  // is simply because we want to test Gecko's Carbon NPAPI support. You can
-  // override this behavior with an environment variable.
-  if (!getenv("TEST_COCOA_NPAPI")) {
-    NPBool supportsCarbonEvents = false;
-    if ((NPN_GetValue(npp, NPNVsupportsCarbonBool, &supportsCarbonEvents) == NPERR_NO_ERROR) &&
-        supportsCarbonEvents) {
-      instanceData->eventModel = NPEventModelCarbon;
-      return NPERR_NO_ERROR;
-    }
-  }
-#endif
-
   NPBool supportsCocoaEvents = false;
   if ((NPN_GetValue(npp, NPNVsupportsCocoaBool, &supportsCocoaEvents) == NPERR_NO_ERROR) &&
       supportsCocoaEvents) {
     NPN_SetValue(npp, NPPVpluginEventModel, (void*)NPEventModelCocoa);
     instanceData->eventModel = NPEventModelCocoa;
   } else {
     printf("Cocoa event model not supported, can't create a plugin instance.\n");
     return NPERR_INCOMPATIBLE_VERSION_ERROR;
@@ -153,26 +139,17 @@ pluginDraw(InstanceData* instanceData, N
     return;
   
   const char* uaString = NPN_UserAgent(npp);
   if (!uaString)
     return;
 
   NPWindow window = instanceData->window;
 
-  CGContextRef cgContext = NULL;
-#ifndef NP_NO_CARBON
-  if (instanceData->eventModel == NPEventModelCocoa) {
-    cgContext = event->data.draw.context;
-  } else {
-    cgContext = ((NP_CGContext*)(window.window))->context;
-  }
-#else
-  cgContext = event->data.draw.context;
-#endif
+  CGContextRef cgContext = event->data.draw.context;
 
   float windowWidth = window.width;
   float windowHeight = window.height;
 
   switch(instanceData->scriptableObject->drawMode) {
   case DM_DEFAULT: {
     CFStringRef uaCFString = CFStringCreateWithCString(kCFAllocatorDefault, uaString, kCFStringEncodingASCII);
     // save the cgcontext gstate
@@ -250,50 +227,16 @@ pluginDraw(InstanceData* instanceData, N
     break;
   }
   }
 }
 
 int16_t
 pluginHandleEvent(InstanceData* instanceData, void* event)
 {
-#ifndef NP_NO_CARBON
-  if (instanceData->eventModel == NPEventModelCarbon) {
-    EventRecord* carbonEvent = (EventRecord*)event;
-    if (!carbonEvent)
-      return kNPEventNotHandled;
-
-    NPWindow* w = &instanceData->window;
-    switch (carbonEvent->what) {
-      case updateEvt:
-        pluginDraw(instanceData, NULL);
-        break;
-      case mouseDown:
-      case mouseUp:
-      case osEvt:
-      {
-        Rect globalBounds = {0};
-        WindowRef nativeWindow = static_cast<WindowRef>(static_cast<NP_CGContext*>(w->window)->window);
-        if (nativeWindow)
-          ::GetWindowBounds(nativeWindow, kWindowStructureRgn, &globalBounds);
-        instanceData->lastMouseX = carbonEvent->where.h - w->x - globalBounds.left;
-        instanceData->lastMouseY = carbonEvent->where.v - w->y - globalBounds.top;
-        if (carbonEvent->what == mouseUp) {
-          instanceData->mouseUpEventCount++;
-        }
-        break;
-      }
-      default:
-        return kNPEventNotHandled;
-    }
-
-    return kNPEventHandled;
-  }
-#endif
-
   NPCocoaEvent* cocoaEvent = (NPCocoaEvent*)event;
   if (!cocoaEvent)
     return kNPEventNotHandled;
 
   switch (cocoaEvent->type) {
     case NPCocoaEventDrawRect:
       pluginDraw(instanceData, cocoaEvent);
       break;
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -152,19 +152,17 @@ using mozilla::DefaultXDisplay;
 #ifdef CreateEvent // Thank you MS.
 #undef CreateEvent
 #endif
 
 #ifdef PR_LOGGING 
 static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
 #endif /* PR_LOGGING */
 
-#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
-
-#define MAC_CARBON_PLUGINS
+#if defined(XP_MACOSX) && !defined(__LP64__)
 
 // The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
 // and up (though the QuickDraw APIs defined in them are still present) -- so
 // we need to supply the relevant parts of their contents here.  It's likely
 // that Apple will eventually remove the APIs themselves (probably in OS X
 // 10.8), so we need to make them weak imports, and test for their presence
 // before using them.
 extern "C" {
@@ -189,17 +187,17 @@ extern "C" {
     Ptr           newBuffer,
     SInt32        rowBytes)
     __attribute__((weak_import));
   extern void DisposeGWorld(GWorldPtr offscreenGWorld)
     __attribute__((weak_import));
   #endif /* __QDOFFSCREEN__ */
 }
 
-#endif /* #if defined(XP_MACOSX) && !defined(NP_NO_CARBON) */
+#endif /* #if defined(XP_MACOSX) && !defined(__LP64__) */
 
 using namespace mozilla;
 using namespace mozilla::plugins;
 using namespace mozilla::layers;
 
 class PluginBackgroundSink : public ReadbackSink {
 public:
   PluginBackgroundSink(nsObjectFrame* aFrame, uint64_t aStartSequenceNumber)
@@ -1340,17 +1338,17 @@ nsObjectFrame::PrintPlugin(nsRenderingCo
   bool windowless = false;
   pi->IsWindowless(&windowless);
   window.type = windowless ? NPWindowTypeDrawable : NPWindowTypeWindow;
 
   window.clipRect.bottom = 0; window.clipRect.top = 0;
   window.clipRect.left = 0; window.clipRect.right = 0;
 
 // platform specific printing code
-#ifdef MAC_CARBON_PLUGINS
+#if defined(XP_MACOSX) && !defined(__LP64__)
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
   // Don't use this code if any of the QuickDraw APIs it currently requires
   // are missing (as they probably will be on OS X 10.8 and up).
   if (!&::SetRect || !&::NewGWorldFromPtr || !&::DisposeGWorld) {
     NS_WARNING("Cannot print plugin -- required QuickDraw APIs are missing!");
     return;
   }
 
@@ -1810,40 +1808,16 @@ nsObjectFrame::PaintPlugin(nsDisplayList
       }
       NP_CGContext* cgPluginPortCopy =
                 static_cast<NP_CGContext*>(mInstanceOwner->GetPluginPortCopy());
       if (!cgPluginPortCopy) {
         NS_WARNING("null plugin port copy during PaintPlugin");
         nativeDrawing.EndNativeDrawing();
         return;
       }
-#ifndef NP_NO_CARBON
-      if (mInstanceOwner->GetEventModel() == NPEventModelCarbon &&
-          !mInstanceOwner->SetPluginPortAndDetectChange()) {
-        NS_WARNING("null plugin port during PaintPlugin");
-        nativeDrawing.EndNativeDrawing();
-        return;
-      }
-
-      // In the Carbon event model...
-      // If gfxQuartzNativeDrawing hands out a CGContext different from the
-      // one set by SetPluginPortAndDetectChange(), we need to pass it to the
-      // plugin via SetWindow().  This will happen in nsPluginInstanceOwner::
-      // FixUpPluginWindow(), called from nsPluginInstanceOwner::Paint().
-      // (If SetPluginPortAndDetectChange() made any changes itself, this has
-      // already been detected in that method, and will likewise result in a
-      // call to SetWindow() from FixUpPluginWindow().)
-      NP_CGContext* windowContext = static_cast<NP_CGContext*>(window->window);
-      if (mInstanceOwner->GetEventModel() == NPEventModelCarbon &&
-          windowContext->context != cgContext) {
-        windowContext->context = cgContext;
-        cgPluginPortCopy->context = cgContext;
-        mInstanceOwner->SetPluginPortChanged(true);
-      }
-#endif
 
       mInstanceOwner->BeginCGPaint();
       if (mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreAnimation ||
           mInstanceOwner->GetDrawingModel() == 
                                    NPDrawingModelInvalidatingCoreAnimation) {
         // CoreAnimation is updated, render the layer and perform a readback.
         mInstanceOwner->RenderCoreAnimation(cgContext, window->width, window->height);
       } else {
@@ -2117,26 +2091,16 @@ nsObjectFrame::HandleEvent(nsPresContext
   if ((anEvent->message == NS_MOUSE_ENTER ||
        anEvent->message == NS_WHEEL_WHEEL) &&
       mInstanceOwner->GetEventModel() == NPEventModelCocoa) {
     *anEventStatus = mInstanceOwner->ProcessEvent(*anEvent);
     return rv;
   }
 #endif
 
-/*
-  // XXXndeakin review note: I don't see how this would ever be called.
-  if (anEvent->message == NS_DESTROY) {
-#ifdef MAC_CARBON_PLUGINS
-    mInstanceOwner->CancelTimer();
-#endif
-    return rv;
-  }
-*/
-
   return nsObjectFrameSuper::HandleEvent(aPresContext, anEvent, anEventStatus);
 }
 
 #ifdef XP_MACOSX
 // Needed to make the routing of mouse events while dragging conform to
 // standard OS X practice, and to the Cocoa NPAPI spec.  See bug 525078.
 NS_IMETHODIMP
 nsObjectFrame::HandlePress(nsPresContext* aPresContext,
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -622,17 +622,17 @@ public:
    * ConvertCocoaKeyEventToNPCocoaEvent() converts aCocoaEvent to NPCocoaEvent.
    *
    * @param aCocoaEvent           A native key event.
    * @param aPluginEvent          The result.
    */
   static void ConvertCocoaKeyEventToNPCocoaEvent(NSEvent* aCocoaEvent,
                                                  NPCocoaEvent& aPluginEvent);
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
 
   /**
    * InstallPluginKeyEventsHandler() is called when initializing process.
    * RemovePluginKeyEventsHandler() is called when finalizing process.
    * These methods initialize/finalize global resource for handling events for
    * plugins.
    */
   static void InstallPluginKeyEventsHandler();
@@ -647,53 +647,31 @@ public:
   /**
    * When a composition starts or finishes, this is called.
    */
   void SetPluginTSMInComposition(bool aInComposition)
   {
     mPluginTSMInComposition = aInComposition;
   }
 
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 
 protected:
   bool mIgnoreNextKeyUpEvent;
 
   PluginTextInputHandler(nsChildView* aWidget, NSView<mozView> *aNativeView);
   ~PluginTextInputHandler();
 
-#ifndef NP_NO_CARBON
-
-  /**
-   * ConvertCocoaKeyEventToCarbonEvent() converts aCocoaKeyEvent to
-   * aCarbonKeyEvent.
-   *
-   * @param aCocoaKeyEvent        A Cocoa key event.
-   * @param aCarbonKeyEvent       Converted Carbon event from aCocoaEvent.
-   * @param aMakeKeyDownEventIfNSFlagsChanged
-   *                              If aCocoaKeyEvent isn't NSFlagsChanged event,
-   *                              this is ignored.  Otherwise, i.e., if
-   *                              aCocoaKeyEvent is NSFlagsChanged event,
-   *                              set TRUE if you need a keydown event.
-   *                              Otherwise, Set FALSE for a keyup event.
-   */
-  static void ConvertCocoaKeyEventToCarbonEvent(
-                NSEvent* aCocoaKeyEvent,
-                EventRecord& aCarbonKeyEvent,
-                bool aMakeKeyDownEventIfNSFlagsChanged = false);
-
-#endif // #ifndef NP_NO_CARBON
-
 private:
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
   TSMDocumentID mPluginTSMDoc;
 
   bool mPluginTSMInComposition;
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 
   bool mPluginComplexTextInputRequested;
 
   /**
    * DispatchCocoaNPAPITextEvent() dispatches a text event for Cocoa plugin.
    *
    * @param aString               A string inputted by the dispatching event.
    * @return                      TRUE if the dispatched event was consumed.
@@ -706,17 +684,17 @@ private:
    * On 32bit build, this returns the state of mPluginTSMInComposition.
    * On 64bit build, this returns ComplexTextInputPanel's state.
    *
    * @return                      TRUE if plugin is in composition.  Otherwise,
    *                              FALSE.
    */
   bool IsInPluginComposition();
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
 
   /**
    * Create a TSM document for use with plugins, so that we can support IME in
    * them.  Once it's created, if need be (re)activate it.  Some plugins (e.g.
    * the Flash plugin running in Camino) don't create their own TSM document --
    * without which IME can't work.  Others (e.g. the Flash plugin running in
    * Firefox) create a TSM document that (somehow) makes the input window behave
    * badly when it contains more than one kind of input (say Hiragana and
@@ -730,42 +708,31 @@ private:
    * HandleCarbonPluginKeyEvent() handles the aKeyEvent.  This is called by
    * PluginKeyEventsHandler().
    *
    * @param aKeyEvent             A native Carbon event.
    */
   void HandleCarbonPluginKeyEvent(EventRef aKeyEvent);
 
   /**
-   * ConvertUnicodeToCharCode() converts aUnichar to native encoded string.
-   *
-   * @param aUniChar              A unicode character.
-   * @param aOutChar              Native encoded string for aUniChar.
-   * @return                      TRUE if the converting succeeded.
-   *                              Otherwise, FALSE.
-   */
-  static bool ConvertUnicodeToCharCode(PRUnichar aUniChar,
-                                         unsigned char* aOutChar);
-
-  /**
    * Target for text services events sent as the result of calls made to
    * TSMProcessRawKeyEvent() in HandleKeyDownEventForPlugin() when a plugin has
    * the focus.  The calls to TSMProcessRawKeyEvent() short-circuit Cocoa-based
    * IME (which would otherwise interfere with our efforts) and allow Carbon-
    * based IME to work in plugins (via the NPAPI).  This strategy doesn't cause
    * trouble for plugins that (like the Java Embedding Plugin) bypass the NPAPI
    * to get their keyboard events and do their own Cocoa-based IME.
    */
   static OSStatus PluginKeyEventsHandler(EventHandlerCallRef aHandlerRef,
                                          EventRef aEvent,
                                          void *aUserData);
 
   static EventHandlerRef sPluginKeyEventsHandler;
 
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 };
 
 /**
  * IMEInputHandler manages:
  *   1. The IME/keyboard layout statement of nsChildView.
  *   2. The IME composition statement of nsChildView.
  * And also provides the methods which controls the current IME transaction of
  * the instance.
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -18,27 +18,47 @@
 #include "nsBidiUtils.h"
 #include "nsToolkit.h"
 #include "nsCocoaUtils.h"
 #include "WidgetUtils.h"
 #include "nsPrintfCString.h"
 
 #ifdef __LP64__
 #include "ComplexTextInputPanel.h"
+#include <objc/runtime.h>
 #endif // __LP64__
 
-#ifndef NP_NO_CARBON
-#include <objc/runtime.h>
-#endif // NP_NO_CARBON
-
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #endif
 #include "prlog.h"
 
+#ifndef __LP64__
+enum {
+  // Currently focused ChildView (while this TSM document is active).
+  // Transient (only set while TSMProcessRawKeyEvent() is processing a key
+  // event), and the ChildView will be retained and released around the call
+  // to TSMProcessRawKeyEvent() -- so it can be weak.
+  kFocusedChildViewTSMDocPropertyTag  = 'GKFV', // type ChildView* [WEAK]
+};
+
+// Undocumented HIToolbox function used by WebKit to allow Carbon-based IME
+// to work in a Cocoa-based browser (like Safari or Cocoa-widgets Firefox).
+// (Recent WebKit versions actually use a thin wrapper around this function
+// called WKSendKeyEventToTSM().)
+//
+// Calling TSMProcessRawKeyEvent() from ChildView's keyDown: and keyUp:
+// methods (when the ChildView is a plugin view) bypasses Cocoa's IME
+// infrastructure and (instead) causes Carbon TSM events to be sent on each
+// NSKeyDown event.  We install a Carbon event handler
+// (PluginKeyEventsHandler()) to catch these events and pass them to Gecko
+// (which in turn passes them to the plugin).
+extern "C" long TSMProcessRawKeyEvent(EventRef carbonEvent);
+#endif // __LP64__
+
 using namespace mozilla;
 using namespace mozilla::widget;
 
 #ifdef PR_LOGGING
 
 PRLogModuleInfo* gLog = nullptr;
 
 static const char*
@@ -1294,24 +1314,16 @@ TextInputHandler::HandleKeyDownEvent(NSE
 
   BOOL nonDeadKeyPress = [[aNativeEvent characters] length] > 0;
   if (nonDeadKeyPress && !IsIMEComposing()) {
     NSResponder* firstResponder = [[mView window] firstResponder];
 
     nsKeyEvent keydownEvent(true, NS_KEY_DOWN, mWidget);
     InitKeyEvent(aNativeEvent, keydownEvent);
 
-#ifndef NP_NO_CARBON
-    EventRecord carbonEvent;
-    if ([mView pluginEventModel] == NPEventModelCarbon) {
-      ConvertCocoaKeyEventToCarbonEvent(aNativeEvent, carbonEvent, true);
-      keydownEvent.pluginEvent = &carbonEvent;
-    }
-#endif // #ifndef NP_NO_CARBON
-
     currentKeyEvent->mKeyDownHandled = DispatchEvent(keydownEvent);
     if (Destroyed()) {
       PR_LOG(gLog, PR_LOG_ALWAYS,
         ("%p TextInputHandler::HandleKeyDownEvent, "
          "widget was destroyed by keydown event", this));
       return currentKeyEvent->KeyDownOrPressHandled();
     }
 
@@ -1537,34 +1549,24 @@ TextInputHandler::DispatchKeyEventForFla
      TrueOrFalse(aDispatchKeyDown), TrueOrFalse(IsIMEComposing())));
 
   if ([aNativeEvent type] != NSFlagsChanged || IsIMEComposing()) {
     return;
   }
 
   uint32_t message = aDispatchKeyDown ? NS_KEY_DOWN : NS_KEY_UP;
 
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif // ifndef NP_NO_CARBON
   NPCocoaEvent cocoaEvent;
 
   // Fire a key event.
   nsKeyEvent keyEvent(true, message, mWidget);
   InitKeyEvent(aNativeEvent, keyEvent);
 
   // create event for use by plugins
   if ([mView isPluginView]) {
-#ifndef NP_NO_CARBON
-    if ([mView pluginEventModel] == NPEventModelCarbon) {
-      ConvertCocoaKeyEventToCarbonEvent(aNativeEvent, carbonEvent,
-                                        aDispatchKeyDown);
-      keyEvent.pluginEvent = &carbonEvent;
-    }
-#endif // ifndef NP_NO_CARBON
     if ([mView pluginEventModel] == NPEventModelCocoa) {
       ConvertCocoaKeyEventToNPCocoaEvent(aNativeEvent, cocoaEvent);
       keyEvent.pluginEvent = &cocoaEvent;
     }
   }
 
   DispatchEvent(keyEvent);
 
@@ -1618,36 +1620,19 @@ TextInputHandler::InsertText(NSAttribute
   // Dispatch keypress event with char instead of textEvent
   nsKeyEvent keypressEvent(true, NS_KEY_PRESS, mWidget);
   keypressEvent.isChar = IsPrintableChar(str.CharAt(0));
 
   // Don't set other modifiers from the current event, because here in
   // -insertText: they've already been taken into account in creating
   // the input string.
 
-  // create event for use by plugins
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif // #ifndef NP_NO_CARBON
-
   if (currentKeyEvent) {
     NSEvent* keyEvent = currentKeyEvent->mKeyEvent;
     InitKeyEvent(keyEvent, keypressEvent, &str);
-
-    // XXX The ASCII characters inputting mode of egbridge (Japanese IME)
-    // might send the keyDown event with wrong keyboard layout if other
-    // keyboard layouts are already loaded. In that case, the native event
-    // doesn't match to this gecko event...
-#ifndef NP_NO_CARBON
-    if ([mView pluginEventModel] == NPEventModelCarbon) {
-      ConvertCocoaKeyEventToCarbonEvent(keyEvent, carbonEvent, true);
-      keypressEvent.pluginEvent = &carbonEvent;
-    }
-#endif // #ifndef NP_NO_CARBON
-
     if (currentKeyEvent->mKeyDownHandled) {
       keypressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
     }
   } else {
     nsCocoaUtils::InitInputEvent(keypressEvent, static_cast<NSEvent*>(nullptr));
     // Note that insertText is not called only at key pressing.
     if (!keypressEvent.charCode) {
       keypressEvent.keyCode =
@@ -3049,30 +3034,30 @@ IMEInputHandler::OpenSystemPreferredLang
  *  PluginTextInputHandler implementation
  *
  ******************************************************************************/
 
 PluginTextInputHandler::PluginTextInputHandler(nsChildView* aWidget,
                                                NSView<mozView> *aNativeView) :
   TextInputHandlerBase(aWidget, aNativeView),
   mIgnoreNextKeyUpEvent(false),
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
   mPluginTSMDoc(0), mPluginTSMInComposition(false),
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
   mPluginComplexTextInputRequested(false)
 {
 }
 
 PluginTextInputHandler::~PluginTextInputHandler()
 {
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
   if (mPluginTSMDoc) {
     ::DeleteTSMDocument(mPluginTSMDoc);
   }
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 }
 
 /* static */ void
 PluginTextInputHandler::ConvertCocoaKeyEventToNPCocoaEvent(
                           NSEvent* aCocoaEvent,
                           NPCocoaEvent& aPluginEvent)
 {
   nsCocoaUtils::InitNPCocoaEvent(&aPluginEvent);
@@ -3097,110 +3082,17 @@ PluginTextInputHandler::ConvertCocoaKeyE
   if (nativeType != NSFlagsChanged) {
     aPluginEvent.data.key.characters = (NPNSString*)[aCocoaEvent characters];
     aPluginEvent.data.key.charactersIgnoringModifiers =
       (NPNSString*)[aCocoaEvent charactersIgnoringModifiers];
     aPluginEvent.data.key.isARepeat = [aCocoaEvent isARepeat];
   }
 }
 
-#ifndef NP_NO_CARBON
-
-/* static */ bool
-PluginTextInputHandler::ConvertUnicodeToCharCode(PRUnichar aUniChar,
-                                                 unsigned char* aOutChar)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
-
-  UnicodeToTextInfo converterInfo;
-  TextEncoding      systemEncoding;
-  Str255            convertedString;
-
-  *aOutChar = '\0';
-
-  OSStatus err =
-    ::UpgradeScriptInfoToTextEncoding(smSystemScript,
-                                      kTextLanguageDontCare,
-                                      kTextRegionDontCare,
-                                      NULL,
-                                      &systemEncoding);
-  NS_ENSURE_TRUE(err == noErr, false);
-
-  err = ::CreateUnicodeToTextInfoByEncoding(systemEncoding, &converterInfo);
-  NS_ENSURE_TRUE(err == noErr, false);
-
-  err = ::ConvertFromUnicodeToPString(converterInfo, sizeof(PRUnichar),
-                                      &aUniChar, convertedString);
-  NS_ENSURE_TRUE(err == noErr, false);
-
-  *aOutChar = convertedString[1];
-  ::DisposeUnicodeToTextInfo(&converterInfo);
-  return true;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
-}
-
-/* static */ void
-PluginTextInputHandler::ConvertCocoaKeyEventToCarbonEvent(
-                          NSEvent* aCocoaKeyEvent,
-                          EventRecord& aCarbonKeyEvent,
-                          bool aMakeKeyDownEventIfNSFlagsChanged)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  UInt32 charCode = 0;
-  if ([aCocoaKeyEvent type] == NSFlagsChanged) {
-    aCarbonKeyEvent.what = aMakeKeyDownEventIfNSFlagsChanged ? keyDown : keyUp;
-  } else {
-    if ([[aCocoaKeyEvent characters] length] > 0) {
-      charCode = [[aCocoaKeyEvent characters] characterAtIndex:0];
-    }
-    if ([aCocoaKeyEvent type] == NSKeyDown) {
-      aCarbonKeyEvent.what = [aCocoaKeyEvent isARepeat] ? autoKey : keyDown;
-    } else {
-      aCarbonKeyEvent.what = keyUp;
-    }
-  }
-
-  if (charCode >= 0x0080) {
-    switch (charCode) {
-      case NSUpArrowFunctionKey:
-        charCode = kUpArrowCharCode;
-        break;
-      case NSDownArrowFunctionKey:
-        charCode = kDownArrowCharCode;
-        break;
-      case NSLeftArrowFunctionKey:
-        charCode = kLeftArrowCharCode;
-        break;
-      case NSRightArrowFunctionKey:
-        charCode = kRightArrowCharCode;
-        break;
-      default:
-        unsigned char convertedCharCode;
-        if (ConvertUnicodeToCharCode(charCode, &convertedCharCode)) {
-          charCode = convertedCharCode;
-        }
-        //NSLog(@"charcode is %d, converted to %c, char is %@",
-        //      charCode, convertedCharCode, [aCocoaKeyEvent characters]);
-        break;
-    }
-  }
-
-  aCarbonKeyEvent.message =
-    (charCode & 0x00FF) | ([aCocoaKeyEvent keyCode] << 8);
-  aCarbonKeyEvent.when = ::TickCount();
-  ::GetGlobalMouse(&aCarbonKeyEvent.where);
-  // XXX Is this correct? If ::GetCurrentKeyModifiers() returns "current"
-  //     state and there is one or more pending modifier key events,
-  //     the result is mismatch with the state at current key event.
-  aCarbonKeyEvent.modifiers = ::GetCurrentKeyModifiers();
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
+#ifndef __LP64__
 
 EventHandlerRef PluginTextInputHandler::sPluginKeyEventsHandler = NULL;
 
 /* static */ void
 PluginTextInputHandler::InstallPluginKeyEventsHandler()
 {
   if (sPluginKeyEventsHandler) {
     return;
@@ -3426,28 +3318,28 @@ PluginTextInputHandler::ActivatePluginTS
     // We'll need to use the "input window".
     ::UseInputWindow(mPluginTSMDoc, YES);
     ::ActivateTSMDocument(mPluginTSMDoc);
   } else if (::TSMGetActiveDocument() != mPluginTSMDoc) {
     ::ActivateTSMDocument(mPluginTSMDoc);
   }
 }
 
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 
 void
 PluginTextInputHandler::HandleKeyDownEventForPlugin(NSEvent* aNativeKeyEvent)
 {
   if (Destroyed()) {
     return;
   }
 
   NS_ASSERTION(mView, "mView must not be NULL");
 
-#ifdef NP_NO_CARBON
+#ifdef __LP64__
 
   if ([mView pluginEventModel] != NPEventModelCocoa) {
     return;
   }
 
   ComplexTextInputPanel* ctiPanel =
     [ComplexTextInputPanel sharedComplexTextInputPanel];
 
@@ -3486,17 +3378,17 @@ PluginTextInputHandler::HandleKeyDownEve
 
     NSString* textString = nil;
     [ctiPanel interpretKeyEvent:aNativeKeyEvent string:&textString];
     if (textString) {
       DispatchCocoaNPAPITextEvent(textString);
     }
   }
 
-#else // #ifdef NP_NO_CARBON
+#else // #ifdef __LP64__
 
   bool wasInComposition = false;
   if ([mView pluginEventModel] == NPEventModelCocoa) {
     if (IsInPluginComposition()) {
       wasInComposition = true;
 
       // Don't send key up events for key downs associated with compositions.
       mIgnoreNextKeyUpEvent = true;
@@ -3545,17 +3437,17 @@ PluginTextInputHandler::HandleKeyDownEve
   nsAutoRetainCocoaObject kungFuDeathGrip(mView);
   ::TSMSetDocumentProperty(mPluginTSMDoc,
                            kFocusedChildViewTSMDocPropertyTag,
                            sizeof(ChildView *), &mView);
   ::TSMProcessRawKeyEvent([aNativeKeyEvent _eventRef]);
   ::TSMRemoveDocumentProperty(mPluginTSMDoc,
                               kFocusedChildViewTSMDocPropertyTag);
 
-#endif // #ifdef NP_NO_CARBON else
+#endif // #ifdef __LP64__ else
 }
 
 void
 PluginTextInputHandler::HandleKeyUpEventForPlugin(NSEvent* aNativeKeyEvent)
 {
   if (mIgnoreNextKeyUpEvent) {
     mIgnoreNextKeyUpEvent = false;
     return;
@@ -3577,64 +3469,27 @@ PluginTextInputHandler::HandleKeyUpEvent
     nsKeyEvent keyupEvent(true, NS_KEY_UP, mWidget);
     InitKeyEvent(aNativeKeyEvent, keyupEvent);
     NPCocoaEvent pluginEvent;
     ConvertCocoaKeyEventToNPCocoaEvent(aNativeKeyEvent, pluginEvent);
     keyupEvent.pluginEvent = &pluginEvent;
     DispatchEvent(keyupEvent);
     return;
   }
-
-#ifndef NP_NO_CARBON
-  if (eventModel == NPEventModelCarbon) {
-    // I'm not sure the call to TSMProcessRawKeyEvent() is needed here (though
-    // WebKit makes one).
-    ::TSMProcessRawKeyEvent([aNativeKeyEvent _eventRef]);
-
-    // Don't send a keyUp event if the corresponding keyDown event(s) is/are
-    // still being processed (idea borrowed from WebKit).
-    ChildView* keydownTarget = nil;
-    OSStatus status =
-      ::TSMGetDocumentProperty(mPluginTSMDoc,
-                               kFocusedChildViewTSMDocPropertyTag,
-                               sizeof(ChildView *), nil, &keydownTarget);
-    NS_ENSURE_TRUE(status == noErr, );
-    if (keydownTarget == mView) {
-      return;
-    }
-
-    // PluginKeyEventsHandler() never sends keyUp events to
-    // HandleCarbonPluginKeyEvent(), so we need to send them to Gecko here.
-    // (This means that when commiting text from IME, several keyDown events
-    // may be sent to Gecko (in processPluginKeyEvent) for one keyUp event here.
-    // But this is how the WebKit does it, and games expect a keyUp event to
-    // be sent when it actually happens (they need to be able to detect how
-    // long a key has been held down) -- which wouldn't be possible if we sent
-    // them from processPluginKeyEvent.)
-    nsKeyEvent keyupEvent(true, NS_KEY_UP, mWidget);
-    InitKeyEvent(aNativeKeyEvent, keyupEvent);
-    EventRecord pluginEvent;
-    ConvertCocoaKeyEventToCarbonEvent(aNativeKeyEvent, pluginEvent, false);
-    keyupEvent.pluginEvent = &pluginEvent;
-    DispatchEvent(keyupEvent);
-    return;
-  }
-#endif // #ifndef NP_NO_CARBON
-
 }
 
 bool
 PluginTextInputHandler::IsInPluginComposition()
 {
   return
-#ifdef NP_NO_CARBON
+#ifdef __LP64__
     [[ComplexTextInputPanel sharedComplexTextInputPanel] inComposition] != NO;
-#else // #ifdef NP_NO_CARBON
+#else // #ifdef __LP64__
     mPluginTSMInComposition;
-#endif // #ifdef NP_NO_CARBON else
+#endif // #ifdef __LP64__ else
 }
 
 bool
 PluginTextInputHandler::DispatchCocoaNPAPITextEvent(NSString* aString)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   NPCocoaEvent cocoaTextEvent;
@@ -3648,17 +3503,17 @@ PluginTextInputHandler::DispatchCocoaNPA
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
 
 #pragma mark -
 
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
 
 /******************************************************************************
  *
  *  PluginTextInputHandler_IMKInputSession_* implementation
  *
  ******************************************************************************/
 
 // IMKInputSession is an undocumented class in the HIToolbox framework.  It's
@@ -3743,17 +3598,17 @@ PluginTextInputHandler::DispatchCocoaNPA
       }
     }
   }
   [self PluginTextInputHandler_IMKInputSession_finishSession];
 }
 
 @end
 
-#endif // #ifndef NP_NO_CARBON
+#endif // #ifndef __LP64__
 
 
 #pragma mark -
 
 
 /******************************************************************************
  *
  *  TextInputHandlerBase implementation
--- a/widget/cocoa/nsAppShell.mm
+++ b/widget/cocoa/nsAppShell.mm
@@ -311,17 +311,17 @@ nsAppShell::Init()
   
   mCFRunLoopSource = ::CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context);
   NS_ENSURE_STATE(mCFRunLoopSource);
 
   ::CFRunLoopAddSource(mCFRunLoop, mCFRunLoopSource, kCFRunLoopCommonModes);
 
   rv = nsBaseAppShell::Init();
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
   TextInputHandler::InstallPluginKeyEventsHandler();
 #endif
 
   gCocoaAppModalWindowList = new nsCocoaAppModalWindowList;
   if (!gAppShellMethodsSwizzled) {
     nsToolkit::SwizzleMethods([NSApplication class], @selector(beginModalSessionForWindow:),
                               @selector(nsAppShell_NSApplication_beginModalSessionForWindow:));
     nsToolkit::SwizzleMethods([NSApplication class], @selector(endModalSession:),
@@ -773,17 +773,17 @@ nsAppShell::Exit(void)
     return NS_OK;
   }
 
   mTerminated = true;
 
   delete gCocoaAppModalWindowList;
   gCocoaAppModalWindowList = NULL;
 
-#ifndef NP_NO_CARBON
+#ifndef __LP64__
   TextInputHandler::RemovePluginKeyEventsHandler();
 #endif
 
   // Quoting from Apple's doc on the [NSApplication stop:] method (from their
   // doc on the NSApplication class):  "If this method is invoked during a
   // modal event loop, it will break that loop but not the main event loop."
   // nsAppShell::Exit() shouldn't be called from a modal event loop.  So if
   // it is we complain about it (to users of debug builds) and call [NSApp
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -87,39 +87,16 @@ namespace gl {
 class TextureImage;
 }
 
 namespace layers {
 class LayerManagerOGL;
 }
 }
 
-#ifndef NP_NO_CARBON
-enum {
-  // Currently focused ChildView (while this TSM document is active).
-  // Transient (only set while TSMProcessRawKeyEvent() is processing a key
-  // event), and the ChildView will be retained and released around the call
-  // to TSMProcessRawKeyEvent() -- so it can be weak.
-  kFocusedChildViewTSMDocPropertyTag  = 'GKFV', // type ChildView* [WEAK]
-};
-
-// Undocumented HIToolbox function used by WebKit to allow Carbon-based IME
-// to work in a Cocoa-based browser (like Safari or Cocoa-widgets Firefox).
-// (Recent WebKit versions actually use a thin wrapper around this function
-// called WKSendKeyEventToTSM().)
-//
-// Calling TSMProcessRawKeyEvent() from ChildView's keyDown: and keyUp:
-// methods (when the ChildView is a plugin view) bypasses Cocoa's IME
-// infrastructure and (instead) causes Carbon TSM events to be sent on each
-// NSKeyDown event.  We install a Carbon event handler
-// (PluginKeyEventsHandler()) to catch these events and pass them to Gecko
-// (which in turn passes them to the plugin).
-extern "C" long TSMProcessRawKeyEvent(EventRef carbonEvent);
-#endif // NP_NO_CARBON
-
 @interface NSEvent (Undocumented)
 
 // Return Cocoa event's corresponding Carbon event.  Not initialized (on
 // synthetic events) until the OS actually "sends" the event.  This method
 // has been present in the same form since at least OS X 10.2.8.
 - (EventRef)_eventRef;
 
 @end
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -149,21 +149,16 @@ uint32_t nsChildView::sLastInputEventCou
 #endif
 
 #ifdef ACCESSIBILITY
 - (id<mozAccessible>)accessible;
 #endif
 
 - (BOOL)inactiveWindowAcceptsMouseEvent:(NSEvent*)aEvent;
 
-#ifndef NP_NO_CARBON
-- (void)sendCarbonWheelEvent:(SInt32)delta
-                     forAxis:(EventMouseWheelAxis)carbonAxis;
-#endif
-
 @end
 
 #pragma mark -
 
 /* Convenience routines to go from a gecko rect to cocoa NSRects and back
  *
  * Gecko rects (nsRect) contain an origin (x,y) in a coordinate
  * system with (0,0) in the top-left of the screen. Cocoa rects
@@ -279,18 +274,17 @@ nsresult nsChildView::Create(nsIWidget *
 #ifdef __LP64__
     if (nsCocoaFeatures::OnLionOrLater()) {
       nsToolkit::SwizzleMethods([NSEvent class], @selector(addLocalMonitorForEventsMatchingMask:handler:),
                                 @selector(nsChildView_NSEvent_addLocalMonitorForEventsMatchingMask:handler:),
                                 true);
       nsToolkit::SwizzleMethods([NSEvent class], @selector(removeMonitor:),
                                 @selector(nsChildView_NSEvent_removeMonitor:), true);
     }
-#endif
-#ifndef NP_NO_CARBON
+#else
     TextInputHandler::SwizzleMethods();
 #endif
     gChildViewMethodsSwizzled = true;
   }
 
   mBounds = aRect;
 
   // Ensure that the toolkit is created.
@@ -557,24 +551,16 @@ void nsChildView::UpdatePluginPort()
   // current graphics context of the current thread."  But sometimes
   // (when called while mView isn't focused for drawing) it returns a
   // graphics context for the wrong window.  [window graphicsContext]
   // (which "provides the graphics context associated with the window
   // for the current thread") seems always to return the "right"
   // graphics context.  See bug 500130.
   mPluginCGContext.context = NULL;
   mPluginCGContext.window = NULL;
-#ifndef NP_NO_CARBON
-  NSWindow* cocoaWindow = [mView window];
-  WindowRef carbonWindow = cocoaWindow ? (WindowRef)[cocoaWindow windowRef] : NULL;
-  if (carbonWindow) {
-    mPluginCGContext.context = (CGContextRef)[[cocoaWindow graphicsContext] graphicsPort];
-    mPluginCGContext.window = carbonWindow;
-  }
-#endif
 }
 
 static void HideChildPluginViews(NSView* aView)
 {
   NSArray* subviews = [aView subviews];
 
   for (unsigned int i = 0; i < [subviews count]; ++i) {
     NSView* view = [subviews objectAtIndex: i];
@@ -956,30 +942,16 @@ NS_IMETHODIMP nsChildView::GetPluginClip
     outWidgetVisible = false;
   }
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-#ifndef NP_NO_CARBON
-static void InitializeEventRecord(EventRecord* event, Point* aMousePosition)
-{
-  memset(event, 0, sizeof(EventRecord));
-  if (aMousePosition) {
-    event->where = *aMousePosition;
-  } else {
-    ::GetGlobalMouse(&event->where);
-  }
-  event->when = ::TickCount();
-  event->modifiers = ::GetCurrentKeyModifiers();
-}
-#endif
-
 NS_IMETHODIMP nsChildView::StartDrawPlugin()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NS_ASSERTION(mWindowType == eWindowType_plugin,
                "StartDrawPlugin must only be called on a plugin widget");
   if (mWindowType != eWindowType_plugin) return NS_ERROR_FAILURE;
 
@@ -1915,16 +1887,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
 - (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if ((self = [super initWithFrame:inFrame])) {
     mGeckoChild = inChild;
     mIsPluginView = NO;
 #ifndef NP_NO_CARBON
+    // We don't support the Carbon event model but it's still the default
+    // model for i386 per NPAPI.
     mPluginEventModel = NPEventModelCarbon;
 #else
     mPluginEventModel = NPEventModelCocoa;
 #endif
 #ifndef NP_NO_QUICKDRAW
     // We don't support the Quickdraw drawing model any more but it's still
     // the default model for i386 per NPAPI.
     mPluginDrawingModel = NPDrawingModelQuickDraw;
@@ -3131,27 +3105,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
   if (modifierFlags & NSControlKeyMask)
     geckoEvent.button = nsMouseEvent::eRightButton;
   else
     geckoEvent.button = nsMouseEvent::eLeftButton;
 
   // Create event for use by plugins.
   // This is going to our child view so we don't need to look up the destination
   // event type.
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-  if (mPluginEventModel == NPEventModelCarbon) {
-    carbonEvent.what = mouseDown;
-    carbonEvent.message = 0;
-    carbonEvent.when = ::TickCount();
-    ::GetGlobalMouse(&carbonEvent.where);
-    carbonEvent.modifiers = ::GetCurrentKeyModifiers();
-    geckoEvent.pluginEvent = &carbonEvent;
-  }
-#endif
   NPCocoaEvent cocoaEvent;
   if (mPluginEventModel == NPEventModelCocoa) {
     nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
     NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
     cocoaEvent.type = NPCocoaEventMouseDown;
     cocoaEvent.data.mouse.modifierFlags = modifierFlags;
     cocoaEvent.data.mouse.pluginX = point.x;
     cocoaEvent.data.mouse.pluginY = point.y;
@@ -3175,42 +3138,29 @@ NSEvent* gLastDragMouseDownEvent = nil;
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild || mBlockedLastMouseDown)
     return;
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
 
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif // ifndef NP_NO_CARBON
   NPCocoaEvent cocoaEvent;
 	
   nsMouseEvent geckoEvent(true, NS_MOUSE_BUTTON_UP, mGeckoChild, nsMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
   if ([theEvent modifierFlags] & NSControlKeyMask)
     geckoEvent.button = nsMouseEvent::eRightButton;
   else
     geckoEvent.button = nsMouseEvent::eLeftButton;
 
   // Create event for use by plugins.
   // This is going to our child view so we don't need to look up the destination
   // event type.
   if (mIsPluginView) {
-#ifndef NP_NO_CARBON
-    if (mPluginEventModel == NPEventModelCarbon) {
-      carbonEvent.what = mouseUp;
-      carbonEvent.message = 0;
-      carbonEvent.when = ::TickCount();
-      ::GetGlobalMouse(&carbonEvent.where);
-      carbonEvent.modifiers = ::GetCurrentKeyModifiers();
-      geckoEvent.pluginEvent = &carbonEvent;
-    }
-#endif
     if (mPluginEventModel == NPEventModelCocoa) {
       nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
       NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       cocoaEvent.type = NPCocoaEventMouseUp;
       cocoaEvent.data.mouse.modifierFlags = [theEvent modifierFlags];
       cocoaEvent.data.mouse.pluginX = point.x;
       cocoaEvent.data.mouse.pluginY = point.y;
       cocoaEvent.data.mouse.buttonNumber = [theEvent buttonNumber];
@@ -3224,20 +3174,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   // This might destroy our widget (and null out mGeckoChild).
   mGeckoChild->DispatchWindowEvent(geckoEvent);
 
   // If our mouse-up event's location is over some other object (as might
   // happen if it came at the end of a dragging operation), also send our
   // Gecko frame a mouse-exit event.
   if (mGeckoChild && mIsPluginView) {
-#ifndef NP_NO_CARBON
-    if (mPluginEventModel == NPEventModelCocoa)
-#endif
-    {
+    if (mPluginEventModel == NPEventModelCocoa) {
       if (ChildViewMouseTracker::ViewForEvent(theEvent) != self) {
         nsMouseEvent geckoExitEvent(true, NS_MOUSE_EXIT, mGeckoChild, nsMouseEvent::eReal);
         [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoExitEvent];
 
         NPCocoaEvent cocoaEvent;
         nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
         NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
         cocoaEvent.type = NPCocoaEventMouseExited;
@@ -3270,31 +3217,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   uint32_t msg = aEnter ? NS_MOUSE_ENTER : NS_MOUSE_EXIT;
   nsMouseEvent event(true, msg, mGeckoChild, nsMouseEvent::eReal);
   event.refPoint = mGeckoChild->CocoaPointsToDevPixels(localEventLocation);
 
   // Create event for use by plugins.
   // This is going to our child view so we don't need to look up the destination
   // event type.
-#ifndef NP_NO_CARBON  
-  EventRecord carbonEvent;
-#endif
   NPCocoaEvent cocoaEvent;
   if (mIsPluginView) {
-#ifndef NP_NO_CARBON  
-    if (mPluginEventModel == NPEventModelCarbon) {
-      carbonEvent.what = NPEventType_AdjustCursorEvent;
-      carbonEvent.message = 0;
-      carbonEvent.when = ::TickCount();
-      ::GetGlobalMouse(&carbonEvent.where);
-      carbonEvent.modifiers = ::GetCurrentKeyModifiers();
-      event.pluginEvent = &carbonEvent;
-    }
-#endif
     if (mPluginEventModel == NPEventModelCocoa) {
       nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
       cocoaEvent.type = ((msg == NS_MOUSE_ENTER) ? NPCocoaEventMouseEntered : NPCocoaEventMouseExited);
       cocoaEvent.data.mouse.modifierFlags = [aEvent modifierFlags];
       cocoaEvent.data.mouse.pluginX = 5;
       cocoaEvent.data.mouse.pluginY = 5;
       cocoaEvent.data.mouse.buttonNumber = [aEvent buttonNumber];
       cocoaEvent.data.mouse.deltaX = [aEvent deltaX];
@@ -3318,31 +3252,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
     return;
 
   nsMouseEvent geckoEvent(true, NS_MOUSE_MOVE, mGeckoChild, nsMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
 
   // Create event for use by plugins.
   // This is going to our child view so we don't need to look up the destination
   // event type.
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif
   NPCocoaEvent cocoaEvent;
   if (mIsPluginView) {
-#ifndef NP_NO_CARBON
-    if (mPluginEventModel == NPEventModelCarbon) {
-      carbonEvent.what = NPEventType_AdjustCursorEvent;
-      carbonEvent.message = 0;
-      carbonEvent.when = ::TickCount();
-      ::GetGlobalMouse(&carbonEvent.where);
-      carbonEvent.modifiers = ::GetCurrentKeyModifiers();
-      geckoEvent.pluginEvent = &carbonEvent;
-    }
-#endif
     if (mPluginEventModel == NPEventModelCocoa) {
       nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
       NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       cocoaEvent.type = NPCocoaEventMouseMoved;
       cocoaEvent.data.mouse.modifierFlags = [theEvent modifierFlags];
       cocoaEvent.data.mouse.pluginX = point.x;
       cocoaEvent.data.mouse.pluginY = point.y;
       cocoaEvent.data.mouse.buttonNumber = [theEvent buttonNumber];
@@ -3362,36 +3283,23 @@ NSEvent* gLastDragMouseDownEvent = nil;
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild)
     return;
 
   gLastDragView = self;
 
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif // ifndef NP_NO_CARBON
   NPCocoaEvent cocoaEvent;
 
   nsMouseEvent geckoEvent(true, NS_MOUSE_MOVE, mGeckoChild, nsMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
 
   // create event for use by plugins
   if (mIsPluginView) {
-#ifndef NP_NO_CARBON
-    if (mPluginEventModel == NPEventModelCarbon) {
-      carbonEvent.what = NPEventType_AdjustCursorEvent;
-      carbonEvent.message = 0;
-      carbonEvent.when = ::TickCount();
-      ::GetGlobalMouse(&carbonEvent.where);
-      carbonEvent.modifiers = btnState | ::GetCurrentKeyModifiers();
-      geckoEvent.pluginEvent = &carbonEvent;
-    }
-#endif
     if (mPluginEventModel == NPEventModelCocoa) {
       nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
       NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       cocoaEvent.type = NPCocoaEventMouseDragged;
       cocoaEvent.data.mouse.modifierFlags = [theEvent modifierFlags];
       cocoaEvent.data.mouse.pluginX = point.x;
       cocoaEvent.data.mouse.pluginY = point.y;
       cocoaEvent.data.mouse.buttonNumber = [theEvent buttonNumber];
@@ -3426,27 +3334,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   // The right mouse went down, fire off a right mouse down event to gecko
   nsMouseEvent geckoEvent(true, NS_MOUSE_BUTTON_DOWN, mGeckoChild, nsMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
   geckoEvent.button = nsMouseEvent::eRightButton;
   geckoEvent.clickCount = [theEvent clickCount];
 
   // create event for use by plugins
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-  if (mPluginEventModel == NPEventModelCarbon) {
-    carbonEvent.what = mouseDown;
-    carbonEvent.message = 0;
-    carbonEvent.when = ::TickCount();
-    ::GetGlobalMouse(&carbonEvent.where);
-    carbonEvent.modifiers = controlKey;  // fake a context menu click
-    geckoEvent.pluginEvent = &carbonEvent;    
-  }
-#endif
   NPCocoaEvent cocoaEvent;
   if (mPluginEventModel == NPEventModelCocoa) {
     nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
     NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
     cocoaEvent.type = NPCocoaEventMouseDown;
     cocoaEvent.data.mouse.modifierFlags = [theEvent modifierFlags];
     cocoaEvent.data.mouse.pluginX = point.x;
     cocoaEvent.data.mouse.pluginY = point.y;
@@ -3470,38 +3367,25 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
 - (void)rightMouseUp:(NSEvent *)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild)
     return;
 
-#ifndef NP_NO_CARBON
-  EventRecord carbonEvent;
-#endif // ifndef NP_NO_CARBON
   NPCocoaEvent cocoaEvent;
 
   nsMouseEvent geckoEvent(true, NS_MOUSE_BUTTON_UP, mGeckoChild, nsMouseEvent::eReal);
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
   geckoEvent.button = nsMouseEvent::eRightButton;
   geckoEvent.clickCount = [theEvent clickCount];
 
   // create event for use by plugins
   if (mIsPluginView) {
-#ifndef NP_NO_CARBON
-    if (mPluginEventModel == NPEventModelCarbon) {
-      carbonEvent.what = mouseUp;
-      carbonEvent.message = 0;
-      carbonEvent.when = ::TickCount();
-      ::GetGlobalMouse(&carbonEvent.where);
-      carbonEvent.modifiers = controlKey;  // fake a context menu click
-      geckoEvent.pluginEvent = &carbonEvent;
-    }
-#endif
     if (mPluginEventModel == NPEventModelCocoa) {
       nsCocoaUtils::InitNPCocoaEvent(&cocoaEvent);
       NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       cocoaEvent.type = NPCocoaEventMouseUp;
       cocoaEvent.data.mouse.modifierFlags = [theEvent modifierFlags];
       cocoaEvent.data.mouse.pluginX = point.x;
       cocoaEvent.data.mouse.pluginY = point.y;
       cocoaEvent.data.mouse.buttonNumber = [theEvent buttonNumber];
@@ -3671,32 +3555,16 @@ static int32_t RoundUp(double aDouble)
     wheelEvent.pluginEvent = &cocoaEvent;
   }
 
   mGeckoChild->DispatchWindowEvent(wheelEvent);
   if (!mGeckoChild) {
     return;
   }
 
-#ifndef NP_NO_CARBON
-  // dispatch scroll wheel carbon event for plugins
-  if (mPluginEventModel == NPEventModelCarbon) {
-    [self sendCarbonWheelEvent:RoundUp([theEvent deltaY])
-                       forAxis:kEventMouseWheelAxisY];
-    if (!mGeckoChild) {
-      return;
-    }
-    [self sendCarbonWheelEvent:RoundUp([theEvent deltaX])
-                       forAxis:kEventMouseWheelAxisX];
-    if (!mGeckoChild) {
-      return;
-    }
-  }
-#endif
-
 #ifdef __LP64__
   // overflowDeltaX tells us when the user has tried to scroll past the edge
   // of a page to the left or the right (in those cases it's non-zero).
   if (wheelEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL &&
       wheelEvent.deltaX != 0.0) {
     [self maybeTrackScrollEventAsSwipe:theEvent
                         scrollOverflow:wheelEvent.overflowDeltaX];
   }
@@ -3751,61 +3619,16 @@ static int32_t RoundUp(double aDouble)
   if ([superView respondsToSelector:@selector(contextMenu)])
     return [(NSView<mozView>*)superView contextMenu];
 
   return nil;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
-#ifndef NP_NO_CARBON
-
-- (void)sendCarbonWheelEvent:(SInt32)delta
-                     forAxis:(EventMouseWheelAxis)carbonAxis
-{
-  if (!delta) {
-    return;
-  }
-
-  EventRef theEvent;
-  OSStatus err = ::CreateEvent(NULL,
-                               kEventClassMouse,
-                               kEventMouseWheelMoved,
-                               TicksToEventTime(TickCount()),
-                               kEventAttributeUserEvent,
-                               &theEvent);
-  if (err != noErr) {
-    return;
-  }
-
-  SetEventParameter(theEvent,
-                    kEventParamMouseWheelAxis,
-                    typeMouseWheelAxis,
-                    sizeof(EventMouseWheelAxis),
-                    &carbonAxis);
-  SetEventParameter(theEvent,
-                    kEventParamMouseWheelDelta,
-                    typeLongInteger,
-                    sizeof(SInt32),
-                    &delta);
-  Point mouseLoc;
-  ::GetGlobalMouse(&mouseLoc);
-  SetEventParameter(theEvent,
-                    kEventParamMouseLocation,
-                    typeQDPoint,
-                    sizeof(Point),
-                    &mouseLoc);
-
-  ::SendEventToEventTarget(theEvent,
-      GetWindowEventTarget((WindowRef)[[self window] windowRef]));
-  ReleaseEvent(theEvent);
-}
-
-#endif // #ifndef NP_NO_CARBON
-
 - (void) convertCocoaMouseEvent:(NSEvent*)aMouseEvent toGeckoEvent:(nsInputEvent*)outGeckoEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   NS_ASSERTION(outGeckoEvent, "convertCocoaMouseEvent:toGeckoEvent: requires non-null aoutGeckoEvent");
   if (!outGeckoEvent)
     return;
 
@@ -3972,17 +3795,17 @@ static int32_t RoundUp(double aDouble)
   NS_ENSURE_TRUE(mTextInputHandler, [NSArray array]);
   return mTextInputHandler->GetValidAttributesForMarkedText();
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 #pragma mark -
 
-#ifdef NP_NO_CARBON
+#ifdef __LP64__
 - (NSTextInputContext *)inputContext
 {
   if (mIsPluginView && mPluginEventModel == NPEventModelCocoa)
     return [[ComplexTextInputPanel sharedComplexTextInputPanel] inputContext];
   else
     return [super inputContext];
 }
 #endif