- Revision
- 135510
- Author
- [email protected]
- Date
- 2012-11-22 05:45:59 -0800 (Thu, 22 Nov 2012)
Log Message
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.
Source/WebCore:
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.
LayoutTests:
* 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:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (135509 => 135510)
--- trunk/LayoutTests/ChangeLog 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/LayoutTests/ChangeLog 2012-11-22 13:45:59 UTC (rev 135510)
@@ -1,3 +1,13 @@
+2012-11-22 Kent Tamura <[email protected]>
+
+ 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 <[email protected]>
Add week-multiple-fields tests
Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt (135509 => 135510)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty-expected.txt 2012-11-22 13:45:59 UTC (rev 135510)
@@ -6,6 +6,13 @@
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
Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html (135509 => 135510)
--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-value-set-empty.html 2012-11-22 13:45:59 UTC (rev 135510)
@@ -5,6 +5,23 @@
<script src=""
<script>
testSettingEmptyStringClearsSubFields('time');
+
+debug('');
+input = document.createElement('input');
+input.type = 'time';
+input.min = '11:23:45';
+input.step = '60';
+// Because the step value is 60 seconds, the seconds fields is read-only.
+document.body.appendChild(input);
+debug('Initial text: ' + getUserAgentShadowTextContent(input));
+debug('Empty value should not clear read-only fields.');
+shouldBeEqualToString('input.value = ""; getUserAgentShadowTextContent(input)', '--:--:45 --');
+
+debug('Empty value should clear only editable fields.');
+input.focus();
+shouldBeEqualToString('eventSender.keyDown("upArrow"); getUserAgentShadowTextContent(input)', '01:--:45 --');
+shouldBeEqualToString('input.value = ""; getUserAgentShadowTextContent(input)', '--:--:45 --');
+
</script>
<script src=""
</body>
Modified: trunk/Source/WebCore/ChangeLog (135509 => 135510)
--- trunk/Source/WebCore/ChangeLog 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/Source/WebCore/ChangeLog 2012-11-22 13:45:59 UTC (rev 135510)
@@ -1,3 +1,29 @@
+2012-11-22 Kent Tamura <[email protected]>
+
+ 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 <[email protected]>
[Qt] Lookup mimetypes using QMimeDatabase
Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (135509 => 135510)
--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp 2012-11-22 13:45:59 UTC (rev 135510)
@@ -325,7 +325,7 @@
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();
}
Modified: trunk/Source/WebCore/html/DateTimeFieldsState.h (135509 => 135510)
--- trunk/Source/WebCore/html/DateTimeFieldsState.h 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/Source/WebCore/html/DateTimeFieldsState.h 2012-11-22 13:45:59 UTC (rev 135510)
@@ -74,7 +74,6 @@
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; }
Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (135509 => 135510)
--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp 2012-11-22 13:45:59 UTC (rev 135510)
@@ -317,6 +317,15 @@
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())
Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.h (135509 => 135510)
--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.h 2012-11-22 13:31:46 UTC (rev 135509)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.h 2012-11-22 13:45:59 UTC (rev 135510)
@@ -86,6 +86,7 @@
virtual ~DateTimeEditElement();
void addField(PassRefPtr<DateTimeFieldElement>);
+ bool anyEditableFieldsHaveValues() const;
void blurByOwner();
virtual void defaultEventHandler(Event*) OVERRIDE;
void disabledStateChanged();