| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 const String& currentValue = innerEditorValue(); | 293 const String& currentValue = innerEditorValue(); |
| 294 unsigned currentLength = computeLengthForSubmission(currentValue); | 294 unsigned currentLength = computeLengthForSubmission(currentValue); |
| 295 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL
ength) | 295 if (currentLength + computeLengthForSubmission(event->text()) < unsignedMaxL
ength) |
| 296 return; | 296 return; |
| 297 | 297 |
| 298 // selectionLength represents the selection length of this text field to be | 298 // selectionLength represents the selection length of this text field to be |
| 299 // removed by this insertion. | 299 // removed by this insertion. |
| 300 // If the text field has no focus, we don't need to take account of the | 300 // If the text field has no focus, we don't need to take account of the |
| 301 // selection length. The selection is the source of text drag-and-drop in | 301 // selection length. The selection is the source of text drag-and-drop in |
| 302 // that case, and nothing in the text field will be removed. | 302 // that case, and nothing in the text field will be removed. |
| 303 unsigned selectionLength = focused() ? computeLengthForSubmission(plainText(
document().frame()->selection().selection().toNormalizedRange().get())) : 0; | 303 unsigned selectionLength = 0; |
| 304 if (focused()) { |
| 305 Position start, end; |
| 306 document().frame()->selection().selection().toNormalizedPositions(start,
end); |
| 307 selectionLength = computeLengthForSubmission(plainText(start, end)); |
| 308 } |
| 304 ASSERT(currentLength >= selectionLength); | 309 ASSERT(currentLength >= selectionLength); |
| 305 unsigned baseLength = currentLength - selectionLength; | 310 unsigned baseLength = currentLength - selectionLength; |
| 306 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng
th - baseLength : 0; | 311 unsigned appendableLength = unsignedMaxLength > baseLength ? unsignedMaxLeng
th - baseLength : 0; |
| 307 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); | 312 event->setText(sanitizeUserInputValue(event->text(), appendableLength)); |
| 308 } | 313 } |
| 309 | 314 |
| 310 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue,
unsigned maxLength) | 315 String HTMLTextAreaElement::sanitizeUserInputValue(const String& proposedValue,
unsigned maxLength) |
| 311 { | 316 { |
| 312 if (maxLength > 0 && U16_IS_LEAD(proposedValue[maxLength - 1])) | 317 if (maxLength > 0 && U16_IS_LEAD(proposedValue[maxLength - 1])) |
| 313 --maxLength; | 318 --maxLength; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 { | 576 { |
| 572 return true; | 577 return true; |
| 573 } | 578 } |
| 574 | 579 |
| 575 bool HTMLTextAreaElement::supportsAutofocus() const | 580 bool HTMLTextAreaElement::supportsAutofocus() const |
| 576 { | 581 { |
| 577 return true; | 582 return true; |
| 578 } | 583 } |
| 579 | 584 |
| 580 } | 585 } |
| OLD | NEW |