Bug 991899 part 3 - Disable prefixed PointerLock API by default. r=smaug
authorXidorn Quan <me@upsuper.org>
Thu, 28 Jul 2016 17:15:21 +1000
changeset 349107 76ead0b044bb01674bc74b47cdc7a5bdb791f73e
parent 349106 c03efdd8732f3f4db58f988e82d098b11d480cdb
child 349108 edb10ed57ed4f02c996cd35196ffe284ccd843ca
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs991899
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 991899 part 3 - Disable prefixed PointerLock API by default. r=smaug Given that Blink has removed prefixed PointerLock API for quite a while without receiving compatibility issue, I'd suggest we try dropping the prefixed version directly. We will either pref the prefixed API on if we see enough compatibility issue, or remove the whole bunch of prefixed PointerLock API after the unprefixed API reaches release channel without issues. MozReview-Commit-ID: ACC69nqSBiH
dom/events/EventListenerManager.cpp
dom/webidl/Document.webidl
dom/webidl/Element.webidl
dom/webidl/EventHandler.webidl
dom/webidl/MouseEvent.webidl
modules/libpref/init/all.js
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -110,16 +110,29 @@ IsWebkitPrefixSupportEnabled()
     sIsPrefCached = true;
     Preferences::AddBoolVarCache(&sIsWebkitPrefixSupportEnabled,
                                  "layout.css.prefixes.webkit");
   }
 
   return sIsWebkitPrefixSupportEnabled;
 }
 
+static bool
+IsPrefixedPointerLockEnabled()
+{
+  static bool sIsPrefixedPointerLockEnabled;
+  static bool sIsPrefCached = false;
+  if (!sIsPrefCached) {
+    sIsPrefCached = true;
+    Preferences::AddBoolVarCache(&sIsPrefixedPointerLockEnabled,
+                                 "pointer-lock-api.prefixed.enabled");
+  }
+  return sIsPrefixedPointerLockEnabled;
+}
+
 EventListenerManagerBase::EventListenerManagerBase()
   : mNoListenerForEvent(eVoidEvent)
   , mMayHavePaintEventListener(false)
   , mMayHaveMutationListeners(false)
   , mMayHaveCapturingListeners(false)
   , mMayHaveSystemGroupListeners(false)
   , mMayHaveTouchEventListener(false)
   , mMayHaveMouseEnterLeaveEventListener(false)
@@ -1127,41 +1140,47 @@ EventListenerManager::HandleEventSubType
   return result;
 }
 
 EventMessage
 EventListenerManager::GetLegacyEventMessage(EventMessage aEventMessage) const
 {
   // (If we're off-main-thread, we can't check the pref; so we just behave as
   // if it's disabled.)
-  if (mIsMainThreadELM && IsWebkitPrefixSupportEnabled()) {
-    // webkit-prefixed legacy events:
-    if (aEventMessage == eTransitionEnd) {
-      return eWebkitTransitionEnd;
+  if (mIsMainThreadELM) {
+    if (IsWebkitPrefixSupportEnabled()) {
+      // webkit-prefixed legacy events:
+      if (aEventMessage == eTransitionEnd) {
+        return eWebkitTransitionEnd;
+      }
+      if (aEventMessage == eAnimationStart) {
+        return eWebkitAnimationStart;
+      }
+      if (aEventMessage == eAnimationEnd) {
+        return eWebkitAnimationEnd;
+      }
+      if (aEventMessage == eAnimationIteration) {
+        return eWebkitAnimationIteration;
+      }
     }
-    if (aEventMessage == eAnimationStart) {
-      return eWebkitAnimationStart;
-    }
-    if (aEventMessage == eAnimationEnd) {
-      return eWebkitAnimationEnd;
-    }
-    if (aEventMessage == eAnimationIteration) {
-      return eWebkitAnimationIteration;
+    if (IsPrefixedPointerLockEnabled()) {
+      if (aEventMessage == ePointerLockChange) {
+        return eMozPointerLockChange;
+      }
+      if (aEventMessage == ePointerLockError) {
+        return eMozPointerLockError;
+      }
     }
   }
 
   switch (aEventMessage) {
     case eFullscreenChange:
       return eMozFullscreenChange;
     case eFullscreenError:
       return eMozFullscreenError;
-    case ePointerLockChange:
-      return eMozPointerLockChange;
-    case ePointerLockError:
-      return eMozPointerLockError;
     default:
       return aEventMessage;
   }
 }
 
 /**
 * Causes a check for event listeners and processing by them if they exist.
 * @param an event listener
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -252,20 +252,20 @@ partial interface Document {
   [Func="nsDocument::IsUnprefixedFullscreenEnabled"]
   attribute EventHandler onfullscreenerror;
 };
 
 // https://w3c.github.io/pointerlock/#extensions-to-the-document-interface
 // https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin
 partial interface Document {
   readonly attribute Element? pointerLockElement;
-  [BinaryName="pointerLockElement"]
+  [BinaryName="pointerLockElement", Pref="pointer-lock-api.prefixed.enabled"]
   readonly attribute Element? mozPointerLockElement;
   void exitPointerLock();
-  [BinaryName="exitPointerLock"]
+  [BinaryName="exitPointerLock", Pref="pointer-lock-api.prefixed.enabled"]
   void mozExitPointerLock();
 
   // Event handlers
   attribute EventHandler onpointerlockchange;
   attribute EventHandler onpointerlockerror;
 };
 
 //http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
--- a/dom/webidl/Element.webidl
+++ b/dom/webidl/Element.webidl
@@ -265,11 +265,11 @@ partial interface Element {
   [Throws, UnsafeInPrerendering, BinaryName="requestFullscreen"]
   void mozRequestFullScreen(optional any options);
 };
 
 // https://w3c.github.io/pointerlock/#extensions-to-the-element-interface
 partial interface Element {
   [UnsafeInPrerendering]
   void requestPointerLock();
-  [UnsafeInPrerendering, BinaryName="requestPointerLock"]
+  [UnsafeInPrerendering, BinaryName="requestPointerLock", Pref="pointer-lock-api.prefixed.enabled"]
   void mozRequestPointerLock();
 };
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -116,17 +116,19 @@ interface GlobalEventHandlers {
            attribute EventHandler ongotpointercapture;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onlostpointercapture;
 
            // Mozilla-specific handlers. Unprefixed handlers live in
            // Document rather than here.
            attribute EventHandler onmozfullscreenchange;
            attribute EventHandler onmozfullscreenerror;
+           [Pref="pointer-lock-api.prefixed.enabled"]
            attribute EventHandler onmozpointerlockchange;
+           [Pref="pointer-lock-api.prefixed.enabled"]
            attribute EventHandler onmozpointerlockerror;
 };
 
 [NoInterfaceObject]
 interface WindowEventHandlers {
            attribute EventHandler onafterprint;
            attribute EventHandler onbeforeprint;
            attribute OnBeforeUnloadEventHandler onbeforeunload;
--- a/dom/webidl/MouseEvent.webidl
+++ b/dom/webidl/MouseEvent.webidl
@@ -66,19 +66,19 @@ dictionary MouseEventInit : EventModifie
   // Pointer Lock
   long           movementX = 0;
   long           movementY = 0;
 };
 
 // Mozilla extensions
 partial interface MouseEvent
 {
-  [BinaryName="movementX"]
+  [BinaryName="movementX", Pref="pointer-lock-api.prefixed.enabled"]
   readonly attribute long mozMovementX;
-  [BinaryName="movementY"]
+  [BinaryName="movementY", Pref="pointer-lock-api.prefixed.enabled"]
   readonly attribute long mozMovementY;
 
   // Finger or touch pressure event value
   // ranges between 0.0 and 1.0
   readonly attribute float mozPressure;
 
   const unsigned short    MOZ_SOURCE_UNKNOWN    = 0;
   const unsigned short    MOZ_SOURCE_MOUSE      = 1;
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4666,16 +4666,17 @@ pref("full-screen-api.transition-duratio
 // timeout for black screen in fullscreen transition, unit: ms
 pref("full-screen-api.transition.timeout", 1000);
 // time for the warning box stays on the screen before sliding out, unit: ms
 pref("full-screen-api.warning.timeout", 3000);
 // delay for the warning box to show when pointer stays on the top, unit: ms
 pref("full-screen-api.warning.delay", 500);
 
 // DOM pointerlock API
+pref("pointer-lock-api.prefixed.enabled", false);
 // time for the warning box stays on the screen before sliding out, unit: ms
 pref("pointer-lock-api.warning.timeout", 3000);
 
 // DOM idle observers API
 pref("dom.idle-observers-api.enabled", true);
 
 // Time limit, in milliseconds, for EventStateManager::IsHandlingUserInput().
 // Used to detect long running handlers of user-generated events.