diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index e7cc1d1c0d1..39a3c7d74ee 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-11-22 Kent Tamura + + INPUT_MULTIPLE_FIELDS_UI: Refactoring: Do not call updateInnerTextValue if only read-only sub-fields have values + https://bugs.webkit.org/show_bug.cgi?id=103033 + + Reviewed by Kentaro Hara. + + * fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt: + * fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html: + 2012-11-22 Keishi Hattori Add week-multiple-fields tests diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt index 8ed3b45356b..a7bb2bbd43f 100644 --- a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt +++ b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt @@ -6,6 +6,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE Empty text: --:-- -- PASS eventSender.keyDown("upArrow"); getUserAgentShadowTextContent(input) is not emptyText PASS input.value = ""; getUserAgentShadowTextContent(input) is emptyText + +Initial text: --:--:45 -- +Empty value should not clear read-only fields. +PASS input.value = ""; getUserAgentShadowTextContent(input) is "--:--:45 --" +Empty value should clear only editable fields. +PASS eventSender.keyDown("upArrow"); getUserAgentShadowTextContent(input) is "01:--:45 --" +PASS input.value = ""; getUserAgentShadowTextContent(input) is "--:--:45 --" PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html index c57c89aec91..af3a31bf1c8 100644 --- a/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html +++ b/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html @@ -5,6 +5,23 @@ diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 82bade2f1fc..38a448fd0cd 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,29 @@ +2012-11-22 Kent Tamura + + INPUT_MULTIPLE_FIELDS_UI: Refactoring: Do not call updateInnerTextValue if only read-only sub-fields have values + https://bugs.webkit.org/show_bug.cgi?id=103033 + + Reviewed by Kentaro Hara. + + input[type=time] can have read-only sub fields. If only read-only fields + have values, we don't need to call updateInnerTextValue when + HTMLInputElement::value is set to "". + + Tests: this patch doesn't change any visible behavior, but we add test cases to + fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html + just in case. + + * html/shadow/DateTimeEditElement.h: + (DateTimeEditElement): Declare anyEditableFieldsHaveValues. + * html/shadow/DateTimeEditElement.cpp: + (WebCore::DateTimeEditElement::anyEditableFieldsHaveValues): + Added. This function checks value existence against only editable sub-fields. + * html/BaseMultipleFieldsDateAndTimeInputType.cpp: + (WebCore::BaseMultipleFieldsDateAndTimeInputType::setValue): + Call DateTimeEditElement::anyEditableFieldsHaveValues() instead of + DateTimeFieldsState::hasAnyValue(). + * html/DateTimeFieldsState.h: Remove hasAnyValue. + 2012-11-22 Allan Sandfeld Jensen [Qt] Lookup mimetypes using QMimeDatabase diff --git a/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp b/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp index addc8063a8b..4bd7cde2c54 100644 --- a/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp +++ b/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp @@ -325,7 +325,7 @@ FormControlState BaseMultipleFieldsDateAndTimeInputType::saveFormControlState() void BaseMultipleFieldsDateAndTimeInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior) { InputType::setValue(sanitizedValue, valueChanged, eventBehavior); - if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->valueAsDateTimeFieldsState().hasAnyValue())) + if (valueChanged || (sanitizedValue.isEmpty() && m_dateTimeEditElement && m_dateTimeEditElement->anyEditableFieldsHaveValues())) updateInnerTextValue(); } diff --git a/Source/WebCore/html/DateTimeFieldsState.h b/Source/WebCore/html/DateTimeFieldsState.h index a05ae59b573..2dd21954606 100644 --- a/Source/WebCore/html/DateTimeFieldsState.h +++ b/Source/WebCore/html/DateTimeFieldsState.h @@ -74,7 +74,6 @@ class DateTimeFieldsState { bool hasSecond() const { return m_second != emptyValue; } bool hasWeekOfYear() const { return m_weekOfYear != emptyValue; } bool hasYear() const { return m_year != emptyValue; } - bool hasAnyValue() const { return hasAMPM() || hasDayOfMonth() || hasHour() || hasMillisecond() || hasMinute() || hasMonth() || hasSecond() || hasWeekOfYear() || hasYear(); } void setAMPM(AMPMValue ampm) { m_ampm = ampm; } void setDayOfMonth(unsigned dayOfMonth) { m_dayOfMonth = dayOfMonth; } diff --git a/Source/WebCore/html/shadow/DateTimeEditElement.cpp b/Source/WebCore/html/shadow/DateTimeEditElement.cpp index e612d2f0bd2..d36ec1cc6dc 100644 --- a/Source/WebCore/html/shadow/DateTimeEditElement.cpp +++ b/Source/WebCore/html/shadow/DateTimeEditElement.cpp @@ -317,6 +317,15 @@ void DateTimeEditElement::addField(PassRefPtr field) appendChild(field); } +bool DateTimeEditElement::anyEditableFieldsHaveValues() const +{ + for (size_t fieldIndex = 0; fieldIndex < m_fields.size(); ++fieldIndex) { + if (!m_fields[fieldIndex]->isReadOnly() && m_fields[fieldIndex]->hasValue()) + return true; + } + return false; +} + void DateTimeEditElement::blurByOwner() { if (DateTimeFieldElement* field = focusedField()) diff --git a/Source/WebCore/html/shadow/DateTimeEditElement.h b/Source/WebCore/html/shadow/DateTimeEditElement.h index 94cb0ac8016..17952acf559 100644 --- a/Source/WebCore/html/shadow/DateTimeEditElement.h +++ b/Source/WebCore/html/shadow/DateTimeEditElement.h @@ -86,6 +86,7 @@ class DateTimeEditElement : public HTMLDivElement, public DateTimeFieldElement:: virtual ~DateTimeEditElement(); void addField(PassRefPtr); + bool anyEditableFieldsHaveValues() const; void blurByOwner(); virtual void defaultEventHandler(Event*) OVERRIDE; void disabledStateChanged();