Backed out 15 changesets (bug 1208944) for failing tests M(2,5) on OSX. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 29 Dec 2015 17:42:02 +0100
changeset 277800 54a19e8d57c42fc139e49d84c880f559ef240f8c
parent 277799 9104abe421a8311a199fdb3be7a60b3ab73a83b5
child 277801 00e82b640de3f997f9780226a9c43d19df121169
push id69603
push userarchaeopteryx@coole-files.de
push dateTue, 29 Dec 2015 16:42:37 +0000
treeherdermozilla-inbound@54a19e8d57c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1208944, 1209844
milestone46.0a1
backs outc29de223de2f8ba0b724ac910b7bacfdddbd2bc7
3d99da255be1f6fd83a86b521cf184895ffe86f6
3c915942af38133b0b771b8c6df58ca15831b14c
759b425b5503edeeaaaa9a5a125b915b20f5afb7
bf73cf8f0fdac96af8e43da129b9544f127599bb
0e337d912b7dbec542798be02ab021cf74838792
31c47f2980b5f9577c5e729c3552dfe778fe489e
3e0d70a6e8096bb12e585790cb3c2f4ed34ca0f0
7685dcb63e5f6b1e823447c07741b1f759556a31
3c2b9372dd36e85c901633bd847b899ebb7e8dec
18160d30649322977fb874e6400bb98435492369
4974e397b655222f73a0b169e3eab7907525633d
fde7e439844da91a275ba19b0b9e29b8264fea98
4213a355fbdc7caa8a8edffbffc1c46c0e965dfe
33cfddbbf5f2bd173b0f25418a07f1e18abe1021
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
Backed out 15 changesets (bug 1208944) for failing tests M(2,5) on OSX. r=backout Backed out changeset c29de223de2f (bug 1208944) Backed out changeset 3d99da255be1 (bug 1209844) Backed out changeset 3c915942af38 (bug 1209844) Backed out changeset 759b425b5503 (bug 1208944) Backed out changeset bf73cf8f0fda (bug 1208944) Backed out changeset 0e337d912b7d (bug 1208944) Backed out changeset 31c47f2980b5 (bug 1208944) Backed out changeset 3e0d70a6e809 (bug 1208944) Backed out changeset 7685dcb63e5f (bug 1208944) Backed out changeset 3c2b9372dd36 (bug 1208944) Backed out changeset 18160d306493 (bug 1208944) Backed out changeset 4974e397b655 (bug 1208944) Backed out changeset fde7e439844d (bug 1208944) Backed out changeset 4213a355fbdc (bug 1208944) Backed out changeset 33cfddbbf5f2 (bug 1208944)
dom/events/EventStateManager.cpp
dom/events/TextComposition.cpp
dom/events/TextComposition.h
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/ipc/NPEventWindows.h
dom/plugins/ipc/PPluginInstance.ipdl
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceChild.h
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginInstanceParent.h
dom/plugins/ipc/PluginQuirks.cpp
dom/plugins/ipc/PluginQuirks.h
dom/plugins/test/mochitest/mochitest.ini
dom/plugins/test/mochitest/test_windowless_ime.html
dom/plugins/test/testplugin/nptest.cpp
dom/plugins/test/testplugin/nptest.h
dom/plugins/test/testplugin/nptest_windows.cpp
dom/plugins/test/testplugin/testplugin.mozbuild
toolkit/xre/test/win/TestDllInterceptor.cpp
widget/ContentCache.cpp
widget/MiscEvents.h
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/TextRange.h
widget/nsBaseWidget.h
widget/nsIWidget.h
widget/windows/IMMHandler.cpp
widget/windows/IMMHandler.h
widget/windows/WinIMEHandler.cpp
widget/windows/WinIMEHandler.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
widget/windows/nsWindowBase.h
xpcom/build/nsWindowsDllInterceptor.h
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1205,20 +1205,16 @@ EventStateManager::DispatchCrossProcessE
       }
     }
 
     bool retval = remote->SendRealDragEvent(*aEvent->AsDragEvent(),
                                             action, dropEffect);
 
     return retval;
   }
-  case ePluginEventClass: {
-    *aStatus = nsEventStatus_eConsumeNoDefault;
-    return remote->SendPluginEvent(*aEvent->AsPluginEvent());
-  }
   default: {
     MOZ_CRASH("Attempt to send non-whitelisted event?");
   }
   }
 }
 
 bool
 EventStateManager::IsRemoteTarget(nsIContent* target) {
--- a/dom/events/TextComposition.cpp
+++ b/dom/events/TextComposition.cpp
@@ -15,31 +15,16 @@
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/unused.h"
 #include "mozilla/dom/TabParent.h"
 
-#ifdef XP_MACOSX
-// Some defiens will be conflict with OSX SDK
-#define TextRange _TextRange
-#define TextRangeArray _TextRangeArray
-#define Comment _Comment
-#endif
-
-#include "nsPluginInstanceOwner.h"
-
-#ifdef XP_MACOSX
-#undef TextRange
-#undef TextRangeArray
-#undef Comment
-#endif
-
 using namespace mozilla::widget;
 
 namespace mozilla {
 
 #define IDEOGRAPHIC_SPACE (NS_LITERAL_STRING("\x3000"))
 
 /******************************************************************************
  * TextComposition
@@ -127,37 +112,23 @@ TextComposition::CloneAndDispatchAs(
   compositionEvent.mOriginalMessage = aCompositionEvent->mMessage;
   compositionEvent.mFlags.mIsSynthesizedForTests =
     aCompositionEvent->mFlags.mIsSynthesizedForTests;
 
   nsEventStatus dummyStatus = nsEventStatus_eConsumeNoDefault;
   nsEventStatus* status = aStatus ? aStatus : &dummyStatus;
   if (aMessage == eCompositionUpdate) {
     mLastData = compositionEvent.mData;
-    mLastRanges = aCompositionEvent->mRanges;
   }
-
-  DispatchEvent(&compositionEvent, status, aCallBack, aCompositionEvent);
+  EventDispatcher::Dispatch(mNode, mPresContext,
+                            &compositionEvent, nullptr, status, aCallBack);
   return compositionEvent.mFlags;
 }
 
 void
-TextComposition::DispatchEvent(WidgetCompositionEvent* aDispatchEvent,
-                               nsEventStatus* aStatus,
-                               EventDispatchingCallback* aCallBack,
-                               const WidgetCompositionEvent *aOriginalEvent)
-{
-  nsPluginInstanceOwner::GeneratePluginEvent(aOriginalEvent,
-                                             aDispatchEvent);
-
-  EventDispatcher::Dispatch(mNode, mPresContext,
-                            aDispatchEvent, nullptr, aStatus, aCallBack);
-}
-
-void
 TextComposition::OnCompositionEventDiscarded(
                    WidgetCompositionEvent* aCompositionEvent)
 {
   // Note that this method is never called for synthesized events for emulating
   // commit or cancel composition.
 
   MOZ_ASSERT(aCompositionEvent->mFlags.mIsTrusted,
              "Shouldn't be called with untrusted event");
@@ -241,17 +212,16 @@ TextComposition::DispatchCompositionEven
 {
   // If the content is a container of TabParent, composition should be in the
   // remote process.
   if (mTabParent) {
     Unused << mTabParent->SendCompositionEvent(*aCompositionEvent);
     aCompositionEvent->mFlags.mPropagationStopped = true;
     if (aCompositionEvent->CausesDOMTextEvent()) {
       mLastData = aCompositionEvent->mData;
-      mLastRanges = aCompositionEvent->mRanges;
       // Although, the composition event hasn't been actually handled yet,
       // emulate an editor to be handling the composition event.
       EditorWillHandleCompositionChangeEvent(aCompositionEvent);
       EditorDidHandleCompositionChangeEvent();
     }
     return;
   }
 
@@ -366,17 +336,18 @@ TextComposition::DispatchCompositionEven
     // the limitation of mapping between event messages and DOM event types,
     // we cannot map multiple event messages to a DOM event type.
     if (dispatchDOMTextEvent &&
         aCompositionEvent->mMessage != eCompositionChange) {
       aCompositionEvent->mFlags =
         CloneAndDispatchAs(aCompositionEvent, eCompositionChange,
                            aStatus, aCallBack);
     } else {
-      DispatchEvent(aCompositionEvent, aStatus, aCallBack);
+      EventDispatcher::Dispatch(mNode, mPresContext,
+                                aCompositionEvent, nullptr, aStatus, aCallBack);
     }
   } else {
     *aStatus = nsEventStatus_eConsumeNoDefault;
   }
 
   if (!IsValidStateForComposition(aCompositionEvent->widget)) {
     return;
   }
--- a/dom/events/TextComposition.h
+++ b/dom/events/TextComposition.h
@@ -56,20 +56,16 @@ public:
   const nsString& LastData() const { return mLastData; }
   // The composition string which is already handled by the focused editor.
   // I.e., this value must be same as the composition string on the focused
   // editor.  This value is modified at a call of
   // EditorDidHandleCompositionChangeEvent().
   // Note that mString and mLastData are different between dispatcing
   // compositionupdate and compositionchange event handled by focused editor.
   const nsString& String() const { return mString; }
-  // The latest clauses range of the composition string.
-  // During compositionupdate event, GetRanges() returns old ranges.
-  // So if getting on compositionupdate, Use GetLastRange instead of GetRange().
-  TextRangeArray* GetLastRanges() const { return mLastRanges; }
   // Returns the clauses and/or caret range of the composition string.
   // This is modified at a call of EditorWillHandleCompositionChangeEvent().
   // This may return null if there is no clauses and caret.
   // XXX We should return |const TextRangeArray*| here, but it causes compile
   //     error due to inaccessible Release() method.
   TextRangeArray* GetRanges() const { return mRanges; }
   // Returns the widget which is proper to call NotifyIME().
   nsIWidget* GetWidget() const
@@ -190,19 +186,16 @@ private:
   // this instance.
   nsPresContext* mPresContext;
   nsCOMPtr<nsINode> mNode;
   RefPtr<TabParent> mTabParent;
 
   // This is the clause and caret range information which is managed by
   // the focused editor.  This may be null if there is no clauses or caret.
   RefPtr<TextRangeArray> mRanges;
-  // Same as mRange, but mRange will have old data during compositionupdate.
-  // So this will be valied during compositionupdate.
-  RefPtr<TextRangeArray> mLastRanges;
 
   // mNativeContext stores a opaque pointer.  This works as the "ID" for this
   // composition.  Don't access the instance, it may not be available.
   widget::NativeIMEContext mNativeContext;
 
   // mEditorWeak is a weak reference to the focused editor handling composition.
   nsWeakPtr mEditorWeak;
 
@@ -296,25 +289,16 @@ private:
    * synchronously. The caller must ensure that it's safe to dispatch the event.
    */
   void DispatchCompositionEvent(WidgetCompositionEvent* aCompositionEvent,
                                 nsEventStatus* aStatus,
                                 EventDispatchingCallback* aCallBack,
                                 bool aIsSynthesized);
 
   /**
-   * Simply calling EventDispatcher::Dispatch() with plugin event.
-   * If dispatching event has no orginal clone, aOriginalEvent can be null.
-   */
-  void DispatchEvent(WidgetCompositionEvent* aDispatchEvent,
-                     nsEventStatus* aStatus,
-                     EventDispatchingCallback* aCallback,
-                     const WidgetCompositionEvent *aOriginalEvent = nullptr);
-
-  /**
    * HandleSelectionEvent() sends the selection event to ContentEventHandler
    * or dispatches it to the focused child process.
    */
   void HandleSelectionEvent(WidgetSelectionEvent* aSelectionEvent)
   {
     HandleSelectionEvent(mPresContext, mTabParent, aSelectionEvent);
   }
   static void HandleSelectionEvent(nsPresContext* aPresContext,
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -47,17 +47,16 @@ using mozilla::gfx::IntRect from "mozill
 using class mozilla::ContentCache from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetDragEvent from "ipc/nsGUIEventIPC.h";
 using struct nsRect from "nsRect.h";
 using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h";
-using class mozilla::WidgetPluginEvent from "ipc/nsGUIEventIPC.h";
 using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h";
 using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
 using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
 using mozilla::CSSPoint from "Units.h";
 using mozilla::CSSToScreenScale from "Units.h";
 using mozilla::CommandInt from "mozilla/EventForwards.h";
 using mozilla::Modifiers from "mozilla/EventForwards.h";
 using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h";
@@ -277,26 +276,16 @@ parent:
      * a plugin (inside the widget) has the keyboard focus.  Should be sent
      * when the keyboard focus changes too or from a plugin.
      *
      * aFocused  Whether or not a plugin is focused
      */
     prio(urgent) async SetPluginFocused(bool aFocused);
 
     /**
-     * Set IME candidate window by windowless plugin if plugin has focus.
-     */
-    async SetCandidateWindowForPlugin(int32_t aX, int32_t aY);
-
-    /**
-     *  When plugin event isn't consumed, call this
-     */
-    async DefaultProcOfPluginEvent(WidgetPluginEvent aEvent);
-
-    /**
      * Request that the parent process move focus to the browser's frame. If
      * canRaise is true, the window can be raised if it is inactive.
      */
     RequestFocus(bool canRaise);
 
     /**
      * Indicate, based on the current state, that some commands are enabled and
      * some are disabled.
@@ -640,17 +629,16 @@ child:
                    ScrollableLayerGuid aGuid,
                    uint64_t aInputBlockId,
                    nsEventStatus aApzResponse);
     RealTouchMoveEvent(WidgetTouchEvent aEvent,
                        ScrollableLayerGuid aGuid,
                        uint64_t aInputBlockId,
                        nsEventStatus aApzResponse);
     RealDragEvent(WidgetDragEvent aEvent, uint32_t aDragAction, uint32_t aDropEffect);
-    PluginEvent(WidgetPluginEvent aEvent);
 
     /**
      * @see nsIDOMWindowUtils sendKeyEvent.
      */
     KeyEvent(nsString aType,
              int32_t aKeyCode,
              int32_t aCharCode,
              int32_t aModifiers,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1938,29 +1938,16 @@ TabChild::RecvRealDragEvent(const Widget
       dragService->FireDragEventAtSource(eDrag);
     }
   }
 
   APZCCallbackHelper::DispatchWidgetEvent(localEvent);
   return true;
 }
 
-bool
-TabChild::RecvPluginEvent(const WidgetPluginEvent& aEvent)
-{
-  WidgetPluginEvent localEvent(aEvent);
-  localEvent.widget = mPuppetWidget;
-  nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent);
-  if (status != nsEventStatus_eConsumeNoDefault) {
-    // If not consumed, we should call default action
-    SendDefaultProcOfPluginEvent(aEvent);
-  }
-  return true;
-}
-
 void
 TabChild::RequestNativeKeyBindings(AutoCacheNativeKeyCommands* aAutoCache,
                                    WidgetKeyboardEvent* aEvent)
 {
   MaybeNativeKeyBinding maybeBindings;
   if (!SendRequestNativeKeyBindings(*aEvent, &maybeBindings)) {
     return;
   }
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -374,17 +374,16 @@ public:
                               const int32_t&  aKeyCode,
                               const int32_t&  aCharCode,
                               const int32_t&  aModifiers,
                               const bool&     aPreventDefault) override;
     virtual bool RecvMouseScrollTestEvent(const FrameMetrics::ViewID& aScrollId,
                                           const nsString& aEvent) override;
     virtual bool RecvNativeSynthesisResponse(const uint64_t& aObserverId,
                                              const nsCString& aResponse) override;
-    virtual bool RecvPluginEvent(const WidgetPluginEvent& aEvent) override;
     virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event) override;
     virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event) override;
     virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture) override;
     virtual bool RecvLoadRemoteScript(const nsString& aURL,
                                       const bool& aRunInGlobalScope) override;
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const ClonedMessageData& aData,
                                   InfallibleTArray<CpowEntry>&& aCpows,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2391,41 +2391,16 @@ TabParent::RecvSetPluginFocused(const bo
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
   }
   widget->SetPluginFocused((bool&)aFocused);
   return true;
 }
 
- bool
-TabParent::RecvSetCandidateWindowForPlugin(const int32_t& aX,
-                                           const int32_t& aY)
-{
-  nsCOMPtr<nsIWidget> widget = GetWidget();
-  if (!widget) {
-    return true;
-  }
-
-  widget->SetCandidateWindowForPlugin(aX, aY);
-  return true;
-}
-
-bool
-TabParent::RecvDefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent)
-{
-  nsCOMPtr<nsIWidget> widget = GetWidget();
-  if (!widget) {
-    return true;
-  }
-
-  widget->DefaultProcOfPluginEvent(aEvent);
-  return true;
-}
-
 bool
 TabParent::RecvGetInputContext(int32_t* aIMEEnabled,
                                int32_t* aIMEOpen)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     *aIMEEnabled = IMEState::DISABLED;
     *aIMEOpen = IMEState::OPEN_STATE_NOT_SUPPORTED;
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -191,20 +191,16 @@ public:
     virtual bool RecvRequestIMEToCommitComposition(const bool& aCancel,
                                                    bool* aIsCommitted,
                                                    nsString* aCommittedString) override;
     virtual bool RecvStartPluginIME(const WidgetKeyboardEvent& aKeyboardEvent,
                                     const int32_t& aPanelX,
                                     const int32_t& aPanelY,
                                     nsString* aCommitted) override;
     virtual bool RecvSetPluginFocused(const bool& aFocused) override;
-    virtual bool RecvSetCandidateWindowForPlugin(const int32_t& aX,
-                                                 const int32_t& aY) override;
-    virtual bool RecvDefaultProcOfPluginEvent(
-                   const WidgetPluginEvent& aEvent) override;
     virtual bool RecvGetInputContext(int32_t* aIMEEnabled,
                                      int32_t* aIMEOpen) override;
     virtual bool RecvSetInputContext(const int32_t& aIMEEnabled,
                                      const int32_t& aIMEOpen,
                                      const nsString& aType,
                                      const nsString& aInputmode,
                                      const nsString& aActionHint,
                                      const int32_t& aCause,
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -55,19 +55,16 @@ using mozilla::DefaultXDisplay;
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/HTMLObjectElementBinding.h"
 #include "mozilla/dom/TabChild.h"
 #include "nsFrameSelection.h"
 #include "PuppetWidget.h"
 #include "nsPIWindowRoot.h"
-#include "mozilla/IMEStateManager.h"
-#include "mozilla/TextComposition.h"
-#include "mozilla/AutoRestore.h"
 
 #include "nsContentCID.h"
 #include "nsWidgetsCID.h"
 static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
 static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
 
 #ifdef XP_WIN
 #include <wtypes.h>
@@ -364,21 +361,16 @@ nsPluginInstanceOwner::nsPluginInstanceO
 #endif
 
   mWaitingForPaint = false;
 
 #ifdef MOZ_WIDGET_ANDROID
   mFullScreen = false;
   mJavaView = nullptr;
 #endif
-
-#ifdef XP_WIN
-  mGotCompositionData = false;
-  mSentStartComposition = false;
-#endif
 }
 
 nsPluginInstanceOwner::~nsPluginInstanceOwner()
 {
   if (mWaitingForPaint) {
     nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
     if (content) {
       // We don't care when the event is dispatched as long as it's "soon",
@@ -794,195 +786,17 @@ nsPluginInstanceOwner::SetNetscapeWindow
     NS_ASSERTION(rootWidget, "Couldn't get topmost document's widget.");
     return NS_ERROR_FAILURE;
   }
 
   rootWidget->SetNativeData(NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW,
                             reinterpret_cast<uintptr_t>(aWindowToAdopt));
   return NS_OK;
 }
-
-bool
-nsPluginInstanceOwner::GetCompositionString(uint32_t aType,
-                                            nsTArray<uint8_t>* aDist,
-                                            int32_t* aLength)
-{
-  // Mark pkugin calls ImmGetCompositionStringW correctly
-  mGotCompositionData = true;
-
-  RefPtr<TextComposition> composition = GetTextComposition();
-  if (NS_WARN_IF(!composition)) {
-    return false;
-  }
-
-  switch(aType) {
-    case GCS_COMPSTR: {
-      if (!composition->IsComposing()) {
-        *aLength = 0;
-        return true;
-      }
-
-      uint32_t len = composition->LastData().Length() * sizeof(char16_t);
-      if (len) {
-        aDist->SetLength(len);
-        memcpy(aDist->Elements(), composition->LastData().get(), len);
-      }
-      *aLength = len;
-      return true;
-    }
-
-    case GCS_RESULTSTR: {
-      if (composition->IsComposing()) {
-        *aLength = 0;
-        return true;
-      }
-
-      uint32_t len = composition->LastData().Length() * sizeof(char16_t);
-      if (len) {
-        aDist->SetLength(len);
-        memcpy(aDist->Elements(), composition->LastData().get(), len);
-      }
-      *aLength = len;
-      return true;
-    }
-
-    case GCS_CURSORPOS: {
-      *aLength = 0;
-      TextRangeArray* ranges = composition->GetLastRanges();
-      if (!ranges) {
-        return true;
-      }
-      *aLength = ranges->GetCaretPosition();
-      if (*aLength < 0) {
-        return false;
-      }
-      return true;
-    }
-
-    case GCS_COMPATTR: {
-      TextRangeArray* ranges = composition->GetLastRanges();
-      if (!ranges || ranges->IsEmpty()) {
-        *aLength = 0;
-        return true;
-      }
-
-      aDist->SetLength(composition->LastData().Length());
-      memset(aDist->Elements(), ATTR_INPUT, aDist->Length());
-
-      for (TextRange& range : *ranges) {
-        uint8_t type = ATTR_INPUT;
-        switch(range.mRangeType) {
-          case NS_TEXTRANGE_RAWINPUT:
-            type = ATTR_INPUT;
-            break;
-          case NS_TEXTRANGE_SELECTEDRAWTEXT:
-            type = ATTR_TARGET_NOTCONVERTED;
-            break;
-          case NS_TEXTRANGE_CONVERTEDTEXT:
-            type = ATTR_CONVERTED;
-            break;
-          case NS_TEXTRANGE_SELECTEDCONVERTEDTEXT:
-            type = ATTR_TARGET_CONVERTED;
-            break;
-          default:
-            continue;
-        }
-
-        size_t minLen = std::min<size_t>(range.mEndOffset, aDist->Length());
-        for (size_t i = range.mStartOffset; i < minLen; i++) {
-          (*aDist)[i] = type;
-        }
-      }
-      *aLength = aDist->Length();
-      return true;
-    }
-
-    case GCS_COMPCLAUSE: {
-      RefPtr<TextRangeArray> ranges = composition->GetLastRanges();
-      if (!ranges || ranges->IsEmpty()) {
-        aDist->SetLength(sizeof(uint32_t));
-        memset(aDist->Elements(), 0, sizeof(uint32_t));
-        *aLength = aDist->Length();
-        return true;
-      }
-      nsAutoTArray<uint32_t, 16> clauses;
-      clauses.AppendElement(0);
-      for (TextRange& range : *ranges) {
-        if (!range.IsClause()) {
-          continue;
-        }
-        clauses.AppendElement(range.mEndOffset);
-      }
-
-      aDist->SetLength(clauses.Length() * sizeof(uint32_t));
-      memcpy(aDist->Elements(), clauses.Elements(), aDist->Length());
-      *aLength = aDist->Length();
-      return true;
-    }
-
-    case GCS_RESULTREADSTR: {
-      // When returning error causes unexpected error, so we return 0 instead.
-      *aLength = 0;
-      return true;
-    }
-
-    case GCS_RESULTCLAUSE: {
-      // When returning error causes unexpected error, so we return 0 instead.
-      *aLength = 0;
-      return true;
-    }
-
-    default:
-      NS_WARNING(
-        nsPrintfCString("Unsupported type %x of ImmGetCompositionStringW hook",
-                        aType).get());
-      break;
-  }
-
-  return false;
-}
-
-bool
-nsPluginInstanceOwner::SetCandidateWindow(int32_t aX, int32_t aY)
-{
-  if (NS_WARN_IF(!mPluginFrame)) {
-    return false;
-  }
-
-  nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
-  if (!widget) {
-    widget = GetRootWidgetForPluginFrame(mPluginFrame);
-    if (NS_WARN_IF(!widget)) {
-      return false;
-    }
-  }
-
-  widget->SetCandidateWindowForPlugin(aX, aY);
-  return true;
-}
-
-bool
-nsPluginInstanceOwner::RequestCommitOrCancel(bool aCommitted)
-{
-  nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
-  if (!widget) {
-    widget = GetRootWidgetForPluginFrame(mPluginFrame);
-    if (NS_WARN_IF(!widget)) {
-      return false;
-    }
-  }
-
-  if (aCommitted) {
-    widget->NotifyIME(widget::REQUEST_TO_COMMIT_COMPOSITION); 
-  } else {
-    widget->NotifyIME(widget::REQUEST_TO_CANCEL_COMPOSITION); 
-  }
-  return true;
-}
-#endif // #ifdef XP_WIN
+#endif
 
 NS_IMETHODIMP nsPluginInstanceOwner::SetEventModel(int32_t eventModel)
 {
 #ifdef XP_MACOSX
   mEventModel = static_cast<NPEventModel>(eventModel);
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
@@ -1664,20 +1478,20 @@ nsresult nsPluginInstanceOwner::Dispatch
     return aFocusEvent->PreventDefault(); // consume event
   }
 #endif
 
   WidgetEvent* theEvent = aFocusEvent->GetInternalNSEvent();
   if (theEvent) {
     WidgetGUIEvent focusEvent(theEvent->mFlags.mIsTrusted, theEvent->mMessage,
                               nullptr);
-    nsEventStatus status = ProcessEvent(focusEvent);
-    if (nsEventStatus_eConsumeNoDefault == status) {
+    nsEventStatus rv = ProcessEvent(focusEvent);
+    if (nsEventStatus_eConsumeNoDefault == rv) {
       aFocusEvent->PreventDefault();
-      aFocusEvent->StopImmediatePropagation();
+      aFocusEvent->StopPropagation();
     }
   }
 
   return NS_OK;
 }
 
 nsresult nsPluginInstanceOwner::ProcessKeyPress(nsIDOMEvent* aKeyEvent)
 {
@@ -1778,164 +1592,16 @@ nsresult nsPluginInstanceOwner::Dispatch
     }
     if (mouseEvent->mMessage == eMouseUp) {
       mLastMouseDownButtonType = -1;
     }
   }
   return NS_OK;
 }
 
-#ifdef XP_WIN
-void
-nsPluginInstanceOwner::CallDefaultProc(const WidgetGUIEvent* aEvent)
-{
-  nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
-  if (!widget) {
-    widget = GetRootWidgetForPluginFrame(mPluginFrame);
-    if (NS_WARN_IF(!widget)) {
-      return;
-    }
-  }
-
-  const NPEvent* npEvent =
-    static_cast<const NPEvent*>(aEvent->mPluginEvent);
-  if (NS_WARN_IF(!npEvent)) {
-    return;
-  }
-
-  WidgetPluginEvent pluginEvent(true, ePluginInputEvent, widget);
-  pluginEvent.mPluginEvent.Copy(*npEvent);
-  widget->DefaultProcOfPluginEvent(pluginEvent);
-}
-
-already_AddRefed<TextComposition>
-nsPluginInstanceOwner::GetTextComposition()
-{
-  if (NS_WARN_IF(!mPluginFrame)) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
-  if (!widget) {
-    widget = GetRootWidgetForPluginFrame(mPluginFrame);
-    if (NS_WARN_IF(!widget)) {
-      return nullptr;
-    }
-  }
-
-  RefPtr<TextComposition> composition =
-    IMEStateManager::GetTextCompositionFor(widget);
-  if (NS_WARN_IF(!composition)) {
-    return nullptr;
-  }
-
-  return composition.forget();
-}
-#endif
-
-nsresult
-nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
-{
-#ifdef XP_WIN
-  if (!mPluginWindow) {
-    // CompositionEvent isn't cancellable.  So it is unnecessary to call
-    // PreventDefaults() to consume event
-    return NS_OK;
-  }
-  WidgetCompositionEvent* compositionEvent =
-    aEvent->GetInternalNSEvent()->AsCompositionEvent();
-  if (NS_WARN_IF(!compositionEvent)) {
-      return NS_ERROR_INVALID_ARG;
-  }
-
-  if (compositionEvent->mMessage == eCompositionChange) {
-    RefPtr<TextComposition> composition = GetTextComposition();
-    if (NS_WARN_IF(!composition)) {
-      return NS_ERROR_FAILURE;
-    }
-    TextComposition::CompositionChangeEventHandlingMarker
-      compositionChangeEventHandlingMarker(composition, compositionEvent);
-  }
-
-  // Protected mode Flash returns noDefault by NPP_HandleEvent, but
-  // composition information into plugin is invalid because plugin's bug.
-  // So if plugin doesn't get composition data by WM_IME_COMPOSITION, we
-  // recongnize it isn't handled
-  AutoRestore<bool> restore(mGotCompositionData);
-  mGotCompositionData = false;
-
-  nsEventStatus rv = ProcessEvent(*compositionEvent);
-  aEvent->StopImmediatePropagation();
-
-  // Composition event isn't handled by plugin, so we have to call default proc.
-  const NPEvent* pPluginEvent =
-    static_cast<const NPEvent*>(compositionEvent->mPluginEvent);
-  if (NS_WARN_IF(!pPluginEvent)) {
-    return NS_OK;
-  }
-
-  if (pPluginEvent->event == WM_IME_STARTCOMPOSITION) {
-    // Flash's protected mode lies that composition event is handled, but it
-    // cannot do it well.  So even if handled, we should post this message when
-    // no IMM API calls during WM_IME_COMPOSITION.
-    if (nsEventStatus_eConsumeNoDefault != rv)  {
-      CallDefaultProc(compositionEvent);
-      mSentStartComposition = true;
-    } else {
-      mSentStartComposition = false;
-    }
-    return NS_OK;
-  }
-
-  if (pPluginEvent->event == WM_IME_ENDCOMPOSITION) {
-    // Always post WM_END_COMPOSITION to default proc. Because Flash may lie
-    // that it doesn't handle composition well, but event is handled.
-    // Even if posting this message, default proc do nothing if unnecessary.
-    CallDefaultProc(compositionEvent);
-    return NS_OK;
-  }
-
-  if (pPluginEvent->event == WM_IME_COMPOSITION && !mGotCompositionData) {
-    nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
-    if (!widget) {
-      widget = GetRootWidgetForPluginFrame(mPluginFrame);
-    }
-
-    if (pPluginEvent->lParam & GCS_RESULTSTR) {
-      // GCS_RESULTSTR's default proc will generate WM_CHAR. So emulate it.
-      for (size_t i = 0; i < compositionEvent->mData.Length(); i++) {
-        WidgetPluginEvent charEvent(true, ePluginInputEvent, widget);
-        NPEvent event;
-        event.event = WM_CHAR;
-        event.wParam = compositionEvent->mData[i];
-        event.lParam = 0;
-        charEvent.mPluginEvent.Copy(event);
-        ProcessEvent(charEvent);
-      }
-      return NS_OK;
-    }
-    if (!mSentStartComposition) {
-      // We post WM_IME_COMPOSITION to default proc, but
-      // WM_IME_STARTCOMPOSITION isn't post yet.  We should post it at first.
-      WidgetPluginEvent event(true, ePluginInputEvent, widget);
-      NPEvent npevent;
-      npevent.event = WM_IME_STARTCOMPOSITION;
-      npevent.wParam = 0;
-      npevent.lParam = 0;
-      event.mPluginEvent.Copy(npevent);
-      CallDefaultProc(&event);
-      mSentStartComposition = true;
-    }
-
-    CallDefaultProc(compositionEvent);
-  }
-#endif // #ifdef XP_WIN
-  return NS_OK;
-}
-
 nsresult
 nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
 {
   NS_ASSERTION(mInstance, "Should have a valid plugin instance or not receive events.");
 
   nsAutoString eventType;
   aEvent->GetType(eventType);
 
@@ -1980,21 +1646,16 @@ nsPluginInstanceOwner::HandleEvent(nsIDO
   }
   if (eventType.EqualsLiteral("keydown") ||
       eventType.EqualsLiteral("keyup")) {
     return DispatchKeyToPlugin(aEvent);
   }
   if (eventType.EqualsLiteral("keypress")) {
     return ProcessKeyPress(aEvent);
   }
-  if (eventType.EqualsLiteral("compositionstart") ||
-      eventType.EqualsLiteral("compositionend") ||
-      eventType.EqualsLiteral("text")) {
-    return DispatchCompositionToPlugin(aEvent);
-  }
 
   nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aEvent));
   if (dragEvent && mInstance) {
     WidgetEvent* ievent = aEvent->GetInternalNSEvent();
     if (ievent && ievent->mFlags.mIsTrusted &&
         ievent->mMessage != eDragEnter && ievent->mMessage != eDragOver) {
       aEvent->PreventDefault();
     }
@@ -2811,21 +2472,16 @@ nsPluginInstanceOwner::Destroy()
   content->RemoveEventListener(NS_LITERAL_STRING("drag"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragenter"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragover"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragleave"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragexit"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragstart"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("draggesture"), this, true);
   content->RemoveEventListener(NS_LITERAL_STRING("dragend"), this, true);
-  content->RemoveSystemEventListener(NS_LITERAL_STRING("compositionstart"),
-                                     this, true);
-  content->RemoveSystemEventListener(NS_LITERAL_STRING("compositionend"),
-                                     this, true);
-  content->RemoveSystemEventListener(NS_LITERAL_STRING("text"), this, true);
 
 #if MOZ_WIDGET_ANDROID
   RemovePluginView();
 #endif
 
   if (mWidget) {
     if (mPluginWindow) {
       mPluginWindow->SetPluginWidget(nullptr);
@@ -3211,21 +2867,16 @@ nsresult nsPluginInstanceOwner::Init(nsI
   aContent->AddEventListener(NS_LITERAL_STRING("drag"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragenter"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragover"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragleave"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragexit"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragstart"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("draggesture"), this, true);
   aContent->AddEventListener(NS_LITERAL_STRING("dragend"), this, true);
-  aContent->AddSystemEventListener(NS_LITERAL_STRING("compositionstart"),
-    this, true);
-  aContent->AddSystemEventListener(NS_LITERAL_STRING("compositionend"), this,
-    true);
-  aContent->AddSystemEventListener(NS_LITERAL_STRING("text"), this, true);
 
   return NS_OK;
 }
 
 void* nsPluginInstanceOwner::GetPluginPort()
 {
 //!!! Port must be released for windowless plugins on Windows, because it is HDC !!!
 
@@ -3718,61 +3369,16 @@ already_AddRefed<nsIURI> nsPluginInstanc
 {
   nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
   if (!content) {
     return nullptr;
   }
   return content->GetBaseURI();
 }
 
-// static
-void
-nsPluginInstanceOwner::GeneratePluginEvent(
-  const WidgetCompositionEvent* aSrcCompositionEvent,
-  WidgetCompositionEvent* aDistCompositionEvent)
-{
-#ifdef XP_WIN
-  NPEvent newEvent;
-  switch (aDistCompositionEvent->mMessage) {
-    case eCompositionChange: {
-      newEvent.event = WM_IME_COMPOSITION;
-      newEvent.wParam = 0;
-      if (aSrcCompositionEvent &&
-          (aSrcCompositionEvent->mMessage == eCompositionCommit ||
-           aSrcCompositionEvent->mMessage == eCompositionCommitAsIs)) {
-        newEvent.lParam = GCS_RESULTSTR;
-      } else {
-        newEvent.lParam = GCS_COMPSTR | GCS_COMPATTR | GCS_COMPCLAUSE;
-      }
-      TextRangeArray* ranges = aDistCompositionEvent->mRanges;
-      if (ranges && ranges->HasCaret()) {
-        newEvent.lParam |= GCS_CURSORPOS;
-      }
-      break;
-    }
-
-    case eCompositionStart:
-      newEvent.event = WM_IME_STARTCOMPOSITION;
-      newEvent.wParam = 0;
-      newEvent.lParam = 0;
-      break;
-
-    case eCompositionEnd:
-      newEvent.event = WM_IME_ENDCOMPOSITION;
-      newEvent.wParam = 0;
-      newEvent.lParam = 0;
-      break;
-
-    default:
-      return;
-  }
-  aDistCompositionEvent->mPluginEvent.Copy(newEvent);
-#endif
-}
-
 // nsPluginDOMContextMenuListener class implementation
 
 nsPluginDOMContextMenuListener::nsPluginDOMContextMenuListener(nsIContent* aContent)
 {
   aContent->AddEventListener(NS_LITERAL_STRING("contextmenu"), this, true);
 }
 
 nsPluginDOMContextMenuListener::~nsPluginDOMContextMenuListener()
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -24,17 +24,16 @@
 #endif
 
 class nsIInputStream;
 class nsPluginDOMContextMenuListener;
 class nsPluginFrame;
 class nsDisplayListBuilder;
 
 namespace mozilla {
-class TextComposition;
 namespace dom {
 struct MozPluginParameter;
 } // namespace dom
 namespace widget {
 class PuppetWidget;
 } // namespace widget
 } // namespace mozilla
 
@@ -114,20 +113,16 @@ public:
   
   nsresult Init(nsIContent* aContent);
   
   void* GetPluginPort();
   void ReleasePluginPort(void* pluginPort);
 
   nsEventStatus ProcessEvent(const mozilla::WidgetGUIEvent& anEvent);
 
-  static void GeneratePluginEvent(
-                const mozilla::WidgetCompositionEvent* aSrcCompositionEvent,
-                mozilla::WidgetCompositionEvent* aDistCompositionEvent);
-
 #if defined(XP_WIN)
   void SetWidgetWindowAsParent(HWND aWindowToAdopt);
   nsresult SetNetscapeWindowAsParent(HWND aWindowToAdopt);
 #endif
   
 #ifdef XP_MACOSX
   enum { ePluginPaintEnable, ePluginPaintDisable };
 
@@ -256,21 +251,16 @@ public:
   // Called from AndroidJNI when we removed the fullscreen view.
   static void ExitFullScreen(jobject view);
 #endif
 
   void NotifyHostAsyncInitFailed();
   void NotifyHostCreateWidget();
   void NotifyDestroyPending();
 
-  bool GetCompositionString(uint32_t aIndex, nsTArray<uint8_t>* aString,
-                            int32_t* aLength);
-  bool SetCandidateWindow(int32_t aX, int32_t aY);
-  bool RequestCommitOrCancel(bool aCommitted);
-
 private:
   virtual ~nsPluginInstanceOwner();
 
   // return FALSE if LayerSurface dirty (newly created and don't have valid plugin content yet)
   bool IsUpToDate()
   {
     nsIntSize size;
     return NS_SUCCEEDED(mInstance->GetImageSize(&size)) &&
@@ -283,20 +273,16 @@ private:
   void RemovePluginView();
 
   bool mFullScreen;
   void* mJavaView;
 #endif 
 
 #if defined(XP_WIN)
   nsIWidget* GetContainingWidgetIfOffset();
-  already_AddRefed<mozilla::TextComposition> GetTextComposition();
-
-  bool mGotCompositionData;
-  bool mSentStartComposition;
 #endif
  
   nsPluginNativeWindow       *mPluginWindow;
   RefPtr<nsNPAPIPluginInstance> mInstance;
   nsPluginFrame              *mPluginFrame;
   nsWeakPtr                   mContent; // WEAK, content owns us
   nsCString                   mDocumentBase;
   bool                        mWidgetCreationComplete;
@@ -338,21 +324,16 @@ private:
   
   // pointer to wrapper for nsIDOMContextMenuListener
   RefPtr<nsPluginDOMContextMenuListener> mCXMenuListener;
   
   nsresult DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent);
   nsresult DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent,
                                  bool aAllowPropagate = false);
   nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
-  nsresult DispatchCompositionToPlugin(nsIDOMEvent* aEvent);
-
-#ifdef XP_WIN
-  void CallDefaultProc(const mozilla::WidgetGUIEvent* aEvent);
-#endif
 
 #ifdef XP_MACOSX
   static NPBool ConvertPointPuppet(PuppetWidget *widget, nsPluginFrame* pluginFrame,
                             double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
                             double *destX, double *destY, NPCoordinateSpace destSpace);
   static NPBool ConvertPointNoPuppet(nsIWidget *widget, nsPluginFrame* pluginFrame,
                             double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
                             double *destX, double *destY, NPCoordinateSpace destSpace);
--- a/dom/plugins/ipc/NPEventWindows.h
+++ b/dom/plugins/ipc/NPEventWindows.h
@@ -95,28 +95,16 @@ struct ParamTraits<mozilla::plugins::NPR
             case WM_MBUTTONDBLCLK:
             case WM_RBUTTONDBLCLK:
 
             case WM_MOUSEWHEEL:
             case WM_MOUSEHWHEEL:
 
             case WM_SETFOCUS:
             case WM_KILLFOCUS:
-
-            case WM_IME_STARTCOMPOSITION:
-            case WM_IME_COMPOSITION:
-            case WM_IME_ENDCOMPOSITION:
-            case WM_IME_CHAR:
-            case WM_IME_SETCONTEXT:
-            case WM_IME_COMPOSITIONFULL:
-            case WM_IME_KEYDOWN:
-            case WM_IME_KEYUP:
-            case WM_IME_SELECT:
-            case WM_INPUTLANGCHANGEREQUEST:
-            case WM_INPUTLANGCHANGE:
                 break;
 
             default:
                 // RegisterWindowMessage events should be passed.
                 if (paramCopy.event.event >= 0xC000)
                     break;
 
                 // FIXME/bug 567465: temporarily work around unhandled
--- a/dom/plugins/ipc/PPluginInstance.ipdl
+++ b/dom/plugins/ipc/PPluginInstance.ipdl
@@ -255,25 +255,16 @@ parent:
 
   // 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)
-                            returns (uint8_t[] aDist, int32_t aLength);
-  // Set candidate window position.
-  //
-  // @param aX  x position of candidate window
-  // @param aY  y position of candidate window
-  async SetCandidateWindow(int32_t aX, int32_t aY);
-  sync RequestCommitOrCancel(bool aCommitted);
-
 both:
   async PPluginScriptableObject();
 
 child:
   /* NPP_NewStream */
   async PBrowserStream(nsCString url,
                        uint32_t length,
                        uint32_t lastmodified,
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -68,35 +68,16 @@ typedef BOOL (WINAPI *User32TrackPopupMe
                                             int y,
                                             int nReserved,
                                             HWND hWnd,
                                             CONST RECT *prcRect);
 static WindowsDllInterceptor sUser32Intercept;
 static HWND sWinlessPopupSurrogateHWND = nullptr;
 static User32TrackPopupMenu sUser32TrackPopupMenuStub = nullptr;
 
-typedef HIMC (WINAPI *Imm32ImmGetContext)(HWND hWND);
-typedef BOOL (WINAPI *Imm32ImmReleaseContext)(HWND hWND, HIMC hIMC);
-typedef LONG (WINAPI *Imm32ImmGetCompositionString)(HIMC hIMC,
-                                                    DWORD dwIndex,
-                                                    LPVOID lpBuf,
-                                                    DWORD dwBufLen);
-typedef BOOL (WINAPI *Imm32ImmSetCandidateWindow)(HIMC hIMC,
-                                                  LPCANDIDATEFORM lpCandidate);
-typedef BOOL (WINAPI *Imm32ImmNotifyIME)(HIMC hIMC, DWORD dwAction,
-                                        DWORD dwIndex, DWORD dwValue);
-static WindowsDllInterceptor sImm32Intercept;
-static Imm32ImmGetContext sImm32ImmGetContextStub = nullptr;
-static Imm32ImmReleaseContext sImm32ImmReleaseContextStub = nullptr;
-static Imm32ImmGetCompositionString sImm32ImmGetCompositionStringStub = nullptr;
-static Imm32ImmSetCandidateWindow sImm32ImmSetCandidateWindowStub = nullptr;
-static Imm32ImmNotifyIME sImm32ImmNotifyIME = nullptr;
-static PluginInstanceChild* sCurrentPluginInstance = nullptr;
-static const HIMC sHookIMC = (const HIMC)0xefefefef;
-
 using mozilla::gfx::SharedDIB;
 
 #include <windows.h>
 #include <windowsx.h>
 
 // Flash WM_USER message delay time for PostDelayedTask. Borrowed
 // from Chromium's web plugin delegate src. See 'flash msg throttling
 // helpers' section for details.
@@ -211,17 +192,16 @@ PluginInstanceChild::PluginInstanceChild
     mWsInfo.display = DefaultXDisplay();
 #endif
 #endif // MOZ_X11 && XP_UNIX && !XP_MACOSX
 #if defined(OS_WIN)
     InitPopupMenuHook();
     if (GetQuirks() & QUIRK_UNITY_FIXUP_MOUSE_CAPTURE) {
         SetUnityHooks();
     }
-    InitImm32Hook();
 #endif // OS_WIN
 }
 
 PluginInstanceChild::~PluginInstanceChild()
 {
 #if defined(OS_WIN)
     NS_ASSERTION(!mPluginWindowHWND, "Destroying PluginInstanceChild without NPP_Destroy?");
     if (GetQuirks() & QUIRK_UNITY_FIXUP_MOUSE_CAPTURE) {
@@ -1998,145 +1978,16 @@ PluginInstanceChild::CreateWinlessPopupS
     if (!mWinlessPopupSurrogateHWND) {
         NS_ERROR("CreateWindowEx failed for winless placeholder!");
         return;
     }
 
     SendSetNetscapeWindowAsParent(mWinlessPopupSurrogateHWND);
 }
 
-// static
-HIMC
-PluginInstanceChild::ImmGetContextProc(HWND aWND)
-{
-    if (!sCurrentPluginInstance) {
-        return sImm32ImmGetContextStub(aWND);
-    }
-
-    wchar_t szClass[21];
-    int haveClass = GetClassNameW(aWND, szClass, ArrayLength(szClass));
-    if (!haveClass || wcscmp(szClass, L"SWFlash_PlaceholderX")) {
-        NS_WARNING("We cannot recongnize hooked window class");
-        return sImm32ImmGetContextStub(aWND);
-    }
-
-    return sHookIMC;
-}
-
-// static
-BOOL
-PluginInstanceChild::ImmReleaseContextProc(HWND aWND, HIMC aIMC)
-{
-    if (aIMC == sHookIMC) {
-        return TRUE;
-    }
-
-    return sImm32ImmReleaseContextStub(aWND, aIMC);
-}
-
-// static
-LONG
-PluginInstanceChild::ImmGetCompositionStringProc(HIMC aIMC, DWORD aIndex,
-                                                 LPVOID aBuf, DWORD aLen)
-{
-    if (aIMC != sHookIMC) {
-        return sImm32ImmGetCompositionStringStub(aIMC, aIndex, aBuf, aLen);
-    }
-    if (!sCurrentPluginInstance) {
-        return IMM_ERROR_GENERAL;
-    }
-    nsAutoTArray<uint8_t, 16> dist;
-    int32_t length = 0; // IMM_ERROR_NODATA
-    sCurrentPluginInstance->SendGetCompositionString(aIndex, &dist, &length);
-    if (length == IMM_ERROR_NODATA || length == IMM_ERROR_GENERAL) {
-      return length;
-    }
-
-    if (aBuf && aLen >= static_cast<DWORD>(length)) {
-        memcpy(aBuf, dist.Elements(), length);
-    }
-    return length;
-}
-
-// staitc
-BOOL
-PluginInstanceChild::ImmSetCandidateWindowProc(HIMC aIMC, LPCANDIDATEFORM aForm)
-{
-    if (aIMC != sHookIMC) {
-        return sImm32ImmSetCandidateWindowStub(aIMC, aForm);
-    }
-
-    if (!sCurrentPluginInstance ||
-        aForm->dwIndex != 0 ||
-        !(aForm->dwStyle & CFS_CANDIDATEPOS)) {
-        // Flash only uses CFS_CANDIDATEPOS with index == 0.
-        return FALSE;
-    }
-
-    sCurrentPluginInstance->SendSetCandidateWindow(
-        aForm->ptCurrentPos.x, aForm->ptCurrentPos.y);
-    return TRUE;
-}
-
-// static
-BOOL
-PluginInstanceChild::ImmNotifyIME(HIMC aIMC, DWORD aAction, DWORD aIndex,
-                                  DWORD aValue)
-{
-    if (aIMC != sHookIMC) {
-        return sImm32ImmNotifyIME(aIMC, aAction, aIndex, aValue);
-    }
-
-    // We only supports NI_COMPOSITIONSTR because Flash uses it only
-    if (!sCurrentPluginInstance ||
-        aAction != NI_COMPOSITIONSTR ||
-        (aIndex != CPS_COMPLETE && aIndex != CPS_CANCEL)) {
-        return FALSE;
-    }
-
-    sCurrentPluginInstance->SendRequestCommitOrCancel(aAction == CPS_COMPLETE);
-    return TRUE;
-}
-
-void
-PluginInstanceChild::InitImm32Hook()
-{
-    if (!(GetQuirks() & QUIRK_WINLESS_HOOK_IME)) {
-        return;
-    }
-
-    if (sImm32ImmGetContextStub) {
-        return;
-    }
-
-    // When using windowless plugin, IMM API won't work due ot OOP.
-
-    sImm32Intercept.Init("imm32.dll");
-    sImm32Intercept.AddHook(
-        "ImmGetContext",
-        reinterpret_cast<intptr_t>(ImmGetContextProc),
-        (void**)&sImm32ImmGetContextStub);
-    sImm32Intercept.AddHook(
-        "ImmReleaseContext",
-        reinterpret_cast<intptr_t>(ImmReleaseContextProc),
-        (void**)&sImm32ImmReleaseContextStub);
-    sImm32Intercept.AddHook(
-        "ImmGetCompositionStringW",
-        reinterpret_cast<intptr_t>(ImmGetCompositionStringProc),
-        (void**)&sImm32ImmGetCompositionStringStub);
-    sImm32Intercept.AddHook(
-        "ImmSetCandidateWindow",
-        reinterpret_cast<intptr_t>(ImmSetCandidateWindowProc),
-        (void**)&sImm32ImmSetCandidateWindowStub);
-    sImm32Intercept.AddHook(
-        "ImmNotifyIME",
-        reinterpret_cast<intptr_t>(ImmNotifyIME),
-        (void**)&sImm32ImmNotifyIME);
-}
-
 void
 PluginInstanceChild::DestroyWinlessPopupSurrogate()
 {
     if (mWinlessPopupSurrogateHWND)
         DestroyWindow(mWinlessPopupSurrogateHWND);
     mWinlessPopupSurrogateHWND = nullptr;
 }
 
@@ -2160,23 +2011,16 @@ PluginInstanceChild::WinlessHandleEvent(
            event.event == WM_RBUTTONUP)) {  // silverlight
       sWinlessPopupSurrogateHWND = mWinlessPopupSurrogateHWND;
       
       // A little trick scrounged from chromium's code - set the focus
       // to our surrogate parent so keyboard nav events go to the menu. 
       focusHwnd = SetFocus(mWinlessPopupSurrogateHWND);
     }
 
-    AutoRestore<PluginInstanceChild *> pluginInstance(sCurrentPluginInstance);
-    if (event.event == WM_IME_STARTCOMPOSITION ||
-        event.event == WM_IME_COMPOSITION ||
-        event.event == WM_KILLFOCUS) {
-      sCurrentPluginInstance = this;
-    }
-
     MessageLoop* loop = MessageLoop::current();
     AutoRestore<bool> modalLoop(loop->os_modal_loop());
 
     handled = mPluginIface->event(&mData, reinterpret_cast<void*>(&event));
 
     sWinlessPopupSurrogateHWND = nullptr;
 
     if (IsWindow(focusHwnd)) {
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -300,17 +300,16 @@ private:
     void CreateWinlessPopupSurrogate();
     void DestroyWinlessPopupSurrogate();
     void InitPopupMenuHook();
     void SetupFlashMsgThrottle();
     void UnhookWinlessFlashThrottle();
     void HookSetWindowLongPtr();
     void SetUnityHooks();
     void ClearUnityHooks();
-    void InitImm32Hook();
     static inline bool SetWindowLongHookCheck(HWND hWnd,
                                                 int nIndex,
                                                 LONG_PTR newLong);
     void FlashThrottleMessage(HWND, UINT, WPARAM, LPARAM, bool);
     static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
                                             UINT message,
                                             WPARAM wParam,
                                             LPARAM lParam);
@@ -346,25 +345,16 @@ private:
     static LONG WINAPI SetWindowLongAHook(HWND hWnd,
                                           int nIndex,
                                           LONG newLong);
     static LONG WINAPI SetWindowLongWHook(HWND hWnd,
                                           int nIndex,
                                           LONG newLong);
 #endif
 
-    static HIMC WINAPI ImmGetContextProc(HWND aWND);
-    static BOOL WINAPI ImmReleaseContextProc(HWND aWND, HIMC aIMC);
-    static LONG WINAPI ImmGetCompositionStringProc(HIMC aIMC, DWORD aIndex,
-                                                   LPVOID aBuf, DWORD aLen);
-    static BOOL WINAPI ImmSetCandidateWindowProc(HIMC hIMC,
-                                                 LPCANDIDATEFORM plCandidate);
-    static BOOL WINAPI ImmNotifyIME(HIMC aIMC, DWORD aAction, DWORD aIndex,
-                                    DWORD aValue);
-
     class FlashThrottleAsyncMsg : public ChildAsyncCall
     {
       public:
         FlashThrottleAsyncMsg();
         FlashThrottleAsyncMsg(PluginInstanceChild* aInst, 
                               HWND aWnd, UINT aMsg,
                               WPARAM aWParam, LPARAM aLParam,
                               bool isWindowed)
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -1563,26 +1563,16 @@ PluginInstanceParent::NPP_HandleEvent(vo
             }
             break;
 
             case WM_WINDOWPOSCHANGED:
             {
                 // We send this in nsPluginFrame just before painting
                 return SendWindowPosChanged(npremoteevent);
             }
-
-            case WM_IME_STARTCOMPOSITION:
-            case WM_IME_COMPOSITION:
-            case WM_IME_ENDCOMPOSITION:
-                if (!(mParent->GetQuirks() & QUIRK_WINLESS_HOOK_IME)) {
-                  // IME message will be posted on allowed plugins only such as
-                  // Flash.  Because if we cannot know that plugin can handle
-                  // IME correctly.
-                  return 0;
-                }
             break;
         }
     }
 #endif
 
 #if defined(MOZ_X11)
     switch (npevent->type) {
     case GraphicsExpose:
@@ -2373,60 +2363,16 @@ PluginInstanceParent::Cast(NPP aInstance
 
     if (aSurrogate) {
         *aSurrogate = resolver->GetAsyncSurrogate();
     }
 
     return instancePtr;
 }
 
-bool
-PluginInstanceParent::RecvGetCompositionString(const uint32_t& aIndex,
-                                               nsTArray<uint8_t>* aDist,
-                                               int32_t* aLength)
-{
-#if defined(OS_WIN)
-    nsPluginInstanceOwner* owner = GetOwner();
-    if (!owner) {
-        *aLength = IMM_ERROR_GENERAL;
-        return true;
-    }
-
-    if (!owner->GetCompositionString(aIndex, aDist, aLength)) {
-        *aLength = IMM_ERROR_NODATA;
-    }
-#endif
-    return true;
-}
-
-bool
-PluginInstanceParent::RecvSetCandidateWindow(const int32_t& aX,
-                                             const int32_t& aY)
-{
-#if defined(OS_WIN)
-    nsPluginInstanceOwner* owner = GetOwner();
-    if (owner) {
-        owner->SetCandidateWindow(aX, aY);
-    }
-#endif
-    return true;
-}
-
-bool
-PluginInstanceParent::RecvRequestCommitOrCancel(const bool& aCommitted)
-{
-#if defined(OS_WIN)
-    nsPluginInstanceOwner* owner = GetOwner();
-    if (owner) {
-        owner->RequestCommitOrCancel(aCommitted);
-    }
-#endif
-    return true;
-}
-
 void
 PluginInstanceParent::RecordDrawingModel()
 {
     int mode = -1;
     switch (mWindowType) {
     case NPWindowTypeWindow:
         // We use 0=windowed since there is no specific NPDrawingModel value.
         mode = 0;
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -347,26 +347,16 @@ public:
 
     virtual PluginAsyncSurrogate* GetAsyncSurrogate() override;
 
     virtual PluginInstanceParent* GetInstance() override { return this; }
 
     static PluginInstanceParent* Cast(NPP instance,
                                       PluginAsyncSurrogate** aSurrogate = nullptr);
 
-    // for IME hook
-    virtual bool
-    RecvGetCompositionString(const uint32_t& aIndex,
-                             nsTArray<uint8_t>* aBuffer,
-                             int32_t* aLength) override;
-    virtual bool
-    RecvSetCandidateWindow(const int32_t& aX, const int32_t& aY) override;
-    virtual bool
-    RecvRequestCommitOrCancel(const bool& aCommitted) override;
-
 private:
     // Create an appropriate platform surface for a background of size
     // |aSize|.  Return true if successful.
     bool CreateBackground(const nsIntSize& aSize);
     void DestroyBackground();
     SurfaceDescriptor BackgroundDescriptor() /*const*/;
 
     typedef mozilla::layers::ImageContainer ImageContainer;
--- a/dom/plugins/ipc/PluginQuirks.cpp
+++ b/dom/plugins/ipc/PluginQuirks.cpp
@@ -29,17 +29,16 @@ int GetQuirksFromMimeTypeAndFilename(con
     if (specialType == nsPluginHost::eSpecialType_Flash) {
         quirks |= QUIRK_FLASH_RETURN_EMPTY_DOCUMENT_ORIGIN;
 #ifdef OS_WIN
         quirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
         quirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
         quirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
         quirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
         quirks |= QUIRK_FLASH_FIXUP_MOUSE_CAPTURE;
-        quirks |= QUIRK_WINLESS_HOOK_IME;
 #endif
     }
 
 #ifdef OS_WIN
     // QuickTime plugin usually loaded with audio/mpeg mimetype
     NS_NAMED_LITERAL_CSTRING(quicktime, "npqtplugin");
     if (FindInReadable(quicktime, aPluginFilename)) {
         quirks |= QUIRK_QUICKTIME_AVOID_SETWINDOW;
@@ -58,19 +57,13 @@ int GetQuirksFromMimeTypeAndFilename(con
 #endif
 
 #ifdef OS_WIN
     if (specialType == nsPluginHost::eSpecialType_Unity) {
         quirks |= QUIRK_UNITY_FIXUP_MOUSE_CAPTURE;
     }
 #endif
 
-#ifdef OS_WIN
-    if (specialType == nsPluginHost::eSpecialType_Test) {
-        quirks |= QUIRK_WINLESS_HOOK_IME;
-    }
-#endif
-
     return quirks;
 }
 
 } /* namespace plugins */
 } /* namespace mozilla */
--- a/dom/plugins/ipc/PluginQuirks.h
+++ b/dom/plugins/ipc/PluginQuirks.h
@@ -53,18 +53,16 @@ enum PluginQuirks {
   // outside of that call.  See bug 804606.
   QUIRK_FLASH_AVOID_CGMODE_CRASHES                = 1 << 10,
   // Work around a Flash bug where it fails to check the error code of a
   // NPN_GetValue(NPNVdocumentOrigin) call before trying to dereference
   // its char* output.
   QUIRK_FLASH_RETURN_EMPTY_DOCUMENT_ORIGIN        = 1 << 11,
   // Win: Addresses a Unity bug with mouse capture.
   QUIRK_UNITY_FIXUP_MOUSE_CAPTURE                 = 1 << 12,
-  // Win: Hook IMM32 API to handle IME event on windowless plugin
-  QUIRK_WINLESS_HOOK_IME                          = 1 << 13,
 };
 
 int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,
                                      const nsCString& aPluginFilename);
 
 } /* namespace plugins */
 } /* namespace mozilla */
 
--- a/dom/plugins/test/mochitest/mochitest.ini
+++ b/dom/plugins/test/mochitest/mochitest.ini
@@ -111,16 +111,14 @@ skip-if = toolkit != "cocoa"
 [test_secondPlugin.html]
 [test_src_url_change.html]
 [test_streamNotify.html]
 [test_stringHandling.html]
 [test_streamatclose.html]
 [test_twostreams.html]
 [test_windowed_invalidate.html]
 skip-if = os != "win"
-[test_windowless_ime.html]
-skip-if = os != "win"
 [test_visibility.html]
 skip-if = toolkit == "cocoa"
 [test_zero_opacity.html]
 skip-if = e10s
 [test_bug1165981.html]
 skip-if = !(os == "win" && processor == "x86_64")
deleted file mode 100644
--- a/dom/plugins/test/mochitest/test_windowless_ime.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=539565
--->
-<head>
-  <title>Test #1 for Bug 539565</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <script type="application/javascript" src="plugin-utils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-
-  <script class="testbody" type="text/javascript">
-function runTests() {
-  var plugin = document.getElementById("plugin1");
-
-  plugin.focus();
-  synthesizeComposition({ type: "compositionstart", data: "" });
-  let data = "composition";
-  synthesizeCompositionChange({
-    composition: {
-      string: data,
-      clauses: [
-        { length: data.length, attr: COMPOSITION_ATTR_RAW_CLAUSE }
-      ]
-    },
-    caret: {start: data.length, length: 0}
-  });
-  is(plugin.getLastCompositionText(), data, "can get composition string");
-  synthesizeComposition({ type: "compositioncommit", data: "" });
-
-  synthesizeComposition({ type: "compositionstart", data: "" });
-  is(plugin.getLastCompositionText(), "", "can get empty composition string");
-  synthesizeComposition({ type: "compositioncommit", data: "" });
-  SimpleTest.finish();
-}
-
-SimpleTest.waitForExplicitFinish();
-SpecialPowers.setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
-  </script>
-</head>
-
-<body onload="runTests()">
-  <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
-</body>
-</html>
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -168,17 +168,16 @@ static bool getLastKeyText(NPObject* npo
 static bool getNPNVdocumentOrigin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getMouseUpEventCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool queryContentsScaleFactor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool echoString(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool startAudioPlayback(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool stopAudioPlayback(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool getAudioMuted(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 static bool nativeWidgetIsVisible(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
-static bool getLastCompositionText(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
 
 static const NPUTF8* sPluginMethodIdentifierNames[] = {
   "npnEvaluateTest",
   "npnInvokeTest",
   "npnInvokeDefaultTest",
   "setUndefinedValueTest",
   "identifierToStringTest",
   "timerTest",
@@ -240,17 +239,16 @@ static const NPUTF8* sPluginMethodIdenti
   "getNPNVdocumentOrigin",
   "getMouseUpEventCount",
   "queryContentsScaleFactor",
   "echoString",
   "startAudioPlayback",
   "stopAudioPlayback",
   "audioMuted",
   "nativeWidgetIsVisible",
-  "getLastCompositionText",
 };
 static NPIdentifier sPluginMethodIdentifiers[MOZ_ARRAY_LENGTH(sPluginMethodIdentifierNames)];
 static const ScriptableFunction sPluginMethodFunctions[] = {
   npnEvaluateTest,
   npnInvokeTest,
   npnInvokeDefaultTest,
   setUndefinedValueTest,
   identifierToStringTest,
@@ -313,17 +311,16 @@ static const ScriptableFunction sPluginM
   getNPNVdocumentOrigin,
   getMouseUpEventCount,
   queryContentsScaleFactor,
   echoString,
   startAudioPlayback,
   stopAudioPlayback,
   getAudioMuted,
   nativeWidgetIsVisible,
-  getLastCompositionText,
 };
 
 static_assert(MOZ_ARRAY_LENGTH(sPluginMethodIdentifierNames) ==
               MOZ_ARRAY_LENGTH(sPluginMethodFunctions),
               "Arrays should have the same size");
 
 static const NPUTF8* sPluginPropertyIdentifierNames[] = {
   "propertyAndMethod"
@@ -850,17 +847,16 @@ NPP_New(NPMIMEType pluginType, NPP insta
   instanceData->eventModel = 0;
   instanceData->closeStream = false;
   instanceData->wantsAllStreams = false;
   instanceData->mouseUpEventCount = 0;
   instanceData->bugMode = -1;
   instanceData->asyncDrawing = AD_NONE;
   instanceData->frontBuffer = nullptr;
   instanceData->backBuffer = nullptr;
-  instanceData->placeholderWnd = nullptr;
   instance->pdata = instanceData;
 
   TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
   if (!scriptableObject) {
     printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
     delete instanceData;
     return NPERR_GENERIC_ERROR;
   }
@@ -3514,36 +3510,16 @@ nativeWidgetIsVisible(NPObject* npobj, c
                       uint32_t argCount, NPVariant* result)
 {
   // XXX Not implemented!
   return false;
 }
 #endif
 
 bool
-getLastCompositionText(NPObject* npobj, const NPVariant* args,
-                       uint32_t argCount, NPVariant* result)
-{
-#ifdef XP_WIN
-  if (argCount != 0) {
-    return false;
-  }
-
-  NPP npp = static_cast<TestNPObject*>(npobj)->npp;
-  InstanceData* id = static_cast<InstanceData*>(npp->pdata);
-  char *outval = NPN_StrDup(id->lastComposition.c_str());
-  STRINGZ_TO_NPVARIANT(outval, *result);
-  return true;
-#else
-  // XXX not implemented
-  return false;
-#endif
-}
-
-bool
 callOnDestroy(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
 
   if (id->callOnDestroy)
     return false;
 
--- a/dom/plugins/test/testplugin/nptest.h
+++ b/dom/plugins/test/testplugin/nptest.h
@@ -151,18 +151,16 @@ typedef struct InstanceData {
   std::string lastKeyText;
   bool wantsAllStreams;
   int32_t mouseUpEventCount;
   int32_t bugMode;
   std::string javaCodebase;
   AsyncDrawing asyncDrawing;
   NPAsyncSurface *frontBuffer;
   NPAsyncSurface *backBuffer;
-  std::string lastComposition;
-  void* placeholderWnd;
 } InstanceData;
 
 void notifyDidPaint(InstanceData* instanceData);
 
 #if defined(XP_WIN)
 bool setupDxgiSurfaces(NPP npp, InstanceData* instanceData);
 void drawDxgiBitmapColor(InstanceData* instanceData);
 #endif
--- a/dom/plugins/test/testplugin/nptest_windows.cpp
+++ b/dom/plugins/test/testplugin/nptest_windows.cpp
@@ -649,39 +649,16 @@ pluginGetClipRegionRectEdge(InstanceData
     return addOffset(rect.right, pluginGetEdge(instanceData, EDGE_LEFT));
   case EDGE_BOTTOM:
     return addOffset(rect.bottom, pluginGetEdge(instanceData, EDGE_TOP));
   }
 
   return NPTEST_INT32_ERROR;
 }
 
-static
-void
-createDummyWindowForIME(InstanceData* instanceData)
-{
-  WNDCLASSW wndClass;
-  wndClass.style = 0;
-  wndClass.lpfnWndProc = DefWindowProcW;
-  wndClass.cbClsExtra = 0;
-  wndClass.cbWndExtra = 0;
-  wndClass.hInstance = GetModuleHandleW(NULL);
-  wndClass.hIcon = nullptr;
-  wndClass.hCursor = nullptr;
-  wndClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
-  wndClass.lpszMenuName = NULL;
-  wndClass.lpszClassName = L"SWFlash_PlaceholderX";
-  RegisterClassW(&wndClass);
-
-  instanceData->placeholderWnd =
-    static_cast<void*>(CreateWindowW(L"SWFlash_PlaceholderX", L"", WS_CHILD, 0,
-                                     0, 0, 0, HWND_MESSAGE, NULL,
-                                     GetModuleHandleW(NULL), NULL));
-}
-
 /* windowless plugin events */
 
 static bool
 handleEventInternal(InstanceData* instanceData, NPEvent* pe, LRESULT* result)
 {
   switch ((UINT)pe->event) {
     case WM_PAINT:
       pluginDraw(instanceData);
@@ -743,45 +720,16 @@ handleEventInternal(InstanceData* instan
                               nullptr, nullptr);
       if (len == 0 || len > 6) {
         return true;
       }
       instanceData->lastKeyText.append(utf8Char, len);
       return true;
     }
 
-    case WM_IME_STARTCOMPOSITION:
-      instanceData->lastComposition.erase();
-      if (!instanceData->placeholderWnd) {
-        createDummyWindowForIME(instanceData);
-      }
-      return true;
-
-    case WM_IME_ENDCOMPOSITION:
-      instanceData->lastComposition.erase();
-      return true;
-
-    case WM_IME_COMPOSITION: {
-      if (pe->lParam & GCS_COMPSTR) {
-        HIMC hIMC = ImmGetContext((HWND)instanceData->placeholderWnd);
-        if (!hIMC) {
-          return false;
-        }
-        WCHAR compStr[256];
-        LONG len = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, compStr,
-                                            256 * sizeof(WCHAR));
-        CHAR buffer[256];
-        len = ::WideCharToMultiByte(CP_UTF8, 0, compStr, len / sizeof(WCHAR),
-                                    buffer, 256, nullptr, nullptr);
-        instanceData->lastComposition.append(buffer, len);
-        ::ImmReleaseContext((HWND)instanceData->placeholderWnd, hIMC);
-      }
-      return true;
-    }
-
     default:
       return false;
   }
 }
 
 int16_t
 pluginHandleEvent(InstanceData* instanceData, void* event)
 {
--- a/dom/plugins/test/testplugin/testplugin.mozbuild
+++ b/dom/plugins/test/testplugin/testplugin.mozbuild
@@ -33,17 +33,16 @@ elif toolkit == 'qt':
         'nptest_qt.cpp',
     ]
 elif toolkit == 'windows':
     UNIFIED_SOURCES += [
         'nptest_windows.cpp',
     ]
     OS_LIBS += [
         'msimg32',
-        'imm32'
     ]
 
 # must link statically with the CRT; nptest isn't Gecko code
 USE_STATIC_LIBS = True
 
 # Don't use STL wrappers; nptest isn't Gecko code
 DISABLE_STL_WRAPPING = True
 
--- a/toolkit/xre/test/win/TestDllInterceptor.cpp
+++ b/toolkit/xre/test/win/TestDllInterceptor.cpp
@@ -154,18 +154,15 @@ int main()
       TestHook("kernel32.dll", "SetUnhandledExceptionFilter") &&
 #ifdef _M_IX86
       // Bug 670967: xpcom/base/AvailableMemoryTracker.cpp
       TestHook("kernel32.dll", "VirtualAlloc") &&
       TestHook("kernel32.dll", "MapViewOfFile") &&
       TestHook("gdi32.dll", "CreateDIBSection") &&
       TestHook("kernel32.dll", "CreateFileW") &&
 #endif
-      TestHook("imm32.dll", "ImmGetContext") &&
-      TestHook("imm32.dll", "ImmGetCompositionStringW") &&
-      TestHook("imm32.dll", "ImmSetCandidateWindow") &&
       TestDetour("ntdll.dll", "LdrLoadDll")) {
     printf("TEST-PASS | WindowsDllInterceptor | all checks passed\n");
     return 0;
   }
 
   return 1;
 }
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -492,27 +492,16 @@ ContentCacheInParent::HandleQueryContent
   aEvent.mReply.mFocusedWidget = aWidget;
 
   switch (aEvent.mMessage) {
     case eQuerySelectedText:
       MOZ_LOG(sContentCacheLog, LogLevel::Info,
         ("ContentCacheInParent: 0x%p HandleQueryContentEvent("
          "aEvent={ mMessage=eQuerySelectedText }, aWidget=0x%p)",
          this, aWidget));
-      if (aWidget->PluginHasFocus()) {
-        MOZ_LOG(sContentCacheLog, LogLevel::Info,
-          ("ContentCacheInParent: 0x%p HandleQueryContentEvent(), "
-           "return emtpy selection becasue plugin has focus",
-           this));
-        aEvent.mSucceeded = true;
-        aEvent.mReply.mOffset = 0;
-        aEvent.mReply.mReversed = false;
-        aEvent.mReply.mHasSelection = false;
-        return true;
-      }
       if (NS_WARN_IF(!IsSelectionValid())) {
         // If content cache hasn't been initialized properly, make the query
         // failed.
         MOZ_LOG(sContentCacheLog, LogLevel::Error,
           ("ContentCacheInParent: 0x%p HandleQueryContentEvent(), "
            "FAILED because mSelection is not valid", this));
         return true;
       }
@@ -841,22 +830,17 @@ ContentCacheInParent::OnCompositionEvent
      this, ToChar(aEvent.mMessage),
      NS_ConvertUTF16toUTF8(aEvent.mData).get(), aEvent.mData.Length(),
      aEvent.mRanges ? aEvent.mRanges->Length() : 0, mPendingEventsNeedingAck,
      GetBoolName(mIsComposing), mCommitStringByRequest));
 
   // We must be able to simulate the selection because
   // we might not receive selection updates in time
   if (!mIsComposing) {
-    if (aEvent.widget && aEvent.widget->PluginHasFocus()) {
-      // If focus is on plugin, we cannot get selection range
-      mCompositionStart = 0;
-    } else {
-      mCompositionStart = mSelection.StartOffset();
-    }
+    mCompositionStart = mSelection.StartOffset();
   }
 
   mIsComposing = !aEvent.CausesDOMCompositionEndEvent();
 
   // During REQUEST_TO_COMMIT_COMPOSITION or REQUEST_TO_CANCEL_COMPOSITION,
   // widget usually sends a eCompositionChange and/or eCompositionCommit event
   // to finalize or clear the composition, respectively.  In this time,
   // we need to intercept all composition events here and pass the commit
--- a/widget/MiscEvents.h
+++ b/widget/MiscEvents.h
@@ -10,21 +10,16 @@
 
 #include "mozilla/BasicEvents.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsITransferable.h"
 
 namespace mozilla {
 
-namespace dom {
-  class PBrowserParent;
-  class PBrowserChild;
-} // namespace dom
-
 /******************************************************************************
  * mozilla::WidgetContentCommandEvent
  ******************************************************************************/
 
 class WidgetContentCommandEvent : public WidgetGUIEvent
 {
 public:
   virtual WidgetContentCommandEvent* AsContentCommandEvent() override
@@ -142,20 +137,16 @@ public:
 /******************************************************************************
  * mozilla::WidgetPluginEvent
  *
  * This event delivers only a native event to focused plugin.
  ******************************************************************************/
 
 class WidgetPluginEvent : public WidgetGUIEvent
 {
-private:
-  friend class dom::PBrowserParent;
-  friend class dom::PBrowserChild;
-
 public:
   virtual WidgetPluginEvent* AsPluginEvent() override { return this; }
 
   WidgetPluginEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
     : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, ePluginEventClass)
     , retargetToFocusedDocument(false)
   {
   }
@@ -179,18 +170,13 @@ public:
 
   void AssignPluginEventData(const WidgetPluginEvent& aEvent,
                              bool aCopyTargets)
   {
     AssignGUIEventData(aEvent, aCopyTargets);
 
     retargetToFocusedDocument = aEvent.retargetToFocusedDocument;
   }
-
-protected:
-  WidgetPluginEvent()
-  {
-  }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_MiscEvents_h__
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -682,25 +682,16 @@ NS_IMETHODIMP
 PuppetWidget::SetPluginFocused(bool& aFocused)
 {
   if (!mTabChild || !mTabChild->SendSetPluginFocused(aFocused)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
-void
-PuppetWidget::DefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent)
-{
-  if (!mTabChild) {
-    return;
-  }
-  mTabChild->SendDefaultProcOfPluginEvent(aEvent);
-}
-
 NS_IMETHODIMP_(void)
 PuppetWidget::SetInputContext(const InputContext& aContext,
                               const InputContextAction& aAction)
 {
   mInputContext = aContext;
 
 #ifndef MOZ_CROSS_PROCESS_IME
   return;
@@ -1408,20 +1399,10 @@ PuppetWidget::GetCurrentWidgetListener()
 
   if (mAttachedWidgetListener->GetView()->IsPrimaryFramePaintSuppressed()) {
     return mPreviouslyAttachedWidgetListener;
   }
 
   return mAttachedWidgetListener;
 }
 
-void
-PuppetWidget::SetCandidateWindowForPlugin(int32_t aX, int32_t aY)
-{
-  if (!mTabChild) {
-    return;
-  }
-
-  mTabChild->SendSetCandidateWindowForPlugin(aX, aY);
-}
-
 } // namespace widget
 } // namespace mozilla
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -215,18 +215,16 @@ public:
 
   NS_IMETHOD GetScreenBounds(LayoutDeviceIntRect& aRect) override;
 
   NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
                             int32_t aPanelX, int32_t aPanelY,
                             nsString& aCommitted) override;
 
   NS_IMETHOD SetPluginFocused(bool& aFocused) override;
-  virtual void DefaultProcOfPluginEvent(
-                 const mozilla::WidgetPluginEvent& aEvent) override;
 
   virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
                                             int32_t aNativeKeyCode,
                                             uint32_t aModifierFlags,
                                             const nsAString& aCharacters,
                                             const nsAString& aUnmodifiedCharacters,
                                             nsIObserver* aObserver) override;
   virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
@@ -251,19 +249,16 @@ public:
                                               nsIObserver* aObserver) override;
   virtual nsresult SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
                                             bool aLongTap,
                                             nsIObserver* aObserver) override;
   virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver) override;
   virtual uint32_t GetMaxTouchPoints() const override;
 
   virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
-
-  virtual void SetCandidateWindowForPlugin(int32_t aX, int32_t aY) override;
-
 protected:
   virtual nsresult NotifyIMEInternal(
                      const IMENotification& aIMENotification) override;
 
 private:
   nsresult Paint();
 
   void SetChild(PuppetWidget* aChild);
--- a/widget/TextRange.h
+++ b/widget/TextRange.h
@@ -251,33 +251,13 @@ public:
   }
 
   void RemoveCharacter(uint32_t aOffset)
   {
     for (size_t i = 0, len = Length(); i < len; i++) {
       ElementAt(i).RemoveCharacter(aOffset);
     }
   }
-
-  bool HasCaret() const
-  {
-    for (const TextRange& range : *this) {
-      if (range.mRangeType == NS_TEXTRANGE_CARETPOSITION) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-  uint32_t GetCaretPosition() const
-  {
-    for (const TextRange& range : *this) {
-      if (range.mRangeType == NS_TEXTRANGE_CARETPOSITION) {
-        return range.mStartOffset;
-      }
-    }
-    return UINT32_MAX;
-  }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_TextRage_h_
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -212,22 +212,16 @@ public:
   virtual nsresult        ForceUpdateNativeMenuAt(const nsAString& indexString) override { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD              NotifyIME(const IMENotification& aIMENotification) override final;
   NS_IMETHOD              StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
                                          int32_t aPanelX, int32_t aPanelY,
                                          nsString& aCommitted) override
                           { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD              SetPluginFocused(bool& aFocused) override
                           { return NS_ERROR_NOT_IMPLEMENTED; }
-  virtual void            SetCandidateWindowForPlugin(int32_t aX,
-                                                      int32_t aY) override
-                          { }
-  virtual void            DefaultProcOfPluginEvent(
-                            const mozilla::WidgetPluginEvent& aEvent) override
-                          { }
   NS_IMETHOD              AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) override { return NS_ERROR_NOT_IMPLEMENTED; }
   NS_IMETHOD_(bool)       ExecuteNativeKeyBinding(
                             NativeKeyBindingsType aType,
                             const mozilla::WidgetKeyboardEvent& aEvent,
                             DoCommandCallback aCallback,
                             void* aCallbackData) override { return false; }
   virtual bool            ComputeShouldAccelerate();
   virtual nsIMEUpdatePreference GetIMEUpdatePreference() override { return nsIMEUpdatePreference(); }
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -128,18 +128,18 @@ typedef void* nsNativeWidget;
 // set/get nsPluginNativeWindowGtk, e10s specific
 #define NS_NATIVE_PLUGIN_OBJECT_PTR    104
 #endif
 #ifdef MOZ_WIDGET_ANDROID
 #define NS_NATIVE_NEW_EGL_SURFACE      100
 #endif
 
 #define NS_IWIDGET_IID \
-{ 0x73c0a475, 0x450f, 0x4202, \
-  { 0xab, 0xb4, 0x62, 0xf8, 0x9d, 0xbe, 0xf7, 0x9a } }
+{ 0xaaa79c8d, 0xc99d, 0x4fe1, \
+  { 0xa5, 0x11, 0xd3, 0xeb, 0xb1, 0x61, 0x9e, 0x26 } }
 
 /*
  * Window shadow styles
  * Also used for the -moz-window-shadow CSS property
  */
 
 #define NS_STYLE_WINDOW_SHADOW_NONE             0
 #define NS_STYLE_WINDOW_SHADOW_DEFAULT          1
@@ -1787,35 +1787,16 @@ public:
      * keyboard focus.  Should be sent when the keyboard focus changes too or
      * from a plugin.
      *
      * aFocused  Whether or not a plugin is focused
      */
     NS_IMETHOD SetPluginFocused(bool& aFocused) = 0;
 
     /*
-     * Tell the plugin has focus.  It is unnecessary to use IPC
-     */
-    bool PluginHasFocus() 
-    {
-      return GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN;
-    }
-
-    /**
-     * Set IME candidate window position by windowless plugin.
-     */
-    virtual void SetCandidateWindowForPlugin(int32_t aX, int32_t aY) = 0;
-
-    /**
-     * Handle default action when PluginEvent isn't handled
-     */
-    virtual void DefaultProcOfPluginEvent(
-                   const mozilla::WidgetPluginEvent& aEvent) = 0;
-
-    /*
      * Notifies the input context changes.
      */
     NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
                                       const InputContextAction& aAction) = 0;
 
     /*
      * Get current input context.
      */
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -580,18 +580,17 @@ IMMHandler::MaybeAdjustCompositionFont(n
       if (!gIMMHandler) {
         return;
       }
   }
 
   // Like Navi-Bar of ATOK, some IMEs may require proper composition font even
   // before sending WM_IME_STARTCOMPOSITION.
   IMEContext context(aWindow);
-  gIMMHandler->AdjustCompositionFont(aWindow, context, aWritingMode,
-                                     aForceUpdate);
+  gIMMHandler->AdjustCompositionFont(context, aWritingMode, aForceUpdate);
 }
 
 // static
 bool
 IMMHandler::ProcessInputLangChangeMessage(nsWindow* aWindow,
                                           WPARAM wParam,
                                           LPARAM lParam,
                                           MSGResult& aResult)
@@ -619,23 +618,20 @@ IMMHandler::ProcessMessage(nsWindow* aWi
                            LPARAM& lParam,
                            MSGResult& aResult)
 {
   // XXX We store the composing window in mComposingWindow.  If IME messages are
   // sent to different window, we should commit the old transaction.  And also
   // if the new window handle is not focused, probably, we should not start
   // the composition, however, such case should not be, it's just bad scenario.
 
-  // When a plug-in has focus, we should dispatch the IME events to
-  // the plug-in at first.
-  if (aWindow->PluginHasFocus()) {
-      bool ret = false;
-      if (ProcessMessageForPlugin(aWindow, msg, wParam, lParam, ret, aResult)) {
-        return ret;
-      }
+  // When a plug-in has focus or compsition, we should dispatch the IME events
+  // to the plug-in.
+  if (aWindow->PluginHasFocus() || IsComposingOnPlugin()) {
+      return ProcessMessageForPlugin(aWindow, msg, wParam, lParam, aResult);
   }
 
   aResult.mResult = 0;
   switch (msg) {
     case WM_INPUTLANGCHANGE:
       return ProcessInputLangChangeMessage(aWindow, wParam, lParam, aResult);
     case WM_IME_STARTCOMPOSITION:
       EnsureHandlerInstance();
@@ -670,54 +666,56 @@ IMMHandler::ProcessMessage(nsWindow* aWi
 }
 
 // static
 bool
 IMMHandler::ProcessMessageForPlugin(nsWindow* aWindow,
                                     UINT msg,
                                     WPARAM& wParam,
                                     LPARAM& lParam,
-                                    bool& aRet,
                                     MSGResult& aResult)
 {
   aResult.mResult = 0;
   aResult.mConsumed = false;
   switch (msg) {
     case WM_INPUTLANGCHANGEREQUEST:
     case WM_INPUTLANGCHANGE:
       aWindow->DispatchPluginEvent(msg, wParam, lParam, false);
-      aRet = ProcessInputLangChangeMessage(aWindow, wParam, lParam, aResult);
-      return true;
+      return ProcessInputLangChangeMessage(aWindow, wParam, lParam, aResult);
+    case WM_IME_COMPOSITION:
+      EnsureHandlerInstance();
+      return gIMMHandler->OnIMECompositionOnPlugin(aWindow, wParam, lParam,
+                                                   aResult);
+    case WM_IME_STARTCOMPOSITION:
+      EnsureHandlerInstance();
+      return gIMMHandler->OnIMEStartCompositionOnPlugin(aWindow, wParam,
+                                                        lParam, aResult);
+    case WM_IME_ENDCOMPOSITION:
+      EnsureHandlerInstance();
+      return gIMMHandler->OnIMEEndCompositionOnPlugin(aWindow, wParam, lParam,
+                                                      aResult);
     case WM_IME_CHAR:
       EnsureHandlerInstance();
-      aRet = gIMMHandler->OnIMECharOnPlugin(aWindow, wParam, lParam, aResult);
-      return true;
+      return gIMMHandler->OnIMECharOnPlugin(aWindow, wParam, lParam, aResult);
     case WM_IME_SETCONTEXT:
-      aRet = OnIMESetContextOnPlugin(aWindow, wParam, lParam, aResult);
-      return true;
+      return OnIMESetContextOnPlugin(aWindow, wParam, lParam, aResult);
     case WM_CHAR:
       if (!gIMMHandler) {
-        return true;
+        return false;
       }
-      aRet = gIMMHandler->OnCharOnPlugin(aWindow, wParam, lParam, aResult);
-      return true;
+      return gIMMHandler->OnCharOnPlugin(aWindow, wParam, lParam, aResult);
     case WM_IME_COMPOSITIONFULL:
     case WM_IME_CONTROL:
     case WM_IME_KEYDOWN:
     case WM_IME_KEYUP:
+    case WM_IME_REQUEST:
     case WM_IME_SELECT:
       aResult.mConsumed =
         aWindow->DispatchPluginEvent(msg, wParam, lParam, false);
-      aRet = true;
       return true;
-    case WM_IME_REQUEST:
-       // Our plugin implementation is alwasy OOP.  So WM_IME_REQUEST doesn't
-       // allow that parameter is pointer and shouldn't handle into Gecko.
-       aRet = false;
-       return true;
   }
   return false;
 }
 
 /****************************************************************************
  * message handlers
  ****************************************************************************/
 
@@ -769,16 +767,19 @@ IMMHandler::OnIMEComposition(nsWindow* a
     ("IMM: OnIMEComposition, hWnd=%08x, lParam=%08x, mIsComposing=%s, "
      "GCS_RESULTSTR=%s, GCS_COMPSTR=%s, GCS_COMPATTR=%s, GCS_COMPCLAUSE=%s, "
      "GCS_CURSORPOS=%s,",
      aWindow->GetWindowHandle(), lParam, GetBoolName(mIsComposing),
      GetBoolName(lParam & GCS_RESULTSTR), GetBoolName(lParam & GCS_COMPSTR),
      GetBoolName(lParam & GCS_COMPATTR), GetBoolName(lParam & GCS_COMPCLAUSE),
      GetBoolName(lParam & GCS_CURSORPOS)));
 
+  MOZ_ASSERT(!aWindow->PluginHasFocus(),
+    "OnIMEComposition should not be called when a plug-in has focus");
+
   IMEContext context(aWindow);
   aResult.mConsumed = HandleComposition(aWindow, context, lParam);
   return true;
 }
 
 bool
 IMMHandler::OnIMEEndComposition(nsWindow* aWindow,
                                 MSGResult& aResult)
@@ -1083,77 +1084,91 @@ IMMHandler::OnChar(nsWindow* aWindow,
   aResult.mConsumed = true;
   return aResult.mConsumed;
 }
 
 /****************************************************************************
  * message handlers for plug-in
  ****************************************************************************/
 
-void
+bool
 IMMHandler::OnIMEStartCompositionOnPlugin(nsWindow* aWindow,
                                           WPARAM wParam,
-                                          LPARAM lParam)
+                                          LPARAM lParam,
+                                          MSGResult& aResult)
 {
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: OnIMEStartCompositionOnPlugin, hWnd=%08x, mIsComposingOnPlugin=%s",
      aWindow->GetWindowHandle(), GetBoolName(mIsComposingOnPlugin)));
   mIsComposingOnPlugin = true;
   mComposingWindow = aWindow;
   IMEContext context(aWindow);
   SetIMERelatedWindowsPosOnPlugin(aWindow, context);
   // On widnowless plugin, we should assume that the focused editor is always
   // in horizontal writing mode.
-  AdjustCompositionFont(aWindow, context, WritingMode());
+  AdjustCompositionFont(context, WritingMode());
+  aResult.mConsumed =
+    aWindow->DispatchPluginEvent(WM_IME_STARTCOMPOSITION, wParam, lParam,
+                                 false);
+  return true;
 }
 
-void
+bool
 IMMHandler::OnIMECompositionOnPlugin(nsWindow* aWindow,
                                      WPARAM wParam,
-                                     LPARAM lParam)
+                                     LPARAM lParam,
+                                     MSGResult& aResult)
 {
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: OnIMECompositionOnPlugin, hWnd=%08x, lParam=%08x, "
      "mIsComposingOnPlugin=%s, GCS_RESULTSTR=%s, GCS_COMPSTR=%s, "
      "GCS_COMPATTR=%s, GCS_COMPCLAUSE=%s, GCS_CURSORPOS=%s",
      aWindow->GetWindowHandle(), lParam, GetBoolName(mIsComposingOnPlugin),
      GetBoolName(lParam & GCS_RESULTSTR), GetBoolName(lParam & GCS_COMPSTR),
      GetBoolName(lParam & GCS_COMPATTR), GetBoolName(lParam & GCS_COMPCLAUSE),
      GetBoolName(lParam & GCS_CURSORPOS)));
   // We should end composition if there is a committed string.
   if (IS_COMMITTING_LPARAM(lParam)) {
     mIsComposingOnPlugin = false;
     mComposingWindow = nullptr;
-    return;
   }
   // Continue composition if there is still a string being composed.
   if (IS_COMPOSING_LPARAM(lParam)) {
     mIsComposingOnPlugin = true;
     mComposingWindow = aWindow;
     IMEContext context(aWindow);
     SetIMERelatedWindowsPosOnPlugin(aWindow, context);
   }
+  aResult.mConsumed =
+    aWindow->DispatchPluginEvent(WM_IME_COMPOSITION, wParam, lParam, true);
+  return true;
 }
 
-void
+bool
 IMMHandler::OnIMEEndCompositionOnPlugin(nsWindow* aWindow,
                                         WPARAM wParam,
-                                        LPARAM lParam)
+                                        LPARAM lParam,
+                                        MSGResult& aResult)
 {
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: OnIMEEndCompositionOnPlugin, hWnd=%08x, mIsComposingOnPlugin=%s",
      aWindow->GetWindowHandle(), GetBoolName(mIsComposingOnPlugin)));
 
   mIsComposingOnPlugin = false;
   mComposingWindow = nullptr;
 
   if (mNativeCaretIsCreated) {
     ::DestroyCaret();
     mNativeCaretIsCreated = false;
   }
+
+  aResult.mConsumed =
+    aWindow->DispatchPluginEvent(WM_IME_ENDCOMPOSITION, wParam, lParam,
+                                 false);
+  return true;
 }
 
 bool
 IMMHandler::OnIMECharOnPlugin(nsWindow* aWindow,
                               WPARAM wParam,
                               LPARAM lParam,
                               MSGResult& aResult)
 {
@@ -1212,22 +1227,16 @@ IMMHandler::OnIMESetContextOnPlugin(nsWi
 }
 
 bool
 IMMHandler::OnCharOnPlugin(nsWindow* aWindow,
                            WPARAM wParam,
                            LPARAM lParam,
                            MSGResult& aResult)
 {
-  NS_WARNING("OnCharOnPlugin");
-  if (mIsComposing) {
-    aWindow->NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
-    return true;
-  }
-
   // We should never consume char message on windowless plugin.
   aResult.mConsumed = false;
   if (IsIMECharRecordsEmpty()) {
     return false;
   }
 
   WPARAM recWParam;
   LPARAM recLParam;
@@ -1250,26 +1259,28 @@ IMMHandler::OnCharOnPlugin(nsWindow* aWi
  ****************************************************************************/
 
 void
 IMMHandler::HandleStartComposition(nsWindow* aWindow,
                                    const IMEContext& aContext)
 {
   NS_PRECONDITION(!mIsComposing,
     "HandleStartComposition is called but mIsComposing is TRUE");
+  NS_PRECONDITION(!aWindow->PluginHasFocus(),
+    "HandleStartComposition should not be called when a plug-in has focus");
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: HandleStartComposition, FAILED, due to "
        "Selection::EnsureValidSelection() failure"));
     return;
   }
 
-  AdjustCompositionFont(aWindow, aContext, selection.mWritingMode);
+  AdjustCompositionFont(aContext, selection.mWritingMode);
 
   mCompositionStart = selection.mOffset;
   mCursorPosition = NO_IME_CARET;
 
   WidgetCompositionEvent event(true, eCompositionStart, aWindow);
   LayoutDeviceIntPoint point(0, 0);
   aWindow->InitEvent(event, &point);
   DispatchEvent(aWindow, event);
@@ -1282,16 +1293,19 @@ IMMHandler::HandleStartComposition(nsWin
      mCompositionStart));
 }
 
 bool
 IMMHandler::HandleComposition(nsWindow* aWindow,
                               const IMEContext& aContext,
                               LPARAM lParam)
 {
+  NS_PRECONDITION(!aWindow->PluginHasFocus(),
+    "HandleComposition should not be called when a plug-in has focus");
+
   // for bug #60050
   // MS-IME 95/97/98/2000 may send WM_IME_COMPOSITION with non-conversion
   // mode before it send WM_IME_STARTCOMPOSITION.
   // However, ATOK sends a WM_IME_COMPOSITION before WM_IME_STARTCOMPOSITION,
   // and if we access ATOK via some APIs, ATOK will sometimes fail to
   // initialize its state.  If WM_IME_STARTCOMPOSITION is already in the
   // message queue, we should ignore the strange WM_IME_COMPOSITION message and
   // skip to the next.  So, we should look for next composition message
@@ -1522,16 +1536,18 @@ IMMHandler::HandleComposition(nsWindow* 
 }
 
 void
 IMMHandler::HandleEndComposition(nsWindow* aWindow,
                                  const nsAString* aCommitString)
 {
   MOZ_ASSERT(mIsComposing,
     "HandleEndComposition is called but mIsComposing is FALSE");
+  MOZ_ASSERT(!aWindow->PluginHasFocus(),
+    "HandleComposition should not be called when a plug-in has focus");
 
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: HandleEndComposition(aWindow=0x%p, aCommitString=0x%p (\"%s\"))",
      aWindow, aCommitString,
      aCommitString ? NS_ConvertUTF16toUTF8(*aCommitString).get() : ""));
 
   if (mNativeCaretIsCreated) {
     ::DestroyCaret();
@@ -1827,29 +1843,32 @@ IMMHandler::HandleDocumentFeed(nsWindow*
 bool
 IMMHandler::CommitCompositionOnPreviousWindow(nsWindow* aWindow)
 {
   if (!mComposingWindow || mComposingWindow == aWindow) {
     return false;
   }
 
   MOZ_LOG(gIMMLog, LogLevel::Info,
-    ("IMM: CommitCompositionOnPreviousWindow, mIsComposing=%s",
-     GetBoolName(mIsComposing)));
+    ("IMM: CommitCompositionOnPreviousWindow, mIsComposing=%s, "
+     "mIsComposingOnPlugin=%s",
+     GetBoolName(mIsComposing), GetBoolName(mIsComposingOnPlugin)));
 
   // If we have composition, we should dispatch composition events internally.
   if (mIsComposing) {
     IMEContext context(mComposingWindow);
     NS_ASSERTION(context.IsValid(), "IME context must be valid");
 
     HandleEndComposition(mComposingWindow);
     return true;
   }
 
-  return false;
+  // XXX When plug-in has composition, we should commit composition on the
+  // plug-in.  However, we need some more work for that.
+  return mIsComposingOnPlugin;
 }
 
 static uint32_t
 PlatformToNSAttr(uint8_t aAttr)
 {
   switch (aAttr)
   {
     case ATTR_INPUT_ERROR:
@@ -2507,18 +2526,17 @@ SetVerticalFontToLogFont(const nsAString
   }
   aLogFont.lfFaceName[0] = '@';
   memcpy(&aLogFont.lfFaceName[1], aFontFace.BeginReading(),
          aFontFace.Length() * sizeof(wchar_t));
   aLogFont.lfFaceName[aFontFace.Length() + 1] = 0;
 }
 
 void
-IMMHandler::AdjustCompositionFont(nsWindow* aWindow,
-                                  const IMEContext& aContext,
+IMMHandler::AdjustCompositionFont(const IMEContext& aContext,
                                   const WritingMode& aWritingMode,
                                   bool aForceUpdate)
 {
   // An instance of IMMHandler is destroyed when active IME is changed.
   // Therefore, we need to store the information which are set to the IM
   // context to static variables since IM context is never recreated.
   static bool sCompositionFontsInitialized = false;
   static nsString sCompositionFont =
@@ -2594,18 +2612,18 @@ IMMHandler::AdjustCompositionFont(nsWind
   }
   // Need to reset some information which should be recomputed with new font.
   logFont.lfWidth = 0;
   logFont.lfWeight = FW_DONTCARE;
   logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
   logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
   logFont.lfPitchAndFamily = DEFAULT_PITCH;
 
-  if (!aWindow->PluginHasFocus() &&
-    aWritingMode.IsVertical() && IsVerticalWritingSupported()) {
+  if (!mIsComposingOnPlugin &&
+      aWritingMode.IsVertical() && IsVerticalWritingSupported()) {
     SetVerticalFontToLogFont(
       IsJapanist2003Active() ? sCompositionFontForJapanist2003 :
                                sCompositionFont, logFont);
   } else {
     SetHorizontalFontToLogFont(
       IsJapanist2003Active() ? sCompositionFontForJapanist2003 :
                                sCompositionFont, logFont);
   }
@@ -2736,51 +2754,16 @@ IMMHandler::OnKeyDownEvent(nsWindow* aWi
         CancelComposition(aWindow, false);
       }
       return false;
     default:
       return false;
   }
 }
 
-// static
-void
-IMMHandler::SetCandidateWindow(nsWindow* aWindow, CANDIDATEFORM* aForm)
-{
-  IMEContext context(aWindow);
-  ImmSetCandidateWindow(context.get(), aForm);
-}
-
-// staitc
-void
-IMMHandler::DefaultProcOfPluginEvent(nsWindow* aWindow, const NPEvent* aEvent)
-{
-  switch (aEvent->event) {
-    case WM_IME_STARTCOMPOSITION:
-      EnsureHandlerInstance();
-      gIMMHandler->OnIMEStartCompositionOnPlugin(aWindow, aEvent->wParam,
-                                                 aEvent->lParam);
-      break;
-
-    case WM_IME_COMPOSITION:
-      if (gIMMHandler) {
-        gIMMHandler->OnIMECompositionOnPlugin(aWindow, aEvent->wParam,
-                                              aEvent->lParam);
-      }
-      break;
-
-    case WM_IME_ENDCOMPOSITION:
-      if (gIMMHandler) {
-        gIMMHandler->OnIMEEndCompositionOnPlugin(aWindow, aEvent->wParam,
-                                                 aEvent->lParam);
-      }
-      break;
-  }
-}
-
 /******************************************************************************
  * IMMHandler::Selection
  ******************************************************************************/
 
 bool
 IMMHandler::Selection::IsValid() const
 {
   if (!mIsValid || NS_WARN_IF(mOffset == UINT32_MAX)) {
--- a/widget/windows/IMMHandler.h
+++ b/widget/windows/IMMHandler.h
@@ -10,17 +10,16 @@
 #include <windows.h>
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsIWidget.h"
 #include "mozilla/EventForwards.h"
 #include "nsRect.h"
 #include "WritingModes.h"
-#include "npapi.h"
 
 class nsWindow;
 
 namespace mozilla {
 namespace widget {
 
 struct MSGResult;
 
@@ -114,17 +113,17 @@ public:
   static void Terminate();
 
   // If Process*() returns true, the caller shouldn't do anything anymore.
   static bool ProcessMessage(nsWindow* aWindow, UINT msg,
                              WPARAM& wParam, LPARAM& lParam,
                              MSGResult& aResult);
   static bool IsComposing()
   {
-    return IsComposingOnOurEditor();
+    return IsComposingOnOurEditor() || IsComposingOnPlugin();
   }
   static bool IsComposingOn(nsWindow* aWindow)
   {
     return IsComposing() && IsComposingWindow(aWindow);
   }
 
 #ifdef DEBUG
   /**
@@ -146,19 +145,16 @@ public:
                                 bool aIsIMMActive);
 
   static nsIMEUpdatePreference GetIMEUpdatePreference();
 
   // Returns NS_SUCCESS_EVENT_CONSUMED if the mouse button event is consumed by
   // IME.  Otherwise, NS_OK.
   static nsresult OnMouseButtonEvent(nsWindow* aWindow,
                                      const IMENotification& aIMENotification);
-  static void SetCandidateWindow(nsWindow* aWindow, CANDIDATEFORM* aForm);
-  static void DefaultProcOfPluginEvent(nsWindow* aWindow,
-                                       const NPEvent* aEvent);
 
 protected:
   static void EnsureHandlerInstance();
 
   static bool IsComposingOnOurEditor();
   static bool IsComposingOnPlugin();
   static bool IsComposingWindow(nsWindow* aWindow);
 
@@ -179,36 +175,37 @@ protected:
   static bool IsTopLevelWindowOfComposition(nsWindow* aWindow);
 
   static bool ProcessInputLangChangeMessage(nsWindow* aWindow,
                                               WPARAM wParam,
                                               LPARAM lParam,
                                               MSGResult& aResult);
   static bool ProcessMessageForPlugin(nsWindow* aWindow, UINT msg,
                                         WPARAM &wParam, LPARAM &lParam,
-                                        bool &aRet, MSGResult& aResult);
+                                        MSGResult& aResult);
 
   IMMHandler();
   ~IMMHandler();
 
   // On*() methods return true if the caller of message handler shouldn't do
   // anything anymore.  Otherwise, false.
   static bool OnKeyDownEvent(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
                              MSGResult& aResult);
 
   bool OnIMEStartComposition(nsWindow* aWindow, MSGResult& aResult);
-  void OnIMEStartCompositionOnPlugin(nsWindow* aWindow,
-                                     WPARAM wParam, LPARAM lParam);
+  bool OnIMEStartCompositionOnPlugin(nsWindow* aWindow,
+                                     WPARAM wParam, LPARAM lParam,
+                                     MSGResult& aResult);
   bool OnIMEComposition(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
                         MSGResult& aResult);
-  void OnIMECompositionOnPlugin(nsWindow* aWindow, WPARAM wParam,
-                                LPARAM lParam);
+  bool OnIMECompositionOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
+                                MSGResult& aResult);
   bool OnIMEEndComposition(nsWindow* aWindow, MSGResult& aResult);
-  void OnIMEEndCompositionOnPlugin(nsWindow* aWindow, WPARAM wParam,
-                                   LPARAM lParam);
+  bool OnIMEEndCompositionOnPlugin(nsWindow* aWindow, WPARAM wParam,
+                                   LPARAM lParam, MSGResult& aResult);
   bool OnIMERequest(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
                     MSGResult& aResult);
   bool OnIMECharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
                          MSGResult& aResult);
   bool OnChar(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
               MSGResult& aResult);
   bool OnCharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
                       MSGResult& aResult);
@@ -324,18 +321,17 @@ protected:
                             DWORD aIndex,
                             nsAString& aCompositionString) const;
 
   /**
    * AdjustCompositionFont() makes IME vertical writing mode if it's supported.
    * If aForceUpdate is true, it will update composition font even if writing
    * mode isn't being changed.
    */
-  void AdjustCompositionFont(nsWindow* aWindow,
-                             const IMEContext& aContext,
+  void AdjustCompositionFont(const IMEContext& aContext,
                              const mozilla::WritingMode& aWritingMode,
                              bool aForceUpdate = false);
 
   /**
    * MaybeAdjustCompositionFont() calls AdjustCompositionFont() when the
    * locale of active IME is CJK.  Note that this creates an instance even
    * when there is no composition but the locale is CJK.
    */
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -943,32 +943,10 @@ IMEHandler::GetOnScreenKeyboardWindow()
   const wchar_t kOSKClassName[] = L"IPTip_Main_Window";
   HWND osk = ::FindWindowW(kOSKClassName, nullptr);
   if (::IsWindow(osk) && ::IsWindowEnabled(osk)) {
     return osk;
   }
   return nullptr;
 }
 
-// static
-void
-IMEHandler::SetCandidateWindow(nsWindow* aWindow, CANDIDATEFORM* aForm)
-{
-  if (!sPluginHasFocus) {
-    return;
-  }
-
-  IMMHandler::SetCandidateWindow(aWindow, aForm);
-}
-
-// static
-void
-IMEHandler::DefaultProcOfPluginEvent(nsWindow* aWindow,
-                                     const NPEvent* aPluginEvent)
-{
-  if (!sPluginHasFocus) {
-    return;
-  }
-  IMMHandler::DefaultProcOfPluginEvent(aWindow, aPluginEvent);
-}
-
 } // namespace widget
 } // namespace mozilla
--- a/widget/windows/WinIMEHandler.h
+++ b/widget/windows/WinIMEHandler.h
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WinIMEHandler_h_
 #define WinIMEHandler_h_
 
 #include "nscore.h"
 #include "nsIWidget.h"
-#include "npapi.h"
 #include <windows.h>
 #include <inputscope.h>
 
 #define NS_WM_IMEFIRST WM_IME_SETCONTEXT
 #define NS_WM_IMELAST  WM_IME_KEYUP
 
 class nsWindow;
 
@@ -99,27 +98,16 @@ public:
    */
   static void AssociateIMEContext(nsWindow* aWindow, bool aEnable);
 
   /**
    * Called when the window is created.
    */
   static void InitInputContext(nsWindow* aWindow, InputContext& aInputContext);
 
-  /*
-   * For windowless plugin helper.
-   */
-  static void SetCandidateWindow(nsWindow* aWindow, CANDIDATEFORM* aForm);
-
-  /*
-   * For WM_IME_*COMPOSITION messages and e10s with windowless plugin
-   */
-  static void DefaultProcOfPluginEvent(nsWindow* aWindow,
-                                       const NPEvent* aPluginEvent);
-
 #ifdef DEBUG
   /**
    * Returns true when current keyboard layout has IME.  Otherwise, false.
    */
   static bool CurrentKeyboardLayoutHasIME();
 #endif // #ifdef DEBUG
 
 private:
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -7746,49 +7746,16 @@ nsWindow::ComputeShouldAccelerate()
   if (mTransparencyMode == eTransparencyTransparent ||
       (IsPopup() && gfxWindowsPlatform::GetPlatform()->IsWARP()))
   {
     return false;
   }
   return nsBaseWidget::ComputeShouldAccelerate();
 }
 
-void
-nsWindow::SetCandidateWindowForPlugin(int32_t aX, int32_t aY)
-{
-  CANDIDATEFORM form;
-  form.dwIndex = 0;
-  form.dwStyle = CFS_CANDIDATEPOS;
-  form.ptCurrentPos.x = aX;
-  form.ptCurrentPos.y = aY;
-
-  IMEHandler::SetCandidateWindow(this, &form);
-}
-
-void
-nsWindow::DefaultProcOfPluginEvent(const WidgetPluginEvent& aEvent)
-{
-  const NPEvent* pPluginEvent =
-   static_cast<const NPEvent*>(aEvent.mPluginEvent);
-
-  if (NS_WARN_IF(!pPluginEvent)) {
-    return;
-  }
-
-  if (!mWnd) {
-    return;
-  }
-
-  // For WM_IME_*COMPOSITION
-  IMEHandler::DefaultProcOfPluginEvent(this, pPluginEvent);
-
-  CallWindowProcW(GetPrevWindowProc(), mWnd, pPluginEvent->event,
-                  pPluginEvent->wParam, pPluginEvent->lParam);
-}
-
 /**************************************************************
  **************************************************************
  **
  ** BLOCK: ChildWindow impl.
  **
  ** Child window overrides.
  **
  **************************************************************
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -292,21 +292,16 @@ public:
 
   bool IsPopup();
   virtual bool ShouldUseOffMainThreadCompositing() override;
 
   bool CaptureWidgetOnScreen(RefPtr<mozilla::gfx::DrawTarget> aDT) override;
 
   const IMEContext& DefaultIMC() const { return mDefaultIMC; }
 
-  virtual void SetCandidateWindowForPlugin(int32_t aX,
-                                           int32_t aY) override;
-  virtual void DefaultProcOfPluginEvent(
-                 const mozilla::WidgetPluginEvent& aEvent) override;
-
 protected:
   virtual ~nsWindow();
 
   virtual void WindowUsesOMTC() override;
   virtual void RegisterTouchWindow() override;
 
   virtual nsresult NotifyIMEInternal(
                      const IMENotification& aIMENotification) override;
--- a/widget/windows/nsWindowBase.h
+++ b/widget/windows/nsWindowBase.h
@@ -73,16 +73,24 @@ public:
   virtual bool DispatchContentCommandEvent(mozilla::WidgetContentCommandEvent* aEvent) = 0;
 
   /*
    * Default dispatch of a plugin event.
    */
   virtual bool DispatchPluginEvent(const MSG& aMsg);
 
   /*
+   * Returns true if a plugin has focus on this widget.  Otherwise, false.
+   */
+  virtual bool PluginHasFocus() const final
+  {
+    return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN);
+  }
+
+  /*
    * Touch input injection apis
    */
   virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
                                               TouchPointerState aPointerState,
                                               ScreenIntPoint aPointerScreenPoint,
                                               double aPointerPressure,
                                               uint32_t aPointerOrientation,
                                               nsIObserver* aObserver) override;
--- a/xpcom/build/nsWindowsDllInterceptor.h
+++ b/xpcom/build/nsWindowsDllInterceptor.h
@@ -94,17 +94,17 @@ private:
   size_t const mSize;
   DWORD const mNewProtect;
   DWORD mOldProtect;
   bool mSuccess;
 };
 
 class WindowsDllNopSpacePatcher
 {
-  typedef uint8_t* byteptr_t;
+  typedef unsigned char* byteptr_t;
   HMODULE mModule;
 
   // Dumb array for remembering the addresses of functions we've patched.
   // (This should be nsTArray, but non-XPCOM code uses this class.)
   static const size_t maxPatchedFns = 128;
   byteptr_t mPatchedFns[maxPatchedFns];
   int mPatchedFnsLen;
 
@@ -366,91 +366,31 @@ protected:
   const static int kPageSize = 4096;
   const static int kHookSize = 128;
 
   HMODULE mModule;
   byteptr_t mHookPage;
   int mMaxHooks;
   int mCurHooks;
 
-#if defined(_M_X64)
-  // To patch for JMP and JE
-
-  enum JumpType {
-   Je,
-   Jmp
-  };
-
-  struct JumpPatch {
-    JumpPatch()
-      : mHookOffset(0), mJumpAddress(0), mType(JumpType::Jmp)
-    {
-    }
-
-    JumpPatch(size_t aOffset, intptr_t aAddress, JumpType aType = JumpType::Jmp)
-      : mHookOffset(aOffset), mJumpAddress(aAddress), mType(aType)
-    {
-    }
-
-    void AddJumpPatch(size_t aHookOffset, intptr_t aAbsJumpAddress,
-                     JumpType aType = JumpType::Jmp)
-    {
-      mHookOffset = aHookOffset;
-      mJumpAddress = aAbsJumpAddress;
-      mType = aType;
-    }
-
-    size_t GenerateJump(uint8_t* aCode)
-    {
-      size_t offset = mHookOffset;
-      if (mType == JumpType::Je) {
-        // JNE RIP+14
-        aCode[offset]     = 0x75;
-        aCode[offset + 1] = 14;
-        offset += 2;
-      }
-
-      // JMP [RIP+0]
-      aCode[offset] = 0xff;
-      aCode[offset + 1] = 0x25;
-      *reinterpret_cast<int32_t*>(aCode + offset + 2) = 0;
-
-      // Jump table
-      *reinterpret_cast<int64_t*>(aCode + offset + 2 + 4) = mJumpAddress;
-
-      return offset + 2 + 4 + 8;
-    }
-
-    bool HasJumpPatch() const
-    {
-      return !!mJumpAddress;
-    }
-
-    size_t mHookOffset;
-    intptr_t mJumpAddress;
-    JumpType mType;
-  };
-
-#endif
-
   void CreateTrampoline(void* aOrigFunction, intptr_t aDest, void** aOutTramp)
   {
     *aOutTramp = nullptr;
 
     byteptr_t tramp = FindTrampolineSpace();
     if (!tramp) {
       return;
     }
 
     byteptr_t origBytes = (byteptr_t)aOrigFunction;
 
     int nBytes = 0;
+    int pJmp32 = -1;
 
 #if defined(_M_IX86)
-    int pJmp32 = -1;
     while (nBytes < 5) {
       // Understand some simple instructions that might be found in a
       // prologue; we might need to extend this as necessary.
       //
       // Note!  If we ever need to understand jump instructions, we'll
       // need to rewrite the displacement argument.
       if (origBytes[nBytes] >= 0x88 && origBytes[nBytes] <= 0x8B) {
         // various MOVs
@@ -502,22 +442,22 @@ protected:
         // jmp [disp32]
         nBytes += 6;
       } else {
         //printf ("Unknown x86 instruction byte 0x%02x, aborting trampoline\n", origBytes[nBytes]);
         return;
       }
     }
 #elif defined(_M_X64)
-    JumpPatch jump;
+    byteptr_t directJmpAddr;
 
     while (nBytes < 13) {
 
       // if found JMP 32bit offset, next bytes must be NOP or INT3
-      if (jump.HasJumpPatch()) {
+      if (pJmp32 >= 0) {
         if (origBytes[nBytes] == 0x90 || origBytes[nBytes] == 0xcc) {
           nBytes++;
           continue;
         }
         return;
       }
       if (origBytes[nBytes] == 0x0f) {
         nBytes++;
@@ -528,25 +468,16 @@ protected:
               (origBytes[nBytes] & 0x7) == 0x04) {
             nBytes += 3;
           } else {
             return;
           }
         } else if (origBytes[nBytes] == 0x05) {
           // syscall
           nBytes++;
-        } else if (origBytes[nBytes] == 0x84) {
-          // je rel32
-          jump.AddJumpPatch(nBytes - 1,
-                            (intptr_t)
-                              origBytes + nBytes + 5 +
-                            *(reinterpret_cast<int32_t*>(origBytes +
-                                                         nBytes + 1)),
-                            JumpType::Je);
-          nBytes += 5;
         } else {
           return;
         }
       } else if (origBytes[nBytes] == 0x40 ||
                  origBytes[nBytes] == 0x41) {
         // Plain REX or REX.B
         nBytes++;
 
@@ -580,23 +511,16 @@ protected:
         } else if (origBytes[nBytes] == 0x83 &&
                    (origBytes[nBytes + 1] & 0xf8) == 0xe8) {
           // sub r, byte
           nBytes += 3;
         } else if (origBytes[nBytes] == 0x83 &&
                    (origBytes[nBytes + 1] & 0xf8) == 0x60) {
           // and [r+d], imm8
           nBytes += 5;
-        } else if (origBytes[nBytes] == 0x85) {
-          // 85 /r => TEST r/m32, r32
-          if ((origBytes[nBytes + 1] & 0xc0) == 0xc0) {
-            nBytes += 2;
-          } else {
-            return;
-          }
         } else if ((origBytes[nBytes] & 0xfd) == 0x89) {
           // MOV r/m64, r64 | MOV r64, r/m64
           if ((origBytes[nBytes + 1] & 0xc0) == 0x40) {
             if ((origBytes[nBytes + 1] & 0x7) == 0x04) {
               // R/M=[SIB+disp8], REG=r64
               nBytes += 4;
             } else {
               // R/M=[r64+disp8], REG=r64
@@ -617,26 +541,25 @@ protected:
           if (origBytes[nBytes + 1] == 0x44) {
             // MOV [r64+disp8], imm32
             // ModR/W + SIB + disp8 + imm32
             nBytes += 8;
           } else {
             return;
           }
         } else if (origBytes[nBytes] == 0xff) {
+          pJmp32 = nBytes - 1;
           // JMP /4
           if ((origBytes[nBytes + 1] & 0xc0) == 0x0 &&
               (origBytes[nBytes + 1] & 0x07) == 0x5) {
             // [rip+disp32]
             // convert JMP 32bit offset to JMP 64bit direct
-            jump.AddJumpPatch(nBytes - 1,
-                              *reinterpret_cast<intptr_t*>(
-                                origBytes + nBytes + 6 +
-                              *reinterpret_cast<int32_t*>(origBytes + nBytes +
-                                                          2)));
+            directJmpAddr =
+              (byteptr_t)*((uint64_t*)(origBytes + nBytes + 6 +
+                                       (*((int32_t*)(origBytes + nBytes + 2)))));
             nBytes += 6;
           } else {
             // not support yet!
             return;
           }
         } else {
           // not support yet!
           return;
@@ -648,26 +571,21 @@ protected:
         // nop
         nBytes++;
       } else if (origBytes[nBytes] == 0xb8) {
         // MOV 0xB8: http://ref.x86asm.net/coder32.html#xB8
         nBytes += 5;
       } else if (origBytes[nBytes] == 0xc3) {
         // ret
         nBytes++;
-      } else if (origBytes[nBytes] == 0xcc) {
-        // int 3
-        nBytes++;
       } else if (origBytes[nBytes] == 0xe9) {
+        pJmp32 = nBytes;
+        // convert JMP 32bit offset to JMP 64bit direct
+        directJmpAddr = origBytes + pJmp32 + 5 + (*((int32_t*)(origBytes + pJmp32 + 1)));
         // jmp 32bit offset
-        jump.AddJumpPatch(nBytes,
-                          // convert JMP 32bit offset to JMP 64bit direct
-                          (intptr_t)
-                            origBytes + nBytes + 5 +
-                          *(reinterpret_cast<int32_t*>(origBytes + nBytes + 1)));
         nBytes += 5;
       } else if (origBytes[nBytes] == 0xff) {
         nBytes++;
         if ((origBytes[nBytes] & 0xf8) == 0xf0) {
           // push r64
           nBytes++;
         } else {
           return;
@@ -702,26 +620,37 @@ protected:
       // Adjust jump target displacement to jump location in the trampoline.
       *((intptr_t*)(tramp + pJmp32 + 1)) += origBytes - tramp;
     } else {
       tramp[nBytes] = 0xE9; // jmp
       *((intptr_t*)(tramp + nBytes + 1)) =
         (intptr_t)trampDest - (intptr_t)(tramp + nBytes + 5); // target displacement
     }
 #elif defined(_M_X64)
-    // If JMP/JE opcode found, we don't insert to trampoline jump
-    if (jump.HasJumpPatch()) {
-      size_t offset = jump.GenerateJump(tramp);
-      if (jump.mType != JumpType::Jmp) {
-        JumpPatch patch(offset, reinterpret_cast<intptr_t>(trampDest));
-        patch.GenerateJump(tramp);
-      }
+    // If JMP32 opcode found, we don't insert to trampoline jump
+    if (pJmp32 >= 0) {
+      // mov r11, address
+      tramp[pJmp32]   = 0x49;
+      tramp[pJmp32 + 1] = 0xbb;
+      *((intptr_t*)(tramp + pJmp32 + 2)) = (intptr_t)directJmpAddr;
+
+      // jmp r11
+      tramp[pJmp32 + 10] = 0x41;
+      tramp[pJmp32 + 11] = 0xff;
+      tramp[pJmp32 + 12] = 0xe3;
     } else {
-      JumpPatch patch(nBytes, reinterpret_cast<intptr_t>(trampDest));
-      patch.GenerateJump(tramp);
+      // mov r11, address
+      tramp[nBytes] = 0x49;
+      tramp[nBytes + 1] = 0xbb;
+      *((intptr_t*)(tramp + nBytes + 2)) = (intptr_t)trampDest;
+
+      // jmp r11
+      tramp[nBytes + 10] = 0x41;
+      tramp[nBytes + 11] = 0xff;
+      tramp[nBytes + 12] = 0xe3;
     }
 #endif
 
     // The trampoline is now valid.
     *aOutTramp = tramp;
 
     // ensure we can modify the original code
     AutoVirtualProtect protect(aOrigFunction, nBytes, PAGE_EXECUTE_READWRITE);