Bug 777972 - [responsive mode] translate click events to touch events. r=smaug
authorPaul Rouget <paul@mozilla.com>
Tue, 03 Sep 2013 09:15:51 +0200
changeset 145229 acd1d842771828ac5546c8922740195100d6ec5c
parent 145228 9cc1839ef1f25741216a529bfa0aed71163a7e7c
child 145230 8b82a374ece51b3d874bbc41db97ef5b2e0c5026
push id2476
push userprouget@mozilla.com
push dateTue, 03 Sep 2013 07:16:13 +0000
treeherderfx-team@61a110ae7914 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs777972
milestone26.0a1
Bug 777972 - [responsive mode] translate click events to touch events. r=smaug
content/events/src/nsDOMTouchEvent.cpp
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -188,40 +188,42 @@ namespace mozilla {
 namespace widget {
 extern int32_t IsTouchDeviceSupportPresent();
 } }
 #endif
 
 bool
 nsDOMTouchEvent::PrefEnabled()
 {
-  static bool sDidCheckPref = false;
-  static bool sPrefValue = false;
-  if (!sDidCheckPref) {
-    sDidCheckPref = true;
-    int32_t flag = 0;
-    if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled",
-                                         &flag))) {
-      if (flag == 2) {
+  bool prefValue = false;
+  int32_t flag = 0;
+  if (NS_SUCCEEDED(Preferences::GetInt("dom.w3c_touch_events.enabled",
+                                        &flag))) {
+    if (flag == 2) {
 #ifdef XP_WIN
-        // On Windows we auto-detect based on device support.
-        sPrefValue = mozilla::widget::IsTouchDeviceSupportPresent();
+      static bool sDidCheckTouchDeviceSupport = false;
+      static bool sIsTouchDeviceSupportPresent = false;
+      // On Windows we auto-detect based on device support.
+      if (!sDidCheckTouchDeviceSupport) {
+        sDidCheckTouchDeviceSupport = true;
+        sIsTouchDeviceSupportPresent = mozilla::widget::IsTouchDeviceSupportPresent();
+      }
+      prefValue = sIsTouchDeviceSupportPresent;
 #else
-        NS_WARNING("dom.w3c_touch_events.enabled=2 not implemented!");
-        sPrefValue = false;
+      NS_WARNING("dom.w3c_touch_events.enabled=2 not implemented!");
+      prefValue = false;
 #endif
-      } else {
-        sPrefValue = !!flag;
-      }
-    }
-    if (sPrefValue) {
-      nsContentUtils::InitializeTouchEventTable();
+    } else {
+      prefValue = !!flag;
     }
   }
-  return sPrefValue;
+  if (prefValue) {
+    nsContentUtils::InitializeTouchEventTable();
+  }
+  return prefValue;
 }
 
 nsresult
 NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
                     mozilla::dom::EventTarget* aOwner,
                     nsPresContext* aPresContext,
                     nsTouchEvent *aEvent)
 {