void BaseMultipleFieldsDateAndTimeInputType::updateView() { DateTimeEditElement* edit = dateTimeEditElement(); if (!edit) return; DateTimeEditElement::LayoutParameters layoutParameters(element().locale(), createStepRange(AnyIsDefaultStep)); DateComponents date; bool hasValue = false; if (!element().suggestedValue().isNull()) hasValue = parseToDateComponents(element().suggestedValue(), &date); else hasValue = parseToDateComponents(element().value(), &date); if (!hasValue) setMillisecondToDateComponents(layoutParameters.stepRange.minimum().toDouble(), &date); setupLayoutParameters(layoutParameters, date); DEFINE_STATIC_LOCAL(AtomicString, datetimeformatAttr, ("datetimeformat", AtomicString::ConstructFromLiteral)); edit->setAttribute(datetimeformatAttr, AtomicString(layoutParameters.dateTimeFormat), ASSERT_NO_EXCEPTION); const AtomicString pattern = edit->fastGetAttribute(HTMLNames::patternAttr); if (!pattern.isEmpty()) layoutParameters.dateTimeFormat = pattern; if (!DateTimeFormatValidator().validateFormat(layoutParameters.dateTimeFormat, *this)) layoutParameters.dateTimeFormat = layoutParameters.fallbackDateTimeFormat; if (hasValue) edit->setValueAsDate(layoutParameters, date); else edit->setEmptyValue(layoutParameters, date); updateClearButtonVisibility(); }
void BaseMultipleFieldsDateAndTimeInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior) { InputType::setValue(sanitizedValue, valueChanged, eventBehavior); DateTimeEditElement* edit = dateTimeEditElement(); if (valueChanged || (sanitizedValue.isEmpty() && edit && edit->anyEditableFieldsHaveValues())) { element().updateView(); element().setNeedsValidityCheck(); } }
void MultipleFieldsTemporalInputTypeView::didSetValue( const String& sanitizedValue, bool valueChanged) { DateTimeEditElement* edit = dateTimeEditElement(); if (valueChanged || (sanitizedValue.isEmpty() && edit && edit->anyEditableFieldsHaveValues())) { element().updateView(); element().setNeedsValidityCheck(); } }
void BaseMultipleFieldsDateAndTimeInputType::restoreFormControlState(const FormControlState& state) { DateTimeEditElement* edit = dateTimeEditElement(); if (!edit) return; DateTimeFieldsState dateTimeFieldsState = DateTimeFieldsState::restoreFormControlState(state); edit->setValueAsDateTimeFieldsState(dateTimeFieldsState); element().setValueInternal(sanitizeValue(edit->value()), DispatchNoEvent); updateClearButtonVisibility(); }
void BaseMultipleFieldsDateAndTimeInputType::handleFocusInEvent(Element* oldFocusedElement, FocusType type) { DateTimeEditElement* edit = dateTimeEditElement(); if (!edit || m_isDestroyingShadowSubtree) return; if (type == FocusTypeBackward) { if (element().document().page()) element().document().page()->focusController().advanceFocus(type); } else if (type == FocusTypeNone || type == FocusTypeMouse || type == FocusTypePage) { edit->focusByOwner(oldFocusedElement); } else { edit->focusByOwner(); } }
void MultipleFieldsTemporalInputTypeView::pickerIndicatorChooseValue( const String& value) { if (element().isValidValue(value)) { element().setValue(value, DispatchInputAndChangeEvent); return; } DateTimeEditElement* edit = this->dateTimeEditElement(); if (!edit) return; EventQueueScope scope; DateComponents date; unsigned end; if (date.parseDate(value, 0, end) && end == value.length()) edit->setOnlyYearMonthDay(date); element().dispatchFormControlChangeEvent(); }
bool MultipleFieldsTemporalInputTypeView::hasBadInput() const { DateTimeEditElement* edit = dateTimeEditElement(); return element().value().isEmpty() && edit && edit->anyEditableFieldsHaveValues(); }
bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const { DateTimeEditElement* edit = dateTimeEditElement(); return element().value().isEmpty() && edit && edit->anyEditableFieldsHaveValues(); }