Diff
Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210723 => 210724)
--- branches/safari-603-branch/LayoutTests/ChangeLog 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/LayoutTests/ChangeLog 2017-01-13 07:05:20 UTC (rev 210724)
@@ -1,5 +1,23 @@
2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r210447. rdar://problem/29872292
+
+ 2017-01-06 Chris Dumez <cdu...@apple.com>
+
+ [Form Validation] "character" in maxlength validation message should be singular when maxlength is 1
+ https://bugs.webkit.org/show_bug.cgi?id=166712
+ <rdar://problem/29872292>
+
+ Reviewed by Darin Adler.
+
+ Add layout test coverage.
+
+ * fast/forms/validation-message-maxLength-expected.txt: Added.
+ * fast/forms/validation-message-maxLength.html: Added.
+ * platform/ios-simulator/TestExpectations:
+
+2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+
Merge r210586. rdar://problem/29861147
2017-01-11 Chris Dumez <cdu...@apple.com>
Added: branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength-expected.txt (0 => 210724)
--- branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength-expected.txt (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength-expected.txt 2017-01-13 07:05:20 UTC (rev 210724)
@@ -0,0 +1,18 @@
+Tests the validation message when maxlength is used.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS input.value is "abc"
+PASS input.checkValidity() is false
+PASS input.validationMessage is "Use no more than 2 characters"
+PASS input.value is "ab"
+PASS input.checkValidity() is false
+PASS input.validationMessage is "Use no more than one character"
+PASS input.value is "a"
+PASS input.checkValidity() is false
+PASS input.validationMessage is "Use no more than 0 characters"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength.html (0 => 210724)
--- branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength.html (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/forms/validation-message-maxLength.html 2017-01-13 07:05:20 UTC (rev 210724)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<form id="testForm">
+<input type="submit" id="submitButton">
+</form>
+<script>
+description("Tests the validation message when maxlength is used.");
+
+var form = document.getElementById("testForm");
+var submit = document.getElementById("submitButton");
+
+var input = document.createElement("input");
+input.value = "abcd";
+input.maxLength = 2;
+form.prepend(input);
+
+input.focus();
+eventSender.keyDown(String.fromCharCode(0x0008)); // Delete.
+shouldBeEqualToString("input.value", "abc");
+shouldBeFalse("input.checkValidity()");
+shouldBeEqualToString("input.validationMessage", "Use no more than 2 characters");
+
+input.maxLength = 1;
+eventSender.keyDown(String.fromCharCode(0x0008)); // Delete.
+shouldBeEqualToString("input.value", "ab");
+shouldBeFalse("input.checkValidity()");
+shouldBeEqualToString("input.validationMessage", "Use no more than one character");
+
+input.maxLength = 0;
+eventSender.keyDown(String.fromCharCode(0x0008)); // Delete.
+shouldBeEqualToString("input.value", "a");
+shouldBeFalse("input.checkValidity()");
+shouldBeEqualToString("input.validationMessage", "Use no more than 0 characters");
+</script>
+<script src=""
+</body>
+</html>
Modified: branches/safari-603-branch/LayoutTests/platform/ios-simulator/TestExpectations (210723 => 210724)
--- branches/safari-603-branch/LayoutTests/platform/ios-simulator/TestExpectations 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/LayoutTests/platform/ios-simulator/TestExpectations 2017-01-13 07:05:20 UTC (rev 210724)
@@ -350,6 +350,7 @@
# This test relies on EventSender.keydown(), which is not supported on iOS
webkit.org/b/155233 fast/events/max-tabindex-focus.html [ Skip ]
+fast/forms/validation-message-maxLength.html [ Skip ]
fast/shadow-dom/shadow-host-removal-crash.html [ Skip ]
fast/shadow-dom/input-element-in-shadow.html [ Skip ]
fast/shadow-dom/activate-over-slotted-content.html [ Skip ]
Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/ChangeLog 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog 2017-01-13 07:05:20 UTC (rev 210724)
@@ -1,5 +1,32 @@
2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+ Merge r210447. rdar://problem/29872292
+
+ 2017-01-06 Chris Dumez <cdu...@apple.com>
+
+ [Form Validation] "character" in maxlength validation message should be singular when maxlength is 1
+ https://bugs.webkit.org/show_bug.cgi?id=166712
+ <rdar://problem/29872292>
+
+ Reviewed by Darin Adler.
+
+ Fix validation message to use singular form of "character" when maxLength value is 1.
+
+ Test: fast/forms/validation-message-maxLength.html
+
+ * English.lproj/Localizable.strings:
+ * English.lproj/Localizable.stringsdict: Added.
+ * WebCore.xcodeproj/project.pbxproj:
+ * extract-localizable-strings.pl:
+ * platform/LocalizedStrings.cpp:
+ * platform/LocalizedStrings.h:
+ * platform/cocoa/LocalizedStringsCocoa.mm:
+ (WebCore::localizedNString):
+ (WebCore::localizedString):
+ (WebCore::validationMessageTooLongText):
+
+2017-01-12 Matthew Hanson <matthew_han...@apple.com>
+
Merge r210474. rdar://problem/29762809
2017-01-06 Daniel Bates <daba...@apple.com>
Modified: branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.strings (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.strings 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.strings 2017-01-13 07:05:20 UTC (rev 210724)
@@ -743,6 +743,9 @@
"Use at least %d characters" = "Use at least %d characters";
/* Validation message for form control elements with a value shorter than maximum allowed length */
+"Use no more than %d character(s)" = "Use no more than %d character(s)";
+
+/* Validation message for form control elements with a value shorter than maximum allowed length */
"Use no more than %d characters" = "Use no more than %d characters";
/* Description of WebCrypto master keys in Keychain */
@@ -847,6 +850,9 @@
/* accessibility help text for elapsed time display */
"current movie time in seconds" = "current movie time in seconds";
+/* accessibility role description for a date and time field. */
+"date and time field" = "date and time field";
+
/* accessibility role description for a date field. */
"date field" = "date field";
Added: branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.stringsdict (0 => 210724)
--- branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.stringsdict (rev 0)
+++ branches/safari-603-branch/Source/WebCore/English.lproj/Localizable.stringsdict 2017-01-13 07:05:20 UTC (rev 210724)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Use no more than %d character(s)</key>
+ <dict>
+ <key>NSStringLocalizedFormatKey</key>
+ <string>Use no more than %#@characters@</string>
+ <key>characters</key>
+ <dict>
+ <key>NSStringFormatSpecTypeKey</key>
+ <string>NSStringPluralRuleType</string>
+ <key>NSStringFormatValueTypeKey</key>
+ <string>d</string>
+ <key>one</key>
+ <string>one character</string>
+ <key>other</key>
+ <string>%d characters</string>
+ </dict>
+ </dict>
+</dict>
+</plist>
Modified: branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-01-13 07:05:20 UTC (rev 210724)
@@ -3021,6 +3021,7 @@
836FBCEC178C117F00B21A15 /* SVGAnimatedProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836FBCEB178C117F00B21A15 /* SVGAnimatedProperty.cpp */; };
8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
83765F951DAC522F00C06537 /* MouseEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 83765F941DAC521800C06537 /* MouseEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 837A80131E1E127300026B9F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 837A80111E1E127300026B9F /* Localizable.stringsdict */; };
837B7D201DC3F55000D051FC /* ValidationBubbleIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */; };
8386A96D19F61B2E00E1EC4A /* StyleBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */; };
8386A97019F61E4F00E1EC4A /* StyleBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */; };
@@ -10554,6 +10555,7 @@
8372DB301A6780A800C697C5 /* DiagnosticLoggingResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingResultType.h; sourceTree = "<group>"; };
83765F931DAC521800C06537 /* MouseEventInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MouseEventInit.idl; sourceTree = "<group>"; };
83765F941DAC521800C06537 /* MouseEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MouseEventInit.h; sourceTree = "<group>"; };
+ 837A80121E1E127300026B9F /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = English; path = English.lproj/Localizable.stringsdict; sourceTree = SOURCE_ROOT; };
837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleIOS.mm; sourceTree = "<group>"; };
8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilder.h; sourceTree = "<group>"; };
8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilder.cpp; sourceTree = "<group>"; };
@@ -15600,6 +15602,7 @@
7CC7E3D617208C0F003C5277 /* IDNScriptWhiteList.txt */,
2D9F0E1214FF1CBF00BA0FF7 /* linearSRGB.icc */,
BCAD1808131C7A0D00990406 /* Localizable.strings */,
+ 837A80111E1E127300026B9F /* Localizable.stringsdict */,
7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */,
93153BE114195A5700FCF5BE /* missingImage.png */,
93153BD914181F7A00FCF5BE /* missingim...@2x.png */,
@@ -28586,6 +28589,7 @@
7CC7E3D717208C0F003C5277 /* IDNScriptWhiteList.txt in Resources */,
2D9F0E1314FF1CBF00BA0FF7 /* linearSRGB.icc in Resources */,
BCAD180A131C7A0D00990406 /* Localizable.strings in Resources */,
+ 837A80131E1E127300026B9F /* Localizable.stringsdict in Resources */,
311C08BD18EB7CAF00B65615 /* mediaControlsApple.css in Resources */,
311C08BE18EB7CAF00B65615 /* mediaControlsApple.js in Resources */,
311C08BF18EB7CAF00B65615 /* mediaControlsiOS.css in Resources */,
@@ -31993,6 +31997,14 @@
name = mediaControlsLocalizedStrings.js;
sourceTree = "<group>";
};
+ 837A80111E1E127300026B9F /* Localizable.stringsdict */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 837A80121E1E127300026B9F /* English */,
+ );
+ name = Localizable.stringsdict;
+ sourceTree = "<group>";
+ };
BCAD1808131C7A0D00990406 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
Modified: branches/safari-603-branch/Source/WebCore/extract-localizable-strings.pl (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/extract-localizable-strings.pl 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/extract-localizable-strings.pl 2017-01-13 07:05:20 UTC (rev 210724)
@@ -153,7 +153,11 @@
# Handle all the tokens in the line.
while (s-^\s*([#\w]+|/\*|//|[^#\w/'"()\[\],]+|.)--) {
my $token = $1;
-
+
+ if ($token eq "@" and $expected and $expected eq "a quoted string") {
+ next;
+ }
+
if ($token eq "\"") {
if ($expected and $expected ne "a quoted string") {
emitError($file, $., "found a quoted string but expected $expected");
@@ -236,7 +240,7 @@
emitError($file, $., "found $token but expected $expected");
$expected = "";
}
- if ($token =~ /(WEB_)?UI_STRING(_KEY)?(_INTERNAL)?$/) {
+ if (($token =~ /(WEB_)?UI_STRING(_KEY)?(_INTERNAL)?$/) || ($token =~ /WEB_UI_NSSTRING$/)) {
$expected = "(";
$macro = $token;
$UIString = undef;
Modified: branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.cpp (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.cpp 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.cpp 2017-01-13 07:05:20 UTC (rev 210724)
@@ -1126,11 +1126,15 @@
return formatLocalizedString(WEB_UI_STRING("Use at least %d characters", "Validation message for form control elements with a value shorter than minimum allowed length"), minLength);
}
+#if !PLATFORM(COCOA)
+
String validationMessageTooLongText(int, int maxLength)
{
return formatLocalizedString(WEB_UI_STRING("Use no more than %d characters", "Validation message for form control elements with a value shorter than maximum allowed length"), maxLength);
}
+#endif
+
String validationMessageRangeUnderflowText(const String& minimum)
{
#if USE(CF)
Modified: branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.h (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.h 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/platform/LocalizedStrings.h 2017-01-13 07:05:20 UTC (rev 210724)
@@ -308,6 +308,11 @@
WEBCORE_EXPORT String localizedString(const char* key);
+#ifdef __OBJC__
+#define WEB_UI_NSSTRING(string, description) WebCore::localizedNSString(string)
+ WEBCORE_EXPORT NSString *localizedNSString(NSString *key) NS_FORMAT_ARGUMENT(1);
+#endif
+
} // namespace WebCore
#endif // LocalizedStrings_h
Modified: branches/safari-603-branch/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm (210723 => 210724)
--- branches/safari-603-branch/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2017-01-13 07:05:15 UTC (rev 210723)
+++ branches/safari-603-branch/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2017-01-13 07:05:20 UTC (rev 210724)
@@ -26,7 +26,6 @@
#include "config.h"
#include "LocalizedStrings.h"
-#include <CoreFoundation/CFBundle.h>
#include <wtf/Assertions.h>
#include <wtf/MainThread.h>
#include <wtf/RetainPtr.h>
@@ -34,10 +33,8 @@
namespace WebCore {
-String localizedString(const char* key)
+NSString *localizedNSString(NSString *key)
{
- static CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebCore"));
-
#if !PLATFORM(IOS)
// Can be called on a dispatch queue when initializing strings on iOS.
// See LoadWebLocalizedStrings and <rdar://problem/7902473>.
@@ -44,16 +41,19 @@
ASSERT(isMainThread());
#endif
+ static NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebCore"];
+ return [bundle localizedStringForKey:key value:@"localized string not found" table:nullptr];
+}
+
+String localizedString(const char* key)
+{
RetainPtr<CFStringRef> keyString = adoptCF(CFStringCreateWithCStringNoCopy(0, key, kCFStringEncodingUTF8, kCFAllocatorNull));
- CFStringRef notFound = CFSTR("localized string not found");
- RetainPtr<CFStringRef> result;
- if (bundle) {
- result = adoptCF(CFBundleCopyLocalizedString(bundle, keyString.get(), notFound, 0));
- ASSERT_WITH_MESSAGE(result.get() != notFound, "could not find localizable string %s in bundle", key);
- } else
- result = notFound;
+ return localizedNSString((NSString *)keyString.get());
+}
- return String(result.get());
+String validationMessageTooLongText(int, int maxLength)
+{
+ return [NSString localizedStringWithFormat:WEB_UI_NSSTRING(@"Use no more than %d character(s)", @"Validation message for form control elements with a value shorter than maximum allowed length"), maxLength];
}
} // namespace WebCore