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.
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; }
<rdar://problem/130825308>