Bug 1125040 - Use LayoutDeviceIntPoint in IME code r=botond
authorDavid Zbarsky <dzbarsky@gmail.com>
Wed, 04 Feb 2015 15:21:03 -0500
changeset 241016 de5837c6e80b4f9e8bea58579e3aefb27257c2d7
parent 241015 3457965811831bd4964305b409adf8ff643a28c7
child 241017 dd07d3c32f6e0b2ab4b65acfb06d323b6421238b
push id567
push usermartin.thomson@gmail.com
push dateThu, 05 Feb 2015 06:19:40 +0000
reviewersbotond
bugs1125040
milestone38.0a1
Bug 1125040 - Use LayoutDeviceIntPoint in IME code r=botond
dom/base/nsQueryContentEventResult.cpp
dom/base/nsQueryContentEventResult.h
dom/events/ContentEventHandler.cpp
dom/events/IMEContentObserver.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/TextEvents.h
widget/cocoa/TextInputHandler.mm
widget/windows/nsIMM32Handler.cpp
widget/windows/nsTextStore.cpp
--- a/dom/base/nsQueryContentEventResult.cpp
+++ b/dom/base/nsQueryContentEventResult.cpp
@@ -144,10 +144,10 @@ nsQueryContentEventResult::SetEventResul
   nsIWidget* topWidget = aWidget->GetTopLevelWidget();
   if (!topWidget || topWidget == aWidget) {
     return;
   }
 
   // Convert the top widget related coordinates to the given widget's.
   LayoutDeviceIntPoint offset =
     aWidget->WidgetToScreenOffset() - topWidget->WidgetToScreenOffset();
-  mRect.MoveBy(-LayoutDeviceIntPoint::ToUntyped(offset));
+  mRect.MoveBy(-offset);
 }
--- a/dom/base/nsQueryContentEventResult.h
+++ b/dom/base/nsQueryContentEventResult.h
@@ -26,15 +26,15 @@ public:
 
 protected:
   ~nsQueryContentEventResult();
 
   uint32_t mEventID;
 
   uint32_t mOffset;
   nsString mString;
-  nsIntRect mRect;
+  mozilla::LayoutDeviceIntRect mRect;
 
   bool mSucceeded;
   bool mReversed;
 };
 
-#endif // mozilla_dom_nsQueryContentEventResult_h
\ No newline at end of file
+#endif // mozilla_dom_nsQueryContentEventResult_h
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -177,18 +177,18 @@ ContentEventHandler::QueryContentRect(ns
   // account for any additional frames
   while ((frame = frame->GetNextContinuation()) != nullptr) {
     nsRect frameRect(nsPoint(0, 0), frame->GetRect().Size());
     rv = ConvertToRootViewRelativeOffset(frame, frameRect);
     NS_ENSURE_SUCCESS(rv, rv);
     resultRect.UnionRect(resultRect, frameRect);
   }
 
-  aEvent->mReply.mRect =
-      resultRect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
+  aEvent->mReply.mRect = LayoutDevicePixel::FromUntyped(
+      resultRect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel()));
   aEvent->mSucceeded = true;
 
   return NS_OK;
 }
 
 // Editor places a bogus BR node under its root content if the editor doesn't
 // have any text. This happens even for single line editors.
 // When we get text content and when we change the selection,
@@ -987,18 +987,18 @@ ContentEventHandler::OnQueryTextRect(Wid
   // minus 1 to avoid creating an empty rect
   frameRect.width -= lastFrame->GetRect().width - ptOffset.x - 1;
 
   if (firstFrame == lastFrame) {
     rect.IntersectRect(rect, frameRect);
   } else {
     rect.UnionRect(rect, frameRect);
   }
-  aEvent->mReply.mRect =
-      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
+  aEvent->mReply.mRect = LayoutDevicePixel::FromUntyped(
+      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel()));
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
 ContentEventHandler::OnQueryEditorRect(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
@@ -1038,18 +1038,18 @@ ContentEventHandler::OnQueryCaretRect(Wi
                                   lineBreakType);
     NS_ENSURE_SUCCESS(rv, rv);
     if (offset == aEvent->mInput.mOffset) {
       if (!caretFrame) {
         return NS_ERROR_FAILURE;
       }
       rv = ConvertToRootViewRelativeOffset(caretFrame, caretRect);
       NS_ENSURE_SUCCESS(rv, rv);
-      aEvent->mReply.mRect =
-        caretRect.ToOutsidePixels(caretFrame->PresContext()->AppUnitsPerDevPixel());
+      aEvent->mReply.mRect = LayoutDevicePixel::FromUntyped(
+        caretRect.ToOutsidePixels(caretFrame->PresContext()->AppUnitsPerDevPixel()));
       aEvent->mReply.mOffset = aEvent->mInput.mOffset;
       aEvent->mSucceeded = true;
       return NS_OK;
     }
   }
 
   // Otherwise, we should set the guessed caret rect.
   nsRefPtr<nsRange> range = new nsRange(mRootContent);
@@ -1071,18 +1071,18 @@ ContentEventHandler::OnQueryCaretRect(Wi
   rect.x = posInFrame.x;
   rect.y = posInFrame.y;
   rect.width = caretRect.width;
   rect.height = frame->GetSize().height;
 
   rv = ConvertToRootViewRelativeOffset(frame, rect);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  aEvent->mReply.mRect =
-      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel());
+  aEvent->mReply.mRect = LayoutDevicePixel::FromUntyped(
+      rect.ToOutsidePixels(mPresContext->AppUnitsPerDevPixel()));
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
 ContentEventHandler::OnQueryContentState(WidgetQueryContentEvent* aEvent)
 {
   nsresult rv = Init(aEvent);
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -444,32 +444,33 @@ IMEContentObserver::OnMouseButtonEvent(n
     return false;
   }
 
   // The result character rect is relative to the top level widget.
   // We should notify it with offset in the widget.
   nsIWidget* topLevelWidget = mWidget->GetTopLevelWidget();
   if (topLevelWidget && topLevelWidget != mWidget) {
     charAtPt.mReply.mRect.MoveBy(
-      topLevelWidget->WidgetToScreenOffsetUntyped() -
-        mWidget->WidgetToScreenOffsetUntyped());
+      topLevelWidget->WidgetToScreenOffset() -
+        mWidget->WidgetToScreenOffset());
   }
   // The refPt is relative to its widget.
   // We should notify it with offset in the widget.
   if (aMouseEvent->widget != mWidget) {
     charAtPt.refPoint += aMouseEvent->widget->WidgetToScreenOffset() -
       mWidget->WidgetToScreenOffset();
   }
 
   IMENotification notification(NOTIFY_IME_OF_MOUSE_BUTTON_EVENT);
   notification.mMouseButtonEventData.mEventMessage = aMouseEvent->message;
   notification.mMouseButtonEventData.mOffset = charAtPt.mReply.mOffset;
   notification.mMouseButtonEventData.mCursorPos.Set(
     LayoutDeviceIntPoint::ToUntyped(charAtPt.refPoint));
-  notification.mMouseButtonEventData.mCharRect.Set(charAtPt.mReply.mRect);
+  notification.mMouseButtonEventData.mCharRect.Set(
+    LayoutDevicePixel::ToUntyped(charAtPt.mReply.mRect));
   notification.mMouseButtonEventData.mButton = aMouseEvent->button;
   notification.mMouseButtonEventData.mButtons = aMouseEvent->buttons;
   notification.mMouseButtonEventData.mModifiers = aMouseEvent->modifiers;
 
   nsresult rv = mWidget->NotifyIME(notification);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return false;
   }
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -20,16 +20,17 @@ include JavaScriptTypes;
 include URIParams;
 include PContentPermission;
 
 
 using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
 using class mozilla::gfx::Matrix from "mozilla/gfx/Matrix.h";
 using struct gfxSize from "gfxPoint.h";
 using CSSRect from "Units.h";
+using LayoutDeviceIntRect from "Units.h";
 using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
 using struct mozilla::layers::ScrollableLayerGuid from "FrameMetrics.h";
 using struct mozilla::layers::ZoomConstraints from "FrameMetrics.h";
 using FrameMetrics::ViewID from "FrameMetrics.h";
 using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
 using nscolor from "nsColor.h";
@@ -201,19 +202,19 @@ parent:
      * Notifies chrome that there is a IME compostion rect updated
      *
      *  offset       The starting offset of this rect
      *  rect         The rect of first character of selected IME composition
      *  caretOffset  The offset of caret position
      *  caretRect    The rect of IME caret
      */
     prio(urgent) async NotifyIMESelectedCompositionRect(uint32_t offset,
-                                                        nsIntRect[] rect,
+                                                        LayoutDeviceIntRect[] rect,
                                                         uint32_t caretOffset,
-                                                        nsIntRect caretRect);
+                                                        LayoutDeviceIntRect caretRect);
 
     /**
      * Notifies chrome that there has been a change in selection
      * Only called when NotifyIMEFocus returns PR_TRUE for mWantUpdates
      *
      *  seqno        Current seqno value on the content side
      *  anchor       Offset where the selection started
      *  focus        Offset where the caret is
@@ -240,27 +241,27 @@ parent:
     prio(urgent) sync NotifyIMEMouseButtonEvent(IMENotification notification)
       returns (bool consumedByIME);
 
     /**
      * Notifies chrome to currect editor rect
      *
      *  rect         Rect of current focused editor
      */
-    prio(urgent) async NotifyIMEEditorRect(nsIntRect rect);
+    prio(urgent) async NotifyIMEEditorRect(LayoutDeviceIntRect rect);
 
     /**
      * Notifies chrome to position change
      *
      *  editorRect   Rect of current focused editor
      *  compositionRects     Rects of current composition string
      */
-    prio(urgent) async NotifyIMEPositionChange(nsIntRect editorRect,
-                                               nsIntRect[] compositionRects,
-                                               nsIntRect caretRect);
+    prio(urgent) async NotifyIMEPositionChange(LayoutDeviceIntRect editorRect,
+                                               LayoutDeviceIntRect[] compositionRects,
+                                               LayoutDeviceIntRect caretRect);
 
     /**
      * Instructs chrome to end any pending composition
      *
      *  cancel       PR_TRUE if composition should be cancelled
      *  composition  Text to commit before ending the composition
      *
      *  if cancel is PR_TRUE,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1607,19 +1607,19 @@ TabParent::RecvNotifyIMETextChange(const
   notification.mTextChangeData.mCausedByComposition = aCausedByComposition;
   widget->NotifyIME(notification);
   return true;
 }
 
 bool
 TabParent::RecvNotifyIMESelectedCompositionRect(
   const uint32_t& aOffset,
-  InfallibleTArray<nsIntRect>&& aRects,
+  InfallibleTArray<LayoutDeviceIntRect>&& aRects,
   const uint32_t& aCaretOffset,
-  const nsIntRect& aCaretRect)
+  const LayoutDeviceIntRect& aCaretRect)
 {
   // add rect to cache for another query
   mIMECompositionRectOffset = aOffset;
   mIMECompositionRects = aRects;
   mIMECaretOffset = aCaretOffset;
   mIMECaretRect = aCaretRect;
 
   nsCOMPtr<nsIWidget> widget = GetWidget();
@@ -1679,27 +1679,27 @@ TabParent::RecvNotifyIMEMouseButtonEvent
     return true;
   }
   nsresult rv = widget->NotifyIME(aIMENotification);
   *aConsumedByIME = rv == NS_SUCCESS_EVENT_CONSUMED;
   return true;
 }
 
 bool
-TabParent::RecvNotifyIMEEditorRect(const nsIntRect& aRect)
+TabParent::RecvNotifyIMEEditorRect(const LayoutDeviceIntRect& aRect)
 {
   mIMEEditorRect = aRect;
   return true;
 }
 
 bool
 TabParent::RecvNotifyIMEPositionChange(
-             const nsIntRect& aEditorRect,
-             InfallibleTArray<nsIntRect>&& aCompositionRects,
-             const nsIntRect& aCaretRect)
+             const LayoutDeviceIntRect& aEditorRect,
+             InfallibleTArray<LayoutDeviceIntRect>&& aCompositionRects,
+             const LayoutDeviceIntRect& aCaretRect)
 {
   mIMEEditorRect = aEditorRect;
   mIMECompositionRects = aCompositionRects;
   mIMECaretRect = aCaretRect;
 
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
@@ -1924,34 +1924,37 @@ TabParent::HandleQueryContentEvent(Widge
       uint32_t baseOffset = aEvent.mInput.mOffset - mIMECompositionRectOffset;
       uint32_t endOffset = baseOffset + aEvent.mInput.mLength;
       aEvent.mReply.mRect.SetEmpty();
       for (uint32_t i = baseOffset; i < endOffset; i++) {
         aEvent.mReply.mRect =
           aEvent.mReply.mRect.Union(mIMECompositionRects[i]);
       }
       aEvent.mReply.mOffset = aEvent.mInput.mOffset;
-      aEvent.mReply.mRect = aEvent.mReply.mRect - GetChildProcessOffset();
+      aEvent.mReply.mRect =
+        aEvent.mReply.mRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
       aEvent.mSucceeded = true;
     }
     break;
   case NS_QUERY_CARET_RECT:
     {
       if (aEvent.mInput.mOffset != mIMECaretOffset) {
         break;
       }
 
       aEvent.mReply.mOffset = mIMECaretOffset;
-      aEvent.mReply.mRect = mIMECaretRect - GetChildProcessOffset();
+      aEvent.mReply.mRect =
+        mIMECaretRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
       aEvent.mSucceeded = true;
     }
     break;
   case NS_QUERY_EDITOR_RECT:
     {
-      aEvent.mReply.mRect = mIMEEditorRect - GetChildProcessOffset();
+      aEvent.mReply.mRect =
+        mIMEEditorRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
       aEvent.mSucceeded = true;
     }
     break;
   }
   return true;
 }
 
 bool
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -167,32 +167,32 @@ public:
                                     nsIMEUpdatePreference* aPreference,
                                     uint32_t* aSeqno) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMETextChange(const uint32_t& aStart,
                                          const uint32_t& aEnd,
                                          const uint32_t& aNewEnd,
                                          const bool& aCausedByComposition) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMESelectedCompositionRect(
                    const uint32_t& aOffset,
-                   InfallibleTArray<nsIntRect>&& aRects,
+                   InfallibleTArray<LayoutDeviceIntRect>&& aRects,
                    const uint32_t& aCaretOffset,
-                   const nsIntRect& aCaretRect) MOZ_OVERRIDE;
+                   const LayoutDeviceIntRect& aCaretRect) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMESelection(const uint32_t& aSeqno,
                                         const uint32_t& aAnchor,
                                         const uint32_t& aFocus,
                                         const mozilla::WritingMode& aWritingMode,
                                         const bool& aCausedByComposition) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMETextHint(const nsString& aText) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMEMouseButtonEvent(const widget::IMENotification& aEventMessage,
                                                bool* aConsumedByIME) MOZ_OVERRIDE;
-    virtual bool RecvNotifyIMEEditorRect(const nsIntRect& aRect) MOZ_OVERRIDE;
+    virtual bool RecvNotifyIMEEditorRect(const LayoutDeviceIntRect& aRect) MOZ_OVERRIDE;
     virtual bool RecvNotifyIMEPositionChange(
-                   const nsIntRect& aEditoRect,
-                   InfallibleTArray<nsIntRect>&& aCompositionRects,
-                   const nsIntRect& aCaretRect) MOZ_OVERRIDE;
+                   const LayoutDeviceIntRect& aEditorRect,
+                   InfallibleTArray<LayoutDeviceIntRect>&& aCompositionRects,
+                   const LayoutDeviceIntRect& aCaretRect) MOZ_OVERRIDE;
     virtual bool RecvEndIMEComposition(const bool& aCancel,
                                        nsString* aComposition) MOZ_OVERRIDE;
     virtual bool RecvGetInputContext(int32_t* aIMEEnabled,
                                      int32_t* aIMEOpen,
                                      intptr_t* aNativeIMEContext) MOZ_OVERRIDE;
     virtual bool RecvSetInputContext(const int32_t& aIMEEnabled,
                                      const int32_t& aIMEOpen,
                                      const nsString& aType,
@@ -409,20 +409,20 @@ protected:
     bool mIMECompositionEnding;
     // Buffer to store composition text during ResetInputState
     // Compositions in almost all cases are small enough for nsAutoString
     nsAutoString mIMECompositionText;
     uint32_t mIMECompositionStart;
     uint32_t mIMESeqno;
 
     uint32_t mIMECompositionRectOffset;
-    InfallibleTArray<nsIntRect> mIMECompositionRects;
+    InfallibleTArray<LayoutDeviceIntRect> mIMECompositionRects;
     uint32_t mIMECaretOffset;
-    nsIntRect mIMECaretRect;
-    nsIntRect mIMEEditorRect;
+    LayoutDeviceIntRect mIMECaretRect;
+    LayoutDeviceIntRect mIMEEditorRect;
 
     // The number of event series we're currently capturing.
     int32_t mEventCaptureDepth;
 
     nsIntRect mRect;
     nsIntSize mDimensions;
     ScreenOrientation mOrientation;
     float mDPI;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -545,35 +545,35 @@ PuppetWidget::NotifyIMEOfUpdateCompositi
 #ifndef MOZ_CROSS_PROCESS_IME
   return NS_OK;
 #endif
 
   NS_ENSURE_TRUE(mTabChild, NS_ERROR_FAILURE);
 
   uint32_t startOffset;
   uint32_t targetCauseOffset;
-  nsAutoTArray<nsIntRect, 16> textRectArray;
+  nsAutoTArray<LayoutDeviceIntRect, 16> textRectArray;
   if (!GetCompositionRects(startOffset,
                            textRectArray,
                            targetCauseOffset)) {
     return NS_ERROR_FAILURE;
   }
-  nsIntRect caretRect;
+  LayoutDeviceIntRect caretRect;
   GetCaretRect(caretRect, targetCauseOffset);
 
   mTabChild->SendNotifyIMESelectedCompositionRect(startOffset,
                                                   textRectArray,
                                                   targetCauseOffset,
                                                   caretRect);
   return NS_OK;
 }
 
 bool
 PuppetWidget::GetCompositionRects(uint32_t& aStartOffset,
-                                  nsTArray<nsIntRect>& aTextRectArray,
+                                  nsTArray<LayoutDeviceIntRect>& aTextRectArray,
                                   uint32_t& aTargetCauseOffset)
 {
   nsRefPtr<TextComposition> textComposition =
     IMEStateManager::GetTextCompositionFor(this);
   NS_ENSURE_TRUE(textComposition, false);
 
   nsEventStatus status;
   aTextRectArray.SetCapacity(textComposition->String().Length());
@@ -600,17 +600,17 @@ PuppetWidget::GetCaretOffset()
   InitEvent(selection, nullptr);
   DispatchEvent(&selection, status);
   NS_ENSURE_TRUE(selection.mSucceeded, 0);
 
   return selection.mReply.mOffset;
 }
 
 bool
-PuppetWidget::GetCaretRect(nsIntRect& aCaretRect, uint32_t aCaretOffset)
+PuppetWidget::GetCaretRect(LayoutDeviceIntRect& aCaretRect, uint32_t aCaretOffset)
 {
   nsEventStatus status;
   WidgetQueryContentEvent caretRect(true, NS_QUERY_CARET_RECT, this);
   InitEvent(caretRect, nullptr);
   caretRect.InitForQueryCaretRect(aCaretOffset);
   DispatchEvent(&caretRect, status);
   NS_ENSURE_TRUE(caretRect.mSucceeded, false);
 
@@ -624,26 +624,26 @@ PuppetWidget::NotifyIMEOfEditorRect()
 {
 #ifndef MOZ_CROSS_PROCESS_IME
   return NS_OK;
 #endif
   if (NS_WARN_IF(!mTabChild)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsIntRect rect;
+  LayoutDeviceIntRect rect;
   if (!GetEditorRect(rect)) {
     return NS_ERROR_FAILURE;
   }
   mTabChild->SendNotifyIMEEditorRect(rect);
   return NS_OK;
 }
 
 bool
-PuppetWidget::GetEditorRect(nsIntRect& aRect)
+PuppetWidget::GetEditorRect(LayoutDeviceIntRect& aRect)
 {
   nsEventStatus status;
   WidgetQueryContentEvent editorRectEvent(true, NS_QUERY_EDITOR_RECT, this);
   InitEvent(editorRectEvent);
   DispatchEvent(&editorRectEvent, status);
   if (NS_WARN_IF(!editorRectEvent.mSucceeded)) {
     return false;
   }
@@ -756,32 +756,32 @@ PuppetWidget::NotifyIMEOfPositionChange(
 {
 #ifndef MOZ_CROSS_PROCESS_IME
   return NS_OK;
 #endif
   if (NS_WARN_IF(!mTabChild)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsIntRect editorRect;
+  LayoutDeviceIntRect editorRect;
   if (!GetEditorRect(editorRect)) {
     return NS_ERROR_FAILURE;
   }
 
   uint32_t startOffset;
   uint32_t targetCauseOffset;
-  nsAutoTArray<nsIntRect, 16> textRectArray;
+  nsAutoTArray<LayoutDeviceIntRect, 16> textRectArray;
   if (!GetCompositionRects(startOffset,
                            textRectArray,
                            targetCauseOffset)) {
     // no composition string, get caret offset by NS_QUERY_SELECTED_TEXT
     targetCauseOffset = GetCaretOffset();
   }
 
-  nsIntRect caretRect;
+  LayoutDeviceIntRect caretRect;
   GetCaretRect(caretRect, targetCauseOffset);
   if (!mTabChild->SendNotifyIMEPositionChange(editorRect, textRectArray,
                                               caretRect)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -216,21 +216,21 @@ private:
   nsresult NotifyIMEOfFocusChange(bool aFocus);
   nsresult NotifyIMEOfSelectionChange(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfUpdateComposition();
   nsresult NotifyIMEOfTextChange(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfMouseButtonEvent(const IMENotification& aIMENotification);
   nsresult NotifyIMEOfEditorRect();
   nsresult NotifyIMEOfPositionChange();
 
-  bool GetEditorRect(nsIntRect& aEditorRect);
+  bool GetEditorRect(mozilla::LayoutDeviceIntRect& aEditorRect);
   bool GetCompositionRects(uint32_t& aStartOffset,
-                           nsTArray<nsIntRect>& aRectArray,
+                           nsTArray<mozilla::LayoutDeviceIntRect>& aRectArray,
                            uint32_t& aTargetCauseOffset);
-  bool GetCaretRect(nsIntRect& aCaretRect, uint32_t aCaretOffset);
+  bool GetCaretRect(mozilla::LayoutDeviceIntRect& aCaretRect, uint32_t aCaretOffset);
   uint32_t GetCaretOffset();
 
   class PaintTask : public nsRunnable {
   public:
     NS_DECL_NSIRUNNABLE
     explicit PaintTask(PuppetWidget* widget) : mWidget(widget) {}
     void Revoke() { mWidget = nullptr; }
   private:
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -487,17 +487,17 @@ public:
     uint32_t mLength;
   } mInput;
   struct
   {
     void* mContentsRoot;
     uint32_t mOffset;
     nsString mString;
     // Finally, the coordinates is system coordinates.
-    nsIntRect mRect;
+    mozilla::LayoutDeviceIntRect mRect;
     // The return widget has the caret. This is set at all query events.
     nsIWidget* mFocusedWidget;
     // true if selection is reversed (end < start)
     bool mReversed;
     // true if the selection exists
     bool mHasSelection;
     // true if DOM element under mouse belongs to widget
     bool mWidgetIsHit;
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -3113,17 +3113,17 @@ IMEInputHandler::FirstRectForCharacterRa
     *aActualRange = actualRange;
   }
   if (Destroyed() || aRange.location == NSNotFound) {
     return rect;
   }
 
   nsRefPtr<IMEInputHandler> kungFuDeathGrip(this);
 
-  nsIntRect r;
+  LayoutDeviceIntRect r;
   bool useCaretRect = (aRange.length == 0);
   if (!useCaretRect) {
     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;
@@ -3149,17 +3149,18 @@ IMEInputHandler::FirstRectForCharacterRa
   nsIWidget* rootWidget = mWidget->GetTopLevelWidget();
   NSWindow* rootWindow =
     static_cast<NSWindow*>(rootWidget->GetNativeData(NS_NATIVE_WINDOW));
   NSView* rootView =
     static_cast<NSView*>(rootWidget->GetNativeData(NS_NATIVE_WIDGET));
   if (!rootWindow || !rootView) {
     return rect;
   }
-  rect = nsCocoaUtils::DevPixelsToCocoaPoints(r, mWidget->BackingScaleFactor());
+  rect = nsCocoaUtils::DevPixelsToCocoaPoints(LayoutDevicePixel::ToUntyped(r),
+                                              mWidget->BackingScaleFactor());
   rect = [rootView convertRect:rect toView:nil];
   rect.origin = [rootWindow convertBaseToScreen:rect.origin];
 
   if (aActualRange) {
     *aActualRange = actualRange;
   }
 
   PR_LOG(gLog, PR_LOG_ALWAYS,
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -1800,17 +1800,17 @@ nsIMM32Handler::GetCharacterRectOfSelect
 
   nsIntRect r;
   if (!useCaretRect) {
     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;
+      aCharRect = LayoutDevicePixel::ToUntyped(charRect.mReply.mRect);
       PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
         ("IMM32: GetCharacterRectOfSelectedTextAt, aOffset=%lu, SUCCEEDED\n",
          aOffset));
       PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
         ("IMM32: GetCharacterRectOfSelectedTextAt, aCharRect={ x: %ld, y: %ld, width: %ld, height: %ld }\n",
          aCharRect.x, aCharRect.y, aCharRect.width, aCharRect.height));
       return true;
     }
@@ -1839,17 +1839,17 @@ nsIMM32Handler::GetCaretRect(nsWindow* a
   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;
   }
-  aCaretRect = caretRect.mReply.mRect;
+  aCaretRect = LayoutDevicePixel::ToUntyped(caretRect.mReply.mRect);
   PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
     ("IMM32: GetCaretRect, SUCCEEDED, aCaretRect={ x: %ld, y: %ld, width: %ld, height: %ld }\n",
      aCaretRect.x, aCaretRect.y, aCaretRect.width, aCaretRect.height));
   return true;
 }
 
 bool
 nsIMM32Handler::SetIMERelatedWindowsPos(nsWindow* aWindow,
@@ -1951,18 +1951,18 @@ nsIMM32Handler::SetIMERelatedWindowsPosO
       ("IMM32: SetIMERelatedWindowsPosOnPlugin, "
        "FAILED (NS_QUERY_EDITOR_RECT)"));
     return;
   }
 
   // Clip the plugin rect by the client rect of the window because composition
   // window needs to be specified the position in the client area.
   nsWindow* toplevelWindow = aWindow->GetTopLevelWindow(false);
-  nsIntRect pluginRectInScreen =
-    editorRectEvent.mReply.mRect + toplevelWindow->WidgetToScreenOffsetUntyped();
+  LayoutDeviceIntRect pluginRectInScreen =
+    editorRectEvent.mReply.mRect + toplevelWindow->WidgetToScreenOffset();
   nsIntRect winRectInScreen;
   aWindow->GetClientBounds(winRectInScreen);
   // composition window cannot be positioned on the edge of client area.
   winRectInScreen.width--;
   winRectInScreen.height--;
   nsIntRect clippedPluginRect;
   clippedPluginRect.x =
     std::min(std::max(pluginRectInScreen.x, winRectInScreen.x),
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -3193,17 +3193,17 @@ nsTextStore::GetTextExt(TsViewCookie vcV
     refWindow = refWindow->GetTopLevelWindow(false);
     if (!refWindow) {
       PR_LOG(sTextStoreLog, PR_LOG_ERROR,
              ("TSF: 0x%p   nsTextStore::GetTextExt() FAILED due to "
               "no top level window", this));
       return E_FAIL;
     }
 
-    event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped());
+    event.mReply.mRect.MoveBy(refWindow->WidgetToScreenOffset());
   }
 
   // get bounding screen rect to test for clipping
   if (!GetScreenExtInternal(*prc)) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::GetTextExt() FAILED due to "
             "GetScreenExtInternal() failure", this));
     return E_FAIL;
@@ -3329,17 +3329,17 @@ nsTextStore::GetScreenExtInternal(RECT &
              ("TSF: 0x%p   nsTextStore::GetScreenExtInternal() FAILED due to "
               "failed to get the client bounds", this));
       return false;
     }
 
     boundRect.MoveTo(0, 0);
 
     // Clip frame rect to window rect
-    boundRect.IntersectRect(event.mReply.mRect, boundRect);
+    boundRect.IntersectRect(LayoutDevicePixel::ToUntyped(event.mReply.mRect), boundRect);
     if (!boundRect.IsEmpty()) {
       boundRect.MoveBy(refWindow->WidgetToScreenOffsetUntyped());
       ::SetRect(&aScreenExt, boundRect.x, boundRect.y,
                 boundRect.XMost(), boundRect.YMost());
     } else {
       ::SetRectEmpty(&aScreenExt);
     }
   }
@@ -4300,17 +4300,17 @@ nsTextStore::CreateNativeCaret()
   mWidget->DispatchWindowEvent(&queryCaretRect);
   if (!queryCaretRect.mSucceeded) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::CreateNativeCaret() FAILED due to "
             "NS_QUERY_CARET_RECT failure (offset=%d)", this, caretOffset));
     return;
   }
 
-  nsIntRect& caretRect = queryCaretRect.mReply.mRect;
+  LayoutDeviceIntRect& caretRect = queryCaretRect.mReply.mRect;
   mNativeCaretIsCreated = ::CreateCaret(mWidget->GetWindowHandle(), nullptr,
                                         caretRect.width, caretRect.height);
   if (!mNativeCaretIsCreated) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::CreateNativeCaret() FAILED due to "
             "CreateCaret() failure", this));
     return;
   }
@@ -4320,18 +4320,18 @@ nsTextStore::CreateNativeCaret()
   if (!toplevelWindow) {
     PR_LOG(sTextStoreLog, PR_LOG_ERROR,
            ("TSF: 0x%p   nsTextStore::CreateNativeCaret() FAILED due to "
             "no top level window", this));
     return;
   }
 
   if (toplevelWindow != window) {
-    caretRect.MoveBy(toplevelWindow->WidgetToScreenOffsetUntyped());
-    caretRect.MoveBy(-window->WidgetToScreenOffsetUntyped());
+    caretRect.MoveBy(toplevelWindow->WidgetToScreenOffset());
+    caretRect.MoveBy(-window->WidgetToScreenOffset());
   }
 
   ::SetCaretPos(caretRect.x, caretRect.y);
 }
 
 void
 nsTextStore::CommitCompositionInternal(bool aDiscard)
 {