bug 1622111 - Convert intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition to static pref r=njn

Converts `intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition` to a static pref.

Differential Revision: https://phabricator.services.mozilla.com/D67203

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kristen Wright 2020-03-18 22:25:54 +00:00
Родитель 92d93617df
Коммит eef87691dc
3 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -13,9 +13,9 @@
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_intl.h"
#include "mozilla/TextComposition.h"
#include "mozilla/TextEvents.h"
#include "mozilla/ToString.h"
@ -76,15 +76,9 @@ InputContext::Origin IMEStateManager::sOrigin = InputContext::ORIGIN_MAIN;
InputContext IMEStateManager::sActiveChildInputContext;
bool IMEStateManager::sInstalledMenuKeyboardListener = false;
bool IMEStateManager::sIsGettingNewIMEState = false;
bool IMEStateManager::sCheckForIMEUnawareWebApps = false;
// static
void IMEStateManager::Init() {
Preferences::AddBoolVarCache(
&sCheckForIMEUnawareWebApps,
"intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition",
false);
sOrigin = XRE_IsParentProcess() ? InputContext::ORIGIN_MAIN
: InputContext::ORIGIN_CONTENT;
ResetActiveChildInputContext();
@ -1262,9 +1256,11 @@ void IMEStateManager::SetIMEState(const IMEState& aState,
InputContext context;
context.mIMEState = aState;
context.mOrigin = aOrigin;
context.mMayBeIMEUnaware = context.mIMEState.IsEditable() &&
sCheckForIMEUnawareWebApps &&
MayBeIMEUnawareWebApp(aContent);
context.mMayBeIMEUnaware =
context.mIMEState.IsEditable() &&
StaticPrefs::
intl_ime_hack_on_ime_unaware_apps_fire_key_events_for_composition() &&
MayBeIMEUnawareWebApp(aContent);
context.mHasHandledUserInput =
aPresContext && aPresContext->PresShell()->HasHandledUserInput();

Просмотреть файл

@ -4456,6 +4456,18 @@
value: @IS_ANDROID@
mirror: always
# Android-specific pref to control if keydown and keyup events are fired even
# during composition. Note that those prefs are ignored if
# dom.keyboardevent.dispatch_during_composition is false.
- name: intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition
type: bool
# If true and intl.ime.hack.on_any_apps.fire_key_events_for_composition is
# false, dispatch the keydown and keyup events only on IME-unaware web apps.
# So, this supports web apps which listen to only keydown or keyup events
# to get a change to do something at every text input.
value: @IS_ANDROID@
mirror: always
#---------------------------------------------------------------------------
# Prefs starting with "javascript."
#---------------------------------------------------------------------------

Просмотреть файл

@ -2037,19 +2037,6 @@ pref("intl.fallbackCharsetList.ISO-8859-1", "windows-1252");
pref("font.language.group", "chrome://global/locale/intl.properties");
pref("font.cjk_pref_fallback_order", "zh-cn,zh-hk,zh-tw,ja,ko");
// Android-specific pref to control if keydown and keyup events are fired even
// in during composition. Note that those prefs are ignored if
// "dom.keyboardevent.dispatch_during_composition" is false.
#ifdef MOZ_WIDGET_ANDROID
// If true and intl.ime.hack.on_any_apps.fire_key_events_for_composition is
// false, dispatch the keydown and keyup events only on IME-unaware web apps.
// So, this supports web apps which listen to only keydown or keyup events
// to get a change to do something at every text input.
pref("intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition", true);
#else
pref("intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition", false);
#endif // MOZ_WIDGET_ANDROID
// If you use legacy Chinese IME which puts an ideographic space to composition
// string as placeholder, this pref might be useful. If this is true and when
// web contents forcibly commits composition (e.g., moving focus), the