Diff
Modified: trunk/Source/WebKit/ChangeLog (122363 => 122364)
--- trunk/Source/WebKit/ChangeLog 2012-07-11 20:20:39 UTC (rev 122363)
+++ trunk/Source/WebKit/ChangeLog 2012-07-11 20:20:54 UTC (rev 122364)
@@ -1,3 +1,14 @@
+2012-07-11 Crystal Zhang <[email protected]>
+
+ [BlackBerry] Implement Date/Time picker
+ https://bugs.webkit.org/show_bug.cgi?id=90911
+
+ Reviewed by Rob Buis.
+
+ Add files into make file.
+
+ * PlatformBlackBerry.cmake:
+
2012-07-09 Christophe Dumez <[email protected]>
[EFL] Battery status code needs refactoring to be reused in WebKit2
Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (122363 => 122364)
--- trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-07-11 20:20:39 UTC (rev 122363)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-07-11 20:20:54 UTC (rev 122364)
@@ -91,6 +91,7 @@
blackberry/WebCoreSupport/VibrationClientBlackBerry.cpp
blackberry/WebCoreSupport/PagePopupBlackBerry.cpp
blackberry/WebCoreSupport/SelectPopupClient.cpp
+ blackberry/WebCoreSupport/DatePickerClient.cpp
blackberry/WebKitSupport/BackingStoreCompositingSurface.cpp
blackberry/WebKitSupport/BackingStoreTile.cpp
blackberry/WebKitSupport/BackingStoreClient.cpp
Modified: trunk/Source/WebKit/blackberry/ChangeLog (122363 => 122364)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-07-11 20:20:39 UTC (rev 122363)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-07-11 20:20:54 UTC (rev 122364)
@@ -1,3 +1,32 @@
+2012-07-11 Crystal Zhang <[email protected]>
+
+ [BlackBerry] Implement Date/Time picker
+ https://bugs.webkit.org/show_bug.cgi?id=90911
+
+ Reviewed by Rob Buis.
+
+ Implement HTML Date/Time picker, also should delete popup when closing popup.
+
+ * WebCoreSupport/ChromeClientBlackBerry.cpp:
+ (WebCore::ChromeClientBlackBerry::closePagePopup):
+ * WebCoreSupport/DatePickerClient.cpp: Added.
+ (WebCore):
+ (WebCore::DatePickerClient::DatePickerClient):
+ (WebCore::DatePickerClient::~DatePickerClient):
+ (WebCore::DatePickerClient::generateHTML):
+ (WebCore::DatePickerClient::closePopup):
+ (WebCore::DatePickerClient::contentSize):
+ (WebCore::DatePickerClient::htmlSource):
+ (WebCore::DatePickerClient::setValueAndClosePopup):
+ (WebCore::DatePickerClient::didClosePopup):
+ (WebCore::DatePickerClient::writeDocument):
+ * WebCoreSupport/DatePickerClient.h: Added.
+ (WebKit):
+ (WebCore):
+ (DatePickerClient):
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::InputHandler::openDatePopup):
+
2012-07-10 Adam Barth <[email protected]>
WebCore::Settings for Hixie76 WebSocket protocol doesn't do anything and should be removed
Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp (122363 => 122364)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp 2012-07-11 20:20:39 UTC (rev 122363)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp 2012-07-11 20:20:54 UTC (rev 122364)
@@ -321,6 +321,7 @@
PagePopupBlackBerry* webPopup = m_webPagePrivate->m_webPage->popup();
webPopup->closePopup();
+ delete webPopup;
}
void ChromeClientBlackBerry::setToolbarsVisible(bool)
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.cpp (0 => 122364)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.cpp 2012-07-11 20:20:54 UTC (rev 122364)
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "DatePickerClient.h"
+
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "Document.h"
+#include "DocumentWriter.h"
+#include "HTMLInputElement.h"
+#include "Page.h"
+#include "PagePopup.h"
+#include "PopupPicker.h"
+#include "RenderObject.h"
+#include "WebPage_p.h"
+#include "WebString.h"
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+DatePickerClient::DatePickerClient(BlackBerry::Platform::BlackBerryInputType type, const BlackBerry::WebKit::WebString& value, const BlackBerry::WebKit::WebString& min, const BlackBerry::WebKit::WebString& max, double step, BlackBerry::WebKit::WebPagePrivate* webPage, HTMLInputElement* element)
+ : m_type(type)
+ , m_webPage(webPage)
+ , m_element(element)
+{
+ generateHTML(type, value, min, max, step);
+}
+
+DatePickerClient::~DatePickerClient()
+{
+}
+
+void DatePickerClient::generateHTML(BlackBerry::Platform::BlackBerryInputType type, const BlackBerry::WebKit::WebString& value, const BlackBerry::WebKit::WebString& min, const BlackBerry::WebKit::WebString& max, double step)
+{
+ StringBuilder source;
+ source.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><style>\n");
+ // Include CSS file.
+ source.append(popupControlBlackBerryCss,
+ sizeof(popupControlBlackBerryCss));
+ source.append("</style>\n<style>");
+ source.append(timeControlBlackBerryCss,
+ sizeof(timeControlBlackBerryCss));
+ source.append("</style></head><body>\n");
+ source.append("<script>\n");
+ source.append("window.addEventListener('load', function () {");
+ switch (type) {
+ case BlackBerry::Platform::InputTypeDate:
+ source.append("window.popupcontrol.show(\"Date\", ");
+ break;
+ case BlackBerry::Platform::InputTypeTime:
+ source.append("window.popupcontrol.show(\"Time\", ");
+ break;
+ case BlackBerry::Platform::InputTypeDateTime:
+ source.append("window.popupcontrol.show(\"DateTime\", ");
+ break;
+ case BlackBerry::Platform::InputTypeDateTimeLocal:
+ source.append("window.popupcontrol.show(\"DateTimeLocal\", ");
+ break;
+ case BlackBerry::Platform::InputTypeMonth:
+ case BlackBerry::Platform::InputTypeWeek:
+ default:
+ break;
+ }
+ if (!value.isEmpty())
+ source.append("\"" + String(value.impl()) + "\", ");
+ else
+ source.append("0, ");
+
+ if (!min.isEmpty())
+ source.append(String(min.impl()) + ", ");
+ else
+ source.append("0, ");
+ if (!max.isEmpty())
+ source.append(String(max.impl()) + ", ");
+ else
+ source.append("0, ");
+ source.append(String::number(step));
+ source.append("); \n }); \n");
+ source.append(timeControlBlackBerryJs, sizeof(timeControlBlackBerryJs));
+ source.append("</script>\n");
+ source.append("</body> </html>\n");
+ m_source = source.toString();
+}
+
+void DatePickerClient::closePopup()
+{
+ ASSERT(m_webPage);
+ m_webPage->m_page->chrome()->client()->closePagePopup(0);
+}
+
+IntSize DatePickerClient::contentSize()
+{
+ // Fixme: will generate content size dynamically
+ return IntSize(320, 256);
+}
+
+String DatePickerClient::htmlSource()
+{
+ return m_source;
+}
+
+void DatePickerClient::setValueAndClosePopup(int, const String& value)
+{
+ // Return -1 if user cancel the selection.
+ ASSERT(m_element);
+
+ if (!value.contains("-1"))
+ m_element->setValue(value);
+ closePopup();
+}
+
+void DatePickerClient::didClosePopup()
+{
+ m_webPage = 0;
+ m_element = 0;
+}
+
+void DatePickerClient::writeDocument(DocumentWriter& writer)
+{
+ writer.setMIMEType("text/html");
+ writer.begin(KURL());
+ writer.addData(m_source.utf8().data(), m_source.utf8().length());
+ writer.end();
+}
+}
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.h (0 => 122364)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/DatePickerClient.h 2012-07-11 20:20:54 UTC (rev 122364)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DatePickerClient_h
+#define DatePickerClient_h
+
+#include "PagePopupClient.h"
+#include <BlackBerryPlatformInputEvents.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+class WebString;
+}
+}
+
+namespace WebCore {
+class DocumentWriter;
+class HTMLInputElement;
+
+class DatePickerClient : public PagePopupClient {
+public:
+ DatePickerClient(BlackBerry::Platform::BlackBerryInputType, const BlackBerry::WebKit::WebString& value, const BlackBerry::WebKit::WebString& min, const BlackBerry::WebKit::WebString& max, double step, BlackBerry::WebKit::WebPagePrivate*, HTMLInputElement*);
+ ~DatePickerClient();
+
+ void generateHTML(BlackBerry::Platform::BlackBerryInputType, const BlackBerry::WebKit::WebString& value, const BlackBerry::WebKit::WebString& min, const BlackBerry::WebKit::WebString& max, double step);
+
+ void writeDocument(DocumentWriter&);
+ virtual IntSize contentSize();
+ virtual String htmlSource();
+ void setValueAndClosePopup(int, const String&);
+ void didClosePopup();
+ void closePopup();
+
+private:
+ BlackBerry::Platform::BlackBerryInputType m_type;
+ String m_source;
+ BlackBerry::WebKit::WebPagePrivate* m_webPage;
+ HTMLInputElement* m_element;
+};
+} // namespace WebCore
+#endif
Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (122363 => 122364)
--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-07-11 20:20:39 UTC (rev 122363)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp 2012-07-11 20:20:54 UTC (rev 122364)
@@ -25,6 +25,7 @@
#include "CString.h"
#include "Chrome.h"
#include "DOMSupport.h"
+#include "DatePickerClient.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "DocumentMarkerController.h"
@@ -495,15 +496,28 @@
if (isActiveTextEdit())
clearCurrentFocusElement();
- m_currentFocusElement = element;
- m_currentFocusElementType = TextPopup;
+ switch (type) {
+ case BlackBerry::Platform::InputTypeDate:
+ case BlackBerry::Platform::InputTypeTime:
+ case BlackBerry::Platform::InputTypeDateTime:
+ case BlackBerry::Platform::InputTypeDateTimeLocal: {
+ // Check if popup already exists, close it if does.
+ m_webPage->m_page->chrome()->client()->closePagePopup(0);
+ String value = element->value();
+ String min = element->getAttribute(HTMLNames::minAttr).string();
+ String max = element->getAttribute(HTMLNames::maxAttr).string();
+ double step = element->getAttribute(HTMLNames::stepAttr).toDouble();
- WTF::String value = element->value();
- WTF::String min = element->getAttribute(HTMLNames::minAttr).string();
- WTF::String max = element->getAttribute(HTMLNames::maxAttr).string();
- double step = element->getAttribute(HTMLNames::stepAttr).toDouble();
- m_webPage->m_client->openDateTimePopup(type, value, min, max, step);
- return true;
+ DatePickerClient* client = new DatePickerClient(type, value, min, max, step, m_webPage, element);
+ // Fail to create HTML popup, use the old path
+ if (!m_webPage->m_page->chrome()->client()->openPagePopup(client, WebCore::IntRect()))
+ m_webPage->m_client->openDateTimePopup(type, value, min, max, step);
+
+ return true;
+ }
+ default: // Other types not supported
+ return false;
+ }
}
bool InputHandler::openColorPopup(HTMLInputElement* element)