Bug 1357638 - Use Preferences::AddBoolVarCache() to accelerate dom.forms.inputmode access in IMEStateManager::SetIMEState(), r=masayuki draft
authorbtian <btian@mozilla.com>
Fri, 21 Apr 2017 14:48:36 +0800
changeset 566218 262b33a1076a3a9c7b6d2d9794221bff756664fc
parent 566156 8b854986038cf3f3f240697e27ef48ea65914c13
child 566234 baff70126575b301983226efec3836933c01bc8f
child 566258 2a20d95684175dfc9563f1cf90d6807c6c527fcf
push id55146
push userbmo:btian@mozilla.com
push dateFri, 21 Apr 2017 06:55:05 +0000
reviewersmasayuki
bugs1357638
milestone55.0a1
Bug 1357638 - Use Preferences::AddBoolVarCache() to accelerate dom.forms.inputmode access in IMEStateManager::SetIMEState(), r=masayuki MozReview-Commit-ID: 8SMud0v3jFr
dom/events/IMEStateManager.cpp
dom/events/IMEStateManager.h
--- 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)
     {