| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 selectionLength = computeLengthForSubmission(document().frame()->selecti
on().selectedText()); | 326 selectionLength = computeLengthForSubmission(document().frame()->selecti
on().selectedText()); |
| 327 } | 327 } |
| 328 ASSERT(currentLength >= selectionLength); | 328 ASSERT(currentLength >= selectionLength); |
| 329 unsigned baseLength = currentLength - selectionLength; | 329 unsigned baseLength = currentLength - selectionLength; |
| 330 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng
th - baseLength : 0; | 330 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng
th - baseLength : 0; |
| 331 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); | 331 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); |
| 332 } | 332 } |
| 333 | 333 |
| 334 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue,
unsigned maxLength) | 334 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue,
unsigned maxLength) |
| 335 { | 335 { |
| 336 if (maxLength > 0 && U16_IS_LEAD(proposedValue[maxLength - 1])) | 336 unsigned submissionLength = 0; |
| 337 --maxLength; | 337 unsigned i = 0; |
| 338 return proposedValue.left(maxLength); | 338 for (; i < proposedValue.length(); ++i) { |
| 339 submissionLength += proposedValue[i] == '\n' ? 2 : 1; |
| 340 if (submissionLength == maxLength) { |
| 341 ++i; |
| 342 break; |
| 343 } |
| 344 if (submissionLength > maxLength) |
| 345 break; |
| 346 } |
| 347 if (i > 0 && U16_IS_LEAD(proposedValue[i - 1])) |
| 348 --i; |
| 349 return proposedValue.left(i); |
| 339 } | 350 } |
| 340 | 351 |
| 341 void HTMLTextAreaElement::updateValue() const | 352 void HTMLTextAreaElement::updateValue() const |
| 342 { | 353 { |
| 343 if (m_valueIsUpToDate) | 354 if (m_valueIsUpToDate) |
| 344 return; | 355 return; |
| 345 | 356 |
| 346 m_value = innerEditorValue(); | 357 m_value = innerEditorValue(); |
| 347 const_cast<HTMLTextAreaElement*>(this)->m_valueIsUpToDate = true; | 358 const_cast<HTMLTextAreaElement*>(this)->m_valueIsUpToDate = true; |
| 348 const_cast<HTMLTextAreaElement*>(this)->notifyFormStateChanged(); | 359 const_cast<HTMLTextAreaElement*>(this)->notifyFormStateChanged(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 | 673 |
| 663 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
ource) | 674 void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& s
ource) |
| 664 { | 675 { |
| 665 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
ment&>(source); | 676 const HTMLTextAreaElement& sourceElement = static_cast<const HTMLTextAreaEle
ment&>(source); |
| 666 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); | 677 setValueCommon(sourceElement.value(), DispatchNoEvent, SetSeletion); |
| 667 m_isDirty = sourceElement.m_isDirty; | 678 m_isDirty = sourceElement.m_isDirty; |
| 668 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); | 679 HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source); |
| 669 } | 680 } |
| 670 | 681 |
| 671 } // namespace blink | 682 } // namespace blink |
| OLD | NEW |