Changeset 116756 in webkit
- Timestamp:
- May 11, 2012 5:56:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r116755 r116756 1 2012-05-11 Sheriff Bot <webkit.review.bot@gmail.com> 2 3 Unreviewed, rolling out r116752. 4 http://trac.webkit.org/changeset/116752 5 https://bugs.webkit.org/show_bug.cgi?id=86201 6 7 Build failure on Chromium-mac (Requested by tkent on #webkit). 8 9 * html/FormAssociatedElement.cpp: 10 * html/FormAssociatedElement.h: 11 (FormAssociatedElement): 12 * html/HTMLFormControlElement.cpp: 13 (WebCore::HTMLFormControlElement::setCustomValidity): 14 * html/HTMLFormControlElement.h: 15 (HTMLFormControlElement): 16 * html/HTMLInputElement.cpp: 17 (WebCore::HTMLInputElement::isValidValue): 18 (WebCore::HTMLInputElement::typeMismatch): 19 (WebCore::HTMLInputElement::valueMissing): 20 (WebCore::HTMLInputElement::patternMismatch): 21 (WebCore::HTMLInputElement::rangeUnderflow): 22 (WebCore::HTMLInputElement::rangeOverflow): 23 (WebCore::HTMLInputElement::minimum): 24 (WebCore::HTMLInputElement::maximum): 25 (WebCore::HTMLInputElement::stepMismatch): 26 (WebCore::HTMLInputElement::minimumString): 27 (WebCore::HTMLInputElement::maximumString): 28 (WebCore): 29 (WebCore::HTMLInputElement::stepBaseString): 30 (WebCore::HTMLInputElement::stepString): 31 (WebCore::HTMLInputElement::typeMismatchText): 32 (WebCore::HTMLInputElement::valueMissingText): 33 (WebCore::HTMLInputElement::isInRange): 34 (WebCore::HTMLInputElement::isOutOfRange): 35 * html/HTMLInputElement.h: 36 (HTMLInputElement): 37 * html/HTMLObjectElement.h: 38 (WebCore::HTMLObjectElement::setCustomValidity): 39 * html/HTMLSelectElement.cpp: 40 (WebCore::HTMLSelectElement::valueMissing): 41 * html/HTMLSelectElement.h: 42 (HTMLSelectElement): 43 * html/HTMLTextAreaElement.cpp: 44 * html/HTMLTextAreaElement.h: 45 (WebCore::HTMLTextAreaElement::valueMissing): 46 (HTMLTextAreaElement): 47 * html/InputType.cpp: 48 (WebCore::InputType::alignValueForStep): 49 (WebCore::InputType::stepUpFromRenderer): 50 * html/InputType.h: 51 (InputType): 52 * html/ValidityState.cpp: 53 (WebCore::ValidityState::validationMessage): 54 (WebCore): 55 (WebCore::ValidityState::setCustomErrorMessage): 56 (WebCore::ValidityState::valueMissing): 57 (WebCore::ValidityState::typeMismatch): 58 (WebCore::ValidityState::patternMismatch): 59 (WebCore::ValidityState::tooLong): 60 (WebCore::ValidityState::rangeUnderflow): 61 (WebCore::ValidityState::rangeOverflow): 62 (WebCore::ValidityState::stepMismatch): 63 (WebCore::ValidityState::customError): 64 (WebCore::ValidityState::valid): 65 * html/ValidityState.h: 66 (ValidityState): 67 1 68 2012-05-11 Alexander Pavlov <apavlov@chromium.org> 2 69 -
trunk/Source/WebCore/html/FormAssociatedElement.cpp
r116752 r116756 158 158 } 159 159 160 bool FormAssociatedElement::customError() const161 {162 const HTMLElement* element = toHTMLElement(this);163 return element->willValidate() && !m_customValidationMessage.isEmpty();164 }165 166 bool FormAssociatedElement::patternMismatch() const167 {168 return false;169 }170 171 bool FormAssociatedElement::rangeOverflow() const172 {173 return false;174 }175 176 bool FormAssociatedElement::rangeUnderflow() const177 {178 return false;179 }180 181 bool FormAssociatedElement::stepMismatch() const182 {183 return false;184 }185 186 bool FormAssociatedElement::tooLong() const187 {188 return false;189 }190 191 bool FormAssociatedElement::typeMismatch() const192 {193 return false;194 }195 196 bool FormAssociatedElement::valid() const197 {198 bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow()199 || tooLong() || patternMismatch() || valueMissing() || customError();200 return !someError;201 }202 203 bool FormAssociatedElement::valueMissing() const204 {205 return false;206 }207 208 String FormAssociatedElement::customValidationMessage() const209 {210 return m_customValidationMessage;211 }212 213 String FormAssociatedElement::validationMessage() const214 {215 return customError() ? m_customValidationMessage : String();216 }217 218 void FormAssociatedElement::setCustomValidity(const String& error)219 {220 m_customValidationMessage = error;221 }222 223 160 const HTMLElement* toHTMLElement(const FormAssociatedElement* associatedElement) 224 161 { -
trunk/Source/WebCore/html/FormAssociatedElement.h
r116752 r116756 61 61 void formRemovedFromTree(const Node* formRoot); 62 62 63 // ValidityState attribute implementations64 bool customError() const;65 66 // Override functions for patterMismatch, rangeOverflow, rangerUnderflow,67 // stepMismatch, tooLong and valueMissing must call willValidate method.68 virtual bool patternMismatch() const;69 virtual bool rangeOverflow() const;70 virtual bool rangeUnderflow() const;71 virtual bool stepMismatch() const;72 virtual bool tooLong() const;73 virtual bool typeMismatch() const;74 virtual bool valueMissing() const;75 virtual String validationMessage() const;76 bool valid() const;77 virtual void setCustomValidity(const String&);78 79 63 protected: 80 64 FormAssociatedElement(); … … 93 77 virtual void didChangeForm(); 94 78 95 String customValidationMessage() const;96 97 79 private: 98 80 virtual const AtomicString& formControlName() const = 0; … … 103 85 HTMLFormElement* m_form; 104 86 OwnPtr<ValidityState> m_validityState; 105 String m_customValidationMessage;106 87 }; 107 88 -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r116752 r116756 485 485 void HTMLFormControlElement::setCustomValidity(const String& error) 486 486 { 487 FormAssociatedElement::setCustomValidity(error); 488 setNeedsValidityCheck(); 487 validity()->setCustomErrorMessage(error); 489 488 } 490 489 -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r116752 r116756 102 102 // This must be called when a validation constraint or control value is changed. 103 103 void setNeedsValidityCheck(); 104 v irtual void setCustomValidity(const String&) OVERRIDE;104 void setCustomValidity(const String&); 105 105 106 106 bool readOnly() const { return m_readOnly; } -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r116752 r116756 192 192 } 193 193 return !m_inputType->typeMismatchFor(value) 194 && ! m_inputType->stepMismatch(value)195 && ! m_inputType->rangeUnderflow(value)196 && ! m_inputType->rangeOverflow(value)194 && !stepMismatch(value) 195 && !rangeUnderflow(value) 196 && !rangeOverflow(value) 197 197 && !tooLong(value, IgnoreDirtyFlag) 198 && !m_inputType->patternMismatch(value) 199 && !m_inputType->valueMissing(value); 200 } 201 202 bool HTMLInputElement::tooLong() const 203 { 204 return willValidate() && tooLong(value(), CheckDirtyFlag); 198 && !patternMismatch(value) 199 && !valueMissing(value); 205 200 } 206 201 207 202 bool HTMLInputElement::typeMismatch() const 208 203 { 209 return willValidate() &&m_inputType->typeMismatch();210 } 211 212 bool HTMLInputElement::valueMissing( ) const213 { 214 return willValidate() && m_inputType->valueMissing(value());215 } 216 217 bool HTMLInputElement::patternMismatch( ) const218 { 219 return willValidate() && m_inputType->patternMismatch(value());204 return m_inputType->typeMismatch(); 205 } 206 207 bool HTMLInputElement::valueMissing(const String& value) const 208 { 209 return m_inputType->valueMissing(value); 210 } 211 212 bool HTMLInputElement::patternMismatch(const String& value) const 213 { 214 return m_inputType->patternMismatch(value); 220 215 } 221 216 … … 238 233 } 239 234 240 bool HTMLInputElement::rangeUnderflow() const 241 { 242 return willValidate() && m_inputType->rangeUnderflow(value()); 243 } 244 245 bool HTMLInputElement::rangeOverflow() const 246 { 247 return willValidate() && m_inputType->rangeOverflow(value()); 248 } 249 250 String HTMLInputElement::validationMessage() const 251 { 252 if (!willValidate()) 235 bool HTMLInputElement::rangeUnderflow(const String& value) const 236 { 237 return m_inputType->rangeUnderflow(value); 238 } 239 240 bool HTMLInputElement::rangeOverflow(const String& value) const 241 { 242 return m_inputType->rangeOverflow(value); 243 } 244 245 double HTMLInputElement::minimum() const 246 { 247 return m_inputType->minimum(); 248 } 249 250 double HTMLInputElement::maximum() const 251 { 252 return m_inputType->maximum(); 253 } 254 255 bool HTMLInputElement::stepMismatch(const String& value) const 256 { 257 double step; 258 if (!getAllowedValueStep(&step)) 259 return false; 260 return m_inputType->stepMismatch(value, step); 261 } 262 263 String HTMLInputElement::minimumString() const 264 { 265 return m_inputType->serialize(minimum()); 266 } 267 268 String HTMLInputElement::maximumString() const 269 { 270 return m_inputType->serialize(maximum()); 271 } 272 273 String HTMLInputElement::stepBaseString() const 274 { 275 return m_inputType->serialize(m_inputType->stepBase()); 276 } 277 278 String HTMLInputElement::stepString() const 279 { 280 double step; 281 if (!getAllowedValueStep(&step)) { 282 // stepString() should be called only if stepMismatch() can be true. 283 ASSERT_NOT_REACHED(); 253 284 return String(); 254 255 if (customError()) 256 return customValidationMessage(); 257 258 return m_inputType->validationMessage(); 259 } 260 261 double HTMLInputElement::minimum() const 262 { 263 return m_inputType->minimum(); 264 } 265 266 double HTMLInputElement::maximum() const 267 { 268 return m_inputType->maximum(); 269 } 270 271 bool HTMLInputElement::stepMismatch() const 272 { 273 return willValidate() && m_inputType->stepMismatch(value()); 285 } 286 return serializeForNumberType(step / m_inputType->stepScaleFactor()); 287 } 288 289 String HTMLInputElement::typeMismatchText() const 290 { 291 return m_inputType->typeMismatchText(); 292 } 293 294 String HTMLInputElement::valueMissingText() const 295 { 296 return m_inputType->valueMissingText(); 274 297 } 275 298 … … 1253 1276 bool HTMLInputElement::isInRange() const 1254 1277 { 1255 return m_inputType->supportsRangeLimitation() && ! m_inputType->rangeUnderflow(value()) && !m_inputType->rangeOverflow(value());1278 return m_inputType->supportsRangeLimitation() && !rangeUnderflow(value()) && !rangeOverflow(value()); 1256 1279 } 1257 1280 1258 1281 bool HTMLInputElement::isOutOfRange() const 1259 1282 { 1260 return m_inputType->supportsRangeLimitation() && ( m_inputType->rangeUnderflow(value()) || m_inputType->rangeOverflow(value()));1283 return m_inputType->supportsRangeLimitation() && (rangeUnderflow(value()) || rangeOverflow(value())); 1261 1284 } 1262 1285 -
trunk/Source/WebCore/html/HTMLInputElement.h
r116752 r116756 49 49 50 50 // For ValidityState 51 virtual bool patternMismatch() const OVERRIDE; 52 virtual bool rangeUnderflow() const OVERRIDE; 53 virtual bool rangeOverflow() const; 54 virtual bool stepMismatch() const OVERRIDE; 55 virtual bool tooLong() const OVERRIDE; 56 virtual bool typeMismatch() const OVERRIDE; 57 virtual bool valueMissing() const OVERRIDE; 58 virtual String validationMessage() const OVERRIDE; 59 51 bool typeMismatch() const; 52 // valueMissing() ignores the specified string value for CHECKBOX and RADIO. 53 bool valueMissing(const String&) const; 54 bool patternMismatch(const String&) const; 55 bool tooLong(const String&, NeedsToCheckDirtyFlag) const; 56 bool rangeUnderflow(const String&) const; 57 bool rangeOverflow(const String&) const; 60 58 // Returns the minimum value for type=date, number, or range. Don't call this for other types. 61 59 double minimum() const; … … 66 64 // Returns false if there is no "allowed value step." 67 65 bool getAllowedValueStep(double*) const; 66 67 // For ValidityState. 68 bool stepMismatch(const String&) const; 69 String minimumString() const; 70 String maximumString() const; 71 String stepBaseString() const; 72 String stepString() const; 73 String typeMismatchText() const; 74 String valueMissingText() const; 68 75 69 76 // Implementations of HTMLInputElement::stepUp() and stepDown(). … … 319 326 bool supportsMaxLength() const { return isTextType(); } 320 327 bool isTextType() const; 321 bool tooLong(const String&, NeedsToCheckDirtyFlag) const;322 328 323 329 virtual bool supportsPlaceholder() const; -
trunk/Source/WebCore/html/HTMLObjectElement.h
r116752 r116756 57 57 String validationMessage() { return String(); } 58 58 bool checkValidity() { return true; } 59 v irtual void setCustomValidity(const String&) OVERRIDE{ }59 void setCustomValidity(const String&) { } 60 60 61 61 using TreeShared<ContainerNode>::ref; -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r116752 r116756 42 42 #include "HTMLOptionsCollection.h" 43 43 #include "KeyboardEvent.h" 44 #include "LocalizedStrings.h"45 44 #include "MouseEvent.h" 46 45 #include "NodeRenderingContext.h" … … 147 146 } 148 147 149 String HTMLSelectElement::validationMessage() const150 {151 if (!willValidate())152 return String();153 154 if (customError())155 return customValidationMessage();156 157 return valueMissing() ? validationMessageValueMissingForSelectText() : String();158 }159 160 148 bool HTMLSelectElement::valueMissing() const 161 149 { 162 if (!willValidate())163 return false;164 165 150 if (!isRequiredFormControl()) 166 151 return false; -
trunk/Source/WebCore/html/HTMLSelectElement.h
r116752 r116756 47 47 48 48 // For ValidityState 49 virtual String validationMessage() const OVERRIDE; 50 virtual bool valueMissing() const OVERRIDE; 49 bool valueMissing() const; 51 50 52 51 unsigned length() const; -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r116752 r116756 38 38 #include "Frame.h" 39 39 #include "HTMLNames.h" 40 #include "LocalizedStrings.h"41 40 #include "RenderTextControlMultiLine.h" 42 41 #include "ShadowRoot.h" … … 425 424 } 426 425 427 String HTMLTextAreaElement::validationMessage() const428 {429 if (!willValidate())430 return String();431 432 if (customError())433 return customValidationMessage();434 435 if (valueMissing())436 return validationMessageValueMissingText();437 438 if (tooLong())439 return validationMessageTooLongText(numGraphemeClusters(value()), maxLength());440 441 return String();442 }443 444 bool HTMLTextAreaElement::valueMissing() const445 {446 return willValidate() && valueMissing(value());447 }448 449 bool HTMLTextAreaElement::tooLong() const450 {451 return willValidate() && tooLong(value(), CheckDirtyFlag);452 }453 454 426 bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag check) const 455 427 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r116752 r116756 48 48 virtual int maxLength() const; 49 49 void setMaxLength(int, ExceptionCode&); 50 // For ValidityState 51 virtual String validationMessage() const OVERRIDE; 52 virtual bool valueMissing() const OVERRIDE; 53 virtual bool tooLong() const OVERRIDE; 50 bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); } 51 bool tooLong(const String&, NeedsToCheckDirtyFlag) const; 54 52 bool isValidValue(const String&) const; 55 53 … … 111 109 virtual bool shouldUseInputMethod(); 112 110 113 bool valueMissing(const String& value) const { return isRequiredFormControl() && !disabled() && !readOnly() && value.isEmpty(); }114 bool tooLong(const String&, NeedsToCheckDirtyFlag) const;115 116 111 int m_rows; 117 112 int m_cols; -
trunk/Source/WebCore/html/InputType.cpp
r116752 r116756 284 284 } 285 285 286 bool InputType::stepMismatch(const String& value) const287 {288 double step;289 if (!getAllowedValueStep(&step))290 return false;291 return stepMismatch(value, step);292 }293 294 286 bool InputType::stepMismatch(const String&, double) const 295 287 { … … 345 337 { 346 338 return validationMessageValueMissingText(); 347 }348 349 String InputType::validationMessage() const350 {351 const String value = element()->value();352 353 // The order of the following checks is meaningful. e.g. We'd like to show the354 // valueMissing message even if the control has other validation errors.355 if (valueMissing(value))356 return valueMissingText();357 358 if (typeMismatch())359 return typeMismatchText();360 361 if (patternMismatch(value))362 return validationMessagePatternMismatchText();363 364 if (element()->tooLong())365 return validationMessageTooLongText(numGraphemeClusters(value), element()->maxLength());366 367 if (rangeUnderflow(value))368 return validationMessageRangeUnderflowText(serialize(minimum()));369 370 if (rangeOverflow(value))371 return validationMessageRangeOverflowText(serialize(maximum()));372 373 if (stepMismatch(value)) {374 String stepString;375 double step;376 if (getAllowedValueStep(&step))377 stepString = serializeForNumberType(step / stepScaleFactor());378 return validationMessageStepMismatchText(serialize(stepBase()), stepString);379 }380 381 return String();382 339 } 383 340 … … 914 871 double base = stepBaseWithDecimalPlaces(&baseDecimalPlaces); 915 872 baseDecimalPlaces = min(baseDecimalPlaces, 16u); 916 if ( stepMismatch(element()->value())) {873 if (element()->stepMismatch(element()->value())) { 917 874 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, currentDecimalPlaces))); 918 875 newValue = round(newValue * scale) / scale; … … 1067 1024 else { 1068 1025 ExceptionCode ec; 1069 if ( stepMismatch(element()->value())) {1026 if (element()->stepMismatch(element()->value())) { 1070 1027 ASSERT(step); 1071 1028 double newValue; -
trunk/Source/WebCore/html/InputType.h
r116752 r116756 141 141 142 142 // Validation functions 143 virtual String validationMessage() const; 143 144 144 virtual bool supportsValidation() const; 145 145 virtual bool typeMismatchFor(const String&) const; … … 158 158 virtual double maximum() const; 159 159 virtual bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const; 160 bool stepMismatch(const String&) const;161 160 virtual bool stepMismatch(const String&, double step) const; 162 161 virtual double stepBase() const; -
trunk/Source/WebCore/html/ValidityState.cpp
r116752 r116756 39 39 String ValidityState::validationMessage() const 40 40 { 41 return m_control->validationMessage(); 41 if (!toHTMLElement(m_control)->willValidate()) 42 return String(); 43 44 if (customError()) 45 return m_customErrorMessage; 46 HTMLElement* element = toHTMLElement(m_control); 47 bool isInputElement = element->isFormControlElement() && element->hasTagName(inputTag); 48 bool isTextAreaElement = element->isFormControlElement() && element->hasTagName(textareaTag); 49 // The order of the following checks is meaningful. e.g. We'd like to show the 50 // valueMissing message even if the control has other validation errors. 51 if (valueMissing()) { 52 if (element->hasTagName(selectTag)) 53 return validationMessageValueMissingForSelectText(); 54 if (isInputElement) 55 return static_cast<HTMLInputElement*>(element)->valueMissingText(); 56 return validationMessageValueMissingText(); 57 } 58 if (typeMismatch()) { 59 if (isInputElement) 60 return static_cast<HTMLInputElement*>(element)->typeMismatchText(); 61 return validationMessageTypeMismatchText(); 62 } 63 if (patternMismatch()) 64 return validationMessagePatternMismatchText(); 65 if (tooLong()) { 66 if (!isInputElement && !isTextAreaElement) { 67 ASSERT_NOT_REACHED(); 68 return String(); 69 } 70 HTMLTextFormControlElement* text = static_cast<HTMLTextFormControlElement*>(element); 71 return validationMessageTooLongText(numGraphemeClusters(text->value()), text->maxLength()); 72 } 73 if (rangeUnderflow()) { 74 if (!isInputElement) { 75 ASSERT_NOT_REACHED(); 76 return String(); 77 } 78 return validationMessageRangeUnderflowText(static_cast<HTMLInputElement*>(element)->minimumString()); 79 } 80 if (rangeOverflow()) { 81 if (!isInputElement) { 82 ASSERT_NOT_REACHED(); 83 return String(); 84 } 85 return validationMessageRangeOverflowText(static_cast<HTMLInputElement*>(element)->maximumString()); 86 } 87 if (stepMismatch()) { 88 if (!isInputElement) { 89 ASSERT_NOT_REACHED(); 90 return String(); 91 } 92 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 93 return validationMessageStepMismatchText(input->stepBaseString(), input->stepString()); 94 } 95 96 return String(); 97 } 98 99 void ValidityState::setCustomErrorMessage(const String& message) 100 { 101 m_customErrorMessage = message; 102 if (m_control->isFormControlElement()) 103 static_cast<HTMLFormControlElement*>(m_control)->setNeedsValidityCheck(); 42 104 } 43 105 44 106 bool ValidityState::valueMissing() const 45 107 { 46 return m_control->valueMissing(); 108 HTMLElement* element = toHTMLElement(m_control); 109 if (!element->willValidate()) 110 return false; 111 112 if (element->hasTagName(inputTag)) { 113 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 114 return input->valueMissing(input->value()); 115 } 116 if (element->hasTagName(textareaTag)) { 117 HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(element); 118 return textArea->valueMissing(textArea->value()); 119 } 120 if (element->hasTagName(selectTag)) 121 return toHTMLSelectElement(element)->valueMissing(); 122 return false; 47 123 } 48 124 49 125 bool ValidityState::typeMismatch() const 50 126 { 51 return m_control->typeMismatch(); 127 HTMLElement* element = toHTMLElement(m_control); 128 if (!element->willValidate()) 129 return false; 130 131 if (!element->hasTagName(inputTag)) 132 return false; 133 return static_cast<HTMLInputElement*>(element)->typeMismatch(); 52 134 } 53 135 54 136 bool ValidityState::patternMismatch() const 55 137 { 56 return m_control->patternMismatch(); 138 HTMLElement* element = toHTMLElement(m_control); 139 if (!element->willValidate()) 140 return false; 141 142 if (!element->hasTagName(inputTag)) 143 return false; 144 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 145 return input->patternMismatch(input->value()); 57 146 } 58 147 59 148 bool ValidityState::tooLong() const 60 149 { 61 return m_control->tooLong(); 150 HTMLElement* element = toHTMLElement(m_control); 151 if (!element->willValidate()) 152 return false; 153 154 if (element->hasTagName(inputTag)) { 155 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 156 return input->tooLong(input->value(), HTMLTextFormControlElement::CheckDirtyFlag); 157 } 158 if (element->hasTagName(textareaTag)) { 159 HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(element); 160 return textArea->tooLong(textArea->value(), HTMLTextFormControlElement::CheckDirtyFlag); 161 } 162 return false; 62 163 } 63 164 64 165 bool ValidityState::rangeUnderflow() const 65 166 { 66 return m_control->rangeUnderflow(); 167 HTMLElement* element = toHTMLElement(m_control); 168 if (!element->willValidate()) 169 return false; 170 171 if (!element->hasTagName(inputTag)) 172 return false; 173 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 174 return input->rangeUnderflow(input->value()); 67 175 } 68 176 69 177 bool ValidityState::rangeOverflow() const 70 178 { 71 return m_control->rangeOverflow(); 179 HTMLElement* element = toHTMLElement(m_control); 180 if (!element->willValidate()) 181 return false; 182 183 if (!element->hasTagName(inputTag)) 184 return false; 185 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 186 return input->rangeOverflow(input->value()); 72 187 } 73 188 74 189 bool ValidityState::stepMismatch() const 75 190 { 76 return m_control->stepMismatch(); 191 HTMLElement* element = toHTMLElement(m_control); 192 if (!element->willValidate()) 193 return false; 194 195 if (!element->hasTagName(inputTag)) 196 return false; 197 HTMLInputElement* input = static_cast<HTMLInputElement*>(element); 198 return input->stepMismatch(input->value()); 77 199 } 78 200 79 201 bool ValidityState::customError() const 80 202 { 81 return m_control->customError(); 203 HTMLElement* element = toHTMLElement(m_control); 204 return element->willValidate() && !m_customErrorMessage.isEmpty(); 82 205 } 83 206 84 207 bool ValidityState::valid() const 85 208 { 86 return m_control->valid(); 209 bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() 210 || tooLong() || patternMismatch() || valueMissing() || customError(); 211 return !someError; 87 212 } 88 213 -
trunk/Source/WebCore/html/ValidityState.h
r116752 r116756 58 58 ValidityState(FormAssociatedElement* control) : m_control(control) { } 59 59 60 static bool isValidColorString(const String&); 61 static bool isValidEmailAddress(const String&); 62 60 63 FormAssociatedElement* m_control; 64 String m_customErrorMessage; 61 65 }; 62 66
Note: See TracChangeset
for help on using the changeset viewer.