Bug 1357638 - Use Preferences::AddBoolVarCache() to accelerate dom.forms.inputmode access in IMEStateManager::SetIMEState(), r=masayuki
MozReview-Commit-ID: 8SMud0v3jFr
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -141,26 +141,32 @@ StaticRefPtr<nsPresContext> IMEStateMana
nsIWidget* IMEStateManager::sFocusedIMEWidget = nullptr;
nsIWidget* IMEStateManager::sActiveInputContextWidget = nullptr;
StaticRefPtr<TabParent> IMEStateManager::sActiveTabParent;
StaticRefPtr<IMEContentObserver> IMEStateManager::sActiveIMEContentObserver;
TextCompositionArray* IMEStateManager::sTextCompositions = nullptr;
bool IMEStateManager::sInstalledMenuKeyboardListener = false;
bool IMEStateManager::sIsGettingNewIMEState = false;
bool IMEStateManager::sCheckForIMEUnawareWebApps = false;
+bool IMEStateManager::sInputModeSupported = false;
bool IMEStateManager::sRemoteHasFocus = false;
// static
void
IMEStateManager::Init()
{
Preferences::AddBoolVarCache(
&sCheckForIMEUnawareWebApps,
"intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition",
false);
+
+ Preferences::AddBoolVarCache(
+ &sInputModeSupported,
+ "dom.forms.inputmode",
+ false);
}
// static
void
IMEStateManager::Shutdown()
{
MOZ_LOG(sISMLog, LogLevel::Info,
("Shutdown(), sTextCompositions=0x%p, sTextCompositions->Length()=%" PRIuSIZE,
@@ -995,17 +1001,17 @@ IMEStateManager::SetIMEState(const IMESt
}
}
content->GetAttr(kNameSpaceID_None, nsGkAtoms::type,
context.mHTMLInputType);
} else {
context.mHTMLInputType.Assign(nsGkAtoms::textarea->GetUTF16String());
}
- if (Preferences::GetBool("dom.forms.inputmode", false) ||
+ if (sInputModeSupported ||
nsContentUtils::IsChromeDoc(aContent->OwnerDoc())) {
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::inputmode,
context.mHTMLInputInputmode);
}
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::moz_action_hint,
context.mActionHint);
--- a/dom/events/IMEStateManager.h
+++ b/dom/events/IMEStateManager.h
@@ -280,16 +280,17 @@ protected:
// When you get an item of this array and use it, please be careful.
// The instances in this array can be destroyed automatically if you do
// something to cause committing or canceling the composition.
static TextCompositionArray* sTextCompositions;
static bool sInstalledMenuKeyboardListener;
static bool sIsGettingNewIMEState;
static bool sCheckForIMEUnawareWebApps;
+ static bool sInputModeSupported;
static bool sRemoteHasFocus;
class MOZ_STACK_CLASS GettingNewIMEStateBlocker final
{
public:
GettingNewIMEStateBlocker()
: mOldValue(IMEStateManager::sIsGettingNewIMEState)
{