Bug 777972 - [responsive mode] translate click events to touch events. r=mratcliffe
authorPaul Rouget <paul@mozilla.com>
Tue, 03 Sep 2013 09:15:51 +0200
changeset 145284 61a110ae7914c242fad4784f726b614d2099a7d9
parent 145283 8b82a374ece51b3d874bbc41db97ef5b2e0c5026
child 145285 7ff96bd19c1c6ac6a2ae7460218a01e55badc2bc
push id25205
push useremorley@mozilla.com
push dateTue, 03 Sep 2013 11:14:02 +0000
treeherdermozilla-central@7ff96bd19c1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs777972
milestone26.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 777972 - [responsive mode] translate click events to touch events. r=mratcliffe
browser/app/profile/firefox.js
browser/devtools/responsivedesign/responsivedesign.jsm
browser/locales/en-US/chrome/browser/devtools/responsiveUI.properties
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1077,16 +1077,17 @@ pref("devtools.inspector.markupPreview",
 pref("devtools.inspector.remote", false);
 
 // Enable the Layout View
 pref("devtools.layoutview.enabled", true);
 pref("devtools.layoutview.open", false);
 
 // Enable the Responsive UI tool
 pref("devtools.responsiveUI.enabled", true);
+pref("devtools.responsiveUI.no-reload-notification", false);
 
 // Enable the Debugger
 pref("devtools.debugger.enabled", true);
 pref("devtools.debugger.chrome-enabled", true);
 pref("devtools.debugger.chrome-debugging-host", "localhost");
 pref("devtools.debugger.chrome-debugging-port", 6080);
 pref("devtools.debugger.remote-host", "localhost");
 pref("devtools.debugger.remote-timeout", 20000);
--- a/browser/devtools/responsivedesign/responsivedesign.jsm
+++ b/browser/devtools/responsivedesign/responsivedesign.jsm
@@ -684,24 +684,57 @@ ResponsiveUI.prototype = {
 
    disableTouch: function RUI_disableTouch() {
      if (this.touchEventHandler.enabled) {
        this.touchEventHandler.stop();
        this.touchbutton.removeAttribute("checked");
      }
    },
 
+   hideTouchNotification: function RUI_hideTouchNotification() {
+     let nbox = this.mainWindow.gBrowser.getNotificationBox(this.browser);
+     let n = nbox.getNotificationWithValue("responsive-ui-need-reload");
+     if (n) {
+       n.close();
+     }
+   },
+
    toggleTouch: function RUI_toggleTouch() {
+     this.hideTouchNotification();
      if (this.touchEventHandler.enabled) {
        this.disableTouch();
      } else {
        let isReloadNeeded = this.enableTouch();
        if (isReloadNeeded) {
-         // Lightest way to reload I found:
-         this.browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
+         if (Services.prefs.getBoolPref("devtools.responsiveUI.no-reload-notification")) {
+           return;
+         }
+
+         let nbox = this.mainWindow.gBrowser.getNotificationBox(this.browser);
+
+         var buttons = [{
+           label: this.strings.GetStringFromName("responsiveUI.notificationReload"),
+           callback: () => {
+             this.browser.reload();
+           },
+           accessKey: this.strings.GetStringFromName("responsiveUI.notificationReload_accesskey"),
+         }, {
+           label: this.strings.GetStringFromName("responsiveUI.dontShowReloadNotification"),
+           callback: function() {
+             Services.prefs.setBoolPref("devtools.responsiveUI.no-reload-notification", true);
+           },
+           accessKey: this.strings.GetStringFromName("responsiveUI.dontShowReloadNotification_accesskey"),
+         }];
+
+         nbox.appendNotification(
+           this.strings.GetStringFromName("responsiveUI.needReload"),
+           "responsive-ui-need-reload",
+           null,
+           nbox.PRIORITY_INFO_LOW,
+           buttons);
        }
      }
    },
 
   /**
    * Change the size of the browser.
    *
    * @param aWidth width of the browser.
--- a/browser/locales/en-US/chrome/browser/devtools/responsiveUI.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/responsiveUI.properties
@@ -19,17 +19,17 @@ responsiveUI.rotate2=Rotate
 responsiveUI.screenshot=Screenshot
 
 # LOCALIZATION NOTE (responsiveUI.screenshotGeneratedFilename): The auto generated filename.
 # The first argument (%1$S) is the date string in yyyy-mm-dd format and the second
 # argument (%2$S) is the time string in HH.MM.SS format.
 responsiveUI.screenshotGeneratedFilename=Screen Shot %1$S at %2$S
 
 # LOCALIZATION NOTE  (responsiveUI.touch): tooltip of the touch button.
-responsiveUI.touch=Simulate touch events (might trigger a reload)
+responsiveUI.touch=Simulate touch events (page reload might be needed)
 
 # LOCALIZATION NOTE  (responsiveUI.addPreset): label of the add preset button.
 responsiveUI.addPreset=Add Preset
 
 # LOCALIZATION NOTE  (responsiveUI.removePreset): label of the remove preset button.
 responsiveUI.removePreset=Remove Preset
 
 # LOCALIZATION NOTE  (responsiveUI.customResolution): label of the first item
@@ -48,12 +48,19 @@ responsiveUI.customNamePromptTitle=Respo
 
 # LOCALIZATION NOTE (responsiveUI.close): tooltip text of the close button.
 responsiveUI.close=Leave Responsive Design View
 
 # LOCALIZATION NOTE  (responsiveUI.customNamePromptMsg): prompt message when asking
 # the user to specify a name for a new custom preset.
 responsiveUI.customNamePromptMsg=Give a name to the %Sx%S preset
 
-
 # LOCALIZATION NOTE (responsiveUI.resizer): tooltip showed when
 # overring the resizers.
 responsiveUI.resizerTooltip=Use the Control key for more precision. Use Shift key for rounded sizes.
+
+# LOCALIZATION NOTE (responsiveUI.needReload): notification that appears
+# when touch events are enabled
+responsiveUI.needReload=If touch event listeners have been added earlier, the page needs to be reloaded.
+responsiveUI.notificationReload=Reload
+responsiveUI.notificationReload_accesskey=R
+responsiveUI.dontShowReloadNotification=Never show again
+responsiveUI.dontShowReloadNotification_accesskey=N