Bug 440702 - Link modifiers should use the command attribute instead of oncommand (and remove observes elements). r=gavin, ui-r=beltzner
authorKlaas Heidstra <klaas1988@gmail.com>
Mon, 01 Sep 2008 22:19:24 +0200
changeset 18554 f8554e4a78097ae9ac8820bf20a43cfd5d5579b8
parent 18553 ad9d3380f03a0013c81497790209fe62646fd5b6
child 18555 6fd9393f7f1c47a7d0c58c09b82d2710789975a1
push id1639
push userdgottwald@mozilla.com
push dateMon, 01 Sep 2008 20:19:53 +0000
treeherdermozilla-central@f8554e4a7809 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin, beltzner
bugs440702
milestone1.9.1b1pre
Bug 440702 - Link modifiers should use the command attribute instead of oncommand (and remove observes elements). r=gavin, ui-r=beltzner
browser/base/content/browser-context.inc
browser/base/content/browser-menubar.inc
browser/base/content/browser-sets.inc
browser/base/content/browser.js
browser/base/content/browser.xul
--- a/browser/base/content/browser-context.inc
+++ b/browser/base/content/browser-context.inc
@@ -109,22 +109,24 @@
       <menuitem id="context-blockimage"
                 type="checkbox"
                 accesskey="&blockImageCmd.accesskey;"
                 oncommand="gContextMenu.toggleImageBlocking(this.getAttribute('checked') == 'true');"/>
       <menuitem id="context-back"
                 label="&backCmd.label;"
                 accesskey="&backCmd.accesskey;"
                 chromedir="&locale.dir;"
-                command="Browser:Back"/>
+                command="Browser:BackOrBackDuplicate"
+                onclick="checkForMiddleClick(this, event);"/>
       <menuitem id="context-forward"
                 label="&forwardCmd.label;"
                 accesskey="&forwardCmd.accesskey;"
                 chromedir="&locale.dir;"
-                command="Browser:Forward"/>
+                command="Browser:ForwardOrForwardDuplicate"
+                onclick="checkForMiddleClick(this, event);"/>
       <menuitem id="context-reload"
                 label="&reloadCmd.label;"
                 accesskey="&reloadCmd.accesskey;"
                 command="Browser:ReloadOrDuplicate"
                 onclick="checkForMiddleClick(this, event);"/>
       <menuitem id="context-stop"
                 label="&stopCmd.label;"
                 accesskey="&stopCmd.accesskey;"
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -357,33 +357,28 @@
                 <menuitem id="historyMenuBack"
                           label="&backCmd.label;"
 #ifdef XP_MACOSX
                           key="goBackKb2"
 #else
                           key="goBackKb"
 #endif
                           chromedir="&locale.dir;"
-                          oncommand="BrowserBack(event, true)"
-                          onclick="checkForMiddleClick(this, event);">
-                  <observes element="Browser:Back" attribute="disabled" />
-                </menuitem>
+                          command="Browser:BackOrBackDuplicate"
+                          onclick="checkForMiddleClick(this, event);"/>
                 <menuitem id="historyMenuForward"
                           label="&forwardCmd.label;"
 #ifdef XP_MACOSX
                           key="goForwardKb2"
 #else
                           key="goForwardKb"
 #endif
                           chromedir="&locale.dir;"
-                          oncommand="BrowserForward(event, true)"
-                          onclick="checkForMiddleClick(this, event);">
-                  <observes element="Browser:Forward" attribute="disabled" />
-                </menuitem>
-
+                          command="Browser:ForwardOrForwardDuplicate"
+                          onclick="checkForMiddleClick(this, event);"/>
                 <menuitem id="historyMenuHome"
                           label="&historyHomeCmd.label;"
                           oncommand="BrowserGoHome(event);"
                           onclick="checkForMiddleClick(this, event);"
                           key="goHome"/>
                 <menuitem label="&showAllHistoryCmd2.label;"
 #ifndef XP_MACOSX
                           key="showAllHistoryKb"
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -93,17 +93,23 @@
              oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksMenuFolderId);"/>
     <!-- The command is disabled for the hidden window. Otherwise its enabled
          state is handled by the BookmarkAllTabsHandler object. -->
     <command id="Browser:BookmarkAllTabs"
              oncommand="gBookmarkAllTabsHandler.doCommand();"
              disabled="true"/>
     <command id="Browser:Home"    oncommand="BrowserHome();"/>
     <command id="Browser:Back"    oncommand="BrowserBack();" disabled="true"/>
+    <command id="Browser:BackOrBackDuplicate" oncommand="BrowserBack(event);" disabled="true">
+      <observes element="Browser:Back" attribute="disabled"/>
+    </command>
     <command id="Browser:Forward" oncommand="BrowserForward();" disabled="true"/>
+    <command id="Browser:ForwardOrForwardDuplicate" oncommand="BrowserForward(event);" disabled="true">
+      <observes element="Browser:Forward" attribute="disabled"/>
+    </command>
     <command id="Browser:Stop"    oncommand="BrowserStop();" disabled="true"/>
     <command id="Browser:Reload"  oncommand="if (event.shiftKey) BrowserReloadSkipCache(); else BrowserReload()" disabled="true"/>
     <command id="Browser:ReloadOrDuplicate" oncommand="BrowserReloadOrDuplicate(event)" disabled="true">
       <observes element="Browser:Reload" attribute="disabled"/>
     </command>
     <command id="Browser:ReloadSkipCache" oncommand="BrowserReloadSkipCache()" disabled="true">
       <observes element="Browser:Reload" attribute="disabled"/>
     </command>
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -153,18 +153,17 @@ function getContentAreaFrameCount()
 {
   var saveFrameItem = document.getElementById("menu_saveFrame");
   if (!content || !content.frames.length || !isContentFrame(document.commandDispatcher.focusedWindow))
     saveFrameItem.setAttribute("hidden", "true");
   else
     saveFrameItem.removeAttribute("hidden");
 }
 
-function UpdateBackForwardCommands(aWebNavigation)
-{
+function UpdateBackForwardCommands(aWebNavigation) {
   var backBroadcaster = document.getElementById("Browser:Back");
   var forwardBroadcaster = document.getElementById("Browser:Forward");
 
   // Avoid setting attributes on broadcasters if the value hasn't changed!
   // Remember, guys, setting attributes on elements is expensive!  They
   // get inherited into anonymous content, broadcast to other widgets, etc.!
   // Don't do it if the value hasn't changed! - dwh
 
@@ -1355,19 +1354,18 @@ function gotoHistoryIndex(aEvent)
     var sessionHistory = getWebNavigation().sessionHistory;
     var entry = sessionHistory.getEntryAtIndex(index, false);
     var url = entry.URI.spec;
     openUILinkIn(url, where);
     return true;
   }
 }
 
-function BrowserForward(aEvent, aIgnoreAlt)
-{
-  var where = whereToOpenLink(aEvent, false, aIgnoreAlt);
+function BrowserForward(aEvent) {
+  var where = whereToOpenLink(aEvent, false, true);
 
   if (where == "current") {
     try {
       gBrowser.goForward();
     }
     catch(ex) {
     }
   }
@@ -1375,19 +1373,18 @@ function BrowserForward(aEvent, aIgnoreA
     var sessionHistory = getWebNavigation().sessionHistory;
     var currentIndex = sessionHistory.index;
     var entry = sessionHistory.getEntryAtIndex(currentIndex + 1, false);
     var url = entry.URI.spec;
     openUILinkIn(url, where);
   }
 }
 
-function BrowserBack(aEvent, aIgnoreAlt)
-{
-  var where = whereToOpenLink(aEvent, false, aIgnoreAlt);
+function BrowserBack(aEvent) {
+  var where = whereToOpenLink(aEvent, false, true);
 
   if (where == "current") {
     try {
       gBrowser.goBack();
     }
     catch(ex) {
     }
   }
@@ -1465,32 +1462,27 @@ function BrowserReloadSkipCache() {
 }
 
 function BrowserHome()
 {
   var homePage = gHomeButton.getHomePage();
   loadOneOrMoreURIs(homePage);
 }
 
-function BrowserGoHome(aEvent)
-{
+function BrowserGoHome(aEvent) {
   if (aEvent && "button" in aEvent &&
       aEvent.button == 2) // right-click: do nothing
     return;
 
   var homePage = gHomeButton.getHomePage();
-  var where = whereToOpenLink(aEvent);
+  var where = whereToOpenLink(aEvent, false, true);
   var urls;
 
   // openUILinkIn in utilityOverlay.js doesn't handle loading multiple pages
   switch (where) {
-  case "save":
-    urls = homePage.split("|");
-    saveURL(urls[0], null, null, true);  // only save the first page
-    break;
   case "current":
     loadOneOrMoreURIs(homePage);
     break;
   case "tabshifted":
   case "tab":
     urls = homePage.split("|");
     var loadInBackground = getBoolPref("browser.tabs.loadBookmarksInBackground", false);
     gBrowser.loadTabs(urls, loadInBackground);
@@ -3230,18 +3222,17 @@ function BrowserCustomizeToolbar()
 #else
   window.openDialog(customizeURL,
                     "CustomizeToolbar",
                     "chrome,all,dependent",
                     gNavToolbox);
 #endif
 }
 
-function BrowserToolboxCustomizeDone(aToolboxChanged)
-{
+function BrowserToolboxCustomizeDone(aToolboxChanged) {
 #ifdef TOOLBAR_CUSTOMIZATION_SHEET
   document.getElementById("customizeToolbarSheetIFrame").hidden = true;
   document.getElementById("customizeToolbarSheetPopup").hidePopup();
 #endif
 
   // Update global UI elements that may have been added or removed
   if (aToolboxChanged) {
     gURLBar = document.getElementById("urlbar");
@@ -3289,16 +3280,27 @@ function BrowserToolboxCustomizeDone(aTo
 
   // XXXmano bug 287105: wallpaper to bug 309953,
   // the reload button isn't in sync with the reload command.
   var reloadButton = document.getElementById("reload-button");
   if (reloadButton) {
     reloadButton.disabled =
       document.getElementById("Browser:Reload").getAttribute("disabled") == "true";
   }
+  //bug 440702: the back and forward buttons also suffer from bug 309953.
+  var backButton = document.getElementById("back-button");
+  if (backButton) {
+    backButton.disabled =
+      document.getElementById("Browser:Back").getAttribute("disabled") == "true";
+  }
+  var forwardButton = document.getElementById("forward-button");
+  if (forwardButton) {
+    forwardButton.disabled =
+      document.getElementById("Browser:Forward").getAttribute("disabled") == "true";
+  }
 
 #ifdef XP_MACOSX
   // make sure to re-enable click-and-hold
   if (!getBoolPref("ui.click_hold_context_menus", false))
     SetClickAndHoldHandlers();
 #endif
 
 #ifndef TOOLBAR_CUSTOMIZATION_SHEET
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -283,46 +283,44 @@
 # hiddenWindow.xul.
 #include browser-menubar.inc
       </toolbaritem>
     </toolbar>
 
     <toolbarpalette id="BrowserToolbarPalette">
 
       <toolbaritem id="unified-back-forward-button" class="chromeclass-toolbar-additional"
-                   context="backForwardMenu"
-                   onbroadcast="document.getElementById('back-forward-dropmarker').disabled =
-                                  document.getElementById('Browser:Back').hasAttribute('disabled') &amp;&amp;
-                                  document.getElementById('Browser:Forward').hasAttribute('disabled');">
+                   context="backForwardMenu">
         <toolbarbutton id="back-button" class="toolbarbutton-1"
                        chromedir="&locale.dir;"
                        label="&backCmd.label;"
-                       oncommand="BrowserBack(event)"
+                       command="Browser:BackOrBackDuplicate"
                        onclick="checkForMiddleClick(this, event);"
-                       tooltiptext="&backButton.tooltip;">
-          <observes element="Browser:Back" attribute="disabled"/>
-        </toolbarbutton>
+                       tooltiptext="&backButton.tooltip;"/>
         <toolbarbutton id="forward-button" class="toolbarbutton-1"
                        chromedir="&locale.dir;"
                        label="&forwardCmd.label;"
-                       oncommand="BrowserForward(event)"
+                       command="Browser:ForwardOrForwardDuplicate"
                        onclick="checkForMiddleClick(this, event);"
-                       tooltiptext="&forwardButton.tooltip;">
-          <observes element="Browser:Forward" attribute="disabled"/>
-        </toolbarbutton>
+                       tooltiptext="&forwardButton.tooltip;"/>
         <toolbarbutton id="back-forward-dropmarker" type="menu" chromedir="&locale.dir;"
-                       disabled="true" tooltiptext="&backForwardMenu.tooltip;">
+                       disabled="true" tooltiptext="&backForwardMenu.tooltip;"
+                       onbroadcast="if (this.disabled) this.disabled =
+                                      document.getElementById('Browser:Back').hasAttribute('disabled') &amp;&amp;
+                                      document.getElementById('Browser:Forward').hasAttribute('disabled');">
           <!-- bug 415444: event.stopPropagation is here for the cloned version of
                this menupopup -->
           <menupopup context=""
                      chromedir="&locale.dir;"
                      position="after_start"
                      onpopupshowing="return FillHistoryMenu(event.target);"
                      oncommand="gotoHistoryIndex(event); event.stopPropagation();"
                      onclick="checkForMiddleClick(this, event);"/>
+          <observes element="Browser:Back" attribute="disabled"/>
+          <observes element="Browser:Forward" attribute="disabled"/>
         </toolbarbutton>
       </toolbaritem>
 
       <toolbarbutton id="reload-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      label="&reloadCmd.label;"
                      command="Browser:ReloadOrDuplicate"
                      onclick="checkForMiddleClick(this, event);"
                      tooltiptext="&reloadButton.tooltip;"/>