зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1705946 - Add some prefs for datetime-local. r=smaug
This is a bit subtler than needed (ideally we'd just need one pref) because android enables the support for the type even if it only creates a textbox. Co-Authored-By: Fernando García <fernando.garciagomez.01@telefonica.com> Differential Revision: https://phabricator.services.mozilla.com/D112488
This commit is contained in:
Родитель
a8b75e4ba3
Коммит
c5e28b2599
|
@ -5055,12 +5055,18 @@ 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 ||
|
||||
((aDateTimeInputType == NS_FORM_INPUT_MONTH ||
|
||||
aDateTimeInputType == NS_FORM_INPUT_WEEK ||
|
||||
aDateTimeInputType == NS_FORM_INPUT_DATETIME_LOCAL) &&
|
||||
StaticPrefs::dom_forms_datetime_others());
|
||||
switch (aDateTimeInputType) {
|
||||
case NS_FORM_INPUT_DATE:
|
||||
case NS_FORM_INPUT_TIME:
|
||||
return true;
|
||||
case NS_FORM_INPUT_DATETIME_LOCAL:
|
||||
return StaticPrefs::dom_forms_datetime_local();
|
||||
case NS_FORM_INPUT_MONTH:
|
||||
case NS_FORM_INPUT_WEEK:
|
||||
return StaticPrefs::dom_forms_datetime_others();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool HTMLInputElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
||||
|
@ -5579,14 +5585,6 @@ void HTMLInputElement::SetDirectionFromValue(bool aNotify) {
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsDateOrTime(uint8_t aType) {
|
||||
return (aType == NS_FORM_INPUT_DATE) || (aType == NS_FORM_INPUT_TIME);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLInputElement::Reset() {
|
||||
// We should be able to reset all dirty flags regardless of the type.
|
||||
|
@ -5597,7 +5595,7 @@ HTMLInputElement::Reset() {
|
|||
switch (GetValueMode()) {
|
||||
case VALUE_MODE_VALUE: {
|
||||
nsresult result = SetDefaultValueAsValue();
|
||||
if (IsDateOrTime(mType)) {
|
||||
if (CreatesDateTimeWidget()) {
|
||||
// mFocusedValue has to be set here, so that `FireChangeEventIfNeeded`
|
||||
// can fire a change event if necessary.
|
||||
GetValue(mFocusedValue, CallerType::System);
|
||||
|
@ -5860,7 +5858,7 @@ void HTMLInputElement::DoneCreatingElement() {
|
|||
// before the type change.)
|
||||
SetValueInternal(aValue, ValueSetterOption::ByInternalAPI);
|
||||
|
||||
if (IsDateOrTime(mType)) {
|
||||
if (CreatesDateTimeWidget()) {
|
||||
// mFocusedValue has to be set here, so that `FireChangeEventIfNeeded` can
|
||||
// fire a change event if necessary.
|
||||
mFocusedValue = aValue;
|
||||
|
|
|
@ -1572,10 +1572,18 @@ class HTMLInputElement final : public TextControlElement,
|
|||
mType == NS_FORM_INPUT_PASSWORD;
|
||||
}
|
||||
|
||||
static bool CreatesDateTimeWidget(uint8_t aType) {
|
||||
return aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME ||
|
||||
(aType == NS_FORM_INPUT_DATETIME_LOCAL &&
|
||||
StaticPrefs::dom_forms_datetime_local_widget());
|
||||
}
|
||||
|
||||
bool CreatesDateTimeWidget() const { return CreatesDateTimeWidget(mType); }
|
||||
|
||||
static bool MayFireChangeOnBlur(uint8_t aType) {
|
||||
return IsSingleLineTextControl(false, aType) ||
|
||||
aType == NS_FORM_INPUT_RANGE || aType == NS_FORM_INPUT_NUMBER ||
|
||||
aType == NS_FORM_INPUT_TIME || aType == NS_FORM_INPUT_DATE;
|
||||
CreatesDateTimeWidget(aType) ||
|
||||
aType == NS_FORM_INPUT_RANGE || aType == NS_FORM_INPUT_NUMBER;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1589,11 +1597,6 @@ class HTMLInputElement final : public TextControlElement,
|
|||
*/
|
||||
static bool IsDateTimeTypeSupported(uint8_t aDateTimeInputType);
|
||||
|
||||
static bool CreatesDateTimeWidget(uint8_t aType) {
|
||||
return aType == NS_FORM_INPUT_TIME || aType == NS_FORM_INPUT_DATE;
|
||||
}
|
||||
bool CreatesDateTimeWidget() const { return CreatesDateTimeWidget(mType); }
|
||||
|
||||
struct nsFilePickerFilter {
|
||||
nsFilePickerFilter() : mFilterMask(0) {}
|
||||
|
||||
|
|
|
@ -3396,6 +3396,21 @@ nsCSSFrameConstructor::FindSearchControlData(const Element& aElement,
|
|||
return &sTextControlData;
|
||||
}
|
||||
|
||||
/* static */
|
||||
const nsCSSFrameConstructor::FrameConstructionData*
|
||||
nsCSSFrameConstructor::FindDateTimeLocalInputData(const Element& aElement,
|
||||
ComputedStyle& aStyle) {
|
||||
if (StaticPrefs::dom_forms_datetime_local_widget()) {
|
||||
static const FrameConstructionData sDateTimeData =
|
||||
SIMPLE_FCDATA(NS_NewDateTimeControlFrame);
|
||||
return &sDateTimeData;
|
||||
}
|
||||
|
||||
static const FrameConstructionData sTextControlData =
|
||||
SIMPLE_FCDATA(NS_NewTextControlFrame);
|
||||
return &sTextControlData;
|
||||
}
|
||||
|
||||
/* static */
|
||||
const nsCSSFrameConstructor::FrameConstructionData*
|
||||
nsCSSFrameConstructor::FindInputData(const Element& aElement,
|
||||
|
@ -3425,8 +3440,8 @@ nsCSSFrameConstructor::FindInputData(const Element& aElement,
|
|||
SIMPLE_INT_CREATE(NS_FORM_INPUT_MONTH, NS_NewTextControlFrame),
|
||||
// TODO: this is temporary until a frame is written: bug 888320
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_WEEK, NS_NewTextControlFrame),
|
||||
// TODO: this is temporary until a frame is written: bug 888320
|
||||
SIMPLE_INT_CREATE(NS_FORM_INPUT_DATETIME_LOCAL, NS_NewTextControlFrame),
|
||||
SIMPLE_INT_CHAIN(NS_FORM_INPUT_DATETIME_LOCAL,
|
||||
FindDateTimeLocalInputData),
|
||||
{NS_FORM_INPUT_SUBMIT,
|
||||
FCDATA_WITH_WRAPPING_BLOCK(0, NS_NewGfxButtonControlFrame,
|
||||
PseudoStyleType::buttonContent)},
|
||||
|
|
|
@ -1375,6 +1375,8 @@ class nsCSSFrameConstructor final : public nsFrameManager {
|
|||
ComputedStyle&);
|
||||
static const FrameConstructionData* FindSearchControlData(const Element&,
|
||||
ComputedStyle&);
|
||||
static const FrameConstructionData* FindDateTimeLocalInputData(
|
||||
const Element&, ComputedStyle&);
|
||||
static const FrameConstructionData* FindInputData(const Element&,
|
||||
ComputedStyle&);
|
||||
static const FrameConstructionData* FindObjectData(const Element&,
|
||||
|
|
|
@ -2302,8 +2302,19 @@
|
|||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
|
||||
# Support for input type=month, type=week and type=datetime-local. By default,
|
||||
# disabled.
|
||||
# Support for input type=datetime-local.
|
||||
- name: dom.forms.datetime-local
|
||||
type: bool
|
||||
value: @IS_ANDROID@
|
||||
mirror: always
|
||||
|
||||
# Support for input type=datetime-local widget. Disabled for now.
|
||||
- name: dom.forms.datetime-local.widget
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Support for input type=month, type=week. By default, disabled.
|
||||
- name: dom.forms.datetime.others
|
||||
type: bool
|
||||
value: @IS_ANDROID@
|
||||
|
|
Загрузка…
Ссылка в новой задаче