Bug 263942 - Reload button should have middle click support. r=gavin, ui-r=beltzner

This commit is contained in:
Klaas Heidstra 2008-08-31 23:00:59 +02:00
Родитель 7f535eb7df
Коммит 9faa172081
7 изменённых файлов: 66 добавлений и 44 удалений

Просмотреть файл

@ -123,7 +123,8 @@
<menuitem id="context-reload"
label="&reloadCmd.label;"
accesskey="&reloadCmd.accesskey;"
command="Browser:Reload"/>
command="Browser:ReloadOrDuplicate"
onclick="checkForMiddleClick(this, event);"/>
<menuitem id="context-stop"
label="&stopCmd.label;"
accesskey="&stopCmd.accesskey;"

Просмотреть файл

@ -186,7 +186,9 @@
#else
key="key_stop"/>
#endif
<menuitem label="&reloadCmd.label;" accesskey="&reloadCmd.accesskey;" command="Browser:Reload" key="key_reload"/>
<menuitem label="&reloadCmd.label;" accesskey="&reloadCmd.accesskey;" key="key_reload"
command="Browser:ReloadOrDuplicate"
onclick="checkForMiddleClick(this, event);"/>
<menuseparator/>
<menu id="viewFullZoomMenu" label="&fullZoom.label;" accesskey="&fullZoom.accesskey;" onpopupshowing="FullZoom.updateMenu();">
<menupopup>

Просмотреть файл

@ -101,7 +101,12 @@
<command id="Browser:Forward" oncommand="BrowserForward();" disabled="true"/>
<command id="Browser:Stop" oncommand="BrowserStop();" disabled="true"/>
<command id="Browser:Reload" oncommand="if (event.shiftKey) BrowserReloadSkipCache(); else BrowserReload()" disabled="true"/>
<command id="Browser:ReloadSkipCache" oncommand="BrowserReloadSkipCache()" 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>
<command id="cmd_fullZoomReduce" oncommand="FullZoom.reduce()"/>
<command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>

Просмотреть файл

@ -1187,9 +1187,9 @@ function BrowserShutdown()
function nonBrowserWindowStartup()
{
// Disable inappropriate commands / submenus
var disabledItems = ['Browser:SavePage', 'Browser:SendLink',
'cmd_pageSetup', 'cmd_print', 'cmd_find', 'cmd_findAgain', 'viewToolbarsMenu',
'cmd_toggleTaskbar', 'viewSidebarMenuMenu', 'Browser:Reload', 'Browser:ReloadSkipCache',
var disabledItems = ['Browser:SavePage',
'Browser:SendLink', 'cmd_pageSetup', 'cmd_print', 'cmd_find', 'cmd_findAgain',
'viewToolbarsMenu', 'cmd_toggleTaskbar', 'viewSidebarMenuMenu', 'Browser:Reload',
'viewFullZoomMenu', 'pageStyleMenu', 'charsetMenu', 'View:PageSource', 'View:FullScreen',
'viewHistorySidebar', 'Browser:AddBookmarkAs', 'View:PageInfo', 'Tasks:InspectPage'];
var element;
@ -1434,17 +1434,34 @@ function BrowserStop()
}
}
function BrowserReload()
{
const reloadFlags = nsIWebNavigation.LOAD_FLAGS_NONE;
return BrowserReloadWithFlags(reloadFlags);
function BrowserReloadOrDuplicate(aEvent) {
var backgroundTabModifier = aEvent.button == 1 ||
#ifdef XP_MACOSX
aEvent.metaKey;
#else
aEvent.ctrlKey;
#endif
if (aEvent.shiftKey && !backgroundTabModifier) {
BrowserReloadSkipCache();
return;
}
var where = whereToOpenLink(aEvent, false, true);
if (where == "current")
BrowserReload();
else
openUILinkIn(getWebNavigation().currentURI.spec, where);
}
function BrowserReloadSkipCache()
{
function BrowserReload() {
const reloadFlags = nsIWebNavigation.LOAD_FLAGS_NONE;
BrowserReloadWithFlags(reloadFlags);
}
function BrowserReloadSkipCache() {
// Bypass proxy and cache.
const reloadFlags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
return BrowserReloadWithFlags(reloadFlags);
BrowserReloadWithFlags(reloadFlags);
}
function BrowserHome()
@ -2369,8 +2386,7 @@ function getWebNavigation()
}
}
function BrowserReloadWithFlags(reloadFlags)
{
function BrowserReloadWithFlags(reloadFlags) {
/* First, we'll try to use the session history object to reload so
* that framesets are handled properly. If we're in a special
* window (such as view-source) that has no session history, fall
@ -3704,15 +3720,14 @@ nsBrowserStatusHandler.prototype =
init : function()
{
this.throbberElement = document.getElementById("navigator-throbber");
this.statusMeter = document.getElementById("statusbar-icon");
this.stopCommand = document.getElementById("Browser:Stop");
this.reloadCommand = document.getElementById("Browser:Reload");
this.reloadSkipCacheCommand = document.getElementById("Browser:ReloadSkipCache");
this.statusTextField = document.getElementById("statusbar-display");
this.securityButton = document.getElementById("security-button");
this.urlBar = document.getElementById("urlbar");
this.isImage = document.getElementById("isImage");
this.throbberElement = document.getElementById("navigator-throbber");
this.statusMeter = document.getElementById("statusbar-icon");
this.stopCommand = document.getElementById("Browser:Stop");
this.reloadCommand = document.getElementById("Browser:Reload");
this.statusTextField = document.getElementById("statusbar-display");
this.securityButton = document.getElementById("security-button");
this.urlBar = document.getElementById("urlbar");
this.isImage = document.getElementById("isImage");
// Initialize the security button's state and tooltip text. Remember to reset
// _hostChanged, otherwise onSecurityChange will short circuit.
@ -3724,16 +3739,15 @@ nsBrowserStatusHandler.prototype =
destroy : function()
{
// XXXjag to avoid leaks :-/, see bug 60729
this.throbberElement = null;
this.statusMeter = null;
this.stopCommand = null;
this.reloadCommand = null;
this.reloadSkipCacheCommand = null;
this.statusTextField = null;
this.securityButton = null;
this.urlBar = null;
this.statusText = null;
this.lastURI = null;
this.throbberElement = null;
this.statusMeter = null;
this.stopCommand = null;
this.reloadCommand = null;
this.statusTextField = null;
this.securityButton = null;
this.urlBar = null;
this.statusText = null;
this.lastURI = null;
},
setJSStatus : function(status)
@ -3978,10 +3992,8 @@ nsBrowserStatusHandler.prototype =
location == "") { // Second condition is for new tabs, otherwise
// reload function is enabled until tab is refreshed.
this.reloadCommand.setAttribute("disabled", "true");
this.reloadSkipCacheCommand.setAttribute("disabled", "true");
} else {
this.reloadCommand.removeAttribute("disabled");
this.reloadSkipCacheCommand.removeAttribute("disabled");
}
if (!gBrowser.mTabbedMode && aWebProgress.isLoadingDocument)

Просмотреть файл

@ -323,7 +323,8 @@
<toolbarbutton id="reload-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&reloadCmd.label;"
command="Browser:Reload"
command="Browser:ReloadOrDuplicate"
onclick="checkForMiddleClick(this, event);"
tooltiptext="&reloadButton.tooltip;"/>
<toolbarbutton id="stop-button" class="toolbarbutton-1 chromeclass-toolbar-additional"

Просмотреть файл

@ -258,8 +258,7 @@ function openUILinkIn( url, where, allowThirdPartyFixup, postData, referrerUrl )
// Used as an onclick handler for UI elements with link-like behavior.
// e.g. onclick="checkForMiddleClick(this, event);"
function checkForMiddleClick(node, event)
{
function checkForMiddleClick(node, event) {
// We should be using the disabled property here instead of the attribute,
// but some elements that this function is used with don't support it (e.g.
// menuitem).
@ -267,12 +266,14 @@ function checkForMiddleClick(node, event)
return; // Do nothing
if (event.button == 1) {
/* Execute the node's oncommand.
/* Execute the node's oncommand or command.
*
* XXX: we should use node.oncommand(event) once bug 246720 is fixed.
*/
var fn = new Function("event", node.getAttribute("oncommand"));
fn.call(node, event);
var target = node.hasAttribute("oncommand") ? node :
node.ownerDocument.getElementById(node.getAttribute("command"));
var fn = new Function("event", target.getAttribute("oncommand"));
fn.call(target, event);
// If the middle-click was on part of a menu, close the menu.
// (Menus close automatically with left-click but not with middle-click.)

Просмотреть файл

@ -370,13 +370,13 @@ menuitem[command="Browser:Stop"][disabled],
#placesContext_reload,
#placesContext_reloadMicrosummary,
menuitem[command="Browser:Reload"],
menuitem[command="Browser:ReloadOrDuplicate"],
#context-reload,
#context-reloadframe {
list-style-image: url("moz-icon://stock/gtk-refresh?size=menu");
}
menuitem[command="Browser:Reload"][disabled],
menuitem[command="Browser:ReloadOrDuplicate"][disabled],
#context-reload[disabled] {
list-style-image: url("moz-icon://stock/gtk-refresh?size=menu&state=disabled");
}