Bug 1290420 Part 3: Set the metaViewportOverride flag when viewing a device with touch event support in Responsive Design Mode. r=gl
authorBotond Ballo <botond@mozilla.com>, Brad Werth <bwerth@mozilla.com>
Thu, 04 Oct 2018 00:19:41 +0000
changeset 495378 c23a9b7119c4fa8a66a09aa56579db8369244ad2
parent 495377 e887b26390ec2f660536f6cac5d63e40163c182b
child 495379 e6cfd555f0d1d013d3c9c5f519f96889c2994609
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1290420
milestone64.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 1290420 Part 3: Set the metaViewportOverride flag when viewing a device with touch event support in Responsive Design Mode. r=gl Depends on D3375 Differential Revision: https://phabricator.services.mozilla.com/D3376
devtools/client/responsive.html/manager.js
devtools/server/actors/emulation.js
devtools/shared/specs/emulation.js
--- a/devtools/client/responsive.html/manager.js
+++ b/devtools/client/responsive.html/manager.js
@@ -664,22 +664,28 @@ ResponsiveUI.prototype = {
 
   /**
    * Set or clear touch simulation.
    *
    * @return boolean
    *         Whether a reload is needed to apply the change.
    */
   updateTouchSimulation(enabled) {
-    if (!enabled) {
-      return this.emulationFront.clearTouchEventsOverride();
+    let reloadNeeded;
+    if (enabled) {
+      reloadNeeded = this.emulationFront.setTouchEventsOverride(
+        Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED
+      ).then(() => this.emulationFront.setMetaViewportOverride(
+        Ci.nsIDocShell.META_VIEWPORT_OVERRIDE_ENABLED
+      ));
+    } else {
+      reloadNeeded = this.emulationFront.clearTouchEventsOverride()
+        .then(() => this.emulationFront.clearMetaViewportOverride());
     }
-    return this.emulationFront.setTouchEventsOverride(
-      Ci.nsIDocShell.TOUCHEVENTS_OVERRIDE_ENABLED
-    );
+    return reloadNeeded;
   },
 
   /**
    * Helper for tests. Assumes a single viewport for now.
    */
   getViewportSize() {
     return this.toolWindow.getViewportSize();
   },
--- a/devtools/server/actors/emulation.js
+++ b/devtools/server/actors/emulation.js
@@ -30,16 +30,17 @@ const EmulationActor = protocol.ActorCla
     this.docShell = targetActor.docShell;
     this.touchSimulator = new TouchSimulator(targetActor.chromeEventHandler);
   },
 
   destroy() {
     this.clearDPPXOverride();
     this.clearNetworkThrottling();
     this.clearTouchEventsOverride();
+    this.clearMetaViewportOverride();
     this.clearUserAgentOverride();
     this.targetActor = null;
     this.docShell = null;
     this.touchSimulator = null;
     protocol.Actor.prototype.destroy.call(this);
   },
 
   /**
@@ -201,16 +202,43 @@ const EmulationActor = protocol.ActorCla
 
   clearTouchEventsOverride() {
     if (this._previousTouchEventsOverride !== undefined) {
       return this.setTouchEventsOverride(this._previousTouchEventsOverride);
     }
     return false;
   },
 
+  /* Meta viewport override */
+
+  _previousMetaViewportOverride: undefined,
+
+  setMetaViewportOverride(flag) {
+    if (this.getMetaViewportOverride() == flag) {
+      return false;
+    }
+    if (this._previousMetaViewportOverride === undefined) {
+      this._previousMetaViewportOverride = this.getMetaViewportOverride();
+    }
+
+    this.docShell.metaViewportOverride = flag;
+    return true;
+  },
+
+  getMetaViewportOverride() {
+    return this.docShell.metaViewportOverride;
+  },
+
+  clearMetaViewportOverride() {
+    if (this._previousMetaViewportOverride !== undefined) {
+      return this.setMetaViewportOverride(this._previousMetaViewportOverride);
+    }
+    return false;
+  },
+
   /* User agent override */
 
   _previousUserAgentOverride: undefined,
 
   setUserAgentOverride(userAgent) {
     if (this.getUserAgentOverride() == userAgent) {
       return false;
     }
--- a/devtools/shared/specs/emulation.js
+++ b/devtools/shared/specs/emulation.js
@@ -73,16 +73,39 @@ const emulationSpec = generateActorSpec(
 
     clearTouchEventsOverride: {
       request: {},
       response: {
         valueChanged: RetVal("boolean")
       }
     },
 
+    setMetaViewportOverride: {
+      request: {
+        flag: Arg(0, "number")
+      },
+      response: {
+        valueChanged: RetVal("boolean")
+      }
+    },
+
+    getMetaViewportOverride: {
+      request: {},
+      response: {
+        flag: RetVal("number")
+      }
+    },
+
+    clearMetaViewportOverride: {
+      request: {},
+      response: {
+        valueChanged: RetVal("boolean")
+      }
+    },
+
     setUserAgentOverride: {
       request: {
         flag: Arg(0, "string")
       },
       response: {
         valueChanged: RetVal("boolean")
       }
     },