Bug 1660048 - Remove dom.forms.color and dom.forms.datetime. r=smaug,marionette-reviewers,whimboo

They're enabled in all configurations and there's no plan to change
this. With it, dom.experimental_forms is also useless, so we can remove
it too.

Differential Revision: https://phabricator.services.mozilla.com/D87623
This commit is contained in:
Emilio Cobos Álvarez 2020-08-19 18:24:06 +00:00
parent 16418eddeb
commit 325d955f89
14 changed files with 37 additions and 203 deletions

View File

@ -437,13 +437,6 @@ void GetDOMFileOrDirectoryPath(const OwningFileOrDirectory& aData,
} // namespace
/* static */
bool HTMLInputElement::ValueAsDateEnabled(JSContext* cx, JSObject* obj) {
return StaticPrefs::dom_experimental_forms() ||
StaticPrefs::dom_forms_datetime() ||
StaticPrefs::dom_forms_datetime_others();
}
NS_IMETHODIMP
HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult) {
mInput->PickerClosed();
@ -1291,8 +1284,7 @@ nsresult HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
mAutocompleteInfoState = nsContentUtils::eAutocompleteAttrState_Unknown;
}
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType)) {
if (mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) {
if (aName == nsGkAtoms::value || aName == nsGkAtoms::readonly ||
aName == nsGkAtoms::tabindex || aName == nsGkAtoms::required ||
aName == nsGkAtoms::disabled) {
@ -1426,10 +1418,8 @@ uint32_t HTMLInputElement::Width() {
}
bool HTMLInputElement::SanitizesOnValueGetter() const {
// Don't return non-sanitized value for types that are experimental on mobile
// or datetime types or number.
return mType == NS_FORM_INPUT_NUMBER || IsExperimentalMobileType(mType) ||
IsDateTimeInputType(mType);
// Don't return non-sanitized value for datetime types or number.
return mType == NS_FORM_INPUT_NUMBER || IsDateTimeInputType(mType);
}
void HTMLInputElement::GetValue(nsAString& aValue, CallerType aCallerType) {
@ -1966,12 +1956,6 @@ nsresult HTMLInputElement::ApplyStep(int32_t aStep) {
return rv;
}
/* static */
bool HTMLInputElement::IsExperimentalMobileType(uint8_t aType) {
return (aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME) &&
!StaticPrefs::dom_forms_datetime();
}
bool HTMLInputElement::IsDateTimeInputType(uint8_t aType) {
return aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME ||
aType == NS_FORM_INPUT_MONTH || aType == NS_FORM_INPUT_WEEK ||
@ -2189,8 +2173,7 @@ bool HTMLInputElement::MozIsTextField(bool aExcludePassword) {
//
// FIXME: Historically we never returned true for `number`, we should consider
// changing that now that it is similar to other inputs.
if (IsExperimentalMobileType(mType) || IsDateTimeInputType(mType) ||
mType == NS_FORM_INPUT_NUMBER) {
if (IsDateTimeInputType(mType) || mType == NS_FORM_INPUT_NUMBER) {
return false;
}
@ -2674,7 +2657,6 @@ nsresult HTMLInputElement::SetValueInternal(const nsAString& aValue,
}
} else if ((mType == NS_FORM_INPUT_TIME ||
mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType) &&
!(aFlags & TextControlState::eSetValue_BySetUserInput)) {
if (Element* dateTimeBoxElement = GetDateTimeBoxElement()) {
AsyncEventDispatcher* dispatcher = new AsyncEventDispatcher(
@ -2944,8 +2926,7 @@ void HTMLInputElement::SetCheckedInternal(bool aChecked, bool aNotify) {
}
void HTMLInputElement::Blur(ErrorResult& aError) {
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType)) {
if (mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) {
if (Element* dateTimeBoxElement = GetDateTimeBoxElement()) {
AsyncEventDispatcher* dispatcher = new AsyncEventDispatcher(
dateTimeBoxElement, u"MozBlurInnerTextBox"_ns, CanBubble::eNo,
@ -2960,8 +2941,7 @@ void HTMLInputElement::Blur(ErrorResult& aError) {
void HTMLInputElement::Focus(const FocusOptions& aOptions,
CallerType aCallerType, ErrorResult& aError) {
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType)) {
if (mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) {
if (Element* dateTimeBoxElement = GetDateTimeBoxElement()) {
AsyncEventDispatcher* dispatcher = new AsyncEventDispatcher(
dateTimeBoxElement, u"MozFocusInnerTextBox"_ns, CanBubble::eNo,
@ -3222,7 +3202,7 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
}
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType) && aVisitor.mEvent->mMessage == eFocus &&
aVisitor.mEvent->mMessage == eFocus &&
aVisitor.mEvent->mOriginalTarget == this) {
// If original target is this and not the inner text control, we should
// pass the focus to the inner text control.
@ -3287,7 +3267,7 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
//
// FIXME(emilio): Is this still needed now that we use Shadow DOM for this?
if ((mType == NS_FORM_INPUT_TIME || mType == NS_FORM_INPUT_DATE) &&
!IsExperimentalMobileType(mType) && aVisitor.mEvent->IsTrusted() &&
aVisitor.mEvent->IsTrusted() &&
(aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eFocusIn ||
aVisitor.mEvent->mMessage == eFocusOut ||
@ -3306,18 +3286,8 @@ void HTMLInputElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
}
nsresult HTMLInputElement::PreHandleEvent(EventChainVisitor& aVisitor) {
nsresult rv;
if (aVisitor.mItemFlags & NS_PRE_HANDLE_BLUR_EVENT) {
MOZ_ASSERT(aVisitor.mEvent->mMessage == eBlur);
// Experimental mobile types rely on the system UI to prevent users to not
// set invalid values but we have to be extra-careful. Especially if the
// option has been enabled on desktop.
if (IsExperimentalMobileType(mType)) {
nsAutoString aValue;
GetNonFileValueInternal(aValue);
rv = SetValueInternal(aValue, TextControlState::eSetValue_Internal);
NS_ENSURE_SUCCESS(rv, rv);
}
FireChangeEventIfNeeded();
}
return nsGenericHTMLFormElementWithState::PreHandleEvent(aVisitor);
@ -3851,8 +3821,7 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
if (aVisitor.mEvent->mMessage == eKeyPress &&
keyEvent->mKeyCode == NS_VK_RETURN &&
(IsSingleLineTextControl(false, mType) ||
mType == NS_FORM_INPUT_NUMBER ||
IsExperimentalMobileType(mType) || IsDateTimeInputType(mType))) {
mType == NS_FORM_INPUT_NUMBER || IsDateTimeInputType(mType))) {
FireChangeEventIfNeeded();
if (aVisitor.mPresContext) {
rv = MaybeSubmitForm(MOZ_KnownLive(aVisitor.mPresContext));
@ -5053,10 +5022,8 @@ bool HTMLInputElement::ParseTime(const nsAString& aValue, uint32_t* aResult) {
/* static */
bool HTMLInputElement::IsDateTimeTypeSupported(uint8_t aDateTimeInputType) {
return ((aDateTimeInputType == NS_FORM_INPUT_DATE ||
aDateTimeInputType == NS_FORM_INPUT_TIME) &&
(StaticPrefs::dom_forms_datetime() ||
StaticPrefs::dom_experimental_forms())) ||
return aDateTimeInputType == NS_FORM_INPUT_DATE ||
aDateTimeInputType == NS_FORM_INPUT_TIME ||
((aDateTimeInputType == NS_FORM_INPUT_MONTH ||
aDateTimeInputType == NS_FORM_INPUT_WEEK ||
aDateTimeInputType == NS_FORM_INPUT_DATETIME_LOCAL) &&
@ -5082,8 +5049,7 @@ bool HTMLInputElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
if (aAttribute == nsGkAtoms::type) {
aResult.ParseEnumValue(aValue, kInputTypeTable, false, kInputDefaultType);
int32_t newType = aResult.GetEnumValue();
if ((newType == NS_FORM_INPUT_COLOR && !StaticPrefs::dom_forms_color()) ||
(IsDateTimeInputType(newType) && !IsDateTimeTypeSupported(newType))) {
if (IsDateTimeInputType(newType) && !IsDateTimeTypeSupported(newType)) {
// There's no public way to set an nsAttrValue to an enum value, but we
// can just re-parse with a table that doesn't have any types other than
// "text" in it.

View File

@ -1589,8 +1589,7 @@ class HTMLInputElement final : public TextControlElement,
}
/**
* Checks if aDateTimeInputType should be supported based on
* "dom.forms.datetime", and "dom.experimental_forms".
* Checks if aDateTimeInputType should be supported.
*/
static bool IsDateTimeTypeSupported(uint8_t aDateTimeInputType);

View File

@ -58,7 +58,7 @@ load 795221-5.xml
load 811226.html
load 819745.html
load 828180.html
pref(dom.experimental_forms,true) load 828472.html
load 828472.html
load 837033.html
load 838256-1.html
load 862084.html

View File

@ -175,10 +175,6 @@ bool DateTimeInputTypeBase::GetTimeFromMs(double aValue, uint16_t* aHours,
// input type=date
nsresult DateInputType::GetBadInputMessage(nsAString& aMessage) {
if (!StaticPrefs::dom_forms_datetime()) {
return NS_ERROR_UNEXPECTED;
}
return nsContentUtils::GetMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidDate",
mInputElement->OwnerDoc(), aMessage);

View File

@ -1,4 +1,3 @@
defaults pref(dom.forms.datetime,true)
needs-focus == input-load.html input-ref.html
needs-focus == input-create.html input-ref.html
needs-focus == input-number.html input-number-ref.html

View File

@ -112,7 +112,6 @@ skip-if = os == 'mac'
[test_stepup_stepdown.html]
[test_textarea_attributes_reflection.html]
[test_validation.html]
[test_valueAsDate_pref.html]
[test_valueasdate_attribute.html]
[test_valueasnumber_attribute.html]
[test_validation_not_in_doc.html]

View File

@ -20,71 +20,39 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=764481
var testData = [
{
prefs: [["dom.forms.color", false]],
inputType: "color",
expectedType: "text"
}, {
prefs: [["dom.forms.color", true]],
inputType: "color",
expectedType: "color"
}, {
prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", false]],
inputType: "date",
expectedType: "text"
}, {
prefs: [["dom.experimental_forms", true], ["dom.forms.datetime", false]],
inputType: "date",
expectedType: "date"
}, {
prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", true]],
inputType: "date",
expectedType: "date"
}, {
prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", false]],
inputType: "time",
expectedType: "text"
}, {
prefs: [["dom.experimental_forms", true], ["dom.forms.datetime", false]],
inputType: "time",
expectedType: "time"
}, {
prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", true]],
inputType: "time",
expectedType: "time"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "month",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "month",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]],
prefs: [["dom.forms.datetime.others", true]],
inputType: "month",
expectedType: "month"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "week",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "week",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]],
prefs: [["dom.forms.datetime.others", true]],
inputType: "week",
expectedType: "week"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "datetime-local",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]],
prefs: [["dom.forms.datetime.others", false]],
inputType: "datetime-local",
expectedType: "text"
}, {
prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]],
prefs: [["dom.forms.datetime.others", true]],
inputType: "datetime-local",
expectedType: "datetime-local"
}

View File

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=874640
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 874640</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 874640 **/
var states = [
// dom.experimental_forms, dom.forms.datetime, dom.forms.datetime.others, expectedValueAsDate
[ 'true', 'true', ,'true', 'true' ],
[ 'true', 'false', 'false', 'true' ],
[ 'false', 'true', 'false', 'true' ],
[ 'false', 'false', 'true', 'true' ],
[ 'false', 'false', 'false', 'false' ],
'end'
];
SimpleTest.waitForExplicitFinish();
function runTest(iframe) {
var state = states.shift();
if (state == 'end') {
SimpleTest.finish();
return;
}
SpecialPowers.pushPrefEnv({"set":[
["dom.experimental_forms", state[0] === 'true'],
["dom.forms.datetime", state[1] === 'true'],
["dom.forms.datetime.others", state[2] === 'true']]},
function() {
iframe.srcdoc = '<script>' +
'parent.is("valueAsDate" in document.createElement("input"), ' +
state[3] + ', "valueAsDate presence state should be ' + state[3] + '");' +
'<\/script>'
});
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=874640">Mozilla Bug 874640</a>
<p id="display"></p>
<div id="content" style="display: none">
<iframe onload='runTest(this);'></iframe>
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -94,7 +94,7 @@ interface HTMLInputElement : HTMLElement {
attribute DOMString defaultValue;
[CEReactions, Pure, SetterThrows, NeedsCallerType]
attribute [TreatNullAs=EmptyString] DOMString value;
[Throws, Func="HTMLInputElement::ValueAsDateEnabled"]
[Throws]
attribute object? valueAsDate;
[Pure, SetterThrows]
attribute unrestricted double valueAsNumber;
@ -248,40 +248,36 @@ dictionary DateTimeValue {
};
partial interface HTMLInputElement {
[Pref="dom.forms.datetime", ChromeOnly]
[ChromeOnly]
DateTimeValue getDateTimeInputBoxValue();
[Pref="dom.forms.datetime", ChromeOnly]
[ChromeOnly]
readonly attribute Element? dateTimeBoxElement;
[Pref="dom.forms.datetime", ChromeOnly,
BinaryName="getMinimumAsDouble"]
[ChromeOnly, BinaryName="getMinimumAsDouble"]
double getMinimum();
[Pref="dom.forms.datetime", ChromeOnly,
BinaryName="getMaximumAsDouble"]
[ChromeOnly, BinaryName="getMaximumAsDouble"]
double getMaximum();
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
[Func="IsChromeOrUAWidget"]
void openDateTimePicker(optional DateTimeValue initialValue = {});
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
[Func="IsChromeOrUAWidget"]
void updateDateTimePicker(optional DateTimeValue value = {});
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
[Func="IsChromeOrUAWidget"]
void closeDateTimePicker();
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
[Func="IsChromeOrUAWidget"]
void setFocusState(boolean aIsFocused);
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget"]
[Func="IsChromeOrUAWidget"]
void updateValidityState();
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget",
BinaryName="getStepAsDouble"]
[Func="IsChromeOrUAWidget", BinaryName="getStepAsDouble"]
double getStep();
[Pref="dom.forms.datetime", Func="IsChromeOrUAWidget",
BinaryName="getStepBaseAsDouble"]
[Func="IsChromeOrUAWidget", BinaryName="getStepBaseAsDouble"]
double getStepBase();
};

View File

@ -1,7 +1,5 @@
== input-color-1.html input-color-1-ref.html
defaults pref(dom.forms.color,true)
fuzzy-if(!nativeThemePref,0-1,0-2) == margin-padding-1.html margin-padding-1-ref.html
== block-invalidate-1.html block-invalidate-1-ref.html
== block-invalidate-2.html block-invalidate-2-ref.html

View File

@ -1,5 +1,3 @@
defaults pref(dom.forms.datetime,true)
!= time-simple-unthemed.html time-simple-unthemed-ref.html
!= time-large-font.html time-basic.html
!= time-width-height.html time-basic.html

View File

@ -2013,24 +2013,6 @@
value: 0
mirror: always
# Don't use new input types.
- name: dom.experimental_forms
type: bool
value: false
mirror: always
# Enable <input type=color> by default. It will be turned off for remaining
# platforms which don't have a color picker implemented yet.
- name: dom.forms.color
type: bool
value: true
mirror: always
# Is support for input type=date and type=time enabled?
- name: dom.forms.datetime
type: bool
value: true
mirror: always
# Support for input type=month, type=week and type=datetime-local. By default,
# disabled.
- name: dom.forms.datetime.others

View File

@ -607,10 +607,7 @@ async function webdriverSendKeysToElement(
event.input(el);
event.change(el);
} else if (
(el.type == "date" || el.type == "time") &&
Preferences.get("dom.forms.datetime")
) {
} else if (el.type == "date" || el.type == "time") {
interaction.setFormControlValue(el, value);
} else {
event.sendKeysToElement(value, el, win);
@ -626,10 +623,7 @@ async function legacySendKeysToElement(el, value, a11y) {
event.input(el);
event.change(el);
} else if (
(el.type == "date" || el.type == "time") &&
Preferences.get("dom.forms.datetime")
) {
} else if (el.type == "date" || el.type == "time") {
interaction.setFormControlValue(el, value);
} else {
let visibilityCheckEl = el;

View File

@ -17,10 +17,6 @@ user_pref("media.mediasource.mp4.enabled", true);
user_pref("media.mediasource.webm.enabled", true);
user_pref("media.av1.enabled", true);
user_pref("media.eme.enabled", true);
// Enable some form preferences for testing
user_pref("dom.experimental_forms", true);
user_pref("dom.forms.color", true);
user_pref("dom.forms.datetime", true);
user_pref("dom.forms.datetime.others", true);
// Enable Gamepad
user_pref("dom.gamepad.enabled", true);