Bug 845011 - Ctrl-s doesn't save current document. r=sfoster
authorBrian R. Bondy <netzen@gmail.com>
Sat, 02 Mar 2013 08:25:19 -0500
changeset 123564 ac4c5ef2e0645cbe37981931ac78ae1d21bbfd26
parent 123563 4467d607386cdfb58f74c353be364106768256cc
child 123565 7d93ba84ce2f3718173b98978ee5876bd1650e6f
push id24385
push usergszorc@mozilla.com
push dateSat, 02 Mar 2013 21:28:09 +0000
treeherdermozilla-central@0f0745beec38 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfoster
bugs845011
milestone22.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 845011 - Ctrl-s doesn't save current document. r=sfoster
browser/metro/base/content/browser-ui.js
browser/metro/base/content/browser.js
browser/metro/base/content/browser.xul
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -775,16 +775,20 @@ var BrowserUI = {
                        nsIFilePicker.filterImages | nsIFilePicker.filterXML |
                        nsIFilePicker.filterHTML);
       fp.open(fpCallback);
     } catch (ex) {
       dump ('BrowserUI openFile exception: ' + ex + '\n');
     }
   },
 
+  savePage: function() {
+    Browser.savePage();
+  },
+
   receiveMessage: function receiveMessage(aMessage) {
     let browser = aMessage.target;
     let json = aMessage.json;
     switch (aMessage.name) {
       case "DOMTitleChanged":
         this._titleChanged(browser);
         break;
       case "DOMWillOpenModalDialog":
@@ -830,16 +834,17 @@ var BrowserUI = {
       case "cmd_panel":
       case "cmd_flyout_back":
       case "cmd_sanitize":
       case "cmd_zoomin":
       case "cmd_zoomout":
       case "cmd_volumeLeft":
       case "cmd_volumeRight":
       case "cmd_openFile":
+      case "cmd_savePage":
         isSupported = true;
         break;
       default:
         isSupported = false;
         break;
     }
     return isSupported;
   },
@@ -956,16 +961,19 @@ var BrowserUI = {
         break;
       case "cmd_volumeRight":
         // Zoom out (portrait) or in (landscape)
         Browser.zoom(Util.isPortrait() ? 1 : -1);
         break;
       case "cmd_openFile":
         this.openFile();
         break;
+      case "cmd_savePage":
+        this.savePage();
+        break;
     }
   }
 };
 
 /**
  * Tracks whether context UI (app bar, tab bar, url bar) is shown or hidden.
  * Manages events to summon and hide the context UI.
  */
--- a/browser/metro/base/content/browser.js
+++ b/browser/metro/base/content/browser.js
@@ -471,16 +471,20 @@ var Browser = {
     if (aOptions && "forceClose" in aOptions && aOptions.forceClose) {
       this._doCloseTab(aTab);
       return;
     }
 
     tab.browser.messageManager.sendAsyncMessage("Browser:CanUnload", {});
   },
 
+  savePage: function() {
+    ContentAreaUtils.saveDocument(this.selectedBrowser.contentWindow.document);
+  },
+
   _doCloseTab: function _doCloseTab(aTab) {
     let nextTab = this._getNextTab(aTab);
     if (!nextTab)
        return;
 
     // Tabs owned by the closed tab are now orphaned.
     this._tabs.forEach(function(item, index, array) {
       if (item.owner == aTab)
--- a/browser/metro/base/content/browser.xul
+++ b/browser/metro/base/content/browser.xul
@@ -63,16 +63,17 @@
     <command id="cmd_handleShiftBackspace" oncommand="BrowserUI.handleShiftBackspace();" />
     <command id="cmd_reload" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_forceReload" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_stop" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_go" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_openLocation" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_home" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_openFile" oncommand="CommandUpdater.doCommand(this.id);"/>
+    <command id="cmd_savePage" oncommand="CommandUpdater.doCommand(this.id);"/>
 
     <!-- tabs -->
     <command id="cmd_newTab" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_closeTab" oncommand="CommandUpdater.doCommand(this.id);"/>
     <command id="cmd_undoCloseTab" oncommand="CommandUpdater.doCommand(this.id);"/>
 #ifdef MOZ_SERVICES_SYNC
     <command id="cmd_remoteTabs" oncommand="CommandUpdater.doCommand(this.id);"/>
 #endif
@@ -130,16 +131,17 @@
     <key id="key_reload" keycode="VK_F5" command="cmd_reload"/>
     <key id="key_reload2" key="r" modifiers="accel" command="cmd_reload"/>
     <key id="key_forceReload" keycode="VK_F5" modifiers="shift" command="cmd_forceReload"/>
     <key id="key_forceReload2" key="r" modifiers="accel,shift" command="cmd_forceReload"/>
     <key id="key_focusURL" key="l" modifiers="accel" command="cmd_openLocation"/>
     <key id="key_focusURL2" key="&urlbar.accesskey;" modifiers="alt" command="cmd_openLocation"/>
     <key id="key_home" keycode="VK_HOME" modifiers="accel" command="cmd_home"/>
     <key id="key_open" key="o" modifiers="accel" command="cmd_openFile"/>
+    <key id="key_save" key="s" modifiers="accel" command="cmd_savePage"/>
 
     <!-- misc -->
     <key id="key_zoomin" key="+" modifiers="accel" command="cmd_zoomin"/>
     <key id="key_zoomout" key="-" modifiers="accel" command="cmd_zoomout"/>
     <key id="key_find" key="f" modifiers="accel" command="cmd_find"/>
     <key id="key_find" key="/" command="cmd_find"/>
     <key id="key_findNext" keycode="VK_F3" command="cmd_findNext"/>
     <key id="key_findNext2" key="g" modifiers="accel" command="cmd_findNext"/>