Skip to content

Commit

Permalink
Introduce InputTypeView::didSetValue().
Browse files Browse the repository at this point in the history
This helps to make BaseChooserOnlyDateAndTimeInputType and
BaseMultipleFieldsDateAndTimeInputType InputTypeView subclasses.

This is a preparation to remove ENABLE_INPUT_MULTIPLE_FIELDS_UI flag.
This CL has no behavior changes.

BUG=243714

Review URL: https://codereview.chromium.org/1901603006

Cr-Commit-Position: refs/heads/master@{#388156}
  • Loading branch information
tkent-google authored and Commit bot committed Apr 19, 2016
1 parent 57c5fa2 commit 24d0d5e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions third_party/WebKit/Source/core/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ void HTMLInputElement::setValue(const String& value, TextFieldEventBehavior even
m_suggestedValue = String(); // Prevent TextFieldInputType::setValue from using the suggested value.

m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior);
m_inputTypeView->didSetValue(sanitizedValue, valueChanged);

if (valueChanged && eventBehavior == DispatchNoEvent)
setTextAsOfLastFormControlChangeEvent(sanitizedValue.isNull() ? defaultValue() : sanitizedValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ void BaseChooserOnlyDateAndTimeInputType::updateView()
toHTMLElement(node)->setTextContent(displayValue);
}

void BaseChooserOnlyDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
void BaseChooserOnlyDateAndTimeInputType::didSetValue(const String& value, bool valueChanged)
{
BaseDateAndTimeInputType::setValue(value, valueChanged, eventBehavior);
if (valueChanged)
updateView();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ class BaseChooserOnlyDateAndTimeInputType : public BaseDateAndTimeInputType, pub
private:
void closeDateTimeChooser();

// InputType functions:
// InputTypeView functions:
void createShadowSubtree() override;
void closePopupView() override;
void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
void didSetValue(const String&, bool valueChanged) override;
void handleDOMActivateEvent(Event*) override;
void handleKeydownEvent(KeyboardEvent*) override;
void handleKeypressEvent(KeyboardEvent*) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,8 @@ FormControlState BaseMultipleFieldsDateAndTimeInputType::saveFormControlState()
return FormControlState();
}

void BaseMultipleFieldsDateAndTimeInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
void BaseMultipleFieldsDateAndTimeInputType::didSetValue(const String& sanitizedValue, bool valueChanged)
{
InputType::setValue(sanitizedValue, valueChanged, eventBehavior);
DateTimeEditElement* edit = dateTimeEditElement();
if (valueChanged || (sanitizedValue.isEmpty() && edit && edit->anyEditableFieldsHaveValues())) {
element().updateView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BaseMultipleFieldsDateAndTimeInputType
void requiredAttributeChanged() final;
void restoreFormControlState(const FormControlState&) final;
FormControlState saveFormControlState() const final;
void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
void didSetValue(const String&, bool valueChanged) final;
void stepAttributeChanged() final;
void updateView() final;
void valueAttributeChanged() override;
Expand Down
4 changes: 4 additions & 0 deletions third_party/WebKit/Source/core/html/forms/InputTypeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ void InputTypeView::valueAttributeChanged()
{
}

void InputTypeView::didSetValue(const String&, bool)
{
}

void InputTypeView::subtreeHasChanged()
{
ASSERT_NOT_REACHED();
Expand Down
1 change: 1 addition & 0 deletions third_party/WebKit/Source/core/html/forms/InputTypeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class CORE_EXPORT InputTypeView : public GarbageCollectedFinalized<InputTypeView
virtual void readonlyAttributeChanged();
virtual void requiredAttributeChanged();
virtual void valueAttributeChanged();
virtual void didSetValue(const String&, bool valueChanged);
virtual void listAttributeTargetChanged();
virtual void updateClearButtonVisibility();
virtual void updatePlaceholderText();
Expand Down

0 comments on commit 24d0d5e

Please sign in to comment.