OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 7 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 return locale().queryString(blink::WebLocalizedString::ValidationValueMi
ssing); | 483 return locale().queryString(blink::WebLocalizedString::ValidationValueMi
ssing); |
484 | 484 |
485 if (tooLong()) | 485 if (tooLong()) |
486 return locale().validationMessageTooLongText(computeLengthForSubmission(
value()), maxLength()); | 486 return locale().validationMessageTooLongText(computeLengthForSubmission(
value()), maxLength()); |
487 | 487 |
488 return String(); | 488 return String(); |
489 } | 489 } |
490 | 490 |
491 bool HTMLTextAreaElement::valueMissing() const | 491 bool HTMLTextAreaElement::valueMissing() const |
492 { | 492 { |
493 return willValidate() && valueMissing(value()); | 493 // We should not call value() for performance. |
| 494 return willValidate() && valueMissing(0); |
| 495 } |
| 496 |
| 497 bool HTMLTextAreaElement::valueMissing(const String* value) const |
| 498 { |
| 499 return isRequiredFormControl() && !isDisabledOrReadOnly() && (value ? *value
: this->value()).isEmpty(); |
494 } | 500 } |
495 | 501 |
496 bool HTMLTextAreaElement::tooLong() const | 502 bool HTMLTextAreaElement::tooLong() const |
497 { | 503 { |
498 return willValidate() && tooLong(value(), CheckDirtyFlag); | 504 // We should not call value() for performance. |
| 505 return willValidate() && tooLong(0, CheckDirtyFlag); |
499 } | 506 } |
500 | 507 |
501 bool HTMLTextAreaElement::tooLong(const String& value, NeedsToCheckDirtyFlag che
ck) const | 508 bool HTMLTextAreaElement::tooLong(const String* value, NeedsToCheckDirtyFlag che
ck) const |
502 { | 509 { |
503 // Return false for the default value or value set by script even if it is | 510 // Return false for the default value or value set by script even if it is |
504 // longer than maxLength. | 511 // longer than maxLength. |
505 if (check == CheckDirtyFlag && !lastChangeWasUserEdit()) | 512 if (check == CheckDirtyFlag && !lastChangeWasUserEdit()) |
506 return false; | 513 return false; |
507 | 514 |
508 int max = maxLength(); | 515 int max = maxLength(); |
509 if (max < 0) | 516 if (max < 0) |
510 return false; | 517 return false; |
511 return computeLengthForSubmission(value) > static_cast<unsigned>(max); | 518 return computeLengthForSubmission(value ? *value : this->value()) > static_c
ast<unsigned>(max); |
512 } | 519 } |
513 | 520 |
514 bool HTMLTextAreaElement::isValidValue(const String& candidate) const | 521 bool HTMLTextAreaElement::isValidValue(const String& candidate) const |
515 { | 522 { |
516 return !valueMissing(candidate) && !tooLong(candidate, IgnoreDirtyFlag); | 523 return !valueMissing(&candidate) && !tooLong(&candidate, IgnoreDirtyFlag); |
517 } | 524 } |
518 | 525 |
519 void HTMLTextAreaElement::accessKeyAction(bool) | 526 void HTMLTextAreaElement::accessKeyAction(bool) |
520 { | 527 { |
521 focus(); | 528 focus(); |
522 } | 529 } |
523 | 530 |
524 void HTMLTextAreaElement::setCols(int cols) | 531 void HTMLTextAreaElement::setCols(int cols) |
525 { | 532 { |
526 setIntegralAttribute(colsAttr, cols); | 533 setIntegralAttribute(colsAttr, cols); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 { | 571 { |
565 return true; | 572 return true; |
566 } | 573 } |
567 | 574 |
568 bool HTMLTextAreaElement::supportsAutofocus() const | 575 bool HTMLTextAreaElement::supportsAutofocus() const |
569 { | 576 { |
570 return true; | 577 return true; |
571 } | 578 } |
572 | 579 |
573 } | 580 } |
OLD | NEW |