Bug 1260091 - Move using SendBidiKeyboardNotify to WidgetUtils. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 19 May 2016 17:47:49 +0900
changeset 298102 4367dd6106dade58eb66ef59c716b369629bac44
parent 298101 830a12b195deadfec1bc69e3f3dd7f498740fee3
child 298103 666bfc7f00ff8b04faab18285bb046817b1d1c90
push id30270
push userryanvm@gmail.com
push dateThu, 19 May 2016 16:47:16 +0000
treeherdermozilla-central@1806d405c871 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1260091
milestone49.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 1260091 - Move using SendBidiKeyboardNotify to WidgetUtils. r=masayuki For e10s, we send Bidi keyboard information to content process. We should add utility method to share it for all platforms. MozReview-Commit-ID: JJX26OivQvt
widget/WidgetUtils.cpp
widget/WidgetUtils.h
widget/cocoa/TextInputHandler.mm
widget/windows/nsBidiKeyboard.cpp
--- a/widget/WidgetUtils.cpp
+++ b/widget/WidgetUtils.cpp
@@ -1,16 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=8 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "mozilla/WidgetUtils.h"
+#include "mozilla/dom/ContentParent.h"
+#include "mozilla/unused.h"
+#include "nsContentUtils.h"
+#include "nsIBidiKeyboard.h"
+#include "nsTArray.h"
 #ifdef XP_WIN
 #include "WinUtils.h"
 #endif
 #if MOZ_WIDGET_GTK == 3
 #include "mozilla/WidgetUtilsGtk.h"
 #endif
 
 namespace mozilla {
@@ -104,10 +109,31 @@ WidgetUtils::IsTouchDeviceSupportPresent
   return WinUtils::IsTouchDeviceSupportPresent();
 #elif MOZ_WIDGET_GTK == 3
   return WidgetUtilsGTK::IsTouchDeviceSupportPresent();
 #else
   return 0;
 #endif
 }
 
+// static
+void
+WidgetUtils::SendBidiKeyboardInfoToContent()
+{
+  nsCOMPtr<nsIBidiKeyboard> bidiKeyboard = nsContentUtils::GetBidiKeyboard();
+  if (!bidiKeyboard) {
+    return;
+  }
+
+  bool rtl;
+  if (NS_FAILED(bidiKeyboard->IsLangRTL(&rtl))) {
+    return;
+  }
+
+  nsTArray<dom::ContentParent*> children;
+  dom::ContentParent::GetAll(children);
+  for (uint32_t i = 0; i < children.Length(); i++) {
+    Unused << children[i]->SendBidiKeyboardNotify(rtl);
+  }
+}
+
 } // namespace widget
 } // namespace mozilla
--- a/widget/WidgetUtils.h
+++ b/widget/WidgetUtils.h
@@ -81,14 +81,19 @@ public:
                                          bool aIsCapsLock,
                                          uint32_t* aUnshiftedCharCode,
                                          uint32_t* aShiftedCharCode);
 
   /**
   * Does device have touch support
   */
   static uint32_t IsTouchDeviceSupportPresent();
+
+  /**
+   * Send bidi keyboard information to content process
+   */
+  static void SendBidiKeyboardInfoToContent();
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif // mozilla_WidgetUtils_h
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -17,18 +17,16 @@
 
 #include "nsChildView.h"
 #include "nsObjCExceptions.h"
 #include "nsBidiUtils.h"
 #include "nsToolkit.h"
 #include "nsCocoaUtils.h"
 #include "WidgetUtils.h"
 #include "nsPrintfCString.h"
-#include "mozilla/unused.h"
-#include "mozilla/dom/ContentParent.h"
 #include "ComplexTextInputPanel.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 PRLogModuleInfo* gLog = nullptr;
 
 static const char*
@@ -2419,21 +2417,17 @@ IMEInputHandler::OnCurrentTextInputSourc
   }
 
   /**
    * When the direction is changed, all the children are notified.
    * No need to treat the initial case separately because it is covered
    * by the general case (sCachedIsForRTLLangage is initially false)
    */
   if (sCachedIsForRTLLangage != tis.IsForRTLLanguage()) {
-    nsTArray<dom::ContentParent*> children;
-    dom::ContentParent::GetAll(children);
-    for (uint32_t i = 0; i < children.Length(); i++) {
-      Unused << children[i]->SendBidiKeyboardNotify(tis.IsForRTLLanguage());
-    }
+    WidgetUtils::SendBidiKeyboardInfoToContent();
     sCachedIsForRTLLangage = tis.IsForRTLLanguage();
   }
 }
 
 // static
 void
 IMEInputHandler::FlushPendingMethods(nsITimer* aTimer, void* aClosure)
 {
--- a/widget/windows/nsBidiKeyboard.cpp
+++ b/widget/windows/nsBidiKeyboard.cpp
@@ -1,21 +1,18 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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 <stdio.h>
 #include "nsBidiKeyboard.h"
+#include "WidgetUtils.h"
 #include "prmem.h"
-#include "nsServiceManagerUtils.h"
-#include "nsTArray.h"
-#include "nsContentUtils.h"
-#include "mozilla/dom/ContentParent.h"
 #include <tchar.h>
 
 NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
 
 nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
 {
   Reset();
 }
@@ -181,24 +178,10 @@ bool nsBidiKeyboard::IsRTLLanguage(HKL a
                            (sizeof(localesig)/sizeof(WCHAR))) &&
           (localesig.lsUsb[3] & 0x08000000));
 }
 
 //static
 void
 nsBidiKeyboard::OnLayoutChange()
 {
-  nsCOMPtr<nsIBidiKeyboard> bidiKeyboard = nsContentUtils::GetBidiKeyboard();
-  if (!bidiKeyboard) {
-    return;
-  }
-
-  bool rtl;
-  if (NS_FAILED(bidiKeyboard->IsLangRTL(&rtl))) {
-    return;
-  }
-
-  nsTArray<mozilla::dom::ContentParent*> children;
-  mozilla::dom::ContentParent::GetAll(children);
-  for (uint32_t i = 0; i < children.Length(); i++) {
-    children[i]->SendBidiKeyboardNotify(rtl);
-  }
+  mozilla::widget::WidgetUtils::SendBidiKeyboardInfoToContent();
 }