Changeset 67166 in webkit


Ignore:
Timestamp:
Sep 9, 2010 10:06:45 PM (14 years ago)
Author:
tkent@chromium.org
Message:

2010-09-09 Kent Tamura <tkent@chromium.org>

Reviewed by Dimitri Glazkov.

Apply :invalid CSS class to <input type=number> with an unacceptable value
https://bugs.webkit.org/show_bug.cgi?id=45376

  • fast/forms/input-number-unacceptable-style-expected.txt: Added.
  • fast/forms/input-number-unacceptable-style.html: Added.

2010-09-09 Kent Tamura <tkent@chromium.org>

Reviewed by Dimitri Glazkov.

Apply :invalid CSS class to <input type=number> with an unacceptable value
https://bugs.webkit.org/show_bug.cgi?id=45376

Apply :invalid CSS class to <input type=number> elements with an
unacceptable value in order to tell users that a value is not
valid.

Introducing Element::hasUnaccceptableValue(), and CSSStyleSelector
applies :invalid to not only elements with !isValidFormControlElement()
but also elements with hasUnaccceptableValue().

HTMLInputElement and RenderTextControlSingleLine need some changes
to update style and to avoid updating renderer value during style
update.

Test: fast/forms/input-number-unacceptable-style.html

  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
  • dom/Element.h: (WebCore::Element::hasUnacceptableValue):
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::handleBlurEvent): (WebCore::HTMLInputElement::hasUnacceptableValue):
  • html/HTMLInputElement.h:
  • rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::subtreeHasChanged): (WebCore::RenderTextControlSingleLine::updateFromElement):
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r67164 r67166  
     12010-09-09  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Apply :invalid CSS class to <input type=number> with an unacceptable value
     6        https://bugs.webkit.org/show_bug.cgi?id=45376
     7
     8        * fast/forms/input-number-unacceptable-style-expected.txt: Added.
     9        * fast/forms/input-number-unacceptable-style.html: Added.
     10
    1112010-09-09  Kent Tamura  <tkent@chromium.org>
    212
  • trunk/WebCore/ChangeLog

    r67165 r67166  
     12010-09-09  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Apply :invalid CSS class to <input type=number> with an unacceptable value
     6        https://bugs.webkit.org/show_bug.cgi?id=45376
     7
     8        Apply :invalid CSS class to <input type=number> elements with an
     9        unacceptable value in order to tell users that a value is not
     10        valid.
     11
     12        Introducing Element::hasUnaccceptableValue(), and CSSStyleSelector
     13        applies :invalid to not only elements with !isValidFormControlElement()
     14        but also elements with hasUnaccceptableValue().
     15
     16        HTMLInputElement and RenderTextControlSingleLine need some changes
     17        to update style and to avoid updating renderer value during style
     18        update.
     19
     20        Test: fast/forms/input-number-unacceptable-style.html
     21
     22        * css/CSSStyleSelector.cpp:
     23        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
     24        * dom/Element.h:
     25        (WebCore::Element::hasUnacceptableValue):
     26        * html/HTMLInputElement.cpp:
     27        (WebCore::HTMLInputElement::handleBlurEvent):
     28        (WebCore::HTMLInputElement::hasUnacceptableValue):
     29        * html/HTMLInputElement.h:
     30        * rendering/RenderTextControlSingleLine.cpp:
     31        (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
     32        (WebCore::RenderTextControlSingleLine::updateFromElement):
     33
    1342010-09-09  Kent Tamura  <tkent@chromium.org>
    235
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r67102 r67166  
    25772577                    return false;
    25782578                e->document()->setContainsValidityStyleRules();
    2579                 return e->willValidate() && !e->isValidFormControlElement();
     2579                return e->willValidate() && !e->isValidFormControlElement() || e->hasUnacceptableValue();
    25802580            } case CSSSelector::PseudoChecked: {
    25812581                if (!e || !e->isFormControlElement())
  • trunk/WebCore/dom/Element.h

    r66954 r67166  
    283283    virtual bool willValidate() const { return false; }
    284284    virtual bool isValidFormControlElement() { return false; }
     285    virtual bool hasUnacceptableValue() const { return false; }
    285286
    286287    virtual bool formControlValueMatchesRenderer() const { return false; }
  • trunk/WebCore/html/HTMLInputElement.cpp

    r67164 r67166  
    829829void HTMLInputElement::handleBlurEvent()
    830830{
    831     // Reset the renderer value, which might be unmatched with the element value.
    832     setFormControlValueMatchesRenderer(false);
     831    if (inputType() == NUMBER) {
     832        // Reset the renderer value, which might be unmatched with the element value.
     833        setFormControlValueMatchesRenderer(false);
     834        // We need to reset the renderer value explicitly because an unacceptable
     835        // renderer value should be purged before style calculation.
     836        if (renderer())
     837            renderer()->updateFromElement();
     838    }
    833839    InputElement::dispatchBlurEvent(this, this);
    834840}
     
    26922698}
    26932699
     2700bool HTMLInputElement::hasUnacceptableValue() const
     2701{
     2702    return inputType() == NUMBER && renderer() && !isAcceptableValue(toRenderTextControl(renderer())->text());
     2703}
     2704
    26942705bool HTMLInputElement::needsActivationCallback()
    26952706{
  • trunk/WebCore/html/HTMLInputElement.h

    r67164 r67166  
    284284    virtual bool isAcceptableValue(const String&) const;
    285285    virtual String sanitizeValue(const String&) const;
     286    virtual bool hasUnacceptableValue() const;
    286287
    287288    virtual void documentDidBecomeActive();
  • trunk/WebCore/rendering/RenderTextControlSingleLine.cpp

    r67164 r67166  
    174174    if (input->isAcceptableValue(value))
    175175        input->setValueFromRenderer(input->sanitizeValue(value));
     176    if (node()->isHTMLElement()) {
     177        // Recalc for :invalid and hasUnacceptableValue() change.
     178        static_cast<HTMLInputElement*>(input)->setNeedsStyleRecalc();
     179    }
    176180
    177181    if (m_cancelButton)
     
    680684        if (!inputElement()->suggestedValue().isNull())
    681685            setInnerTextValue(inputElement()->suggestedValue());
    682         else
     686        else if (!node()->isHTMLElement() || !static_cast<HTMLInputElement*>(node())->formControlValueMatchesRenderer())
     687            // For HTMLInputElement, update the renderer value only if the
     688            // formControlValueMatchesRenderer() flag is false. It protects an
     689            // unacceptable renderer value from being overwritten with the DOM value.
    683690            setInnerTextValue(inputElement()->value());
    684691    }
Note: See TracChangeset for help on using the changeset viewer.