| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of the WebKit project. | 2 * This file is part of the WebKit project. |
| 3 * | 3 * |
| 4 * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> | 4 * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> |
| 5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 // An empty string is excluded from minlength check. | 69 // An empty string is excluded from minlength check. |
| 70 unsigned len = value.length(); | 70 unsigned len = value.length(); |
| 71 return len > 0 && len < static_cast<unsigned>(min); | 71 return len > 0 && len < static_cast<unsigned>(min); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool BaseTextInputType::patternMismatch(const String& value) const | 74 bool BaseTextInputType::patternMismatch(const String& value) const |
| 75 { | 75 { |
| 76 const AtomicString& rawPattern = element().fastGetAttribute(patternAttr); | 76 const AtomicString& rawPattern = element().fastGetAttribute(patternAttr); |
| 77 // Empty values can't be mismatched | 77 // Empty values can't be mismatched |
| 78 if (rawPattern.isNull() || value.isEmpty() || !ScriptRegexp(rawPattern, Text
CaseSensitive).isValid()) | 78 if (rawPattern.isNull() || value.isEmpty()) |
| 79 return false; | 79 return false; |
| 80 bool rawPatternIsValid = ScriptRegexp(rawPattern, TextCaseSensitive).isValid
(); |
| 81 bool rawUnicodePatternIsValid = ScriptRegexp(rawPattern, TextCaseSensitive,
MultilineDisabled, ScriptRegexp::UTF16).isValid(); |
| 82 if (rawPatternIsValid != rawUnicodePatternIsValid) |
| 83 UseCounter::count(element().document(), UseCounter::PatternAttributeUnic
odeFlagIsIncompatible); |
| 84 if (!rawPatternIsValid) |
| 85 return false; |
| 86 |
| 80 String pattern = "^(?:" + rawPattern + ")$"; | 87 String pattern = "^(?:" + rawPattern + ")$"; |
| 81 int matchLength = 0; | 88 int matchLength = 0; |
| 82 int valueLength = value.length(); | 89 int valueLength = value.length(); |
| 83 int matchOffset = ScriptRegexp(pattern, TextCaseSensitive).match(value, 0, &
matchLength); | 90 int matchOffset = ScriptRegexp(pattern, TextCaseSensitive).match(value, 0, &
matchLength); |
| 84 return matchOffset || matchLength != valueLength; | 91 bool bmpMismatched = matchOffset != 0 || matchLength != valueLength; |
| 92 matchLength = 0; |
| 93 matchOffset = ScriptRegexp(pattern, TextCaseSensitive, MultilineDisabled, Sc
riptRegexp::UTF16).match(value, 0, &matchLength); |
| 94 bool utf16Mismatched = matchOffset != 0 || matchLength != valueLength; |
| 95 if (bmpMismatched != utf16Mismatched) |
| 96 UseCounter::count(element().document(), UseCounter::PatternAttributeUnic
odeFlagIsIncompatible); |
| 97 return bmpMismatched; |
| 85 } | 98 } |
| 86 | 99 |
| 87 bool BaseTextInputType::supportsPlaceholder() const | 100 bool BaseTextInputType::supportsPlaceholder() const |
| 88 { | 101 { |
| 89 return true; | 102 return true; |
| 90 } | 103 } |
| 91 | 104 |
| 92 bool BaseTextInputType::supportsSelectionAPI() const | 105 bool BaseTextInputType::supportsSelectionAPI() const |
| 93 { | 106 { |
| 94 return true; | 107 return true; |
| 95 } | 108 } |
| 96 | 109 |
| 97 bool BaseTextInputType::supportsAutocapitalize() const | 110 bool BaseTextInputType::supportsAutocapitalize() const |
| 98 { | 111 { |
| 99 return true; | 112 return true; |
| 100 } | 113 } |
| 101 | 114 |
| 102 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |