Bug 1130935 part.3 Add hack for Japanist because its candidate window is broken with @System font r=emk
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 15 May 2015 10:18:07 +0900
changeset 244009 3cca44bb0f434426685cebeadcb3e7568407439c
parent 244008 eb660def02c0f6a1568e98ea6f5b48f46a2a0929
child 244010 8ba5a18f576859065bf862a57d70956d86a3101d
push id28762
push usercbook@mozilla.com
push dateFri, 15 May 2015 15:40:04 +0000
treeherdermozilla-central@1a8343f8ed83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1130935
milestone41.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 1130935 part.3 Add hack for Japanist because its candidate window is broken with @System font r=emk
modules/libpref/init/all.js
widget/windows/nsIMM32Handler.cpp
widget/windows/nsIMM32Handler.h
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3072,16 +3072,23 @@ pref("intl.tsf.hack.google_ja_input.do_n
 // If composition_font is set, Gecko sets the font to IME.  IME may use
 // the fonts on their window like candidate window.  If they are empty,
 // Gecko uses the system default font which is set to the IM context.
 // The font name must not start with '@'.  When the writing mode is vertical,
 // Gecko inserts '@' to the start of the font name automatically.
 // FYI: Changing these prefs requires to restart.
 pref("intl.imm.composition_font", "");
 
+// Japanist 2003's candidate window is broken if the font is "@System" which
+// is default composition font for vertical writing mode.
+// You can specify font to use on candidate window of Japanist 2003.
+// This value must not start with '@'.
+// FYI: Changing this pref requires to restart.
+pref("intl.imm.composition_font.japanist_2003", "MS PGothic");
+
 // Even if IME claims that they support vertical writing mode but it may not
 // support vertical writing mode for its candidate window.  This pref allows
 // to ignore the claim.
 // FYI: Changing this pref requires to restart.
 pref("intl.imm.vertical_writing.always_assume_not_supported", false);
 
 // See bug 448927, on topmost panel, some IMEs are not usable on Windows.
 pref("ui.panel.default_level_parent", false);
--- a/widget/windows/nsIMM32Handler.cpp
+++ b/widget/windows/nsIMM32Handler.cpp
@@ -175,16 +175,23 @@ nsIMM32Handler::IsTopLevelWindowOfCompos
 {
   if (!gIMM32Handler || !gIMM32Handler->mComposingWindow) {
     return false;
   }
   HWND wnd = gIMM32Handler->mComposingWindow->GetWindowHandle();
   return WinUtils::GetTopLevelHWND(wnd, true) == aWindow->GetWindowHandle();
 }
 
+/* static */
+bool
+nsIMM32Handler::IsJapanist2003Active()
+{
+  return sIMEName.EqualsLiteral("Japanist 2003");
+}
+
 /* static */ bool
 nsIMM32Handler::ShouldDrawCompositionStringOurselves()
 {
   // If current IME has special UI or its composition window should not
   // positioned to caret position, we should now draw composition string
   // ourselves.
   return !(sIMEProperty & IME_PROP_SPECIAL_UI) &&
           (sIMEProperty & IME_PROP_AT_CARET);
@@ -2200,16 +2207,31 @@ nsIMM32Handler::AdjustCompositionFont(co
       }
     }
 
     PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
       ("IMM32: AdjustCompositionFont, sCompositionFont=\"%s\" is initialized",
        NS_ConvertUTF16toUTF8(sCompositionFont).get()));
   }
 
+  static nsString sCompositionFontForJapanist2003;
+  if (IsJapanist2003Active() && sCompositionFontForJapanist2003.IsEmpty()) {
+    const char* kCompositionFontForJapanist2003 =
+      "intl.imm.composition_font.japanist_2003";
+    sCompositionFontForJapanist2003 =
+      Preferences::GetString(kCompositionFontForJapanist2003);
+    // If the font name is not specified properly, let's use
+    // "MS PGothic" instead.
+    if (sCompositionFontForJapanist2003.IsEmpty() ||
+        sCompositionFontForJapanist2003.Length() > LF_FACESIZE - 2 ||
+        sCompositionFontForJapanist2003[0] == '@') {
+      sCompositionFontForJapanist2003.AssignLiteral("MS PGothic");
+    }
+  }
+
   sCurrentWritingMode = aWritingMode;
   sCurrentIMEName = sIMEName;
 
   LOGFONTW logFont;
   memset(&logFont, 0, sizeof(logFont));
   if (!::ImmGetCompositionFont(aIMEContext.get(), &logFont)) {
     PR_LOG(gIMM32Log, PR_LOG_ERROR,
       ("IMM32: AdjustCompositionFont, ::ImmGetCompositionFont() failed"));
@@ -2219,19 +2241,23 @@ nsIMM32Handler::AdjustCompositionFont(co
   logFont.lfWidth = 0;
   logFont.lfWeight = FW_DONTCARE;
   logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
   logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
   logFont.lfPitchAndFamily = DEFAULT_PITCH;
 
   if (!mIsComposingOnPlugin &&
       aWritingMode.IsVertical() && IsVerticalWritingSupported()) {
-    SetVerticalFontToLogFont(sCompositionFont, logFont);
+    SetVerticalFontToLogFont(
+      IsJapanist2003Active() ? sCompositionFontForJapanist2003 :
+                               sCompositionFont, logFont);
   } else {
-    SetHorizontalFontToLogFont(sCompositionFont, logFont);
+    SetHorizontalFontToLogFont(
+      IsJapanist2003Active() ? sCompositionFontForJapanist2003 :
+                               sCompositionFont, logFont);
   }
   PR_LOG(gIMM32Log, PR_LOG_WARNING,
     ("IMM32: AdjustCompositionFont, calling ::ImmSetCompositionFont(\"%s\")",
      NS_ConvertUTF16toUTF8(nsDependentString(logFont.lfFaceName)).get()));
   ::ImmSetCompositionFontW(aIMEContext.get(), &logFont);
 }
 
 /* static */ nsresult
--- a/widget/windows/nsIMM32Handler.h
+++ b/widget/windows/nsIMM32Handler.h
@@ -156,16 +156,18 @@ public:
 
 protected:
   static void EnsureHandlerInstance();
 
   static bool IsComposingOnOurEditor();
   static bool IsComposingOnPlugin();
   static bool IsComposingWindow(nsWindow* aWindow);
 
+  static bool IsJapanist2003Active();
+
   static bool ShouldDrawCompositionStringOurselves();
   static bool IsVerticalWritingSupported();
   static void InitKeyboardLayout(HKL aKeyboardLayout);
   static UINT GetKeyboardCodePage();
 
   /**
    * Checks whether the window is top level window of the composing window.
    * In this method, the top level window means in all windows, not only in all