Skip to content

Commit 0e34541

Browse files
committed
Classic View Image and View Background Image context menu entries
At first I was probably going to drop this, but I've gotten used to it, and it's a lot better than the only able to open image in new tab in normal Firefox. Here you can view the image in the same tab, or middle click to open in a new tab in the background.
1 parent 8cbed35 commit 0e34541

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

browser/base/content/browser-context.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@
288288
hidden="true"
289289
oncommand="gContextMenu.openPasswordManager();"/>
290290
<menuseparator id="passwordmgr-items-separator"/>
291+
<menuseparator id="context-sep-viewbgimage"/>
292+
<menuitem id="context-viewbgimage"
293+
data-l10n-id="main-context-menu-image-view-background"
294+
oncommand="gContextMenu.viewMedia(event);"/>
291295
<menuitem id="context-undo"
292296
data-l10n-id="text-action-undo"
293297
command="cmd_undo"/>

browser/base/content/nsContextMenu.js

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,35 @@ class nsContextMenu {
677677
!this.onAudio &&
678678
!this.onLink &&
679679
!this.onTextInput;
680-
this.showItem("context-viewimage", showViewImage || showBGImage);
680+
this.showItem("context-viewimage", showViewImage);
681+
682+
var shouldShow = !(
683+
this.isContentSelected ||
684+
this.onImage ||
685+
this.onCanvas ||
686+
this.onVideo ||
687+
this.onAudio ||
688+
this.onLink ||
689+
this.onTextInput
690+
);
691+
692+
this.showItem(
693+
"context-viewbgimage",
694+
shouldShow &&
695+
!this.hasMultipleBGImages &&
696+
!this.inSyntheticDoc &&
697+
!this.inPDFViewer
698+
);
699+
700+
this.showItem(
701+
"context-sep-viewbgimage",
702+
shouldShow &&
703+
!this.hasMultipleBGImages &&
704+
!this.inSyntheticDoc &&
705+
!this.inPDFViewer
706+
);
707+
708+
this.document.getElementById("context-viewbgimage").disabled = !this.hasBGImage;
681709

682710
// Save image depends on having loaded its content.
683711
this.showItem(
@@ -1688,9 +1716,9 @@ class nsContextMenu {
16881716
// Change current window to the URL of the image, video, or audio.
16891717
viewMedia(e) {
16901718
let where = BrowserUtils.whereToOpenLink(e, false, false);
1691-
if (where == "current") {
1692-
where = "tab";
1693-
}
1719+
// if (where == "current") {
1720+
// where = "tab";
1721+
// }
16941722
let referrerInfo = this.contentData.referrerInfo;
16951723
let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
16961724
if (this.onCanvas) {

browser/locales/en-US/browser/browserContext.ftl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,15 @@ main-context-menu-image-reload =
266266
.accesskey = R
267267
268268
main-context-menu-image-view-new-tab =
269-
.label = Open Image in New Tab
269+
.label = View Image
270270
.accesskey = I
271271
272+
main-context-menu-image-view-background =
273+
.label = View Background Image
274+
.accesskey = w
275+
272276
main-context-menu-video-view-new-tab =
273-
.label = Open Video in New Tab
277+
.label = View Video
274278
.accesskey = i
275279
276280
main-context-menu-image-copy =

0 commit comments

Comments
 (0)