Title: [136343] trunk/Source/WebKit/chromium
Revision
136343
Author
[email protected]
Date
2012-12-02 05:09:17 -0800 (Sun, 02 Dec 2012)

Log Message

[Chromium] Create an enum for the kind of date input and use that on WebDateTimeChooserParams instead of a bare WebString
https://bugs.webkit.org/show_bug.cgi?id=103746

Patch by Miguel Garcia <[email protected]> on 2012-12-02
Reviewed by Kent Tamura.

Using an enum makes the chromium part much simpler and prevents makes sure that new items are added explicitly.

* WebKit.gyp:
* public/WebDateTimeChooserParams.h:
(WebDateTimeChooserParams):
* public/WebDateTimeInputType.h: Copied from Source/WebKit/chromium/public/WebTextInputType.h.
(WebKit):
* public/WebTextInputType.h:
* public/WebViewClient.h:
(WebViewClient):
* src/ExternalDateTimeChooser.cpp:
(WebKit::ExternalDateTimeChooser::openDateTimeChooser):
(WebKit::ExternalDateTimeChooser::webType):
(WebKit):
* src/ExternalDateTimeChooser.h:
(ExternalDateTimeChooser):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (136342 => 136343)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-12-02 13:09:17 UTC (rev 136343)
@@ -1,3 +1,27 @@
+2012-12-02  Miguel Garcia  <[email protected]>
+
+        [Chromium] Create an enum for the kind of date input and use that on WebDateTimeChooserParams instead of a bare WebString
+        https://bugs.webkit.org/show_bug.cgi?id=103746
+
+        Reviewed by Kent Tamura.
+
+        Using an enum makes the chromium part much simpler and prevents makes sure that new items are added explicitly.
+
+        * WebKit.gyp:
+        * public/WebDateTimeChooserParams.h:
+        (WebDateTimeChooserParams):
+        * public/WebDateTimeInputType.h: Copied from Source/WebKit/chromium/public/WebTextInputType.h.
+        (WebKit):
+        * public/WebTextInputType.h:
+        * public/WebViewClient.h:
+        (WebViewClient):
+        * src/ExternalDateTimeChooser.cpp:
+        (WebKit::ExternalDateTimeChooser::openDateTimeChooser):
+        (WebKit::ExternalDateTimeChooser::webType):
+        (WebKit):
+        * src/ExternalDateTimeChooser.h:
+        (ExternalDateTimeChooser):
+
 2012-12-02  Robert Kroeger  <[email protected]>
 
         [chromium] make sourceDevice available to more WebGestureEvent subtypes

Modified: trunk/Source/WebKit/chromium/WebKit.gyp (136342 => 136343)


--- trunk/Source/WebKit/chromium/WebKit.gyp	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/WebKit.gyp	2012-12-02 13:09:17 UTC (rev 136343)
@@ -131,6 +131,7 @@
                 'public/WebDataSource.h',
                 'public/WebDatabase.h',
                 'public/WebDatabaseObserver.h',
+                'public/WebDateTimeInputType.h',
                 'public/WebDateTimeChooserCompletion.h',
                 'public/WebDateTimeChooserParams.h',
                 'public/WebDeliveredIntentClient.h',

Modified: trunk/Source/WebKit/chromium/public/WebDateTimeChooserParams.h (136342 => 136343)


--- trunk/Source/WebKit/chromium/public/WebDateTimeChooserParams.h	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/public/WebDateTimeChooserParams.h	2012-12-02 13:09:17 UTC (rev 136343)
@@ -26,6 +26,8 @@
 #ifndef WebDateTimeChooserParams_h
 #define WebDateTimeChooserParams_h
 
+#include "WebDateTimeInputType.h"
+
 #include "platform/WebRect.h"
 #include "platform/WebString.h"
 #include "platform/WebVector.h"
@@ -35,9 +37,8 @@
 // This class conveys various information to make date/time chooser UI.
 // See WebViewClient::openDateTimeChooser.
 struct WebDateTimeChooserParams {
-    // Input type string. This is one of "date", "datetime", "datetime-local",
-    // "month", "time", and "week".
-    WebString type;
+    // The type of chooser to show.
+    WebDateTimeInputType type;
     // Bounding rectangle of the requester element.
     WebRect anchorRectInScreen;
     // The current value of the requester element.

Copied: trunk/Source/WebKit/chromium/public/WebDateTimeInputType.h (from rev 136342, trunk/Source/WebKit/chromium/public/WebTextInputType.h) (0 => 136343)


--- trunk/Source/WebKit/chromium/public/WebDateTimeInputType.h	                        (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebDateTimeInputType.h	2012-12-02 13:09:17 UTC (rev 136343)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef WebDateTimeInputType_h
+#define WebDateTimeInputType_h
+
+namespace WebKit {
+
+enum WebDateTimeInputType {
+    WebDateTimeInputTypeNone,
+    WebDateTimeInputTypeDate,
+    WebDateTimeInputTypeDateTime,
+    WebDateTimeInputTypeDateTimeLocal,
+    WebDateTimeInputTypeMonth,
+    WebDateTimeInputTypeTime,
+    WebDateTimeInputTypeWeek,
+};
+
+} // namespace WebKit
+
+#endif

Modified: trunk/Source/WebKit/chromium/public/WebTextInputType.h (136342 => 136343)


--- trunk/Source/WebKit/chromium/public/WebTextInputType.h	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/public/WebTextInputType.h	2012-12-02 13:09:17 UTC (rev 136343)
@@ -48,6 +48,9 @@
     WebTextInputTypeNumber,
     WebTextInputTypeTelephone,
     WebTextInputTypeURL,
+
+    // FIXME: Remove these types once Date like types are not
+    // seen as Text. For now they also exist in WebTextInputType
     WebTextInputTypeDate,
     WebTextInputTypeDateTime,
     WebTextInputTypeDateTimeLocal,

Modified: trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.cpp (136342 => 136343)


--- trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.cpp	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.cpp	2012-12-02 13:09:17 UTC (rev 136343)
@@ -29,9 +29,11 @@
 
 #include "ChromeClientImpl.h"
 #include "DateTimeChooserClient.h"
+#include "InputTypeNames.h"
 #include "WebDateTimeChooserCompletion.h"
 #include "WebDateTimeChooserParams.h"
 #include "WebViewClient.h"
+#include <wtf/text/AtomicString.h>
 
 using namespace WebCore;
 
@@ -79,13 +81,31 @@
     return chooser.release();
 }
 
+
+static WebDateTimeInputType toWebDateTimeInputType(const AtomicString& source)
+{
+    if (source == InputTypeNames::date())
+        return WebDateTimeInputTypeDate;
+    if (source == InputTypeNames::datetime())
+        return WebDateTimeInputTypeDateTime;
+    if (source == InputTypeNames::datetimelocal())
+        return WebDateTimeInputTypeDateTimeLocal;
+    if (source == InputTypeNames::month())
+        return WebDateTimeInputTypeMonth;
+    if (source == InputTypeNames::time())
+        return WebDateTimeInputTypeTime;
+    if (source == InputTypeNames::week())
+        return WebDateTimeInputTypeWeek;
+    return WebDateTimeInputTypeNone;
+}
+
 bool ExternalDateTimeChooser::openDateTimeChooser(ChromeClientImpl* chromeClient, WebViewClient* webViewClient, const DateTimeChooserParameters& parameters)
 {
     if (!webViewClient)
         return false;
 
     WebDateTimeChooserParams webParams;
-    webParams.type = parameters.type;
+    webParams.type = toWebDateTimeInputType(parameters.type);
     webParams.anchorRectInScreen = chromeClient->rootViewToScreen(parameters.anchorRectInRootView);
     webParams.currentValue = parameters.currentValue;
     webParams.suggestionValues = parameters.suggestionValues;

Modified: trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.h (136342 => 136343)


--- trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.h	2012-12-02 13:00:22 UTC (rev 136342)
+++ trunk/Source/WebKit/chromium/src/ExternalDateTimeChooser.h	2012-12-02 13:09:17 UTC (rev 136343)
@@ -52,7 +52,7 @@
     ExternalDateTimeChooser(WebCore::DateTimeChooserClient*);
     bool openDateTimeChooser(ChromeClientImpl*, WebViewClient*, const WebCore::DateTimeChooserParameters&);
 
-    // DateTimeChooer function:
+    // DateTimeChooser function:
     virtual void endChooser() OVERRIDE;
 
     WebCore::DateTimeChooserClient* m_client;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to