From 8ef5716c097776a9ae5c93e895c0effe7695a985 Mon Sep 17 00:00:00 2001 From: "tkent@chromium.org" Date: Thu, 25 Nov 2010 05:37:37 +0000 Subject: Add form validation message strings. * webkit/glue/ - Add overloads of queryLocalizedString() functions They will be added to WebKit::WebKitClient later. - Add implementations for WebLocalizedString::Validation* - Add message strings The English strings are different from WebKit's to avoid the brusque WebKit's strings. Port some messages from Mozilla. * webkit/tools/test_shell/ and webkit/support/ Hook queryLocalizedString() functions in order to return messages same as WebKit in layout test. BUG=28264 TEST=LayoutTests/fast/forms/validationMessage.html Review URL: http://codereview.chromium.org/4678006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67382 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/support/test_webkit_client.cc | 52 ++++++++++++++++++++++++++++++++++++ webkit/support/test_webkit_client.h | 7 +++++ 2 files changed, 59 insertions(+) (limited to 'webkit/support') diff --git a/webkit/support/test_webkit_client.cc b/webkit/support/test_webkit_client.cc index 5c46cf8..e45c263 100644 --- a/webkit/support/test_webkit_client.cc +++ b/webkit/support/test_webkit_client.cc @@ -247,6 +247,58 @@ WebKit::WebData TestWebKitClient::loadResource(const char* name) { return webkit_glue::WebKitClientImpl::loadResource(name); } +WebKit::WebString TestWebKitClient::queryLocalizedString( + WebKit::WebLocalizedString::Name name) { + // Returns messages same as WebKit's in DRT. + // We use different strings for form validation messages. + switch (name) { + case WebKit::WebLocalizedString::ValidationValueMissing: + case WebKit::WebLocalizedString::ValidationValueMissingForCheckbox: + case WebKit::WebLocalizedString::ValidationValueMissingForFile: + case WebKit::WebLocalizedString::ValidationValueMissingForMultipleFile: + case WebKit::WebLocalizedString::ValidationValueMissingForRadio: + case WebKit::WebLocalizedString::ValidationValueMissingForSelect: + return ASCIIToUTF16("value missing"); + case WebKit::WebLocalizedString::ValidationTypeMismatch: + case WebKit::WebLocalizedString::ValidationTypeMismatchForEmail: + case WebKit::WebLocalizedString::ValidationTypeMismatchForMultipleEmail: + case WebKit::WebLocalizedString::ValidationTypeMismatchForURL: + return ASCIIToUTF16("type mismatch"); + case WebKit::WebLocalizedString::ValidationPatternMismatch: + return ASCIIToUTF16("pattern mismatch"); + case WebKit::WebLocalizedString::ValidationTooLong: + return ASCIIToUTF16("too long"); + case WebKit::WebLocalizedString::ValidationRangeUnderflow: + return ASCIIToUTF16("range underflow"); + case WebKit::WebLocalizedString::ValidationRangeOverflow: + return ASCIIToUTF16("range overflow"); + case WebKit::WebLocalizedString::ValidationStepMismatch: + return ASCIIToUTF16("step mismatch"); + default: + return WebKitClientImpl::queryLocalizedString(name); + } +} + +WebKit::WebString TestWebKitClient::queryLocalizedString( + WebKit::WebLocalizedString::Name name, const WebKit::WebString& value) { + if (name == WebKit::WebLocalizedString::ValidationRangeUnderflow) + return ASCIIToUTF16("range underflow"); + if (name == WebKit::WebLocalizedString::ValidationRangeOverflow) + return ASCIIToUTF16("range overflow"); + return WebKitClientImpl::queryLocalizedString(name, value); +} + +WebKit::WebString TestWebKitClient::queryLocalizedString( + WebKit::WebLocalizedString::Name name, + const WebKit::WebString& value1, + const WebKit::WebString& value2) { + if (name == WebKit::WebLocalizedString::ValidationTooLong) + return ASCIIToUTF16("too long"); + if (name == WebKit::WebLocalizedString::ValidationStepMismatch) + return ASCIIToUTF16("step mismatch"); + return WebKitClientImpl::queryLocalizedString(name, value1, value2); +} + WebKit::WebString TestWebKitClient::defaultLocale() { return ASCIIToUTF16("en-US"); } diff --git a/webkit/support/test_webkit_client.h b/webkit/support/test_webkit_client.h index 6f1d28d..07beae7 100644 --- a/webkit/support/test_webkit_client.h +++ b/webkit/support/test_webkit_client.h @@ -47,6 +47,13 @@ class TestWebKitClient : public webkit_glue::WebKitClientImpl { virtual void prefetchHostName(const WebKit::WebString&); virtual WebKit::WebURLLoader* createURLLoader(); virtual WebKit::WebData loadResource(const char* name); + virtual WebKit::WebString queryLocalizedString( + WebKit::WebLocalizedString::Name name); + virtual WebKit::WebString queryLocalizedString( + WebKit::WebLocalizedString::Name name, const WebKit::WebString& value); + virtual WebKit::WebString queryLocalizedString( + WebKit::WebLocalizedString::Name name, + const WebKit::WebString& value1, const WebKit::WebString& value2); virtual WebKit::WebString defaultLocale(); virtual WebKit::WebStorageNamespace* createLocalStorageNamespace( const WebKit::WebString& path, unsigned quota); -- cgit v1.1