- Revision
- 108051
- Author
- [email protected]
- Date
- 2012-02-17 01:22:41 -0800 (Fri, 17 Feb 2012)
Log Message
[Forms] Integrate InputType::dispatchChangeEventInResponseToSetValue into InputType::setValue
https://bugs.webkit.org/show_bug.cgi?id=78873
Patch by Yosifumi Inoue <[email protected]> on 2012-02-17
Reviewed by Kent Tamura.
This patch moves event dispatch logic to InputType and TextFieldInputType from HTMLInputElement
and merge dispatchChangeEventInResponseToSetValue to setValue.
No new tests. No change in behavior.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setValue): Move dispatch logic to InputType and TextFieldInput.
* html/InputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
* html/InputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
(WebCore::InputType::setValue): Move code from dispatchChangeEventInResponseToSetValue.
* html/TextFieldInputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
* html/TextFieldInputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
(WebCore::TextFieldInputType::setValue): Move code from dispatchChangeEventInResponseToSetValue. Stop dispatching event in InputType::setValue.
* html/HTMLTextFormControlElement.h: Make setTextAsOfLastFormControlChangeEvent to public from protected for accessing from InputType class.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (108050 => 108051)
--- trunk/Source/WebCore/ChangeLog 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/ChangeLog 2012-02-17 09:22:41 UTC (rev 108051)
@@ -1,3 +1,25 @@
+2012-02-17 Yosifumi Inoue <[email protected]>
+
+ [Forms] Integrate InputType::dispatchChangeEventInResponseToSetValue into InputType::setValue
+ https://bugs.webkit.org/show_bug.cgi?id=78873
+
+ Reviewed by Kent Tamura.
+
+ This patch moves event dispatch logic to InputType and TextFieldInputType from HTMLInputElement
+ and merge dispatchChangeEventInResponseToSetValue to setValue.
+
+ No new tests. No change in behavior.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setValue): Move dispatch logic to InputType and TextFieldInput.
+ * html/InputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
+ * html/InputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
+ (WebCore::InputType::setValue): Move code from dispatchChangeEventInResponseToSetValue.
+ * html/TextFieldInputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
+ * html/TextFieldInputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
+ (WebCore::TextFieldInputType::setValue): Move code from dispatchChangeEventInResponseToSetValue. Stop dispatching event in InputType::setValue.
+ * html/HTMLTextFormControlElement.h: Make setTextAsOfLastFormControlChangeEvent to public from protected for accessing from InputType class.
+
2012-02-17 Yury Semikhatsky <[email protected]>
Unreviewed. Mac build fix after r108047.
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (108050 => 108051)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-02-17 09:22:41 UTC (rev 108051)
@@ -1043,13 +1043,6 @@
if (!valueChanged)
return;
- if (eventBehavior != DispatchNoEvent)
- m_inputType->dispatchChangeEventInResponseToSetValue();
-
- // FIXME: Why do we do this when eventBehavior == DispatchNoEvent
- if (isTextField() && (!focused() || eventBehavior == DispatchNoEvent))
- setTextAsOfLastFormControlChangeEvent(value);
-
notifyFormStateChanged();
}
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (108050 => 108051)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2012-02-17 09:22:41 UTC (rev 108051)
@@ -82,14 +82,14 @@
String directionForFormData() const;
+ void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
+
protected:
HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
virtual void updatePlaceholderText() = 0;
virtual void parseAttribute(Attribute*) OVERRIDE;
- void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
-
void cacheSelection(int start, int end, TextFieldSelectionDirection direction)
{
m_cachedSelectionStart = start;
Modified: trunk/Source/WebCore/html/InputType.cpp (108050 => 108051)
--- trunk/Source/WebCore/html/InputType.cpp 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/InputType.cpp 2012-02-17 09:22:41 UTC (rev 108051)
@@ -540,17 +540,14 @@
return true;
}
-void InputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior eventBehavior)
+void InputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
element()->setValueInternal(sanitizedValue, eventBehavior);
element()->setNeedsStyleRecalc();
+ if (valueChanged && eventBehavior != DispatchNoEvent)
+ element()->dispatchFormControlChangeEvent();
}
-void InputType::dispatchChangeEventInResponseToSetValue()
-{
- element()->dispatchFormControlChangeEvent();
-}
-
bool InputType::canSetValue(const String&)
{
return true;
Modified: trunk/Source/WebCore/html/InputType.h (108050 => 108051)
--- trunk/Source/WebCore/html/InputType.h 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/InputType.h 2012-02-17 09:22:41 UTC (rev 108051)
@@ -227,7 +227,6 @@
virtual bool canSetValue(const String&);
virtual bool storesValueSeparateFromAttribute();
virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior);
- virtual void dispatchChangeEventInResponseToSetValue();
virtual bool shouldResetOnDocumentActivation();
virtual bool shouldRespectListAttribute();
virtual bool shouldRespectSpeechAttribute();
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (108050 => 108051)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2012-02-17 09:22:41 UTC (rev 108051)
@@ -80,7 +80,9 @@
void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
{
- InputType::setValue(sanitizedValue, valueChanged, eventBehavior);
+ // We don't ask InputType::setValue to dispatch events because
+ // TextFieldInputType dispatches events different way from InputType.
+ InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent);
if (valueChanged)
element()->updateInnerTextValue();
@@ -90,17 +92,22 @@
element()->setSelectionRange(max, max);
else
element()->cacheSelectionInResponseToSetValue(max);
-}
-void TextFieldInputType::dispatchChangeEventInResponseToSetValue()
-{
- // If the user is still editing this field, dispatch an input event rather than a change event.
- // The change event will be dispatched when editing finishes.
- if (element()->focused()) {
- element()->dispatchFormControlInputEvent();
+ if (!valueChanged)
return;
+
+ if (eventBehavior != DispatchNoEvent) {
+ // If the user is still editing this field, dispatch an input event rather than a change event.
+ // The change event will be dispatched when editing finishes.
+ if (element()->focused())
+ element()->dispatchFormControlInputEvent();
+ else
+ element()->dispatchFormControlChangeEvent();
}
- InputType::dispatchChangeEventInResponseToSetValue();
+
+ // FIXME: Why do we do this when eventBehavior == DispatchNoEvent
+ if (!element()->focused() || eventBehavior == DispatchNoEvent)
+ element()->setTextAsOfLastFormControlChangeEvent(sanitizedValue);
}
void TextFieldInputType::handleKeydownEvent(KeyboardEvent* event)
Modified: trunk/Source/WebCore/html/TextFieldInputType.h (108050 => 108051)
--- trunk/Source/WebCore/html/TextFieldInputType.h 2012-02-17 09:09:09 UTC (rev 108050)
+++ trunk/Source/WebCore/html/TextFieldInputType.h 2012-02-17 09:22:41 UTC (rev 108051)
@@ -74,7 +74,6 @@
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
virtual bool shouldUseInputMethod() const OVERRIDE;
virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
- virtual void dispatchChangeEventInResponseToSetValue() OVERRIDE;
virtual String sanitizeValue(const String&) const OVERRIDE;
virtual bool shouldRespectListAttribute() OVERRIDE;
virtual HTMLElement* placeholderElement() const OVERRIDE;