Bug 556563 - Disable/remove "View video" when you're already viewing the video. r=dolske

This commit is contained in:
Paul ADENOT 2011-11-02 13:52:21 -07:00
Родитель 3adefde552
Коммит 7f19f93e4b
3 изменённых файлов: 76 добавлений и 12 удалений

Просмотреть файл

@ -277,9 +277,10 @@ nsContextMenu.prototype = {
// 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 &&
(!this.onStandaloneImage || this.inFrame)) || this.onCanvas);
(!this.inSyntheticDoc || this.inFrame)) || this.onCanvas);
this.showItem("context-viewvideo", this.onVideo);
// View video depends on not having a standalone video.
this.showItem("context-viewvideo", this.onVideo && (!this.inSyntheticDoc || this.inFrame));
this.setItemAttr("context-viewvideo", "disabled", !this.mediaURL);
// View background image depends on whether there is one.
@ -466,7 +467,6 @@ nsContextMenu.prototype = {
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.onStandaloneImage = false;
this.onCanvas = false;
this.onVideo = false;
this.onAudio = false;
@ -482,6 +482,7 @@ nsContextMenu.prototype = {
this.linkProtocol = "";
this.onMathML = false;
this.inFrame = false;
this.inSyntheticDoc = false;
this.hasBGImage = false;
this.bgImageURL = "";
this.onEditableArea = false;
@ -500,6 +501,8 @@ nsContextMenu.prototype = {
// Remember the node that was clicked.
this.target = aNode;
// Check if we are in a synthetic document (stand alone image, video, etc.).
this.inSyntheticDoc = this.target.ownerDocument.mozSyntheticDocument;
// First, do checks for nodes that never have children.
if (this.target.nodeType == Node.ELEMENT_NODE) {
// See if the user clicked on an image.
@ -515,8 +518,6 @@ nsContextMenu.prototype = {
this.onCompletedImage = true;
this.mediaURL = this.target.currentURI.spec;
if (this.target.ownerDocument instanceof ImageDocument)
this.onStandaloneImage = true;
}
else if (this.target instanceof HTMLCanvasElement) {
this.onCanvas = true;

Просмотреть файл

@ -18,6 +18,8 @@ Browser context menu subtest.
<source src="bogus.duh" type="video/durrrr;">
</video>
<iframe id="test-iframe" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-video-in-iframe" src="video.ogg" width="98" height="98" style="border: 1px solid black"></iframe>
<iframe id="test-image-in-iframe" src="ctxmenu-image.png" width="98" height="98" style="border: 1px solid black"></iframe>
<textarea id="test-textarea">chssseesbbbie</textarea> <!-- a weird word which generates only one suggestion -->
<div id="test-contenteditable" contenteditable="true">chssseefsbbbie</div> <!-- a more weird word which generates no suggestions -->
<input id="test-input-spellcheck" type="text" spellcheck="true" autofocus value="prodkjfgigrty"> <!-- this one also generates one suggestion -->

Просмотреть файл

@ -433,10 +433,68 @@ function runTest(testNum) {
"context-viewinfo", true
].concat(inspectItems));
closeContextMenu();
openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck.
openContextMenuFor(video_in_iframe); // Invoke context menu for next test.
break;
case 12:
// Context menu for a video in an iframe
checkContextMenu(["context-media-play", true,
"context-media-mute", true,
"context-media-hidecontrols", true,
"context-video-showstats", true,
"context-video-fullscreen", true,
"---", null,
"context-viewvideo", true,
"context-copyvideourl", true,
"---", null,
"context-savevideo", true,
"context-video-saveimage", true,
"context-sendvideo", true,
"frame", null,
["context-showonlythisframe", true,
"context-openframeintab", true,
"context-openframe", true,
"---", null,
"context-reloadframe", true,
"---", null,
"context-bookmarkframe", true,
"context-saveframe", true,
"---", null,
"context-printframe", true,
"---", null,
"context-viewframeinfo", true], null].concat(inspectItems));
closeContextMenu();
openContextMenuFor(image_in_iframe); // Invoke context menu for next test.
break;
case 13:
// Context menu for an image in an iframe
checkContextMenu(["context-viewimage", true,
"context-copyimage-contents", true,
"context-copyimage", true,
"---", null,
"context-saveimage", true,
"context-sendimage", true,
"context-setDesktopBackground", true,
"context-viewimageinfo", true,
"frame", null,
["context-showonlythisframe", true,
"context-openframeintab", true,
"context-openframe", true,
"---", null,
"context-reloadframe", true,
"---", null,
"context-bookmarkframe", true,
"context-saveframe", true,
"---", null,
"context-printframe", true,
"---", null,
"context-viewframeinfo", true], null].concat(inspectItems));
closeContextMenu();
openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck.
break;
case 14:
// Context menu for textarea
checkContextMenu(["*chubbiness", true, // spelling suggestion
"spell-add-to-dictionary", true,
@ -461,7 +519,7 @@ function runTest(testNum) {
openContextMenuFor(contenteditable); // Invoke context menu for next test.
break;
case 13:
case 15:
// Context menu for contenteditable
checkContextMenu(["spell-no-suggestions", false,
"spell-add-to-dictionary", true,
@ -486,7 +544,7 @@ function runTest(testNum) {
openContextMenuFor(inputspell); // Invoke context menu for next test.
break;
case 14:
case 16:
// Context menu for spell-check input
checkContextMenu(["*prodigality", true, // spelling suggestion
"spell-add-to-dictionary", true,
@ -511,13 +569,13 @@ function runTest(testNum) {
openContextMenuFor(link); // Invoke context menu for next test.
break;
case 15:
case 17:
executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
closeContextMenu();
openContextMenuFor(pagemenu); // Invoke context menu for next test.
break;
case 16:
case 18:
// Context menu for element with assigned content context menu
checkContextMenu(["+Plain item", {type: "", icon: "", checked: false, disabled: false},
"+Disabled item", {type: "", icon: "", checked: false, disabled: true},
@ -560,7 +618,7 @@ function runTest(testNum) {
openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
break;
case 17:
case 19:
// Context menu for element with assigned content context menu
// The shift key should bypass content context menu processing
checkContextMenu(["context-back", false,
@ -604,7 +662,7 @@ function runTest(testNum) {
var testNum = 1;
var subwindow, chromeWin, contextMenu, lastElement;
var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
iframe, textarea, contenteditable, inputspell, pagemenu;
iframe, video_in_iframe, image_in_iframe, textarea, contenteditable, inputspell, pagemenu;
function startTest() {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
@ -636,6 +694,9 @@ function startTest() {
video_bad = subwindow.document.getElementById("test-video-bad");
video_bad2 = subwindow.document.getElementById("test-video-bad2");
iframe = subwindow.document.getElementById("test-iframe");
video_in_iframe = subwindow.document.getElementById("test-video-in-iframe").contentDocument.getElementsByTagName("video")[0];
video_in_iframe.pause();
image_in_iframe = subwindow.document.getElementById("test-image-in-iframe").contentDocument.getElementsByTagName("img")[0];
textarea = subwindow.document.getElementById("test-textarea");
contenteditable = subwindow.document.getElementById("test-contenteditable");
contenteditable.focus(); // content editable needs to be focused to enable spellcheck