Landing pref based, automatic image resizing.

Disabled by default.
r=jst, sr=jag
This commit is contained in:
varga%netscape.com 2006-07-29 05:41:41 +00:00
parent 2d9b5bf1e5
commit 86c22ad044
3 changed files with 25 additions and 3 deletions

View File

@ -83,6 +83,11 @@
accesskey="&copyLinkCmd.accesskey;"
command="cmd_copyLink"/>
<menuseparator id="context-sep-copylink"/>
<menuitem id="context-fitimage"
type="checkbox"
label="&fitImageCmd.label;"
accesskey="&fitImageCmd.accesskey;"
oncommand="gContextMenu.toggleImageSize();"/>
<menuitem id="context-viewimage"
label="&viewImageCmd.label;"
accesskey="&viewImageCmd.accesskey;"

View File

@ -137,8 +137,14 @@ nsContextMenu.prototype = {
// Disable the Set As Wallpaper menu item if we're still trying to load the image
this.setItemAttr( "context-setWallpaper", "disabled", (("complete" in this.target) && !this.target.complete) ? "true" : null );
this.showItem( "context-fitimage", this.onStandaloneImage && _content.document.imageResizingEnabled );
if ( this.onStandaloneImage && _content.document.imageResizingEnabled ) {
this.setItemAttr( "context-fitimage", "disabled", _content.document.imageIsOverflowing ? null : "true");
this.setItemAttr( "context-fitimage", "checked", _content.document.imageIsResized ? "true" : null);
}
// View Image depends on whether an image was clicked on.
this.showItem( "context-viewimage", this.onImage );
this.showItem( "context-viewimage", this.onImage && !this.onStandaloneImage);
// View background image depends on whether there is one.
this.showItem( "context-viewbgimage", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) );
@ -218,6 +224,7 @@ nsContextMenu.prototype = {
}
// Initialize contextual info.
this.onImage = false;
this.onStandaloneImage = false;
this.onMetaDataItem = false;
this.onTextInput = false;
this.imageURL = "";
@ -235,6 +242,11 @@ nsContextMenu.prototype = {
if ( this.target.localName.toUpperCase() == "IMG" ) {
this.onImage = true;
this.imageURL = this.target.src;
var documentType = window._content.document.contentType;
if ( documentType.substr(0,6) == "image/" )
this.onStandaloneImage = true;
// Look for image map.
var mapName = this.target.getAttribute( "usemap" );
if ( mapName ) {
@ -574,10 +586,13 @@ nsContextMenu.prototype = {
BrowserViewSourceOfDocument(this.target.ownerDocument);
},
viewInfo : function () {
BrowserPageInfo();
BrowserPageInfo();
},
viewFrameInfo : function () {
BrowserPageInfo(this.target.ownerDocument);
BrowserPageInfo(this.target.ownerDocument);
},
toggleImageSize : function () {
_content.document.toggleImageSize();
},
// Change current window to the URL of the image.
viewImage : function () {

View File

@ -39,6 +39,8 @@
<!ENTITY viewPageInfoCmd.accesskey "I">
<!ENTITY viewFrameInfoCmd.label "View Frame Info">
<!ENTITY viewFrameInfoCmd.accesskey "I">
<!ENTITY fitImageCmd.label "Fit Image to Window">
<!ENTITY fitImageCmd.accesskey "F">
<!ENTITY viewImageCmd.label "View Image">
<!ENTITY viewImageCmd.accesskey "I">
<!ENTITY viewBGImageCmd.label "View Background Image">