Bug 47475 Need "Show(View) Image" / "Reload Image" on context menu (UI is SeaMonkey-only)
r=bz r=biesi sr=neil git-svn-id: svn://10.0.0.236/trunk@209387 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -64,7 +64,7 @@ interface nsIURI;
|
||||
* sufficient, when combined with the imageBlockingStatus information.)
|
||||
*/
|
||||
|
||||
[scriptable, uuid(49b02654-5f96-48a0-bf99-0fe467a3fa52)]
|
||||
[scriptable, uuid(7744c6d3-5c60-4b7b-a526-4fe9d5ac7e97)]
|
||||
interface nsIImageLoadingContent : imgIDecoderObserver
|
||||
{
|
||||
/**
|
||||
@@ -160,4 +160,11 @@ interface nsIImageLoadingContent : imgIDecoderObserver
|
||||
* @throws NS_ERROR_NULL_POINTER if aChannel is null
|
||||
*/
|
||||
nsIStreamListener loadImageWithChannel(in nsIChannel aChannel);
|
||||
|
||||
/**
|
||||
* forceReload forces reloading of the image pointed to by currentURI
|
||||
*
|
||||
* @throws NS_ERROR_NOT_AVAILABLE if there is no current URI to reload
|
||||
*/
|
||||
void forceReload();
|
||||
};
|
||||
|
||||
@@ -475,6 +475,17 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoadingContent::ForceReload()
|
||||
{
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
GetCurrentURI(getter_AddRefs(currentURI));
|
||||
if (!currentURI) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return LoadImage(currentURI, PR_TRUE, PR_TRUE, nsnull, nsIRequest::VALIDATE_ALWAYS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-interface methods
|
||||
*/
|
||||
@@ -505,7 +516,8 @@ nsresult
|
||||
nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
||||
PRBool aForce,
|
||||
PRBool aNotify,
|
||||
nsIDocument* aDocument)
|
||||
nsIDocument* aDocument,
|
||||
nsLoadFlags aLoadFlags)
|
||||
{
|
||||
if (!mLoadingEnabled) {
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
@@ -583,7 +595,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
||||
|
||||
rv = nsContentUtils::LoadImage(aNewURI, aDocument,
|
||||
aDocument->GetDocumentURI(),
|
||||
this, nsIRequest::LOAD_NORMAL,
|
||||
this, aLoadFlags,
|
||||
getter_AddRefs(req));
|
||||
if (NS_FAILED(rv)) {
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
|
||||
@@ -108,9 +108,12 @@ protected:
|
||||
* will be sent as needed.
|
||||
* @param aDocument Optional parameter giving the document this node is in.
|
||||
* This is purely a performance optimization.
|
||||
* @param aLoadFlags Optional parameter specifying load flags to use for
|
||||
* the image load
|
||||
*/
|
||||
nsresult LoadImage(nsIURI* aNewURI, PRBool aForce, PRBool aNotify,
|
||||
nsIDocument* aDocument = nsnull);
|
||||
nsIDocument* aDocument = nsnull,
|
||||
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL);
|
||||
|
||||
/**
|
||||
* helper to get the document for this content (from the nodeinfo
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
label="&fitImageCmd.label;"
|
||||
accesskey="&fitImageCmd.accesskey;"
|
||||
oncommand="gContextMenu.toggleImageSize();"/>
|
||||
<menuitem id="context-reloadimage"
|
||||
label="&reloadImageCmd.label;"
|
||||
accesskey="&reloadImageCmd.accesskey;"
|
||||
oncommand="gContextMenu.reloadImage();"/>
|
||||
<menuitem id="context-viewimage"
|
||||
label="&viewImageCmd.label;"
|
||||
accesskey="&viewImageCmd.accesskey;"
|
||||
|
||||
@@ -181,6 +181,8 @@ nsContextMenu.prototype = {
|
||||
this.setItemAttr( "context-fitimage", "checked", content.document.imageIsResized ? "true" : null);
|
||||
}
|
||||
|
||||
this.showItem( "context-reloadimage", this.onImage);
|
||||
|
||||
// View Image depends on whether an image was clicked on.
|
||||
this.showItem( "context-viewimage", this.onImage && !this.onStandaloneImage);
|
||||
|
||||
@@ -580,6 +582,12 @@ nsContextMenu.prototype = {
|
||||
toggleImageSize : function () {
|
||||
content.document.toggleImageSize();
|
||||
},
|
||||
// Reload image
|
||||
reloadImage : function () {
|
||||
urlSecurityCheck( this.imageURL, document );
|
||||
if (this.target instanceof Components.interfaces.nsIImageLoadingContent)
|
||||
this.target.forceReload();
|
||||
},
|
||||
// Change current window to the URL of the image.
|
||||
viewImage : function () {
|
||||
urlSecurityCheck( this.imageURL, document );
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
<!ENTITY viewFrameInfoCmd.accesskey "I">
|
||||
<!ENTITY fitImageCmd.label "Fit Image to Window">
|
||||
<!ENTITY fitImageCmd.accesskey "F">
|
||||
<!ENTITY reloadImageCmd.label "Reload Image">
|
||||
<!ENTITY reloadImageCmd.accesskey "e">
|
||||
<!ENTITY viewImageCmd.label "View Image">
|
||||
<!ENTITY viewImageCmd.accesskey "I">
|
||||
<!ENTITY viewBGImageCmd.label "View Background Image">
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
label="&fitImageCmd.label;"
|
||||
accesskey="&fitImageCmd.accesskey;"
|
||||
oncommand="gContextMenu.toggleImageSize();"/>
|
||||
<menuitem id="context-reloadimage"
|
||||
label="&reloadImageCmd.label;"
|
||||
accesskey="&reloadImageCmd.accesskey;"
|
||||
oncommand="gContextMenu.reloadImage();"/>
|
||||
<menuitem id="context-viewimage"
|
||||
label="&viewImageCmd.label;"
|
||||
accesskey="&viewImageCmd.accesskey;"
|
||||
|
||||
@@ -181,6 +181,8 @@ nsContextMenu.prototype = {
|
||||
this.setItemAttr( "context-fitimage", "checked", content.document.imageIsResized ? "true" : null);
|
||||
}
|
||||
|
||||
this.showItem( "context-reloadimage", this.onImage);
|
||||
|
||||
// View Image depends on whether an image was clicked on.
|
||||
this.showItem( "context-viewimage", this.onImage && !this.onStandaloneImage);
|
||||
|
||||
@@ -580,6 +582,12 @@ nsContextMenu.prototype = {
|
||||
toggleImageSize : function () {
|
||||
content.document.toggleImageSize();
|
||||
},
|
||||
// Reload image
|
||||
reloadImage : function () {
|
||||
urlSecurityCheck( this.imageURL, document );
|
||||
if (this.target instanceof Components.interfaces.nsIImageLoadingContent)
|
||||
this.target.forceReload();
|
||||
},
|
||||
// Change current window to the URL of the image.
|
||||
viewImage : function () {
|
||||
urlSecurityCheck( this.imageURL, document );
|
||||
|
||||
Reference in New Issue
Block a user