Bug 433168 - Context menu is not shown for form buttons and select elements. r=gavin

This commit is contained in:
Johan Charlez 2012-12-13 01:09:49 -05:00
parent 5926e0e97f
commit 6f175675e3
2 changed files with 10 additions and 23 deletions

View File

@ -438,8 +438,7 @@ nsContextMenu.prototype = {
setTarget: function (aNode, aRangeParent, aRangeOffset) {
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
if (aNode.namespaceURI == xulNS ||
aNode.nodeType == Node.DOCUMENT_NODE ||
this.isTargetAFormControl(aNode)) {
aNode.nodeType == Node.DOCUMENT_NODE) {
this.shouldDisplay = false;
return;
}
@ -1297,18 +1296,6 @@ nsContextMenu.prototype = {
"contextMenu.hasBGImage = " + this.hasBGImage + "\n";
},
// Returns true if aNode is a from control (except text boxes and images).
// This is used to disable the context menu for form controls.
isTargetAFormControl: function(aNode) {
if (aNode instanceof HTMLInputElement)
return (!aNode.mozIsTextField(false) && aNode.type != "image");
return (aNode instanceof HTMLButtonElement) ||
(aNode instanceof HTMLSelectElement) ||
(aNode instanceof HTMLOptionElement) ||
(aNode instanceof HTMLOptGroupElement);
},
isTargetATextBox: function(node) {
if (node instanceof HTMLInputElement)
return node.mozIsTextField(false);

View File

@ -34,15 +34,15 @@ function test() {
testInput("text", true);
testInput("password", true);
testInput("image", true);
testInput("button", false);
testInput("submit", false);
testInput("reset", false);
testInput("checkbox", false);
testInput("radio", false);
testElement("button", false);
testElement("select", false);
testElement("option", false);
testElement("optgroup", false);
testInput("button", true);
testInput("submit", true);
testInput("reset", true);
testInput("checkbox", true);
testInput("radio", true);
testElement("button", true);
testElement("select", true);
testElement("option", true);
testElement("optgroup", true);
// cleanup
document.popupNode = null;