Bug 218142 - "Need "Show Image" / "Reload Image" on context menu" [p=ehsan.akhgari@gmail.com (Ehsan Akhgari [ehsan]) r=gavin ui-r+a1.9=beltzner]

This commit is contained in:
reed@reedloden.com 2008-02-13 02:38:33 -08:00
parent b3bca88630
commit aac4552292
2 changed files with 21 additions and 0 deletions

View File

@ -74,6 +74,10 @@
accesskey="&copyLinkCmd.accesskey;"
oncommand="goDoCommand('cmd_copyLink');"/>
<menuseparator id="context-sep-copylink"/>
<menuitem id="context-showimage"
label="&showImageCmd.label;"
accesskey="&showImageCmd.accesskey;"
oncommand="gContextMenu.showImage();"/>
<menuitem id="context-viewimage"
label="&viewImageCmd.label;"
accesskey="&viewImageCmd.accesskey;"

View File

@ -65,6 +65,7 @@ function nsContextMenu(aXulMenu, aBrowser) {
this.onKeywordField = false;
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.onCanvas = false;
this.onLink = false;
this.onMailtoLink = false;
@ -198,6 +199,9 @@ nsContextMenu.prototype = {
.disabled = this.disableSetDesktopBackground();
}
// Show image depends on an image that's not fully loaded
this.showItem("context-showimage", (this.onImage && !this.onCompletedImage));
// View image depends on having an image that's not standalone
// (or is in a frame), or a canvas.
this.showItem("context-viewimage", (this.onImage &&
@ -366,6 +370,7 @@ nsContextMenu.prototype = {
// Initialize contextual info.
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.onStandaloneImage = false;
this.onCanvas = false;
this.onMetaDataItem = false;
@ -407,6 +412,8 @@ nsContextMenu.prototype = {
this.target.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
if (request && (request.imageStatus & request.STATUS_SIZE_AVAILABLE))
this.onLoadedImage = true;
if (request && (request.imageStatus & request.STATUS_LOAD_COMPLETE))
this.onCompletedImage = true;
this.imageURL = this.target.currentURI.spec;
if (this.target.ownerDocument instanceof ImageDocument)
@ -590,6 +597,7 @@ nsContextMenu.prototype = {
this.onKeywordField = false;
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.onMetaDataItem = false;
this.onMathML = false;
this.inFrame = false;
@ -719,6 +727,15 @@ nsContextMenu.prototype = {
BrowserPageInfo(this.target.ownerDocument);
},
showImage: function(e) {
urlSecurityCheck(this.imageURL,
this.browser.contentPrincipal,
Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
if (this.target instanceof Ci.nsIImageLoadingContent)
this.target.forceReload();
},
// Change current window to the URL of the image.
viewImage: function(e) {
var viewURL;