mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 20:49:27 +00:00
Bug 361698 - Navigation menuitems don't work in the sidebar's context menu. r=gavin.
This commit is contained in:
parent
a23cd46973
commit
691b0217b6
@ -173,13 +173,11 @@ function getContentAreaFrameCount()
|
||||
saveFrameItem.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
function UpdateBackForwardButtons()
|
||||
function UpdateBackForwardCommands(aWebNavigation)
|
||||
{
|
||||
var backBroadcaster = document.getElementById("Browser:Back");
|
||||
var forwardBroadcaster = document.getElementById("Browser:Forward");
|
||||
|
||||
var webNavigation = gBrowser.webNavigation;
|
||||
|
||||
// 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.!
|
||||
@ -187,14 +185,14 @@ function UpdateBackForwardButtons()
|
||||
|
||||
var backDisabled = backBroadcaster.hasAttribute("disabled");
|
||||
var forwardDisabled = forwardBroadcaster.hasAttribute("disabled");
|
||||
if (backDisabled == webNavigation.canGoBack) {
|
||||
if (backDisabled == aWebNavigation.canGoBack) {
|
||||
if (backDisabled)
|
||||
backBroadcaster.removeAttribute("disabled");
|
||||
else
|
||||
backBroadcaster.setAttribute("disabled", true);
|
||||
}
|
||||
|
||||
if (forwardDisabled == webNavigation.canGoForward) {
|
||||
if (forwardDisabled == aWebNavigation.canGoForward) {
|
||||
if (forwardDisabled)
|
||||
forwardBroadcaster.removeAttribute("disabled");
|
||||
else
|
||||
@ -3853,7 +3851,7 @@ nsBrowserStatusHandler.prototype =
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateBackForwardButtons();
|
||||
UpdateBackForwardCommands(gBrowser.webNavigation);
|
||||
|
||||
if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
|
||||
// Close the Find toolbar if we're in old-style TAF mode
|
||||
|
@ -126,12 +126,6 @@ nsContextMenu.prototype = {
|
||||
},
|
||||
|
||||
initNavigationItems: function() {
|
||||
var webNavigation = this.browser.webNavigation;
|
||||
document.getElementById("context-back")
|
||||
.disabled = !webNavigation.canGoBack;
|
||||
document.getElementById("context-forward")
|
||||
.disabled = !webNavigation.canGoForward;
|
||||
|
||||
var shouldShow = !(this.isContentSelected || this.onLink || this.onImage ||
|
||||
this.onTextInput);
|
||||
this.showItem("context-back", shouldShow);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#
|
||||
# Contributor(s):
|
||||
# David Hyatt <hyatt@mozilla.org>
|
||||
# Asaf Romano <mano@mozilla.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -36,10 +37,15 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
function getPanelBrowser()
|
||||
{
|
||||
return document.getElementById("web-panels-browser");
|
||||
}
|
||||
|
||||
var panelProgressListener = {
|
||||
onProgressChange : function (aWebProgress, aRequest,
|
||||
aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress) {
|
||||
aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress) {
|
||||
},
|
||||
|
||||
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
||||
@ -51,20 +57,19 @@ var panelProgressListener = {
|
||||
if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
|
||||
return;
|
||||
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START &&
|
||||
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
|
||||
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true");
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
|
||||
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
|
||||
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
window.parent.document.getElementById('sidebar-throbber').removeAttribute("loading");
|
||||
}
|
||||
}
|
||||
,
|
||||
|
||||
onLocationChange : function(aWebProgress, aRequest, aLocation) {
|
||||
UpdateBackForwardCommands(getPanelBrowser().webNavigation);
|
||||
},
|
||||
|
||||
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
|
||||
@ -75,35 +80,55 @@ var panelProgressListener = {
|
||||
|
||||
QueryInterface : function(aIID)
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
if (aIID.equals(Ci.nsIWebProgressListener) ||
|
||||
aIID.equals(Ci.nsISupportsWeakReference) ||
|
||||
aIID.equals(Ci.nsISupports))
|
||||
return this;
|
||||
throw Cr.NS_NOINTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
var gLoadFired = false;
|
||||
function loadWebPanel(aURI) {
|
||||
var panelBrowser = document.getElementById('web-panels-browser');
|
||||
if (gLoadFired)
|
||||
panelBrowser.webNavigation.loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
||||
var panelBrowser = getPanelBrowser();
|
||||
if (gLoadFired) {
|
||||
panelBrowser.webNavigation
|
||||
.loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
|
||||
null, null, null);
|
||||
}
|
||||
panelBrowser.setAttribute("cachedurl", aURI);
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
var panelBrowser = document.getElementById('web-panels-browser');
|
||||
panelBrowser.webProgress.addProgressListener(panelProgressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
||||
if (panelBrowser.getAttribute("cachedurl"))
|
||||
panelBrowser.webNavigation.loadURI(panelBrowser.getAttribute("cachedurl"), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
|
||||
gNavigatorBundle = document.getElementById("bundle_browser");
|
||||
|
||||
gLoadFired = true;
|
||||
var panelBrowser = getPanelBrowser();
|
||||
panelBrowser.webProgress.addProgressListener(panelProgressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
if (panelBrowser.getAttribute("cachedurl")) {
|
||||
panelBrowser.webNavigation
|
||||
.loadURI(panelBrowser.getAttribute("cachedurl"),
|
||||
nsIWebNavigation.LOAD_FLAGS_NONE, null,
|
||||
null, null);
|
||||
}
|
||||
|
||||
gNavigatorBundle = document.getElementById("bundle_browser");
|
||||
gLoadFired = true;
|
||||
}
|
||||
|
||||
function unload()
|
||||
{
|
||||
var panelBrowser = document.getElementById('web-panels-browser');
|
||||
panelBrowser.webProgress.removeProgressListener(panelProgressListener);
|
||||
getPanelBrowser().webProgress.removeProgressListener(panelProgressListener);
|
||||
}
|
||||
|
||||
function PanelBrowserStop()
|
||||
{
|
||||
getPanelBrowser().webNavigation.stop(nsIWebNavigation.STOP_ALL)
|
||||
}
|
||||
|
||||
function PanelBrowserReload()
|
||||
{
|
||||
getPanelBrowser().webNavigation
|
||||
.sessionHistory
|
||||
.QueryInterface(nsIWebNavigation)
|
||||
.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
|
||||
}
|
||||
|
@ -40,6 +40,9 @@
|
||||
|
||||
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||
#ifdef MOZ_PLACES
|
||||
<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
|
||||
#endif
|
||||
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
||||
@ -51,26 +54,46 @@
|
||||
<page id="webpanels-window"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="load()" onunload="unload()">
|
||||
onload="load()" onunload="unload()">
|
||||
# These are loaded by placesOverlay in places-enabled builds
|
||||
#ifndef MOZ_PLACES
|
||||
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||
#endif
|
||||
<script type="application/x-javascript" src="chrome://global/content/contentAreaUtils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/browser.js"/>
|
||||
<script type="application/x-javascript" src="chrome://global/content/inlineSpellCheckUI.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/nsContextMenu.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/web-panels.js"/>
|
||||
#ifndef MOZ_PLACES_BOOKMARKS
|
||||
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarks.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarksMenu.js"/>
|
||||
#endif
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
|
||||
<commandset id="mainCommandset">
|
||||
<command id="Browser:Back"
|
||||
oncommand="getPanelBrowser().webNavigation.goBack();"
|
||||
disabled="true"/>
|
||||
<command id="Browser:Forward"
|
||||
oncommand="getPanelBrowser().webNavigation.goForward();"
|
||||
disabled="true"/>
|
||||
<command id="Browser:Stop" oncommand="PanelBrowserStop();"/>
|
||||
<command id="Browser:Reload" oncommand="PanelBrowserReload();"/>
|
||||
</commandset>
|
||||
|
||||
<popupset id="mainPopupSet">
|
||||
<popup id="contentAreaContextMenu"
|
||||
onpopupshowing="if (event.target != this) return true; gContextMenu = new nsContextMenu(this, document.getElementById('web-panels-browser')); return gContextMenu.shouldDisplay;"
|
||||
onpopuphiding="if (event.target == this) { gContextMenu = null; }">
|
||||
onpopupshowing="if (event.target != this)
|
||||
return true;
|
||||
gContextMenu = new nsContextMenu(this, getPanelBrowser());
|
||||
return gContextMenu.shouldDisplay;"
|
||||
onpopuphiding="if (event.target == this)
|
||||
gContextMenu = null;">
|
||||
#include browser-context.inc
|
||||
</popup>
|
||||
</popupset>
|
||||
|
Loading…
x
Reference in New Issue
Block a user