mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 635498 - Make <input type='number'> behaves like <input type='text'>. r=sicking
--HG-- extra : rebase_source : 0754f845fd6223cd48ca8908ebf642636f0fd9ed
This commit is contained in:
parent
c76979351d
commit
c70ab8fd5b
@ -1901,6 +1901,7 @@ nsEventStateManager::FireContextClick()
|
||||
type == NS_FORM_INPUT_URL ||
|
||||
type == NS_FORM_INPUT_PASSWORD ||
|
||||
type == NS_FORM_INPUT_FILE ||
|
||||
type == NS_FORM_INPUT_NUMBER ||
|
||||
type == NS_FORM_TEXTAREA);
|
||||
}
|
||||
else if (tag == nsGkAtoms::applet ||
|
||||
|
@ -53,6 +53,7 @@ enum InputElementTypes {
|
||||
NS_FORM_INPUT_HIDDEN,
|
||||
NS_FORM_INPUT_RESET,
|
||||
NS_FORM_INPUT_IMAGE,
|
||||
NS_FORM_INPUT_NUMBER,
|
||||
NS_FORM_INPUT_PASSWORD,
|
||||
NS_FORM_INPUT_RADIO,
|
||||
NS_FORM_INPUT_SEARCH,
|
||||
@ -229,6 +230,8 @@ nsIFormControl::IsSingleLineTextControl(bool aExcludePassword, PRUint32 aType)
|
||||
aType == NS_FORM_INPUT_SEARCH ||
|
||||
aType == NS_FORM_INPUT_TEL ||
|
||||
aType == NS_FORM_INPUT_URL ||
|
||||
// TODO: this is temporary until bug 635240 is fixed.
|
||||
aType == NS_FORM_INPUT_NUMBER ||
|
||||
(!aExcludePassword && aType == NS_FORM_INPUT_PASSWORD);
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,7 @@ ShouldBeInElements(nsIFormControl* aFormControl)
|
||||
case NS_FORM_INPUT_TEXT :
|
||||
case NS_FORM_INPUT_TEL :
|
||||
case NS_FORM_INPUT_URL :
|
||||
case NS_FORM_INPUT_NUMBER :
|
||||
case NS_FORM_SELECT :
|
||||
case NS_FORM_TEXTAREA :
|
||||
case NS_FORM_FIELDSET :
|
||||
|
@ -119,6 +119,7 @@ static const nsAttrValue::EnumTable kInputTypeTable[] = {
|
||||
{ "hidden", NS_FORM_INPUT_HIDDEN },
|
||||
{ "reset", NS_FORM_INPUT_RESET },
|
||||
{ "image", NS_FORM_INPUT_IMAGE },
|
||||
{ "number", NS_FORM_INPUT_NUMBER },
|
||||
{ "password", NS_FORM_INPUT_PASSWORD },
|
||||
{ "radio", NS_FORM_INPUT_RADIO },
|
||||
{ "search", NS_FORM_INPUT_SEARCH },
|
||||
@ -130,7 +131,7 @@ static const nsAttrValue::EnumTable kInputTypeTable[] = {
|
||||
};
|
||||
|
||||
// Default type is 'text'.
|
||||
static const nsAttrValue::EnumTable* kInputDefaultType = &kInputTypeTable[12];
|
||||
static const nsAttrValue::EnumTable* kInputDefaultType = &kInputTypeTable[13];
|
||||
|
||||
static const PRUint8 NS_INPUT_AUTOCOMPLETE_OFF = 0;
|
||||
static const PRUint8 NS_INPUT_AUTOCOMPLETE_ON = 1;
|
||||
@ -646,6 +647,7 @@ nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
if (mValueChanged) {
|
||||
// We don't have our default value anymore. Set our value on
|
||||
// the clone.
|
||||
@ -1097,6 +1099,12 @@ nsHTMLInputElement::MozSetFileNameArray(const PRUnichar **aFileNames, PRUint32 a
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::MozIsTextField(bool aExcludePassword, bool* aResult)
|
||||
{
|
||||
// TODO: temporary until bug 635240 is fixed.
|
||||
if (mType == NS_FORM_INPUT_NUMBER) {
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aResult = IsSingleLineTextControl(aExcludePassword);
|
||||
|
||||
return NS_OK;
|
||||
@ -2174,7 +2182,8 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
if (aVisitor.mEvent->message == NS_KEY_PRESS &&
|
||||
(keyEvent->keyCode == NS_VK_RETURN ||
|
||||
keyEvent->keyCode == NS_VK_ENTER) &&
|
||||
IsSingleLineTextControl(false, mType)) {
|
||||
(IsSingleLineTextControl(false, mType) ||
|
||||
mType == NS_FORM_INPUT_NUMBER)) {
|
||||
FireChangeEventIfNeeded();
|
||||
rv = MaybeSubmitForm(aVisitor.mPresContext);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -3068,6 +3077,7 @@ nsHTMLInputElement::SaveState()
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
{
|
||||
if (mValueChanged) {
|
||||
inputState = new nsHTMLInputElementState();
|
||||
@ -3245,6 +3255,7 @@ nsHTMLInputElement::RestoreState(nsPresState* aState)
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
{
|
||||
SetValueInternal(inputState->GetValue(), false, true);
|
||||
break;
|
||||
@ -3469,6 +3480,7 @@ nsHTMLInputElement::GetValueMode() const
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_EMAIL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
return VALUE_MODE_VALUE;
|
||||
default:
|
||||
NS_NOTYETIMPLEMENTED("Unexpected input type in GetValueMode()");
|
||||
@ -3512,6 +3524,7 @@ nsHTMLInputElement::DoesReadOnlyApply() const
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_EMAIL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
return true;
|
||||
default:
|
||||
NS_NOTYETIMPLEMENTED("Unexpected input type in DoesReadOnlyApply()");
|
||||
@ -3547,6 +3560,7 @@ nsHTMLInputElement::DoesRequiredApply() const
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_EMAIL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
return true;
|
||||
default:
|
||||
NS_NOTYETIMPLEMENTED("Unexpected input type in DoesRequiredApply()");
|
||||
@ -3561,6 +3575,11 @@ nsHTMLInputElement::DoesRequiredApply() const
|
||||
bool
|
||||
nsHTMLInputElement::DoesPatternApply() const
|
||||
{
|
||||
// TODO: temporary until bug 635240 is fixed.
|
||||
if (mType == NS_FORM_INPUT_NUMBER) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsSingleLineTextControl(false);
|
||||
}
|
||||
|
||||
|
@ -181,11 +181,11 @@ reflectLimitedEnumerated({
|
||||
attribute: "type",
|
||||
validValues: [ "hidden", "text", "search", "tel", "url", "email", "password",
|
||||
"checkbox", "radio", "file", "submit", "image", "reset",
|
||||
"button" ],
|
||||
"button", "number" ],
|
||||
invalidValues: [ "this-is-probably-a-wrong-type", "", "tulip" ],
|
||||
defaultValue: "text",
|
||||
unsupportedValues: [ "datetime", "date", "month", "week", "time",
|
||||
"datetime-local", "number", "range", "color" ]
|
||||
"datetime-local", "range", "color" ]
|
||||
});
|
||||
|
||||
// .defaultValue
|
||||
|
@ -44,12 +44,10 @@ var gInputTestData = [
|
||||
['image', false],
|
||||
['radio', false],
|
||||
['submit', false],
|
||||
// TODO: the next states are not yet implemented but we can't use a todo for
|
||||
// them as the check will success so the test will fail (todo _has_ to fail).
|
||||
// The tests are not failing because the unvalid states fallback to 'text'.
|
||||
['search', true],
|
||||
['email', true],
|
||||
['url', true],
|
||||
['number', false],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -58,7 +56,6 @@ var gInputTestData = [
|
||||
*/
|
||||
var gInputTodoData = [
|
||||
/* type expected result */
|
||||
['number', false],
|
||||
['range', false],
|
||||
['color', false],
|
||||
['date', false],
|
||||
|
@ -261,10 +261,10 @@ var input = document.getElementById('i');
|
||||
// and |invalidTypes| are the ones which do not accept it.
|
||||
var validTypes = Array('text', 'password', 'search', 'tel', 'email', 'url');
|
||||
var barredTypes = Array('hidden', 'reset', 'button', 'submit', 'image');
|
||||
var invalidTypes = Array('checkbox', 'radio', 'file');
|
||||
var invalidTypes = Array('checkbox', 'radio', 'file', 'number');
|
||||
// TODO: 'datetime', 'date', 'month', 'week', 'time', 'datetime-local',
|
||||
// 'number', 'range', ande 'color' do not accept the @pattern too but are
|
||||
// not implemented yet.
|
||||
// 'range', and 'color' do not accept the @pattern too but are not
|
||||
// implemented yet.
|
||||
|
||||
for each (type in validTypes) {
|
||||
input.type = type;
|
||||
|
@ -162,6 +162,8 @@ function checkInputRequiredValidity(type)
|
||||
element.value = 'foo@bar.com';
|
||||
} else if (element.type == 'url') {
|
||||
element.value = 'http://mozilla.org/';
|
||||
} else if (element.type == 'number') {
|
||||
element.value = '42';
|
||||
} else {
|
||||
element.value = 'foo';
|
||||
}
|
||||
@ -369,9 +371,10 @@ for each (type in typeRequireNotApply) {
|
||||
}
|
||||
|
||||
// Now, checking for all types which accept the required attribute.
|
||||
// TODO: check 'datetime', 'date', 'month', 'week', 'time', 'datetime-local'
|
||||
// and 'number' when they will be implemented.
|
||||
var typeRequireApply = ["text", "password", "search", "tel", "email", "url"];
|
||||
// TODO: check 'datetime', 'date', 'month', 'week', 'time' and 'datetime-local'
|
||||
// when they will be implemented.
|
||||
var typeRequireApply = ["text", "password", "search", "tel", "email", "url",
|
||||
"number"];
|
||||
|
||||
for each (type in typeRequireApply) {
|
||||
checkInputRequiredValidity(type);
|
||||
|
@ -30,7 +30,7 @@ var inputTypes =
|
||||
|
||||
var todoTypes =
|
||||
[
|
||||
"number", "range", "color",
|
||||
"range", "color",
|
||||
"date", "month", "week", "time", "datetime", "datetime-local",
|
||||
];
|
||||
|
||||
@ -60,7 +60,7 @@ function sanitizeValue(aType, aValue)
|
||||
// TODO: write the sanitize algorithm.
|
||||
return "";
|
||||
case "number":
|
||||
// TODO: write the sanitize algorithm.
|
||||
todo(false, "will be done with bug 635281");
|
||||
return "";
|
||||
case "range":
|
||||
// TODO: write the sanitize algorithm.
|
||||
|
@ -3236,6 +3236,7 @@ nsWebBrowserPersist::CloneNodeWithFixedUpAttributes(
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
case NS_FORM_INPUT_TEL:
|
||||
case NS_FORM_INPUT_URL:
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
nodeAsInput->GetValue(valueStr);
|
||||
// Avoid superfluous value="" serialization
|
||||
if (valueStr.IsEmpty())
|
||||
|
@ -3443,6 +3443,8 @@ nsCSSFrameConstructor::FindInputData(Element* aElement,
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_TEL, NS_NewTextControlFrame),
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_URL, NS_NewTextControlFrame),
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_PASSWORD, NS_NewTextControlFrame),
|
||||
// TODO: this is temporary until a frame is written: bug 635240.
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_NUMBER, NS_NewTextControlFrame),
|
||||
{ NS_FORM_INPUT_SUBMIT,
|
||||
FCDATA_WITH_WRAPPING_BLOCK(0, NS_NewGfxButtonControlFrame,
|
||||
nsCSSAnonBoxes::buttonContent) },
|
||||
|
@ -80,8 +80,14 @@ Form History test: form field autocomplete
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- normal, basic form (with fieldname='searchbar-history') -->
|
||||
<!-- form with input type='number' -->
|
||||
<form id="form12" onsubmit="return false;">
|
||||
<input type="number" name="field10">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- normal, basic form (with fieldname='searchbar-history') -->
|
||||
<form id="form13" onsubmit="return false;">
|
||||
<input type="text" name="searchbar-history">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
@ -127,11 +133,12 @@ fh.addEntry("field6", "value");
|
||||
fh.addEntry("field7", "value");
|
||||
fh.addEntry("field8", "value");
|
||||
fh.addEntry("field9", "value");
|
||||
fh.addEntry("field10", "value");
|
||||
fh.addEntry("searchbar-history", "blacklist test");
|
||||
|
||||
// All these non-implemeted types might need autocomplete tests in the future.
|
||||
var todoTypes = [ "datetime", "date", "month", "week", "time", "datetime-local",
|
||||
"number", "range", "color" ];
|
||||
"range", "color" ];
|
||||
var todoInput = document.createElement("input");
|
||||
for each (var type in todoTypes) {
|
||||
todoInput.type = type;
|
||||
@ -698,6 +705,7 @@ function runTest(testNum) {
|
||||
case 401:
|
||||
case 402:
|
||||
case 403:
|
||||
case 404:
|
||||
checkMenuEntries(["value"]);
|
||||
doKey("down");
|
||||
doKey("return");
|
||||
@ -710,6 +718,8 @@ function runTest(testNum) {
|
||||
} else if (testNum == 402) {
|
||||
input = $_(11, "field9");
|
||||
} else if (testNum == 403) {
|
||||
input = $_(12, "field10");
|
||||
} else if (testNum == 404) {
|
||||
// Go to test 500.
|
||||
fh.addEntry("field1", "value1");
|
||||
input = $_(1, "field1");
|
||||
@ -738,7 +748,7 @@ function runTest(testNum) {
|
||||
|
||||
case 600:
|
||||
// check we don't show autocomplete for searchbar-history
|
||||
input = $_(12, "searchbar-history");
|
||||
input = $_(13, "searchbar-history");
|
||||
|
||||
// Trigger autocomplete popup
|
||||
checkForm("");
|
||||
|
Loading…
Reference in New Issue
Block a user