| 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 } | |
| 411 if (newLength == string.length()) | 402 if (newLength == string.length()) |
| 412 return string; | 403 return string; |
| 413 if (newLength > 0 && U16_IS_LEAD(string[newLength - 1])) | 404 if (newLength > 0 && U16_IS_LEAD(string[newLength - 1])) |
| 414 --newLength; | 405 --newLength; |
| 415 return string.left(newLength); | 406 return string.left(newLength); |
| 416 } | 407 } |
| 417 | 408 |
| 418 String TextFieldInputType::sanitizeValue(const String& proposedValue) const | 409 String TextFieldInputType::sanitizeValue(const String& proposedValue) const |
| 419 { | 410 { |
| 420 return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInp
utElement::maximumLength); | 411 return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInp
utElement::maximumLength); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 { | 550 { |
| 560 return !element().isDisabledOrReadOnly(); | 551 return !element().isDisabledOrReadOnly(); |
| 561 } | 552 } |
| 562 | 553 |
| 563 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() | 554 bool TextFieldInputType::shouldSpinButtonRespondToWheelEvents() |
| 564 { | 555 { |
| 565 return shouldSpinButtonRespondToMouseEvents() && element().focused(); | 556 return shouldSpinButtonRespondToMouseEvents() && element().focused(); |
| 566 } | 557 } |
| 567 | 558 |
| 568 } // namespace WebCore | 559 } // namespace WebCore |
| OLD | NEW |