Bug 59975 - ValidityState::valid causes value sanitization 7 times
Summary: ValidityState::valid causes value sanitization 7 times
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-02 16:26 PDT by Joseph Pecoraro
Modified: 2023-06-07 01:57 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2011-05-02 16:26:48 PDT
I noticed this while working on value sanitization for date inputs.
This could be a performance issue, because sanitization requires
parsing the input to see if it is valid.

    bool ValidityState::valid() const
    {
        bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()
            || tooLong() || patternMismatch() || valueMissing() || customError();
        return !someError;
    }

It seems like this could really benefit from caching, or a better
design that allows for getting the sanitized value once, and running
the different validity tests on the pre-calculated value.
Comment 1 Ahmad Saleem 2023-06-07 01:57:11 PDT
We still have similar function but different name:

https://searchfox.org/wubkat/source/Source/WebCore/html/FormListedElement.cpp#244


bool FormListedElement::computeValidity() const
{
    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()
        || tooShort() || tooLong() || patternMismatch() || valueMissing() || hasBadInput() || customError();
    return !someError;
}

https://searchfox.org/wubkat/source/Source/WebCore/html/HTMLInputElement.cpp#344

bool HTMLInputElement::computeValidity() const
{
    String value = this->value();
    bool someError = m_inputType->isInvalid(value) || tooShort(value, CheckDirtyFlag) || tooLong(value, CheckDirtyFlag) || customError();
    return !someError;
}