⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 91353 in webkit


Ignore:
Timestamp:
Jul 20, 2011, 3:23:42 AM (15 years ago)
Author:
commit-queue@webkit.org
Message:

The value of a number input form continues to increase/decrease even if we disable the input form.
https://bugs.webkit.org/show_bug.cgi?id=64786

Patch by Kentaro Hara <haraken@google.com> on 2011-07-20
Reviewed by Kent Tamura.

Source/WebCore:

The value of the number input form continues to increase/decrease in the following scenario:
(1) Click the spin button of the input form.
(2) Hook the 'mouseup' event and disable the input form.
(3) Enable the input form after some delay (e.g. 50ms).

What is happening above is as follows:
(1) When the 'mousedown' event happens, the repeating timer of the spin button starts.
(2) If the input form is not disabled, the repeating timer stops at the 'mouseup' event.
However, if the input form is disabled, the 'mouseup' event is ignored, failing to stop
the repeating timer.
(3) The value continues to increase/decrease, since the repeating timer is still working.

This patch stops the repeating timer when the input form gets disabled or readonly.

Test: fast/forms/spin-button-gets-disabled-or-readonly.html

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::parseMappedAttribute): Calls disabledAttributeChanged() when 'disabled' attribute gets changed. Calls readonlyAttributeChanged() when 'readonly' attribute gets changed.

  • html/InputType.cpp:

(WebCore::InputType::disabledAttributeChanged): Stops the repeating timer and releases mouse capturing.
(WebCore::InputType::readonlyAttributeChanged): Ditto.

  • html/InputType.h:
  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::disabledAttributeChanged): Ditto.
(WebCore::TextFieldInputType::readonlyAttributeChanged): Ditto.

  • html/TextFieldInputType.h:
  • html/shadow/TextControlInnerElements.cpp:

(WebCore::SpinButtonElement::detach): Replased the code with releaseCapture().
(WebCore::SpinButtonElement::defaultEventHandler): Ditto.
(WebCore::SpinButtonElement::releaseCapture): Stops the repeating timer and releases mouse capturing.

  • html/shadow/TextControlInnerElements.h:

LayoutTests:

The value of the number input form continues to increase/decrease in the following scenario:
(1) Click the spin button of the number input form.
(2) Hook the 'mouseup' event and disable the number input form.
(3) Enable the number input form after some delay (e.g. 50ms).

What is happening above is as follows:
(1) When the 'mousedown' event happens, the repeating timer of the spin button starts.
(2) If the input form is not disabled, the repeating timer stops at the 'mouseup' event.
However, if the input form is disabled, the 'mouseup' event is ignored, failing to stop
the repeating timer.
(3) The value continues to increase/decrease, since the repeating timer is still working.

The added test checks if the value does not continue to increase/decrease when we do the above operation.

  • fast/forms/spin-button-gets-disabled-or-readonly-expected.txt: Added.
  • fast/forms/spin-button-gets-disabled-or-readonly.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r91352 r91353  
     12011-07-20  Kentaro Hara  <haraken@google.com>
     2
     3        The value of a number input form continues to increase/decrease even if we disable the input form.
     4        https://bugs.webkit.org/show_bug.cgi?id=64786
     5
     6        Reviewed by Kent Tamura.
     7
     8        The value of the number input form continues to increase/decrease in the following scenario:
     9        (1) Click the spin button of the number input form.
     10        (2) Hook the 'mouseup' event and disable the number input form.
     11        (3) Enable the number input form after some delay (e.g. 50ms).
     12
     13        What is happening above is as follows:
     14        (1) When the 'mousedown' event happens, the repeating timer of the spin button starts.
     15        (2) If the input form is not disabled, the repeating timer stops at the 'mouseup' event.
     16        However, if the input form is disabled, the 'mouseup' event is ignored, failing to stop
     17        the repeating timer.
     18        (3) The value continues to increase/decrease, since the repeating timer is still working.
     19
     20        The added test checks if the value does not continue to increase/decrease when we do the above operation.
     21
     22        * fast/forms/spin-button-gets-disabled-or-readonly-expected.txt: Added.
     23        * fast/forms/spin-button-gets-disabled-or-readonly.html: Added.
     24
    1252011-07-20  Kent Tamura  <tkent@chromium.org>
    226
  • trunk/Source/WebCore/ChangeLog

    r91349 r91353  
     12011-07-20  Kentaro Hara  <haraken@google.com>
     2
     3        The value of a number input form continues to increase/decrease even if we disable the input form.
     4        https://bugs.webkit.org/show_bug.cgi?id=64786
     5
     6        Reviewed by Kent Tamura.
     7
     8        The value of the number input form continues to increase/decrease in the following scenario:
     9        (1) Click the spin button of the input form.
     10        (2) Hook the 'mouseup' event and disable the input form.
     11        (3) Enable the input form after some delay (e.g. 50ms).
     12
     13        What is happening above is as follows:
     14        (1) When the 'mousedown' event happens, the repeating timer of the spin button starts.
     15        (2) If the input form is not disabled, the repeating timer stops at the 'mouseup' event.
     16        However, if the input form is disabled, the 'mouseup' event is ignored, failing to stop
     17        the repeating timer.
     18        (3) The value continues to increase/decrease, since the repeating timer is still working.
     19
     20        This patch stops the repeating timer when the input form gets disabled or readonly.
     21
     22        Test: fast/forms/spin-button-gets-disabled-or-readonly.html
     23
     24        * html/HTMLInputElement.cpp:
     25        (WebCore::HTMLInputElement::parseMappedAttribute): Calls disabledAttributeChanged() when 'disabled' attribute gets changed. Calls readonlyAttributeChanged() when 'readonly' attribute gets changed.
     26        * html/InputType.cpp:
     27        (WebCore::InputType::disabledAttributeChanged): Stops the repeating timer and releases mouse capturing.
     28        (WebCore::InputType::readonlyAttributeChanged): Ditto.
     29        * html/InputType.h:
     30        * html/TextFieldInputType.cpp:
     31        (WebCore::TextFieldInputType::disabledAttributeChanged): Ditto.
     32        (WebCore::TextFieldInputType::readonlyAttributeChanged): Ditto.
     33        * html/TextFieldInputType.h:
     34        * html/shadow/TextControlInnerElements.cpp:
     35        (WebCore::SpinButtonElement::detach): Replased the code with releaseCapture().
     36        (WebCore::SpinButtonElement::defaultEventHandler): Ditto.
     37        (WebCore::SpinButtonElement::releaseCapture): Stops the repeating timer and releases mouse capturing.
     38        * html/shadow/TextControlInnerElements.h:
     39
    1402011-07-20  Sheriff Bot  <webkit.review.bot@gmail.com>
    241
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r91049 r91353  
    790790    } else if (attr->name() == patternAttr || attr->name() == precisionAttr || attr->name() == stepAttr)
    791791        setNeedsValidityCheck();
     792    else if (attr->name() == disabledAttr) {
     793        m_inputType->disabledAttributeChanged();
     794        HTMLTextFormControlElement::parseMappedAttribute(attr);
     795    } else if (attr->name() == readonlyAttr) {
     796        m_inputType->readonlyAttributeChanged();
     797        HTMLTextFormControlElement::parseMappedAttribute(attr);
     798    }
    792799#if ENABLE(DATALIST)
    793800    else if (attr->name() == listAttr)
  • trunk/Source/WebCore/html/InputType.cpp

    r90971 r91353  
    674674}
    675675
     676void InputType::disabledAttributeChanged()
     677{
     678}
     679
     680void InputType::readonlyAttributeChanged()
     681{
     682}
     683
    676684namespace InputTypeNames {
    677685
  • trunk/Source/WebCore/html/InputType.h

    r90971 r91353  
    230230    virtual void updatePlaceholderText();
    231231    virtual void multipleAttributeChanged();
     232    virtual void disabledAttributeChanged();
     233    virtual void readonlyAttributeChanged();
    232234
    233235    // Parses the specified string for the type, and return
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r91014 r91353  
    239239}
    240240
     241void TextFieldInputType::disabledAttributeChanged()
     242{
     243    if (m_innerSpinButton)
     244        m_innerSpinButton->releaseCapture();
     245}
     246
     247void TextFieldInputType::readonlyAttributeChanged()
     248{
     249    if (m_innerSpinButton)
     250        m_innerSpinButton->releaseCapture();
     251}
     252
    241253bool TextFieldInputType::shouldUseInputMethod() const
    242254{
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r90971 r91353  
    3636namespace WebCore {
    3737
     38class SpinButtonElement;
     39
    3840// The class represents types of which UI contain text fields.
    3941// It supports not only the types for BaseTextInputType but also type=number.
     
    5961    virtual void createShadowSubtree();
    6062    virtual void destroyShadowSubtree();
     63    virtual void disabledAttributeChanged();
     64    virtual void readonlyAttributeChanged();
    6165
    6266private:
     
    7781    RefPtr<HTMLElement> m_innerText;
    7882    RefPtr<HTMLElement> m_placeholder;
    79     RefPtr<HTMLElement> m_innerSpinButton;
     83    RefPtr<SpinButtonElement> m_innerSpinButton;
    8084#if ENABLE(INPUT_SPEECH)
    8185    RefPtr<HTMLElement> m_speechButton;
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r90225 r91353  
    253253void SpinButtonElement::detach()
    254254{
    255     stopRepeatingTimer();
    256     if (m_capturing) {
    257         if (Frame* frame = document()->frame()) {
    258             frame->eventHandler()->setCapturingMouseEventsNode(0);
    259             m_capturing = false;
    260         }
    261     }
     255    releaseCapture();
    262256    HTMLDivElement::detach();
    263257}
     
    316310            if (m_upDownState != oldUpDownState)
    317311                renderer()->repaint();
    318         } else {
    319             if (m_capturing) {
    320                 stopRepeatingTimer();
    321                 if (Frame* frame = document()->frame()) {
    322                     frame->eventHandler()->setCapturingMouseEventsNode(0);
    323                     m_capturing = false;
    324                 }
    325             }
    326         }
     312        } else
     313            releaseCapture();
    327314    }
    328315
    329316    if (!event->defaultHandled())
    330317        HTMLDivElement::defaultEventHandler(event);
     318}
     319
     320void SpinButtonElement::releaseCapture()
     321{
     322    stopRepeatingTimer();
     323    if (m_capturing) {
     324        if (Frame* frame = document()->frame()) {
     325            frame->eventHandler()->setCapturingMouseEventsNode(0);
     326            m_capturing = false;
     327        }
     328    }
    331329}
    332330
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.h

    r90094 r91353  
    9999    static PassRefPtr<SpinButtonElement> create(Document*);
    100100    UpDownState upDownState() const { return m_upDownState; }
     101    virtual void releaseCapture();
    101102
    102103private:
Note: See TracChangeset for help on using the changeset viewer.