Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp

Issue 1822883002: Merge "Add unicode flag to blink::ScriptRegexp, and measure incompatibility for |pattern| content a… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp b/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
index 8d7065a1828a66d6760751251aac21157108b448..4cf599322bd59de5e26e42074709b8f8560eb99c 100644
--- a/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/BaseTextInputType.cpp
@@ -75,13 +75,26 @@ bool BaseTextInputType::patternMismatch(const String& value) const
{
const AtomicString& rawPattern = element().fastGetAttribute(patternAttr);
// Empty values can't be mismatched
- if (rawPattern.isNull() || value.isEmpty() || !ScriptRegexp(rawPattern, TextCaseSensitive).isValid())
+ if (rawPattern.isNull() || value.isEmpty())
return false;
+ bool rawPatternIsValid = ScriptRegexp(rawPattern, TextCaseSensitive).isValid();
+ bool rawUnicodePatternIsValid = ScriptRegexp(rawPattern, TextCaseSensitive, MultilineDisabled, ScriptRegexp::UTF16).isValid();
+ if (rawPatternIsValid != rawUnicodePatternIsValid)
+ UseCounter::count(element().document(), UseCounter::PatternAttributeUnicodeFlagIsIncompatible);
+ if (!rawPatternIsValid)
+ return false;
+
String pattern = "^(?:" + rawPattern + ")$";
int matchLength = 0;
int valueLength = value.length();
int matchOffset = ScriptRegexp(pattern, TextCaseSensitive).match(value, 0, &matchLength);
- return matchOffset || matchLength != valueLength;
+ bool bmpMismatched = matchOffset != 0 || matchLength != valueLength;
+ matchLength = 0;
+ matchOffset = ScriptRegexp(pattern, TextCaseSensitive, MultilineDisabled, ScriptRegexp::UTF16).match(value, 0, &matchLength);
+ bool utf16Mismatched = matchOffset != 0 || matchLength != valueLength;
+ if (bmpMismatched != utf16Mismatched)
+ UseCounter::count(element().document(), UseCounter::PatternAttributeUnicodeFlagIsIncompatible);
+ return bmpMismatched;
}
bool BaseTextInputType::supportsPlaceholder() const
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698