コード例 #1
0
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();
}
コード例 #2
0
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();
    }
}
コード例 #3
0
void MultipleFieldsTemporalInputTypeView::didSetValue(
    const String& sanitizedValue,
    bool valueChanged) {
  DateTimeEditElement* edit = dateTimeEditElement();
  if (valueChanged || (sanitizedValue.isEmpty() && edit &&
                       edit->anyEditableFieldsHaveValues())) {
    element().updateView();
    element().setNeedsValidityCheck();
  }
}
コード例 #4
0
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();
}
コード例 #5
0
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();
    }
}
コード例 #6
0
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();
}
コード例 #7
0
bool MultipleFieldsTemporalInputTypeView::hasBadInput() const {
  DateTimeEditElement* edit = dateTimeEditElement();
  return element().value().isEmpty() && edit &&
         edit->anyEditableFieldsHaveValues();
}
コード例 #8
0
bool BaseMultipleFieldsDateAndTimeInputType::hasBadInput() const
{
    DateTimeEditElement* edit = dateTimeEditElement();
    return element().value().isEmpty() && edit && edit->anyEditableFieldsHaveValues();
}