OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 392 } |
393 | 393 |
394 static bool isASCIILineBreak(UChar c) | 394 static bool isASCIILineBreak(UChar c) |
395 { | 395 { |
396 return c == '\r' || c == '\n'; | 396 return c == '\r' || c == '\n'; |
397 } | 397 } |
398 | 398 |
399 static String limitLength(const String& string, unsigned maxLength) | 399 static String limitLength(const String& string, unsigned maxLength) |
400 { | 400 { |
401 unsigned newLength = std::min(maxLength, string.length()); | 401 unsigned newLength = std::min(maxLength, string.length()); |
| 402 // FIXME: We should not truncate the string at a control character. It's not |
| 403 // compatible with IE and Firefox. |
| 404 for (unsigned i = 0; i < newLength; ++i) { |
| 405 const UChar current = string[i]; |
| 406 if (current < ' ' && current != '\t') { |
| 407 newLength = i; |
| 408 break; |
| 409 } |
| 410 } |
402 if (newLength == string.length()) | 411 if (newLength == string.length()) |
403 return string; | 412 return string; |
404 if (newLength > 0 && U16_IS_LEAD(string[newLength - 1])) | 413 if (newLength > 0 && U16_IS_LEAD(string[newLength - 1])) |
405 --newLength; | 414 --newLength; |
406 return string.left(newLength); | 415 return string.left(newLength); |
407 } | 416 } |
408 | 417 |
409 String TextFieldInputType::sanitizeValue(const String& proposedValue) const | 418 String TextFieldInputType::sanitizeValue(const String& proposedValue) const |
410 { | 419 { |
411 return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInp
utElement::maximumLength); | 420 return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInp
utElement::maximumLength); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 { | 559 { |
551 return !element().isDisabledOrReadOnly(); | 560 return !element().isDisabledOrReadOnly(); |
552 } | 561 } |
553 | 562 |
554 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() | 563 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() |
555 { | 564 { |
556 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 565 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
557 } | 566 } |
558 | 567 |
559 } // namespace WebCore | 568 } // namespace WebCore |
OLD | NEW |