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

This commit is contained in:
Paul ADENOT 2011-09-22 17:35:25 +01:00
Родитель cd94872103
Коммит 0f7c6f0ae2
3 изменённых файлов: 73 добавлений и 11 удалений

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

@ -272,9 +272,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.
@ -443,7 +444,6 @@ nsContextMenu.prototype = {
this.onImage = false;
this.onLoadedImage = false;
this.onCompletedImage = false;
this.onStandaloneImage = false;
this.onCanvas = false;
this.onVideo = false;
this.onAudio = false;
@ -459,6 +459,7 @@ nsContextMenu.prototype = {
this.linkProtocol = "";
this.onMathML = false;
this.inFrame = false;
this.inSyntheticDoc = false;
this.hasBGImage = false;
this.bgImageURL = "";
this.onEditableArea = false;
@ -477,6 +478,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.
@ -492,8 +495,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 -->

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

@ -395,10 +395,66 @@ function runTest(testNum) {
"context-viewsource", true,
"context-viewinfo", true]);
closeContextMenu();
openContextMenuFor(textarea); // Invoke context menu for next test.
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-fullscreen", true,
"---", null,
"context-viewvideo", true,
"context-copyvideourl", true,
"---", null,
"context-savevideo", 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]);
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]);
closeContextMenu();
openContextMenuFor(textarea); // Invoke context menu for next test.
break;
case 14:
// Context menu for textarea
checkContextMenu(["*chubbiness", true, // spelling suggestion
"spell-add-to-dictionary", true,
@ -422,7 +478,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,
@ -446,7 +502,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,
@ -470,13 +526,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},
@ -518,7 +574,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,
@ -593,6 +649,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