Changeset 108051 in webkit


Ignore:
Timestamp:
Feb 17, 2012, 1:22:41 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

[Forms] Integrate InputType::dispatchChangeEventInResponseToSetValue into InputType::setValue
https://bugs.webkit.org/show_bug.cgi?id=78873

Patch by Yosifumi Inoue <yosin@chromium.org> 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.
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r108050 r108051  
     12012-02-17  Yosifumi Inoue  <yosin@chromium.org>
     2
     3        [Forms] Integrate InputType::dispatchChangeEventInResponseToSetValue into InputType::setValue
     4        https://bugs.webkit.org/show_bug.cgi?id=78873
     5
     6        Reviewed by Kent Tamura.
     7
     8        This patch moves event dispatch logic to InputType and TextFieldInputType from HTMLInputElement
     9        and merge dispatchChangeEventInResponseToSetValue to setValue.
     10
     11        No new tests. No change in behavior.
     12
     13        * html/HTMLInputElement.cpp:
     14        (WebCore::HTMLInputElement::setValue): Move dispatch logic to InputType and TextFieldInput.
     15        * html/InputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
     16        * html/InputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
     17        (WebCore::InputType::setValue): Move code from dispatchChangeEventInResponseToSetValue.
     18        * html/TextFieldInputType.cpp: Remove dispatchChangeEventInResponseToSetValue implementation.
     19        * html/TextFieldInputType.h: Remove dispatchChangeEventInResponseToSetValue declaration.
     20        (WebCore::TextFieldInputType::setValue): Move code from dispatchChangeEventInResponseToSetValue. Stop dispatching event in InputType::setValue.
     21        * html/HTMLTextFormControlElement.h: Make setTextAsOfLastFormControlChangeEvent to public from protected for accessing from InputType class.
     22
    1232012-02-17  Yury Semikhatsky  <yurys@chromium.org>
    224
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r107706 r108051  
    10441044        return;
    10451045
    1046     if (eventBehavior != DispatchNoEvent)
    1047         m_inputType->dispatchChangeEventInResponseToSetValue();
    1048 
    1049     // FIXME: Why do we do this when eventBehavior == DispatchNoEvent
    1050     if (isTextField() && (!focused() || eventBehavior == DispatchNoEvent))
    1051         setTextAsOfLastFormControlChangeEvent(value);
    1052 
    10531046    notifyFormStateChanged();
    10541047}
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.h

    r107555 r108051  
    8383    String directionForFormData() const;
    8484
     85    void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
     86
    8587protected:
    8688    HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
     
    8991    virtual void parseAttribute(Attribute*) OVERRIDE;
    9092
    91     void setTextAsOfLastFormControlChangeEvent(const String& text) { m_textAsOfLastFormControlChangeEvent = text; }
    92    
    9393    void cacheSelection(int start, int end, TextFieldSelectionDirection direction)
    9494    {
  • trunk/Source/WebCore/html/InputType.cpp

    r107706 r108051  
    541541}
    542542
    543 void InputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior eventBehavior)
     543void InputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
    544544{
    545545    element()->setValueInternal(sanitizedValue, eventBehavior);
    546546    element()->setNeedsStyleRecalc();
    547 }
    548 
    549 void InputType::dispatchChangeEventInResponseToSetValue()
    550 {
    551     element()->dispatchFormControlChangeEvent();
     547    if (valueChanged && eventBehavior != DispatchNoEvent)
     548        element()->dispatchFormControlChangeEvent();
    552549}
    553550
  • trunk/Source/WebCore/html/InputType.h

    r107555 r108051  
    228228    virtual bool storesValueSeparateFromAttribute();
    229229    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior);
    230     virtual void dispatchChangeEventInResponseToSetValue();
    231230    virtual bool shouldResetOnDocumentActivation();
    232231    virtual bool shouldRespectListAttribute();
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r107706 r108051  
    8181void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
    8282{
    83     InputType::setValue(sanitizedValue, valueChanged, eventBehavior);
     83    // We don't ask InputType::setValue to dispatch events because
     84    // TextFieldInputType dispatches events different way from InputType.
     85    InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent);
    8486
    8587    if (valueChanged)
     
    9193    else
    9294        element()->cacheSelectionInResponseToSetValue(max);
    93 }
    94 
    95 void TextFieldInputType::dispatchChangeEventInResponseToSetValue()
    96 {
    97     // If the user is still editing this field, dispatch an input event rather than a change event.
    98     // The change event will be dispatched when editing finishes.
    99     if (element()->focused()) {
    100         element()->dispatchFormControlInputEvent();
    101         return;
    102     }
    103     InputType::dispatchChangeEventInResponseToSetValue();
     95
     96    if (!valueChanged)
     97        return;
     98
     99    if (eventBehavior != DispatchNoEvent) {
     100        // If the user is still editing this field, dispatch an input event rather than a change event.
     101        // The change event will be dispatched when editing finishes.
     102        if (element()->focused())
     103            element()->dispatchFormControlInputEvent();
     104        else
     105            element()->dispatchFormControlChangeEvent();
     106    }
     107
     108    // FIXME: Why do we do this when eventBehavior == DispatchNoEvent
     109    if (!element()->focused() || eventBehavior == DispatchNoEvent)
     110        element()->setTextAsOfLastFormControlChangeEvent(sanitizedValue);
    104111}
    105112
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r107555 r108051  
    7575    virtual bool shouldUseInputMethod() const OVERRIDE;
    7676    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
    77     virtual void dispatchChangeEventInResponseToSetValue() OVERRIDE;
    7877    virtual String sanitizeValue(const String&) const OVERRIDE;
    7978    virtual bool shouldRespectListAttribute() OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.