void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionState& exceptionState) { int min = minLength(); if (newValue < 0) exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(newValue) + ") is not positive or 0."); else if (min >= 0 && newValue < min) exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::indexExceedsMinimumBound("maxLength", newValue, min)); else setIntegralAttribute(maxlengthAttr, newValue); }
bool HTMLTextAreaElement::tooShort(const String* value, NeedsToCheckDirtyFlag check) const { // Return false for the default value or value set by script even if it is // shorter than minLength. if (check == CheckDirtyFlag && !lastChangeWasUserEdit()) return false; int min = minLength(); if (min <= 0) return false; // An empty string is excluded from minlength check. unsigned len = computeLengthForSubmission(value ? *value : this->value()); return len > 0 && len < static_cast<unsigned>(min); }
SRecord::SRecord(const char *line, const unsigned int length) { if (length < minLength()) { throw PoaException(tr("Record is too short")); } if (line[0] == 'S' && line[1] == '1') { type_ = S1; } else { throw PoaException(tr("Invalid type")); } bool ok; count_ = QString::fromLatin1(&line[2], 2).toUInt(&ok, 16); if (!ok || count_ < 3 || count_ * 2 > length - 4) { throw PoaException(tr("Invalid count")); } address_ = QString::fromLatin1(&line[4], 4).toUInt(&ok, 16); if (!ok) { throw PoaException(tr("Invalid address")); } if (count_ > 3) { data_ = new unsigned char[count_ - 3]; for (unsigned int i = 0; i < count_ - 3; i++) { data_[i] = QString::fromLatin1(&line[8 + i * 2], 2).toUInt(&ok, 16); if (!ok) { throw PoaException(tr("Invalid data")); } } } else { data_ = 0; } checksum_ = QString::fromLatin1(&line[4 + count_ * 2 - 2], 2).toUInt(&ok, 16); if (!ok) { throw PoaException(tr("Invalid checksum")); } }
String HTMLTextAreaElement::validationMessage() const { if (!willValidate()) return String(); if (customError()) return customValidationMessage(); if (valueMissing()) return locale().queryString(WebLocalizedString::ValidationValueMissing); if (tooLong()) return locale().validationMessageTooLongText(value().length(), maxLength()); if (tooShort()) return locale().validationMessageTooShortText(value().length(), minLength()); return String(); }