Bug 1059219, show text-related items (clipboard, undo, etc) in context menu for input type=number, r=mconley

This commit is contained in:
Neil Deakin 2015-02-10 21:00:05 -05:00
parent a4d38f4368
commit 3014be5692
3 changed files with 20 additions and 10 deletions

View File

@ -332,9 +332,9 @@ nsContextMenu.prototype = {
}
// BiDi UI
this.showItem("context-sep-bidi", top.gBidiUI);
this.showItem("context-sep-bidi", !this.onNumeric && top.gBidiUI);
this.showItem("context-bidi-text-direction-toggle",
this.onTextInput && top.gBidiUI);
this.onTextInput && !this.onNumeric && top.gBidiUI);
this.showItem("context-bidi-page-direction-toggle",
!this.onTextInput && top.gBidiUI);
@ -563,6 +563,7 @@ nsContextMenu.prototype = {
this.onVideo = false;
this.onAudio = false;
this.onTextInput = false;
this.onNumeric = false;
this.onKeywordField = false;
this.mediaURL = "";
this.onLink = false;
@ -658,6 +659,7 @@ nsContextMenu.prototype = {
}
else if (editFlags & (SpellCheckHelper.INPUT | SpellCheckHelper.TEXTAREA)) {
this.onTextInput = (editFlags & SpellCheckHelper.TEXTINPUT) !== 0;
this.onNumeric = (editFlags & SpellCheckHelper.NUMERIC) !== 0;
this.onEditableArea = (editFlags & SpellCheckHelper.EDITABLE) !== 0;
if (this.onEditableArea) {
if (this.isRemote) {

View File

@ -160,7 +160,8 @@ function runTest(testNum) {
case 8: // email
case 9: // url
case 10: // tel
// Context menu for tel, password, email and url input fields.
case 11: // type='number'
// Context menu for tel, password, email, url and number input fields.
checkContextMenu(["context-undo", false,
"---", null,
"context-cut", false,
@ -181,15 +182,16 @@ function runTest(testNum) {
} else if (testNum == 9) {
input.type = 'tel';
} else if (testNum == 10) {
input.type = 'number';
} else if (testNum == 11) {
input.type = 'date';
}
openContextMenuFor(input); // Invoke context menu for next test.
break;
case 11: // type='date'
case 12: // type='time'
case 13: // type='number'
case 12: // type='date'
case 13: // type='time'
case 14: // type='color'
case 15: // type='range'
checkContextMenu(["context-navigation", null,
@ -209,10 +211,8 @@ function runTest(testNum) {
"context-inspect", true]);
closeContextMenu();
if (testNum == 11) {
if (testNum == 12) {
input.type = 'time';
} else if (testNum == 12) {
input.type = 'number';
} else if (testNum == 13) {
input.type = 'color';
} else if (testNum == 14) {

View File

@ -419,6 +419,9 @@ var SpellCheckHelper = {
// "editable" but is because content editable is enabled for the document.
CONTENTEDITABLE: 0x20,
// Set when over an <input type="number"> or other non-text field.
NUMERIC: 0x40,
isTargetAKeywordField(aNode, window) {
if (!(aNode instanceof window.HTMLInputElement))
return false;
@ -454,9 +457,14 @@ var SpellCheckHelper = {
var flags = 0;
if (element instanceof window.HTMLInputElement) {
flags |= this.INPUT;
if (element.mozIsTextField(false)) {
if (element.mozIsTextField(false) || element.type == "number") {
flags |= this.TEXTINPUT;
if (element.type == "number") {
flags |= this.NUMERIC;
}
// Allow spellchecking UI on all text and search inputs.
if (!element.readOnly &&
(element.type == "text" || element.type == "search")) {