Bug 920377 part.23 Get rid of nsQueryContentEvent r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 01 Oct 2013 16:23:00 +0900
changeset 149432 d0b1a13f856d40b5e75505210d57151f8565d203
parent 149431 d569f145443df13c10894dec9b0baa82560848b5
child 149433 43bc4b6c0535890dad6dcedce94edb9b0093fe7e
push id25389
push userryanvm@gmail.com
push dateTue, 01 Oct 2013 20:35:30 +0000
treeherdermozilla-central@4364824a4cab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs920377
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 920377 part.23 Get rid of nsQueryContentEvent r=roc
content/events/src/TextComposition.cpp
content/events/src/nsContentEventHandler.cpp
content/events/src/nsContentEventHandler.h
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
dom/base/nsDOMWindowUtils.cpp
dom/base/nsQueryContentEventResult.cpp
dom/base/nsQueryContentEventResult.h
dom/ipc/PBrowser.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/EventForwards.h
widget/TextEvents.h
widget/android/nsWindow.cpp
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/cocoa/nsChildView.mm
widget/gtk/nsGtkIMModule.cpp
widget/nsGUIEventIPC.h
widget/os2/nsWindow.cpp
widget/windows/nsIMM32Handler.cpp
widget/windows/nsTextStore.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/content/events/src/TextComposition.cpp
+++ b/content/events/src/TextComposition.cpp
@@ -110,17 +110,18 @@ TextComposition::CompositionEventDispatc
       mPresContext->GetPresShell()->IsDestroying()) {
     return NS_OK; // cannot dispatch any events anymore
   }
 
   nsEventStatus status = nsEventStatus_eIgnore;
   switch (mEventMessage) {
     case NS_COMPOSITION_START: {
       WidgetCompositionEvent compStart(true, NS_COMPOSITION_START, mWidget);
-      nsQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT, mWidget);
+      WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
+                                           mWidget);
       nsContentEventHandler handler(mPresContext);
       handler.OnQuerySelectedText(&selectedText);
       NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text");
       compStart.data = selectedText.mReply.mString;
       nsIMEStateManager::DispatchCompositionEvent(mEventTarget, mPresContext,
                                                   &compStart, &status, nullptr);
       break;
     }
--- a/content/events/src/nsContentEventHandler.cpp
+++ b/content/events/src/nsContentEventHandler.cpp
@@ -80,17 +80,17 @@ nsContentEventHandler::InitCommon()
                "mFirstSelectedRange crosses the document boundary");
 
   mRootContent = startNode->GetSelectionRootContent(mPresShell);
   NS_ENSURE_TRUE(mRootContent, NS_ERROR_FAILURE);
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::Init(nsQueryContentEvent* aEvent)
+nsContentEventHandler::Init(WidgetQueryContentEvent* aEvent)
 {
   NS_ASSERTION(aEvent, "aEvent must not be null");
 
   nsresult rv = InitCommon();
   NS_ENSURE_SUCCESS(rv, rv);
 
   aEvent->mSucceeded = false;
 
@@ -470,17 +470,17 @@ nsContentEventHandler::SetRangeFromFlatT
     }
   }
   rv = aRange->SetEnd(domNode, int32_t(mRootContent->GetChildCount()));
   NS_ASSERTION(NS_SUCCEEDED(rv), "nsIDOMRange::SetEnd failed");
   return rv;
 }
 
 nsresult
-nsContentEventHandler::OnQuerySelectedText(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   NS_ASSERTION(aEvent->mReply.mString.IsEmpty(),
                "The reply string must be empty");
 
@@ -513,17 +513,17 @@ nsContentEventHandler::OnQuerySelectedTe
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryTextContent(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryTextContent(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   NS_ASSERTION(aEvent->mReply.mString.IsEmpty(),
                "The reply string must be empty");
 
@@ -574,17 +574,17 @@ static nsresult GetFrameForTextRect(nsIN
   nsIFrame* frame = content->GetPrimaryFrame();
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
   int32_t childOffset = 0;
   return frame->GetChildFrameContainingOffset(aOffset, aHint, &childOffset,
                                               aReturnFrame);
 }
 
 nsresult
-nsContentEventHandler::OnQueryTextRect(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryTextRect(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   nsRefPtr<nsRange> range = new nsRange(mRootContent);
   rv = SetRangeFromFlatTextOffset(range, aEvent->mInput.mOffset,
                                   aEvent->mInput.mLength, true,
@@ -664,17 +664,17 @@ nsContentEventHandler::OnQueryTextRect(n
   }
   aEvent->mReply.mRect =
       rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryEditorRect(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryEditorRect(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   nsIFrame* frame = mRootContent->GetPrimaryFrame();
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
 
@@ -693,17 +693,17 @@ nsContentEventHandler::OnQueryEditorRect
 
   aEvent->mReply.mRect =
       resultRect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
   NS_ASSERTION(caret, "GetCaret returned null");
 
@@ -765,29 +765,30 @@ nsContentEventHandler::OnQueryCaretRect(
 
   aEvent->mReply.mRect =
       rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryContentState(nsQueryContentEvent * aEvent)
+nsContentEventHandler::OnQueryContentState(WidgetQueryContentEvent * aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
   
   aEvent->mSucceeded = true;
 
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQuerySelectionAsTransferable(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQuerySelectionAsTransferable(
+                         WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   if (!aEvent->mReply.mHasSelection) {
     aEvent->mSucceeded = true;
     aEvent->mReply.mTransferable = nullptr;
@@ -800,17 +801,17 @@ nsContentEventHandler::OnQuerySelectionA
   rv = nsCopySupport::GetTransferableForSelection(mSelection, doc, getter_AddRefs(aEvent->mReply.mTransferable));
   NS_ENSURE_SUCCESS(rv, rv);
 
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   nsIFrame* rootFrame = mPresShell->GetRootFrame();
   NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
   nsIWidget* rootWidget = rootFrame->GetNearestWidget();
@@ -823,33 +824,33 @@ nsContentEventHandler::OnQueryCharacterA
     nsView* view = nsView::GetViewFor(aEvent->widget);
     NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
     rootFrame = view->GetFrame();
     NS_ENSURE_TRUE(rootFrame, NS_ERROR_FAILURE);
     rootWidget = rootFrame->GetNearestWidget();
     NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE);
   }
 
-  nsQueryContentEvent eventOnRoot(true, NS_QUERY_CHARACTER_AT_POINT,
-                                  rootWidget);
+  WidgetQueryContentEvent eventOnRoot(true, NS_QUERY_CHARACTER_AT_POINT,
+                                      rootWidget);
   eventOnRoot.refPoint = aEvent->refPoint;
   if (rootWidget != aEvent->widget) {
     eventOnRoot.refPoint += LayoutDeviceIntPoint::FromUntyped(
       aEvent->widget->WidgetToScreenOffset() - rootWidget->WidgetToScreenOffset());
   }
   nsPoint ptInRoot =
     nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame);
 
   nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
   if (!targetFrame || targetFrame->GetType() != nsGkAtoms::textFrame ||
       !targetFrame->GetContent() ||
       !nsContentUtils::ContentIsDescendantOf(targetFrame->GetContent(),
                                              mRootContent)) {
     // there is no character at the point.
-    aEvent->mReply.mOffset = nsQueryContentEvent::NOT_FOUND;
+    aEvent->mReply.mOffset = WidgetQueryContentEvent::NOT_FOUND;
     aEvent->mSucceeded = true;
     return NS_OK;
   }
   nsPoint ptInTarget = ptInRoot + rootFrame->GetOffsetToCrossDoc(targetFrame);
   int32_t rootAPD = rootFrame->PresContext()->AppUnitsPerDevPixel();
   int32_t targetAPD = targetFrame->PresContext()->AppUnitsPerDevPixel();
   ptInTarget = ptInTarget.ConvertAppUnits(rootAPD, targetAPD);
 
@@ -857,31 +858,31 @@ nsContentEventHandler::OnQueryCharacterA
   nsIFrame::ContentOffsets offsets =
     textframe->GetCharacterOffsetAtFramePoint(ptInTarget);
   NS_ENSURE_TRUE(offsets.content, NS_ERROR_FAILURE);
   uint32_t nativeOffset;
   rv = GetFlatTextOffsetOfRange(mRootContent, offsets.content, offsets.offset,
                                 &nativeOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsQueryContentEvent textRect(true, NS_QUERY_TEXT_RECT, aEvent->widget);
+  WidgetQueryContentEvent textRect(true, NS_QUERY_TEXT_RECT, aEvent->widget);
   textRect.InitForQueryTextRect(nativeOffset, 1);
   rv = OnQueryTextRect(&textRect);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(textRect.mSucceeded, NS_ERROR_FAILURE);
 
   // currently, we don't need to get the actual text.
   aEvent->mReply.mOffset = nativeOffset;
   aEvent->mReply.mRect = textRect.mReply.mRect;
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::OnQueryDOMWidgetHittest(nsQueryContentEvent* aEvent)
+nsContentEventHandler::OnQueryDOMWidgetHittest(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
   if (NS_FAILED(rv))
     return rv;
 
   aEvent->mReply.mWidgetIsHit = false;
 
   NS_ENSURE_TRUE(aEvent->widget, NS_ERROR_FAILURE);
--- a/content/events/src/nsContentEventHandler.h
+++ b/content/events/src/nsContentEventHandler.h
@@ -25,45 +25,46 @@ struct nsRect;
  *   This class answers to NS_QUERY_* events from actual contents.
  */
 
 class MOZ_STACK_CLASS nsContentEventHandler {
 public:
   nsContentEventHandler(nsPresContext *aPresContext);
 
   // NS_QUERY_SELECTED_TEXT event handler
-  nsresult OnQuerySelectedText(nsQueryContentEvent* aEvent);
+  nsresult OnQuerySelectedText(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_TEXT_CONTENT event handler
-  nsresult OnQueryTextContent(nsQueryContentEvent* aEvent);
+  nsresult OnQueryTextContent(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_CARET_RECT event handler
-  nsresult OnQueryCaretRect(nsQueryContentEvent* aEvent);
+  nsresult OnQueryCaretRect(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_TEXT_RECT event handler
-  nsresult OnQueryTextRect(nsQueryContentEvent* aEvent);
+  nsresult OnQueryTextRect(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_EDITOR_RECT event handler
-  nsresult OnQueryEditorRect(nsQueryContentEvent* aEvent);
+  nsresult OnQueryEditorRect(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_CONTENT_STATE event handler
-  nsresult OnQueryContentState(nsQueryContentEvent* aEvent);
+  nsresult OnQueryContentState(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_SELECTION_AS_TRANSFERABLE event handler
-  nsresult OnQuerySelectionAsTransferable(nsQueryContentEvent* aEvent);
+  nsresult OnQuerySelectionAsTransferable(
+             mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_CHARACTER_AT_POINT event handler
-  nsresult OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent);
+  nsresult OnQueryCharacterAtPoint(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_DOM_WIDGET_HITTEST event handler
-  nsresult OnQueryDOMWidgetHittest(nsQueryContentEvent* aEvent);
+  nsresult OnQueryDOMWidgetHittest(mozilla::WidgetQueryContentEvent* aEvent);
 
   // NS_SELECTION_* event
   nsresult OnSelectionEvent(nsSelectionEvent* aEvent);
 
 protected:
   nsPresContext* mPresContext;
   nsCOMPtr<nsIPresShell> mPresShell;
   nsCOMPtr<nsISelection> mSelection;
   nsRefPtr<nsRange> mFirstSelectedRange;
   nsCOMPtr<nsIContent> mRootContent;
 
-  nsresult Init(nsQueryContentEvent* aEvent);
+  nsresult Init(mozilla::WidgetQueryContentEvent* aEvent);
   nsresult Init(nsSelectionEvent* aEvent);
 
   // InitCommon() is called from each Init().
   nsresult InitCommon();
 
 public:
   // FlatText means the text that is generated from DOM tree. The BR elements
   // are replaced to native linefeeds. Other elements are ignored.
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -987,73 +987,76 @@ nsEventStateManager::PreHandleEvent(nsPr
       // on some platforms which might dispatch wheel events which don't have
       // lineOrPageDelta values.  And also, if delta values are customized by
       // prefs, this recomputes them.
       DeltaAccumulator::GetInstance()->
         InitLineOrPageDelta(aTargetFrame, this, wheelEvent);
     }
     break;
   case NS_QUERY_SELECTED_TEXT:
-    DoQuerySelectedText(static_cast<nsQueryContentEvent*>(aEvent));
+    DoQuerySelectedText(static_cast<WidgetQueryContentEvent*>(aEvent));
     break;
   case NS_QUERY_TEXT_CONTENT:
     {
       if (RemoteQueryContentEvent(aEvent))
         break;
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryTextContent((nsQueryContentEvent*)aEvent);
+      handler.OnQueryTextContent(static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_CARET_RECT:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryCaretRect((nsQueryContentEvent*)aEvent);
+      handler.OnQueryCaretRect(static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_TEXT_RECT:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryTextRect((nsQueryContentEvent*)aEvent);
+      handler.OnQueryTextRect(static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_EDITOR_RECT:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryEditorRect((nsQueryContentEvent*)aEvent);
+      handler.OnQueryEditorRect(static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_CONTENT_STATE:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryContentState(static_cast<nsQueryContentEvent*>(aEvent));
+      handler.OnQueryContentState(static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_SELECTION_AS_TRANSFERABLE:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQuerySelectionAsTransferable(static_cast<nsQueryContentEvent*>(aEvent));
+      handler.OnQuerySelectionAsTransferable(
+        static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_CHARACTER_AT_POINT:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryCharacterAtPoint(static_cast<nsQueryContentEvent*>(aEvent));
+      handler.OnQueryCharacterAtPoint(
+        static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_QUERY_DOM_WIDGET_HITTEST:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
-      handler.OnQueryDOMWidgetHittest(static_cast<nsQueryContentEvent*>(aEvent));
+      handler.OnQueryDOMWidgetHittest(
+        static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_SELECTION_SET:
     {
       nsSelectionEvent *selectionEvent =
           static_cast<nsSelectionEvent*>(aEvent);
       if (IsTargetCrossProcess(selectionEvent)) {
         // Will not be handled locally, remote the event
@@ -1095,18 +1098,18 @@ nsEventStateManager::PreHandleEvent(nsPr
     }
     break;
   case NS_COMPOSITION_START:
     if (aEvent->mFlags.mIsTrusted) {
       // If the event is trusted event, set the selected text to data of
       // composition event.
       WidgetCompositionEvent *compositionEvent =
         static_cast<WidgetCompositionEvent*>(aEvent);
-      nsQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
-                                       compositionEvent->widget);
+      WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
+                                           compositionEvent->widget);
       DoQuerySelectedText(&selectedText);
       NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text");
       compositionEvent->data = selectedText.mReply.mString;
     }
     // through to compositionend handling
   case NS_COMPOSITION_UPDATE:
   case NS_COMPOSITION_END:
     {
@@ -3443,18 +3446,18 @@ nsEventStateManager::PostHandleEvent(nsP
   mCurrentTargetContent = nullptr;
 
   return ret;
 }
 
 bool
 nsEventStateManager::RemoteQueryContentEvent(nsEvent *aEvent)
 {
-  nsQueryContentEvent *queryEvent =
-      static_cast<nsQueryContentEvent*>(aEvent);
+  WidgetQueryContentEvent *queryEvent =
+      static_cast<WidgetQueryContentEvent*>(aEvent);
   if (!IsTargetCrossProcess(queryEvent)) {
     return false;
   }
   // Will not be handled locally, remote the event
   GetCrossProcessTarget()->HandleQueryContentEvent(*queryEvent);
   return true;
 }
 
@@ -5043,17 +5046,17 @@ nsEventStateManager::DoContentCommandScr
   }
 
   // The caller may want synchronous scrolling.
   sf->ScrollBy(pt, scrollUnit, nsIScrollableFrame::INSTANT);
   return NS_OK;
 }
 
 void
-nsEventStateManager::DoQuerySelectedText(nsQueryContentEvent* aEvent)
+nsEventStateManager::DoQuerySelectedText(WidgetQueryContentEvent* aEvent)
 {
   if (RemoteQueryContentEvent(aEvent)) {
     return;
   }
   nsContentEventHandler handler(mPresContext);
   handler.OnQuerySelectedText(aEvent);
 }
 
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -704,17 +704,17 @@ protected:
    * mCurrentTarget->GetNearestWidget().
    */
   void FillInEventFromGestureDown(nsMouseEvent* aEvent);
 
   nsresult DoContentCommandEvent(mozilla::WidgetContentCommandEvent* aEvent);
   nsresult DoContentCommandScrollEvent(
              mozilla::WidgetContentCommandEvent* aEvent);
 
-  void DoQuerySelectedText(nsQueryContentEvent* aEvent);
+  void DoQuerySelectedText(mozilla::WidgetQueryContentEvent* aEvent);
 
   bool RemoteQueryContentEvent(nsEvent *aEvent);
   mozilla::dom::TabParent *GetCrossProcessTarget();
   bool IsTargetCrossProcess(nsGUIEvent *aEvent);
 
   bool DispatchCrossProcessEvent(nsEvent* aEvent, nsFrameLoader* remote,
                                  nsEventStatus *aStatus);
   bool HandleCrossProcessEvent(nsEvent *aEvent,
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1896,17 +1896,17 @@ nsDOMWindowUtils::SendQueryContentEvent(
     return NS_ERROR_INVALID_ARG;
   }
 
   nsCOMPtr<nsIWidget> targetWidget = widget;
   LayoutDeviceIntPoint pt(aX, aY);
 
   if (aType == QUERY_CHARACTER_AT_POINT) {
     // Looking for the widget at the point.
-    nsQueryContentEvent dummyEvent(true, NS_QUERY_CONTENT_STATE, widget);
+    WidgetQueryContentEvent dummyEvent(true, NS_QUERY_CONTENT_STATE, widget);
     InitEvent(dummyEvent, &pt);
     nsIFrame* popupFrame =
       nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
 
     nsIntRect widgetBounds;
     nsresult rv = widget->GetClientBounds(widgetBounds);
     NS_ENSURE_SUCCESS(rv, rv);
     widgetBounds.MoveTo(0, 0);
@@ -1921,17 +1921,17 @@ nsDOMWindowUtils::SendQueryContentEvent(
     if (popupFrame) {
       targetWidget = popupFrame->GetNearestWidget();
     }
   }
 
   pt += LayoutDeviceIntPoint::FromUntyped(
     widget->WidgetToScreenOffset() - targetWidget->WidgetToScreenOffset());
 
-  nsQueryContentEvent queryEvent(true, aType, targetWidget);
+  WidgetQueryContentEvent queryEvent(true, aType, targetWidget);
   InitEvent(queryEvent, &pt);
 
   switch (aType) {
     case NS_QUERY_TEXT_CONTENT:
       queryEvent.InitForQueryTextContent(aOffset, aLength);
       break;
     case NS_QUERY_CARET_RECT:
       queryEvent.InitForQueryCaretRect(aOffset);
--- a/dom/base/nsQueryContentEventResult.cpp
+++ b/dom/base/nsQueryContentEventResult.cpp
@@ -3,16 +3,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsQueryContentEventResult.h"
 #include "nsIWidget.h"
 #include "nsPoint.h"
 #include "mozilla/TextEvents.h"
 
+using namespace mozilla;
+
 NS_INTERFACE_MAP_BEGIN(nsQueryContentEventResult)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIQueryContentEventResult)
   NS_INTERFACE_MAP_ENTRY(nsIQueryContentEventResult)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsQueryContentEventResult)
 NS_IMPL_RELEASE(nsQueryContentEventResult)
 
@@ -115,23 +117,23 @@ nsQueryContentEventResult::GetSucceeded(
 
 NS_IMETHODIMP
 nsQueryContentEventResult::GetNotFound(bool *aNotFound)
 {
   NS_ENSURE_TRUE(mSucceeded, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mEventID == NS_QUERY_SELECTED_TEXT ||
                  mEventID == NS_QUERY_CHARACTER_AT_POINT,
                  NS_ERROR_NOT_AVAILABLE);
-  *aNotFound = (mOffset == nsQueryContentEvent::NOT_FOUND);
+  *aNotFound = (mOffset == WidgetQueryContentEvent::NOT_FOUND);
   return NS_OK;
 }
 
 void
 nsQueryContentEventResult::SetEventResult(nsIWidget* aWidget,
-                                          const nsQueryContentEvent &aEvent)
+                                          const WidgetQueryContentEvent &aEvent)
 {
   mEventID = aEvent.message;
   mSucceeded = aEvent.mSucceeded;
   mReversed = aEvent.mReply.mReversed;
   mRect = aEvent.mReply.mRect;
   mOffset = aEvent.mReply.mOffset;
   mString = aEvent.mReply.mString;
 
--- a/dom/base/nsQueryContentEventResult.h
+++ b/dom/base/nsQueryContentEventResult.h
@@ -14,17 +14,18 @@ class nsIWidget;
 class nsQueryContentEventResult MOZ_FINAL : public nsIQueryContentEventResult
 {
 public:
   nsQueryContentEventResult();
   ~nsQueryContentEventResult();
   NS_DECL_ISUPPORTS
   NS_DECL_NSIQUERYCONTENTEVENTRESULT
 
-  void SetEventResult(nsIWidget* aWidget, const nsQueryContentEvent &aEvent);
+  void SetEventResult(nsIWidget* aWidget,
+                      const mozilla::WidgetQueryContentEvent &aEvent);
 
 protected:
   uint32_t mEventID;
 
   uint32_t mOffset;
   nsString mString;
   nsIntRect mRect;
 
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -40,17 +40,16 @@ using mozilla::WidgetCompositionEvent;
 using nsIMEUpdatePreference;
 using nsIntPoint;
 using nsIntRect;
 using nsIntSize;
 using mozilla::WidgetKeyboardEvent;
 using nsMouseEvent;
 using nsMouseScrollEvent;
 using mozilla::WheelEvent;
-using nsQueryContentEvent;
 using nsRect;
 using nsSelectionEvent;
 using mozilla::WidgetTextEvent;
 using mozilla::WidgetTouchEvent;
 using RemoteDOMEvent;
 using mozilla::dom::ScreenOrientation;
 using mozilla::layers::TextureFactoryIdentifier;
 using mozilla::CSSIntPoint;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -927,17 +927,17 @@ TabParent::RecvRequestFocus(const bool& 
  * For NS_QUERY_TEXT_CONTENT, fail only if the cache doesn't overlap with
  *  the queried range. Note the difference from above. We use
  *  this behavior because a normal NS_QUERY_TEXT_CONTENT event is allowed to
  *  have out-of-bounds offsets, so that widget can request content without
  *  knowing the exact length of text. It's up to widget to handle cases when
  *  the returned offset/length are different from the queried offset/length.
  */
 bool
-TabParent::HandleQueryContentEvent(nsQueryContentEvent& aEvent)
+TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
 {
   aEvent.mSucceeded = false;
   aEvent.mWasAsync = false;
   aEvent.mReply.mFocusedWidget = nsCOMPtr<nsIWidget>(GetWidget()).get();
 
   switch (aEvent.message)
   {
   case NS_QUERY_SELECTED_TEXT:
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -219,17 +219,17 @@ public:
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIAUTHPROMPTPROVIDER
     NS_DECL_NSISECUREBROWSERUI
 
     void HandleDelayedDialogs();
 
     static TabParent *GetIMETabParent() { return mIMETabParent; }
-    bool HandleQueryContentEvent(nsQueryContentEvent& aEvent);
+    bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent);
     bool SendCompositionEvent(mozilla::WidgetCompositionEvent& event);
     bool SendTextEvent(mozilla::WidgetTextEvent& event);
     bool SendSelectionEvent(nsSelectionEvent& event);
 
     static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
     static TabParent* GetFrom(nsIContent* aContent);
 
     ContentParent* Manager() { return mManager; }
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -102,17 +102,16 @@ class WidgetPluginEvent;
 class InternalMutationEvent;
 } // namespace mozilla
 
 // TODO: Remove following typedefs
 typedef mozilla::WidgetEvent               nsEvent;
 typedef mozilla::WidgetGUIEvent            nsGUIEvent;
 typedef mozilla::WidgetInputEvent          nsInputEvent;
 typedef mozilla::InternalUIEvent           nsUIEvent;
-typedef mozilla::WidgetQueryContentEvent   nsQueryContentEvent;
 typedef mozilla::WidgetSelectionEvent      nsSelectionEvent;
 typedef mozilla::WidgetMouseEventBase      nsMouseEvent_base;
 typedef mozilla::WidgetMouseEvent          nsMouseEvent;
 typedef mozilla::WidgetDragEvent           nsDragEvent;
 typedef mozilla::WidgetMouseScrollEvent    nsMouseScrollEvent;
 
 namespace mozilla {
 typedef WidgetWheelEvent                   WheelEvent;
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -529,12 +529,11 @@ public:
   bool mExpandToClusterBoundary;
   // true if setting selection succeeded.
   bool mSucceeded;
 };
 
 } // namespace mozilla
 
 // TODO: Remove following typedefs
-typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
 typedef mozilla::WidgetSelectionEvent    nsSelectionEvent;
 
 #endif // mozilla_TextEvents_h__
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1954,17 +1954,18 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             AutoIMEMask selMask(mIMEMaskSelectionUpdate);
             RemoveIMEComposition();
             nsSelectionEvent selEvent(true, NS_SELECTION_SET, this);
             InitEvent(selEvent, nullptr);
 
             int32_t start = ae->Start(), end = ae->End();
 
             if (start < 0 || end < 0) {
-                nsQueryContentEvent event(true, NS_QUERY_SELECTED_TEXT, this);
+                WidgetQueryContentEvent event(true, NS_QUERY_SELECTED_TEXT,
+                                              this);
                 InitEvent(event, nullptr);
                 DispatchEvent(&event);
                 MOZ_ASSERT(event.mSucceeded && !event.mWasAsync);
 
                 if (start < 0)
                     start = int32_t(event.GetSelectionStart());
                 if (end < 0)
                     end = int32_t(event.GetSelectionEnd());
@@ -2023,18 +2024,19 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                 nsSelectionEvent event(true, NS_SELECTION_SET, this);
                 InitEvent(event, nullptr);
                 event.mOffset = uint32_t(ae->Start());
                 event.mLength = uint32_t(ae->End() - ae->Start());
                 event.mExpandToClusterBoundary = false;
                 DispatchEvent(&event);
             }
             {
-                nsQueryContentEvent queryEvent(true,
-                        NS_QUERY_SELECTED_TEXT, this);
+                WidgetQueryContentEvent queryEvent(true,
+                                                   NS_QUERY_SELECTED_TEXT,
+                                                   this);
                 InitEvent(queryEvent, nullptr);
                 DispatchEvent(&queryEvent);
                 MOZ_ASSERT(queryEvent.mSucceeded && !queryEvent.mWasAsync);
                 event.theText = queryEvent.mReply.mString;
             }
             {
                 WidgetCompositionEvent event(true, NS_COMPOSITION_START, this);
                 InitEvent(event, nullptr);
@@ -2256,33 +2258,33 @@ nsWindow::PostFlushIMEChanges()
 
 void
 nsWindow::FlushIMEChanges()
 {
     nsRefPtr<nsWindow> kungFuDeathGrip(this);
     for (uint32_t i = 0; i < mIMETextChanges.Length(); i++) {
         IMEChange &change = mIMETextChanges[i];
 
-        nsQueryContentEvent event(true, NS_QUERY_TEXT_CONTENT, this);
+        WidgetQueryContentEvent event(true, NS_QUERY_TEXT_CONTENT, this);
         InitEvent(event, nullptr);
         event.InitForQueryTextContent(change.mStart,
                                       change.mNewEnd - change.mStart);
         DispatchEvent(&event);
         if (!event.mSucceeded)
             return;
 
         AndroidBridge::NotifyIMEChange(event.mReply.mString,
                                        change.mStart,
                                        change.mOldEnd,
                                        change.mNewEnd);
     }
     mIMETextChanges.Clear();
 
     if (mIMESelectionChanged) {
-        nsQueryContentEvent event(true, NS_QUERY_SELECTED_TEXT, this);
+        WidgetQueryContentEvent event(true, NS_QUERY_SELECTED_TEXT, this);
         InitEvent(event, nullptr);
 
         DispatchEvent(&event);
         if (!event.mSucceeded)
             return;
 
         AndroidBridge::NotifyIMEChange(EmptyString(),
                              (int32_t) event.GetSelectionStart(),
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -1006,17 +1006,17 @@ private:
 
   bool mIsIMEComposing;
   bool mIsIMEEnabled;
   bool mIsASCIICapableOnly;
   bool mIgnoreIMECommit;
   // This flag is enabled by OnFocusChangeInGecko, and will be cleared by
   // ExecutePendingMethods.  When this is true, IsFocus() returns TRUE.  At
   // that time, the focus processing in Gecko might not be finished yet.  So,
-  // you cannot use nsQueryContentEvent or something.
+  // you cannot use WidgetQueryContentEvent or something.
   bool mIsInFocusProcessing;
   bool mIMEHasFocus;
 
   void KillIMEComposition();
   void SendCommittedText(NSString *aString);
   void OpenSystemPreferredLanguageIME();
 
   // Pending methods
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2887,17 +2887,17 @@ IMEInputHandler::ConversationIdentifier(
 
   if (Destroyed()) {
     return reinterpret_cast<NSInteger>(mView);
   }
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
   // NOTE: The size of NSInteger is same as pointer size.
-  nsQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, mWidget);
+  WidgetQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, mWidget);
   textContent.InitForQueryTextContent(0, 0);
   DispatchEvent(textContent);
   if (!textContent.mSucceeded) {
     PR_LOG(gLog, PR_LOG_ALWAYS,
       ("%p IMEInputHandler::ConversationIdentifier, Failed", this));
     return reinterpret_cast<NSInteger>(mView);
   }
   // XXX This might return same ID as a previously existing editor if the
@@ -2923,17 +2923,17 @@ IMEInputHandler::GetAttributedSubstringF
 
   if (Destroyed() || aRange.location == NSNotFound || aRange.length == 0) {
     return nil;
   }
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
   nsAutoString str;
-  nsQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, mWidget);
+  WidgetQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, mWidget);
   textContent.InitForQueryTextContent(aRange.location, aRange.length);
   DispatchEvent(textContent);
 
   PR_LOG(gLog, PR_LOG_ALWAYS,
     ("%p IMEInputHandler::GetAttributedSubstringFromRange, "
      "textContent={ mSucceeded=%s, mReply={ mString=\"%s\", mOffset=%llu } }",
      this, TrueOrFalse(textContent.mSucceeded),
      NS_ConvertUTF16toUTF8(textContent.mReply.mString).get(),
@@ -2998,17 +2998,17 @@ IMEInputHandler::SelectedRange()
 
   if (mSelectedRange.location != NSNotFound) {
     MOZ_ASSERT(mIMEHasFocus);
     return mSelectedRange;
   }
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, mWidget);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, mWidget);
   DispatchEvent(selection);
 
   PR_LOG(gLog, PR_LOG_ALWAYS,
     ("%p IMEInputHandler::SelectedRange, selection={ mSucceeded=%s, "
      "mReply={ mOffset=%llu, mString.Length()=%llu } }",
      this, TrueOrFalse(selection.mSucceeded), selection.mReply.mOffset,
      selection.mReply.mString.Length()));
 
@@ -3053,30 +3053,30 @@ IMEInputHandler::FirstRectForCharacterRa
     return rect;
   }
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
   nsIntRect r;
   bool useCaretRect = (aRange.length == 0);
   if (!useCaretRect) {
-    nsQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT, mWidget);
+    WidgetQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT, mWidget);
     charRect.InitForQueryTextRect(aRange.location, 1);
     DispatchEvent(charRect);
     if (charRect.mSucceeded) {
       r = charRect.mReply.mRect;
       actualRange.location = charRect.mReply.mOffset;
       actualRange.length = charRect.mReply.mString.Length();
     } else {
       useCaretRect = true;
     }
   }
 
   if (useCaretRect) {
-    nsQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, mWidget);
+    WidgetQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, mWidget);
     caretRect.InitForQueryCaretRect(aRange.location);
     DispatchEvent(caretRect);
     if (!caretRect.mSucceeded) {
       return rect;
     }
     r = caretRect.mReply.mRect;
     r.width = 0;
     actualRange.location = caretRect.mReply.mOffset;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1933,17 +1933,17 @@ NS_IMETHODIMP nsChildView::GetToggledKey
 }
 
 NSView<mozView>* nsChildView::GetEditorView()
 {
   NSView<mozView>* editorView = mView;
   // We need to get editor's view. E.g., when the focus is in the bookmark
   // dialog, the view is <panel> element of the dialog.  At this time, the key
   // events are processed the parent window's view that has native focus.
-  nsQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, this);
+  WidgetQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, this);
   textContent.InitForQueryTextContent(0, 0);
   DispatchWindowEvent(textContent);
   if (textContent.mSucceeded && textContent.mReply.mFocusedWidget) {
     NSView<mozView>* view = static_cast<NSView<mozView>*>(
       textContent.mReply.mFocusedWidget->GetNativeData(NS_NATIVE_WIDGET));
     if (view)
       editorView = view;
   }
@@ -5270,17 +5270,18 @@ static int32_t RoundUp(double aDouble)
 
   // hitTest needs coordinates in device pixels
   NSPoint eventLoc = nsCocoaUtils::ScreenLocationForEvent(currentEvent);
   eventLoc.y = nsCocoaUtils::FlippedScreenY(eventLoc.y);
   LayoutDeviceIntPoint widgetLoc = LayoutDeviceIntPoint::FromUntyped(
     mGeckoChild->CocoaPointsToDevPixels(eventLoc) -
     mGeckoChild->WidgetToScreenOffset());
 
-  nsQueryContentEvent hitTest(true, NS_QUERY_DOM_WIDGET_HITTEST, mGeckoChild);
+  WidgetQueryContentEvent hitTest(true, NS_QUERY_DOM_WIDGET_HITTEST,
+                                  mGeckoChild);
   hitTest.InitForQueryDOMWidgetHittest(widgetLoc);
   // This might destroy our widget (and null out mGeckoChild).
   mGeckoChild->DispatchWindowEvent(hitTest);
   if (!mGeckoChild)
     return NO;
   if (hitTest.mSucceeded && !hitTest.mReply.mWidgetIsHit)
     return NO;
 
@@ -5752,17 +5753,18 @@ static int32_t RoundUp(double aDouble)
       // Assume that this object will be able to handle this request.
       result = self;
 
       // Keep the ChildView alive during this operation.
       nsAutoRetainCocoaObject kungFuDeathGrip(self);
       
       // Determine if there is a selection (if sending to the service).
       if (sendType) {
-        nsQueryContentEvent event(true, NS_QUERY_CONTENT_STATE, mGeckoChild);
+        WidgetQueryContentEvent event(true, NS_QUERY_CONTENT_STATE,
+                                      mGeckoChild);
         // This might destroy our widget (and null out mGeckoChild).
         mGeckoChild->DispatchWindowEvent(event);
         if (!mGeckoChild || !event.mSucceeded || !event.mReply.mHasSelection)
           result = nil;
       }
 
       // Determine if we can paste (if receiving data from the service).
       if (mGeckoChild && returnType) {
@@ -5800,19 +5802,19 @@ static int32_t RoundUp(double aDouble)
       [types containsObject:NSHTMLPboardType] == NO)
     return NO;
 
   // Bail out if there is no Gecko object.
   if (!mGeckoChild)
     return NO;
 
   // Obtain the current selection.
-  nsQueryContentEvent event(true,
-                            NS_QUERY_SELECTION_AS_TRANSFERABLE,
-                            mGeckoChild);
+  WidgetQueryContentEvent event(true,
+                                NS_QUERY_SELECTION_AS_TRANSFERABLE,
+                                mGeckoChild);
   mGeckoChild->DispatchWindowEvent(event);
   if (!event.mSucceeded || !event.mReply.mTransferable)
     return NO;
 
   // Transform the transferable to an NSDictionary.
   NSDictionary* pasteboardOutputDict = nsClipboard::PasteboardDictFromTransferable(event.mReply.mTransferable);
   if (!pasteboardOutputDict)
     return NO;
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -924,18 +924,18 @@ nsGtkIMModule::DispatchCompositionStart(
 
     if (!mLastFocusedWindow) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, there are no focused window in this module"));
         return false;
     }
 
     nsEventStatus status;
-    nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT,
-                                  mLastFocusedWindow);
+    WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT,
+                                      mLastFocusedWindow);
     InitEvent(selection);
     mLastFocusedWindow->DispatchEvent(&selection, status);
 
     if (!selection.mSucceeded || selection.mReply.mOffset == UINT32_MAX) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, cannot query the selection offset"));
         return false;
     }
@@ -1070,19 +1070,19 @@ nsGtkIMModule::DispatchTextEvent(const n
           return false;
       }
     }
 
     // Store the selected string which will be removed by following text event.
     if (mCompositionState == eCompositionState_CompositionStartDispatched) {
         // XXX We should assume, for now, any web applications don't change
         //     selection at handling this text event.
-        nsQueryContentEvent querySelectedTextEvent(true,
-                                                   NS_QUERY_SELECTED_TEXT,
-                                                   mLastFocusedWindow);
+        WidgetQueryContentEvent querySelectedTextEvent(true,
+                                                       NS_QUERY_SELECTED_TEXT,
+                                                       mLastFocusedWindow);
         mLastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
         if (querySelectedTextEvent.mSucceeded) {
             mSelectedString = querySelectedTextEvent.mReply.mString;
             mCompositionStart = querySelectedTextEvent.mReply.mOffset;
         }
     }
 
     WidgetTextEvent textEvent(true, NS_TEXT_TEXT, mLastFocusedWindow);
@@ -1271,18 +1271,18 @@ nsGtkIMModule::SetCursorPosition(uint32_
 
     GtkIMContext *im = GetContext();
     if (!im) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, there are no context"));
         return;
     }
 
-    nsQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT,
-                                 mLastFocusedWindow);
+    WidgetQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT,
+                                     mLastFocusedWindow);
     charRect.InitForQueryTextRect(aTargetOffset, 1);
     InitEvent(charRect);
     nsEventStatus status;
     mLastFocusedWindow->DispatchEvent(&charRect, status);
     if (!charRect.mSucceeded) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, NS_QUERY_TEXT_RECT was failed"));
         return;
@@ -1325,19 +1325,19 @@ nsGtkIMModule::GetCurrentParagraph(nsASt
 
     uint32_t selOffset = mCompositionStart;
     uint32_t selLength = mSelectedString.Length();
 
     // If focused editor doesn't have composition string, we should use
     // current selection.
     if (!EditorHasCompositionString()) {
         // Query cursor position & selection
-        nsQueryContentEvent querySelectedTextEvent(true,
-                                                   NS_QUERY_SELECTED_TEXT,
-                                                   mLastFocusedWindow);
+        WidgetQueryContentEvent querySelectedTextEvent(true,
+                                                       NS_QUERY_SELECTED_TEXT,
+                                                       mLastFocusedWindow);
         mLastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
         NS_ENSURE_TRUE(querySelectedTextEvent.mSucceeded, NS_ERROR_FAILURE);
 
         selOffset = querySelectedTextEvent.mReply.mOffset;
         selLength = querySelectedTextEvent.mReply.mString.Length();
     }
 
     PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
@@ -1350,19 +1350,19 @@ nsGtkIMModule::GetCurrentParagraph(nsASt
     if (selOffset > INT32_MAX || selLength > INT32_MAX ||
         selOffset + selLength > INT32_MAX) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, The selection is out of range"));
         return NS_ERROR_FAILURE;
     }
 
     // Get all text contents of the focused editor
-    nsQueryContentEvent queryTextContentEvent(true,
-                                              NS_QUERY_TEXT_CONTENT,
-                                              mLastFocusedWindow);
+    WidgetQueryContentEvent queryTextContentEvent(true,
+                                                  NS_QUERY_TEXT_CONTENT,
+                                                  mLastFocusedWindow);
     queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX);
     mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status);
     NS_ENSURE_TRUE(queryTextContentEvent.mSucceeded, NS_ERROR_FAILURE);
 
     nsAutoString textContent(queryTextContentEvent.mReply.mString);
     if (selOffset + selLength > textContent.Length()) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, The selection is invalid, textContent.Length()=%u",
@@ -1435,29 +1435,29 @@ nsGtkIMModule::DeleteText(const int32_t 
         }
         if (!DispatchCompositionEnd()) {
             PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
                 ("    FAILED, quitting from DeletText"));
             return NS_ERROR_FAILURE;
         }
     } else {
         // Query cursor position & selection
-        nsQueryContentEvent querySelectedTextEvent(true,
-                                                   NS_QUERY_SELECTED_TEXT,
-                                                   mLastFocusedWindow);
+        WidgetQueryContentEvent querySelectedTextEvent(true,
+                                                       NS_QUERY_SELECTED_TEXT,
+                                                       mLastFocusedWindow);
         lastFocusedWindow->DispatchEvent(&querySelectedTextEvent, status);
         NS_ENSURE_TRUE(querySelectedTextEvent.mSucceeded, NS_ERROR_FAILURE);
 
         selOffset = querySelectedTextEvent.mReply.mOffset;
     }
 
     // Get all text contents of the focused editor
-    nsQueryContentEvent queryTextContentEvent(true,
-                                              NS_QUERY_TEXT_CONTENT,
-                                              mLastFocusedWindow);
+    WidgetQueryContentEvent queryTextContentEvent(true,
+                                                  NS_QUERY_TEXT_CONTENT,
+                                                  mLastFocusedWindow);
     queryTextContentEvent.InitForQueryTextContent(0, UINT32_MAX);
     mLastFocusedWindow->DispatchEvent(&queryTextContentEvent, status);
     NS_ENSURE_TRUE(queryTextContentEvent.mSucceeded, NS_ERROR_FAILURE);
     if (queryTextContentEvent.mReply.mString.IsEmpty()) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, there is no contents"));
         return NS_ERROR_FAILURE;
     }
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -401,19 +401,19 @@ struct ParamTraits<mozilla::WidgetCompos
   {
     return ReadParam(aMsg, aIter, static_cast<nsGUIEvent*>(aResult)) &&
            ReadParam(aMsg, aIter, &aResult->seqno) &&
            ReadParam(aMsg, aIter, &aResult->data);
   }
 };
 
 template<>
-struct ParamTraits<nsQueryContentEvent>
+struct ParamTraits<mozilla::WidgetQueryContentEvent>
 {
-  typedef nsQueryContentEvent paramType;
+  typedef mozilla::WidgetQueryContentEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
     WriteParam(aMsg, aParam.mSucceeded);
     WriteParam(aMsg, aParam.mInput.mOffset);
     WriteParam(aMsg, aParam.mInput.mLength);
     WriteParam(aMsg, aParam.mReply.mOffset);
--- a/widget/os2/nsWindow.cpp
+++ b/widget/os2/nsWindow.cpp
@@ -2436,23 +2436,23 @@ bool nsWindow::OnTranslateAccelerator(PQ
   return false;
 }
 bool nsWindow::OnQueryConvertPos(MPARAM mp1, MRESULT& mresult)
 {
   PRECTL pCursorPos = (PRECTL)mp1;
 
   nsIntPoint point(0, 0);
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, this);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, this);
   InitEvent(selection, &point);
   DispatchWindowEvent(&selection);
   if (!selection.mSucceeded)
     return false;
 
-  nsQueryContentEvent caret(true, NS_QUERY_CARET_RECT, this);
+  WidgetQueryContentEvent caret(true, NS_QUERY_CARET_RECT, this);
   caret.InitForQueryCaretRect(selection.mReply.mOffset);
   InitEvent(caret, &point);
   DispatchWindowEvent(&caret);
   if (!caret.mSucceeded)
     return false;
 
   pCursorPos->xLeft = caret.mReply.mRect.x;
   pCursorPos->yBottom = caret.mReply.mRect.y;
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -916,17 +916,17 @@ void
 nsIMM32Handler::HandleStartComposition(nsWindow* aWindow,
                                        const nsIMEContext &aIMEContext)
 {
   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");
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
   nsIntPoint point(0, 0);
   aWindow->InitEvent(selection, &point);
   aWindow->DispatchWindowEvent(&selection);
   if (!selection.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: HandleStartComposition, FAILED (NS_QUERY_SELECTED_TEXT)\n"));
     return;
   }
@@ -1233,17 +1233,17 @@ DumpReconvertString(RECONVERTSTRING* aRe
 bool
 nsIMM32Handler::HandleReconvert(nsWindow* aWindow,
                                 LPARAM lParam,
                                 LRESULT *oResult)
 {
   *oResult = 0;
   RECONVERTSTRING* pReconv = reinterpret_cast<RECONVERTSTRING*>(lParam);
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
   nsIntPoint point(0, 0);
   aWindow->InitEvent(selection, &point);
   aWindow->DispatchWindowEvent(&selection);
   if (!selection.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: HandleReconvert, FAILED (NS_QUERY_SELECTED_TEXT)\n"));
     return false;
   }
@@ -1361,17 +1361,17 @@ nsIMM32Handler::HandleDocumentFeed(nsWin
 
   nsIntPoint point(0, 0);
 
   bool hasCompositionString =
     mIsComposing && ShouldDrawCompositionStringOurselves();
 
   int32_t targetOffset, targetLength;
   if (!hasCompositionString) {
-    nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
+    WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
     aWindow->InitEvent(selection, &point);
     aWindow->DispatchWindowEvent(&selection);
     if (!selection.mSucceeded) {
       PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
         ("IMM32: HandleDocumentFeed, FAILED (NS_QUERY_SELECTED_TEXT)\n"));
       return false;
     }
     targetOffset = int32_t(selection.mReply.mOffset);
@@ -1387,17 +1387,17 @@ nsIMM32Handler::HandleDocumentFeed(nsWin
   if (targetOffset < 0 || targetLength < 0 ||
       targetOffset + targetLength < 0) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: HandleDocumentFeed, FAILED (The selection is out of range)\n"));
     return false;
   }
 
   // Get all contents of the focused editor.
-  nsQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, aWindow);
+  WidgetQueryContentEvent textContent(true, NS_QUERY_TEXT_CONTENT, aWindow);
   textContent.InitForQueryTextContent(0, UINT32_MAX);
   aWindow->InitEvent(textContent, &point);
   aWindow->DispatchWindowEvent(&textContent);
   if (!textContent.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: HandleDocumentFeed, FAILED (NS_QUERY_TEXT_CONTENT)\n"));
     return false;
   }
@@ -1759,17 +1759,17 @@ nsIMM32Handler::ConvertToANSIString(cons
 
 bool
 nsIMM32Handler::GetCharacterRectOfSelectedTextAt(nsWindow* aWindow,
                                                  uint32_t aOffset,
                                                  nsIntRect &aCharRect)
 {
   nsIntPoint point(0, 0);
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
   aWindow->InitEvent(selection, &point);
   aWindow->DispatchWindowEvent(&selection);
   if (!selection.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: GetCharacterRectOfSelectedTextAt, aOffset=%lu, FAILED (NS_QUERY_SELECTED_TEXT)\n",
        aOffset));
     return false;
   }
@@ -1786,17 +1786,17 @@ nsIMM32Handler::GetCharacterRectOfSelect
         std::min<uint32_t>(mCursorPosition, mCompositionString.Length());
       NS_ASSERTION(offset >= cursorPosition, "offset is less than cursorPosition!");
       offset -= cursorPosition;
     }
   }
 
   nsIntRect r;
   if (!useCaretRect) {
-    nsQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT, aWindow);
+    WidgetQueryContentEvent charRect(true, NS_QUERY_TEXT_RECT, aWindow);
     charRect.InitForQueryTextRect(offset, 1);
     aWindow->InitEvent(charRect, &point);
     aWindow->DispatchWindowEvent(&charRect);
     if (charRect.mSucceeded) {
       aCharRect = charRect.mReply.mRect;
       PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
         ("IMM32: GetCharacterRectOfSelectedTextAt, aOffset=%lu, SUCCEEDED\n",
          aOffset));
@@ -1810,28 +1810,28 @@ nsIMM32Handler::GetCharacterRectOfSelect
   return GetCaretRect(aWindow, aCharRect);
 }
 
 bool
 nsIMM32Handler::GetCaretRect(nsWindow* aWindow, nsIntRect &aCaretRect)
 {
   nsIntPoint point(0, 0);
 
-  nsQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
+  WidgetQueryContentEvent selection(true, NS_QUERY_SELECTED_TEXT, aWindow);
   aWindow->InitEvent(selection, &point);
   aWindow->DispatchWindowEvent(&selection);
   if (!selection.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: GetCaretRect,  FAILED (NS_QUERY_SELECTED_TEXT)\n"));
     return false;
   }
 
   uint32_t offset = selection.mReply.mOffset;
 
-  nsQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, aWindow);
+  WidgetQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, aWindow);
   caretRect.InitForQueryCaretRect(offset);
   aWindow->InitEvent(caretRect, &point);
   aWindow->DispatchWindowEvent(&caretRect);
   if (!caretRect.mSucceeded) {
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: GetCaretRect,  FAILED (NS_QUERY_CARET_RECT)\n"));
     return false;
   }
@@ -1955,21 +1955,21 @@ nsIMM32Handler::OnMouseEvent(nsWindow* a
   aResult.mConsumed = false; // always call next wndprc
 
   if (!sWM_MSIME_MOUSE || !mIsComposing ||
       !ShouldDrawCompositionStringOurselves()) {
     return false;
   }
 
   nsIntPoint cursor(LOWORD(lParam), HIWORD(lParam));
-  nsQueryContentEvent charAtPt(true, NS_QUERY_CHARACTER_AT_POINT, aWindow);
+  WidgetQueryContentEvent charAtPt(true, NS_QUERY_CHARACTER_AT_POINT, aWindow);
   aWindow->InitEvent(charAtPt, &cursor);
   aWindow->DispatchWindowEvent(&charAtPt);
   if (!charAtPt.mSucceeded ||
-      charAtPt.mReply.mOffset == nsQueryContentEvent::NOT_FOUND ||
+      charAtPt.mReply.mOffset == WidgetQueryContentEvent::NOT_FOUND ||
       charAtPt.mReply.mOffset < mCompositionStart ||
       charAtPt.mReply.mOffset >
         mCompositionStart + mCompositionString.Length()) {
     return false;
   }
 
   // calcurate positioning and offset
   // char :            JCH1|JCH2|JCH3
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -1181,17 +1181,17 @@ nsTextStore::CurrentContent()
   if (currentSel.IsDirty()) {
     mContent.Clear();
     return mContent;
   }
 
   if (!mContent.IsInitialized()) {
     MOZ_ASSERT(mWidget && !mWidget->Destroyed());
 
-    nsQueryContentEvent queryText(true, NS_QUERY_TEXT_CONTENT, mWidget);
+    WidgetQueryContentEvent queryText(true, NS_QUERY_TEXT_CONTENT, mWidget);
     queryText.InitForQueryTextContent(0, UINT32_MAX);
     mWidget->InitEvent(queryText);
     mWidget->DispatchWindowEvent(&queryText);
     NS_ENSURE_TRUE(queryText.mSucceeded, mContent);
 
     mContent.Init(queryText.mReply.mString);
   }
 
@@ -1208,17 +1208,18 @@ nsTextStore::CurrentSelection()
 {
   if (mSelection.IsDirty()) {
     // If the window has never been available, we should crash since working
     // with broken values may make TIP confused.
     if (!mWidget || mWidget->Destroyed()) {
       MOZ_CRASH();
     }
 
-    nsQueryContentEvent querySelection(true, NS_QUERY_SELECTED_TEXT, mWidget);
+    WidgetQueryContentEvent querySelection(true, NS_QUERY_SELECTED_TEXT,
+                                           mWidget);
     mWidget->InitEvent(querySelection);
     mWidget->DispatchWindowEvent(&querySelection);
     NS_ENSURE_TRUE(querySelection.mSucceeded, mSelection);
 
     mSelection.SetSelection(querySelection.mReply.mOffset,
                             querySelection.mReply.mString.Length(),
                             querySelection.mReply.mReversed);
   }
@@ -2255,17 +2256,17 @@ nsTextStore::GetTextExt(TsViewCookie vcV
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::GetTextExt() FAILED due to "
             "layout not recomputed at %d", this, acpEnd));
     mContent.NeedsToNotifyTSFOfLayoutChange();
     return TS_E_NOLAYOUT;
   }
 
   // use NS_QUERY_TEXT_RECT to get rect in system, screen coordinates
-  nsQueryContentEvent event(true, NS_QUERY_TEXT_RECT, mWidget);
+  WidgetQueryContentEvent event(true, NS_QUERY_TEXT_RECT, mWidget);
   mWidget->InitEvent(event);
   event.InitForQueryTextRect(acpStart, acpEnd - acpStart);
   mWidget->DispatchWindowEvent(&event);
   if (!event.mSucceeded) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::GetTextExt() FAILED due to "
             "NS_QUERY_TEXT_RECT failure", this));
     return TS_E_INVALIDPOS; // but unexpected failure, maybe.
@@ -2358,17 +2359,17 @@ nsTextStore::GetScreenExt(TsViewCookie v
 
 bool
 nsTextStore::GetScreenExtInternal(RECT &aScreenExt)
 {
   PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
          ("TSF: 0x%p   nsTextStore::GetScreenExtInternal()", this));
 
   // use NS_QUERY_EDITOR_RECT to get rect in system, screen coordinates
-  nsQueryContentEvent event(true, NS_QUERY_EDITOR_RECT, mWidget);
+  WidgetQueryContentEvent event(true, NS_QUERY_EDITOR_RECT, mWidget);
   mWidget->InitEvent(event);
   mWidget->DispatchWindowEvent(&event);
   if (!event.mSucceeded) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::GetScreenExtInternal() FAILED due to "
             "NS_QUERY_EDITOR_RECT failure", this));
     return false;
   }
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -436,17 +436,17 @@ PuppetWidget::NotifyIMEOfFocusChange(boo
   return NS_OK;
 #endif
 
   if (!mTabChild)
     return NS_ERROR_FAILURE;
 
   if (aFocus) {
     nsEventStatus status;
-    nsQueryContentEvent queryEvent(true, NS_QUERY_TEXT_CONTENT, this);
+    WidgetQueryContentEvent queryEvent(true, NS_QUERY_TEXT_CONTENT, this);
     InitEvent(queryEvent, nullptr);
     // Query entire content
     queryEvent.InitForQueryTextContent(0, UINT32_MAX);
     DispatchEvent(&queryEvent, status);
 
     if (queryEvent.mSucceeded) {
       mTabChild->SendNotifyIMETextHint(queryEvent.mReply.mString);
     }
@@ -488,17 +488,17 @@ PuppetWidget::NotifyIMEOfTextChange(uint
   return NS_OK;
 #endif
 
   if (!mTabChild)
     return NS_ERROR_FAILURE;
 
   if (mIMEPreference.mWantHints) {
     nsEventStatus status;
-    nsQueryContentEvent queryEvent(true, NS_QUERY_TEXT_CONTENT, this);
+    WidgetQueryContentEvent queryEvent(true, NS_QUERY_TEXT_CONTENT, this);
     InitEvent(queryEvent, nullptr);
     queryEvent.InitForQueryTextContent(0, UINT32_MAX);
     DispatchEvent(&queryEvent, status);
 
     if (queryEvent.mSucceeded) {
       mTabChild->SendNotifyIMETextHint(queryEvent.mReply.mString);
     }
   }
@@ -516,17 +516,17 @@ PuppetWidget::NotifyIMEOfSelectionChange
 #endif
 
   if (!mTabChild)
     return NS_ERROR_FAILURE;
 
   if (mIMEPreference.mWantUpdates &
         nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE) {
     nsEventStatus status;
-    nsQueryContentEvent queryEvent(true, NS_QUERY_SELECTED_TEXT, this);
+    WidgetQueryContentEvent queryEvent(true, NS_QUERY_SELECTED_TEXT, this);
     InitEvent(queryEvent, nullptr);
     DispatchEvent(&queryEvent, status);
 
     if (queryEvent.mSucceeded) {
       mTabChild->SendNotifyIMESelection(mIMELastReceivedSeqno,
                                         queryEvent.GetSelectionStart(),
                                         queryEvent.GetSelectionEnd());
     }