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
--- 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 "nsTArray.h"
+#include "nsContentUtils.h"
+#include "nsIBidiKeyboard.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<mozilla::dom::ContentParent*> children;
+ mozilla::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();
}