Bug 1224403 (part 7) - Use LayoutDeviceIntMargin more in IMMHandler. r=kats.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 12 Nov 2015 05:22:44 -0800
changeset 308735 c62ae26405f4577d022a80fad1b1f131e8493f58
parent 308734 6c83f9b94af271ce17f3f4c7ec31317a9029dd87
child 308736 c7bddc993c53e9beefdd7995dfd195576e54faf2
push id7515
push usermjzffr@gmail.com
push dateFri, 13 Nov 2015 14:42:42 +0000
reviewerskats
bugs1224403
milestone45.0a1
Bug 1224403 (part 7) - Use LayoutDeviceIntMargin more in IMMHandler. r=kats.
widget/windows/IMMHandler.cpp
widget/windows/IMMHandler.h
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -1627,22 +1627,22 @@ IMMHandler::HandleQueryCharPosition(nsWi
   if (pCharPosition->dwCharPos > len) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: HandleQueryCharPosition, FAILED, pCharPosition->dwCharPos=%ld, "
        "len=%ld",
        pCharPosition->dwCharPos, len));
     return false;
   }
 
-  nsIntRect r;
+  LayoutDeviceIntRect r;
   bool ret =
     GetCharacterRectOfSelectedTextAt(aWindow, pCharPosition->dwCharPos, r);
   NS_ENSURE_TRUE(ret, false);
 
-  nsIntRect screenRect;
+  LayoutDeviceIntRect screenRect;
   // We always need top level window that is owner window of the popup window
   // even if the content of the popup window has focus.
   ResolveIMECaretPos(aWindow->GetTopLevelWindow(false),
                      r, nullptr, screenRect);
 
   // XXX This might need to check writing mode.  However, MSDN doesn't explain
   //     how to set the values in vertical writing mode. Additionally, IME
   //     doesn't work well with top-left of the character (this is explicitly
@@ -1657,20 +1657,20 @@ IMMHandler::HandleQueryCharPosition(nsWi
   WidgetQueryContentEvent editorRect(true, eQueryEditorRect, aWindow);
   aWindow->InitEvent(editorRect);
   aWindow->DispatchWindowEvent(&editorRect);
   if (NS_WARN_IF(!editorRect.mSucceeded)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: HandleQueryCharPosition, eQueryEditorRect failed"));
     ::GetWindowRect(aWindow->GetWindowHandle(), &pCharPosition->rcDocument);
   } else {
-    nsIntRect editorRectInWindow = editorRect.mReply.mRect.ToUnknownRect();
+    LayoutDeviceIntRect editorRectInWindow = editorRect.mReply.mRect;
     nsWindow* window = editorRect.mReply.mFocusedWidget ?
       static_cast<nsWindow*>(editorRect.mReply.mFocusedWidget) : aWindow;
-    nsIntRect editorRectInScreen;
+    LayoutDeviceIntRect editorRectInScreen;
     ResolveIMECaretPos(window, editorRectInWindow, nullptr, editorRectInScreen);
     ::SetRect(&pCharPosition->rcDocument,
               editorRectInScreen.x, editorRectInScreen.y,
               editorRectInScreen.XMost(), editorRectInScreen.YMost());
   }
 
   *oResult = TRUE;
 
@@ -2089,17 +2089,17 @@ IMMHandler::ConvertToANSIString(const ns
   ::WideCharToMultiByte(aCodePage, 0, (LPCWSTR)aStr.get(), aStr.Length(),
                         (LPSTR)aANSIStr.BeginWriting(), len, nullptr, nullptr);
   return true;
 }
 
 bool
 IMMHandler::GetCharacterRectOfSelectedTextAt(nsWindow* aWindow,
                                              uint32_t aOffset,
-                                             nsIntRect& aCharRect,
+                                             LayoutDeviceIntRect& aCharRect,
                                              WritingMode* aWritingMode)
 {
   LayoutDeviceIntPoint point(0, 0);
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: GetCharacterRectOfSelectedTextAt, FAILED, due to "
@@ -2164,17 +2164,17 @@ IMMHandler::GetCharacterRectOfSelectedTe
   // If there is a caret and retrieving offset is same as the caret offset,
   // we should use the caret rect.
   if (offset != caretOffset) {
     WidgetQueryContentEvent charRect(true, eQueryTextRect, aWindow);
     charRect.InitForQueryTextRect(offset, 1);
     aWindow->InitEvent(charRect, &point);
     aWindow->DispatchWindowEvent(&charRect);
     if (charRect.mSucceeded) {
-      aCharRect = charRect.mReply.mRect.ToUnknownRect();
+      aCharRect = charRect.mReply.mRect;
       if (aWritingMode) {
         *aWritingMode = charRect.GetWritingMode();
       }
       MOZ_LOG(gIMMLog, LogLevel::Debug,
         ("IMM: GetCharacterRectOfSelectedTextAt, Succeeded, aOffset=%u, "
          "aCharRect={ x: %ld, y: %ld, width: %ld, height: %ld }, "
          "charRect.GetWritingMode()=%s",
          aOffset, aCharRect.x, aCharRect.y, aCharRect.width, aCharRect.height,
@@ -2183,17 +2183,17 @@ IMMHandler::GetCharacterRectOfSelectedTe
     }
   }
 
   return GetCaretRect(aWindow, aCharRect, aWritingMode);
 }
 
 bool
 IMMHandler::GetCaretRect(nsWindow* aWindow,
-                         nsIntRect& aCaretRect,
+                         LayoutDeviceIntRect& aCaretRect,
                          WritingMode* aWritingMode)
 {
   LayoutDeviceIntPoint point(0, 0);
 
   Selection& selection = GetSelection();
   if (!selection.EnsureValidSelection(aWindow)) {
     MOZ_LOG(gIMMLog, LogLevel::Error,
       ("IMM: GetCaretRect, FAILED, due to "
@@ -2205,47 +2205,47 @@ IMMHandler::GetCaretRect(nsWindow* aWind
   caretRect.InitForQueryCaretRect(selection.mOffset);
   aWindow->InitEvent(caretRect, &point);
   aWindow->DispatchWindowEvent(&caretRect);
   if (!caretRect.mSucceeded) {
     MOZ_LOG(gIMMLog, LogLevel::Info,
       ("IMM: GetCaretRect, FAILED, due to eQueryCaretRect failure"));
     return false;
   }
-  aCaretRect = caretRect.mReply.mRect.ToUnknownRect();
+  aCaretRect = caretRect.mReply.mRect;
   if (aWritingMode) {
     *aWritingMode = caretRect.GetWritingMode();
   }
   MOZ_LOG(gIMMLog, LogLevel::Info,
     ("IMM: GetCaretRect, SUCCEEDED, "
      "aCaretRect={ x: %ld, y: %ld, width: %ld, height: %ld }, "
      "caretRect.GetWritingMode()=%s",
      aCaretRect.x, aCaretRect.y, aCaretRect.width, aCaretRect.height,
      GetWritingModeName(caretRect.GetWritingMode()).get()));
   return true;
 }
 
 bool
 IMMHandler::SetIMERelatedWindowsPos(nsWindow* aWindow,
                                     const IMEContext& aContext)
 {
-  nsIntRect r;
+  LayoutDeviceIntRect r;
   // Get first character rect of current a normal selected text or a composing
   // string.
   WritingMode writingMode;
   bool ret = GetCharacterRectOfSelectedTextAt(aWindow, 0, r, &writingMode);
   NS_ENSURE_TRUE(ret, false);
   nsWindow* toplevelWindow = aWindow->GetTopLevelWindow(false);
-  nsIntRect firstSelectedCharRect;
+  LayoutDeviceIntRect firstSelectedCharRect;
   ResolveIMECaretPos(toplevelWindow, r, aWindow, firstSelectedCharRect);
 
   // Set native caret size/position to our caret. Some IMEs honor it. E.g.,
   // "Intelligent ABC" (Simplified Chinese) and "MS PinYin 3.0" (Simplified
   // Chinese) on XP.
-  nsIntRect caretRect(firstSelectedCharRect);
+  LayoutDeviceIntRect caretRect(firstSelectedCharRect);
   if (GetCaretRect(aWindow, r)) {
     ResolveIMECaretPos(toplevelWindow, r, aWindow, caretRect);
   } else {
     NS_WARNING("failed to get caret rect");
     caretRect.width = 1;
   }
   if (!mNativeCaretIsCreated) {
     mNativeCaretIsCreated = ::CreateCaret(aWindow->GetWindowHandle(), nullptr,
@@ -2257,17 +2257,17 @@ IMMHandler::SetIMERelatedWindowsPos(nsWi
   }
   ::SetCaretPos(caretRect.x, caretRect.y);
 
   if (ShouldDrawCompositionStringOurselves()) {
     MOZ_LOG(gIMMLog, LogLevel::Info,
       ("IMM: SetIMERelatedWindowsPos, Set candidate window"));
 
     // Get a rect of first character in current target in composition string.
-    nsIntRect firstTargetCharRect, lastTargetCharRect;
+    LayoutDeviceIntRect firstTargetCharRect, lastTargetCharRect;
     if (mIsComposing && !mCompositionString.IsEmpty()) {
       // If there are no targetted selection, we should use it's first character
       // rect instead.
       uint32_t offset, length;
       if (!GetTargetClauseRange(&offset, &length)) {
         MOZ_LOG(gIMMLog, LogLevel::Error,
           ("IMM: SetIMERelatedWindowsPos, FAILED, due to "
            "GetTargetClauseRange() failure"));
@@ -2291,17 +2291,17 @@ IMMHandler::SetIMERelatedWindowsPos(nsWi
                                              firstTargetCharRect, &writingMode);
       NS_ENSURE_TRUE(ret, false);
       lastTargetCharRect = firstTargetCharRect;
     }
     ResolveIMECaretPos(toplevelWindow, firstTargetCharRect,
                        aWindow, firstTargetCharRect);
     ResolveIMECaretPos(toplevelWindow, lastTargetCharRect,
                        aWindow, lastTargetCharRect);
-    nsIntRect targetClauseRect;
+    LayoutDeviceIntRect targetClauseRect;
     targetClauseRect.UnionRect(firstTargetCharRect, lastTargetCharRect);
 
     // Move the candidate window to proper position from the target clause as
     // far as possible.
     CANDIDATEFORM candForm;
     candForm.dwIndex = 0;
     if (!writingMode.IsVertical() || IsVerticalWritingSupported()) {
       candForm.dwStyle = CFS_EXCLUDE;
@@ -2430,30 +2430,30 @@ IMMHandler::SetIMERelatedWindowsPosOnPlu
       ("IMM: SetIMERelatedWindowsPosOnPlugin, "
        "FAILED, due to ::ImmSetCompositionWindow() failure"));
     return;
   }
 }
 
 void
 IMMHandler::ResolveIMECaretPos(nsIWidget* aReferenceWidget,
-                               nsIntRect& aCursorRect,
+                               LayoutDeviceIntRect& aCursorRect,
                                nsIWidget* aNewOriginWidget,
-                               nsIntRect& aOutRect)
+                               LayoutDeviceIntRect& aOutRect)
 {
   aOutRect = aCursorRect;
 
   if (aReferenceWidget == aNewOriginWidget)
     return;
 
   if (aReferenceWidget)
-    aOutRect.MoveBy(aReferenceWidget->WidgetToScreenOffsetUntyped());
+    aOutRect.MoveBy(aReferenceWidget->WidgetToScreenOffset());
 
   if (aNewOriginWidget)
-    aOutRect.MoveBy(-aNewOriginWidget->WidgetToScreenOffsetUntyped());
+    aOutRect.MoveBy(-aNewOriginWidget->WidgetToScreenOffset());
 }
 
 static void
 SetHorizontalFontToLogFont(const nsAString& aFontFace,
                            LOGFONTW& aLogFont)
 {
   aLogFont.lfEscapement = aLogFont.lfOrientation = 0;
   if (NS_WARN_IF(aFontFace.Length() > LF_FACESIZE - 1)) {
--- a/widget/windows/IMMHandler.h
+++ b/widget/windows/IMMHandler.h
@@ -262,19 +262,19 @@ protected:
    *                          coordinates, set nullptr.
    *  @param aCursorRect      The cursor rect.
    *  @param aNewOriginWidget aOutRect will be in this widget's coordinates. If
    *                          this is nullptr, aOutRect will be in screen
    *                          coordinates.
    *  @param aOutRect         The converted cursor rect.
    */
   void ResolveIMECaretPos(nsIWidget* aReferenceWidget,
-                          nsIntRect& aCursorRect,
+                          mozilla::LayoutDeviceIntRect& aCursorRect,
                           nsIWidget* aNewOriginWidget,
-                          nsIntRect& aOutRect);
+                          mozilla::LayoutDeviceIntRect& aOutRect);
 
   bool ConvertToANSIString(const nsAFlatString& aStr,
                              UINT aCodePage,
                              nsACString& aANSIStr);
 
   bool SetIMERelatedWindowsPos(nsWindow* aWindow,
                                const IMEContext& aContext);
   void SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow,
@@ -294,31 +294,31 @@ protected:
    *                        is nullptr, this assumes that the selection is in
    *                        horizontal writing mode.
    * @return                true if this succeeded to retrieve the rect.
    *                        Otherwise, false.
    */
   bool GetCharacterRectOfSelectedTextAt(
          nsWindow* aWindow,
          uint32_t aOffset,
-         nsIntRect& aCharRect,
+         mozilla::LayoutDeviceIntRect& aCharRect,
          mozilla::WritingMode* aWritingMode = nullptr);
   /**
    * GetCaretRect() returns caret rect at current selection start.
    *
    * @param aWindow         The window which has focus.
    * @param aCaretRect      The result.
    * @param aWritingMode    The writing mode of current selection.  When this
    *                        is nullptr, this assumes that the selection is in
    *                        horizontal writing mode.
    * @return                true if this succeeded to retrieve the rect.
    *                        Otherwise, false.
    */
   bool GetCaretRect(nsWindow* aWindow,
-                    nsIntRect& aCaretRect,
+                    mozilla::LayoutDeviceIntRect& aCaretRect,
                     mozilla::WritingMode* aWritingMode = nullptr);
   void GetCompositionString(const IMEContext& aContext,
                             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