Implement <input type=color> UI WebKit chromium part
authorkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 10:37:10 +0000 (10:37 +0000)
committerkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 18 Dec 2011 10:37:10 +0000 (10:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65897

Reviewed by Darin Fisher.

Source/WebCore:

* WebCore.gypi: Added ColorChooser.h and ColorChooserClient.h

Source/WebKit/chromium:

* WebKit.gyp: Added new files.
* features.gypi: Added ENABLE_INPUT_COLOR.
* public/WebColorChooser.h: Added. Interface for ColorChooserProxy to call.
(WebKit::WebColorChooser::~WebColorChooser):
(WebKit::WebColorChooser::setSelectedColor):
(WebKit::WebColorChooser::endChooser):
* public/WebColorChooserClient.h: Added.
(WebKit::WebColorChooserClient::~WebColorChooserClient):
(WebKit::WebColorChooserClient::didChooseColor): Only called when user changes the color.
(WebKit::WebColorChooserClient::didEndChooser): Called when WebColorChooser::endChooser is called.
* public/WebViewClient.h:
(WebKit::WebViewClient::createColorChooser): Creates a new color chooser. If there is an old color chooser, this will end it.
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::createColorChooser): Calls WebViewClient::createColorChooser.
* src/ChromeClientImpl.h:
* src/ColorChooserProxy.cpp: Proxies calls to WebCore::ColorChooser to WebKit::WebColorChooser.
(WebKit::ColorChooserProxy::ColorChooserProxy):
(WebKit::ColorChooserProxy::~ColorChooserProxy):
(WebKit::ColorChooserProxy::setSelectedColor):
(WebKit::ColorChooserProxy::endChooser):
* src/ColorChooserProxy.h:
* src/WebColorChooserClientImpl.cpp: Proxies calls to WebKit::WebColorChooserClient to WebCore::ColorChooserClient.
(WebKit::WebColorChooserClientImpl::WebColorChooserClientImpl):
(WebKit::WebColorChooserClientImpl::~WebColorChooserClientImpl):
(WebKit::WebColorChooserClientImpl::didChooseColor):
(WebKit::WebColorChooserClientImpl::didEndChooser):
* src/WebColorChooserClientImpl.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103169 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/features.gypi
Source/WebKit/chromium/public/WebColorChooser.h [new file with mode: 0644]
Source/WebKit/chromium/public/WebColorChooserClient.h [new file with mode: 0644]
Source/WebKit/chromium/public/WebViewClient.h
Source/WebKit/chromium/src/ChromeClientImpl.cpp
Source/WebKit/chromium/src/ChromeClientImpl.h
Source/WebKit/chromium/src/ColorChooserProxy.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/ColorChooserProxy.h [moved from Source/WebCore/platform/ColorChooser.cpp with 57% similarity]
Source/WebKit/chromium/src/WebColorChooserClientImpl.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebColorChooserClientImpl.h [new file with mode: 0644]

index 929d50e..457034e 100644 (file)
@@ -1,3 +1,12 @@
+2011-12-18  Keishi Hattori  <keishi@webkit.org>
+
+        Implement <input type=color> UI WebKit chromium part
+        https://bugs.webkit.org/show_bug.cgi?id=65897
+
+        Reviewed by Darin Fisher.
+
+        * WebCore.gypi: Added ColorChooser.h and ColorChooserClient.h
+
 2011-12-17  Keishi Hattori  <keishi@webkit.org>
 
         Refactor input type color WebCore part
index 792c633..cfde617 100644 (file)
             'page/mac/WebCoreFrameView.h',
             'platform/AsyncFileStream.h',
             'platform/Clock.h',
+            'platform/ColorChooser.h',
+            'platform/ColorChooserClient.h',
             'platform/ContextMenu.h',
             'platform/ContextMenuItem.h',
             'platform/Cookie.h',
index 6acb75f..142cf3f 100644 (file)
@@ -1,3 +1,38 @@
+2011-12-18  Keishi Hattori  <keishi@webkit.org>
+
+        Implement <input type=color> UI WebKit chromium part
+        https://bugs.webkit.org/show_bug.cgi?id=65897
+
+        Reviewed by Darin Fisher.
+
+        * WebKit.gyp: Added new files.
+        * features.gypi: Added ENABLE_INPUT_COLOR.
+        * public/WebColorChooser.h: Added. Interface for ColorChooserProxy to call.
+        (WebKit::WebColorChooser::~WebColorChooser):
+        (WebKit::WebColorChooser::setSelectedColor):
+        (WebKit::WebColorChooser::endChooser):
+        * public/WebColorChooserClient.h: Added.
+        (WebKit::WebColorChooserClient::~WebColorChooserClient):
+        (WebKit::WebColorChooserClient::didChooseColor): Only called when user changes the color.
+        (WebKit::WebColorChooserClient::didEndChooser): Called when WebColorChooser::endChooser is called.
+        * public/WebViewClient.h:
+        (WebKit::WebViewClient::createColorChooser): Creates a new color chooser. If there is an old color chooser, this will end it.
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::createColorChooser): Calls WebViewClient::createColorChooser.
+        * src/ChromeClientImpl.h:
+        * src/ColorChooserProxy.cpp: Proxies calls to WebCore::ColorChooser to WebKit::WebColorChooser.
+        (WebKit::ColorChooserProxy::ColorChooserProxy):
+        (WebKit::ColorChooserProxy::~ColorChooserProxy):
+        (WebKit::ColorChooserProxy::setSelectedColor):
+        (WebKit::ColorChooserProxy::endChooser):
+        * src/ColorChooserProxy.h:
+        * src/WebColorChooserClientImpl.cpp: Proxies calls to WebKit::WebColorChooserClient to WebCore::ColorChooserClient.
+        (WebKit::WebColorChooserClientImpl::WebColorChooserClientImpl):
+        (WebKit::WebColorChooserClientImpl::~WebColorChooserClientImpl):
+        (WebKit::WebColorChooserClientImpl::didChooseColor):
+        (WebKit::WebColorChooserClientImpl::didEndChooser):
+        * src/WebColorChooserClientImpl.h: Added.
+
 2011-12-17  Sam Weinig  <sam@webkit.org>
 
         Make PlatformTouchEvent inherit from PlatformEvent
index f65fdc9..3fccca5 100644 (file)
                 'public/WebBindings.h',
                 'public/WebBlob.h',
                 'public/WebCache.h',
+                'public/WebColorChooser.h',
+                'public/WebColorChooserClient.h',
                 'public/WebCommonWorkerClient.h',
                 'public/WebCompositionUnderline.h',
                 'public/WebCompositor.h',
                 'src/CCThreadImpl.h',
                 'src/ChromeClientImpl.cpp',
                 'src/ChromeClientImpl.h',
+                'src/ColorChooserProxy.cpp',
+                'src/ColorChooserProxy.h',
                 'src/ChromiumCurrentTime.cpp',
                 'src/ChromiumOSRandomSource.cpp',
                 'src/ChromiumThreading.cpp',
                 'src/WebBlobData.cpp',
                 'src/WebCache.cpp',
                 'src/WebColor.cpp',
+                'src/WebColorChooserClientImpl.cpp',
+                'src/WebColorChooserClientImpl.h',
                 'src/WebCommon.cpp',
                 'src/WebCompositorImpl.cpp',
                 'src/WebCompositorImpl.h',
index 0eb9de9..387e460 100644 (file)
@@ -53,6 +53,7 @@
       'ENABLE_GESTURE_RECOGNIZER=1',
       'ENABLE_ICONDATABASE=0',
       'ENABLE_INDEXED_DATABASE=1',
+      'ENABLE_INPUT_COLOR=0',
       'ENABLE_INPUT_SPEECH=1',
       'ENABLE_INPUT_TYPE_COLOR=0',
       'ENABLE_INPUT_TYPE_DATE=0',
diff --git a/Source/WebKit/chromium/public/WebColorChooser.h b/Source/WebKit/chromium/public/WebColorChooser.h
new file mode 100644 (file)
index 0000000..057f66e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 WebColorChooser_h
+#define WebColorChooser_h
+
+#include "platform/WebColor.h"
+#include "platform/WebCommon.h"
+
+namespace WebKit {
+
+// This represents a color chooser.
+class WebColorChooser {
+public:
+    virtual ~WebColorChooser() { }
+
+    // Set selected color in the color chooser.
+    virtual void setSelectedColor(const WebColor color) { }
+
+    // Calling this ends the color chooser and the client won't be recieving
+    // didChooseColor callbacks anymore.
+    virtual void endChooser() { }
+};
+
+}
+
+#endif // WebColorChooser_h
diff --git a/Source/WebKit/chromium/public/WebColorChooserClient.h b/Source/WebKit/chromium/public/WebColorChooserClient.h
new file mode 100644 (file)
index 0000000..a80a984
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 WebColorChooserClient_h
+#define WebColorChooserClient_h
+
+#include "platform/WebColor.h"
+#include "platform/WebCommon.h"
+
+namespace WebKit {
+
+// Receives calls from WebColorChooser and passes it to the WebCore side.
+class WebColorChooserClient {
+public:
+    virtual ~WebColorChooserClient() { }
+
+    // Called when user selects a color in the color chooser.
+    virtual void didChooseColor(const WebColor&) { }
+
+    // Called when color chooser has ended.
+    virtual void didEndChooser() { }
+};
+
+}
+
+#endif // WebColorChooserClient_h
index 039d49d..5a4d4e8 100644 (file)
 #include "WebTextAffinity.h"
 #include "WebTextDirection.h"
 #include "WebWidgetClient.h"
+#include "platform/WebColor.h"
 #include "platform/WebString.h"
 
 namespace WebKit {
 
 class WebAccessibilityObject;
+class WebColorChooser;
+class WebColorChooserClient;
 class WebDeviceOrientationClient;
 class WebDragData;
 class WebElement;
@@ -177,9 +180,15 @@ public:
     // indicating that the default action should be suppressed.
     virtual bool handleCurrentKeyboardEvent() { return false; }
 
-
     // Dialogs -------------------------------------------------------------
 
+    // This method opens the color chooser and returns a new WebColorChooser
+    // instance. If there is a WebColorChooser already from the last time this
+    // was called, it ends the color chooser by calling endChooser, and replaces
+    // it with the new one.
+    virtual WebColorChooser* createColorChooser(WebColorChooserClient*,
+                                                const WebColor&) { return 0; }
+
     // This method returns immediately after showing the dialog. When the
     // dialog is closed, it should call the WebFileChooserCompletion to
     // pass the results of the dialog. Returns false if
index 7ddbfac..6ba8366 100644 (file)
 
 #include "AXObjectCache.h"
 #include "AccessibilityObject.h"
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#include "ColorChooserClient.h"
+#include "ColorChooserProxy.h"
+#endif
 #include "Console.h"
 #include "Cursor.h"
 #include "DatabaseTracker.h"
 #include "V8Proxy.h"
 #endif
 #include "WebAccessibilityObject.h"
+#if ENABLE(INPUT_COLOR)
+#include "WebColorChooser.h"
+#include "WebColorChooserClientImpl.h"
+#endif
 #include "WebConsoleMessage.h"
 #include "WebCursorInfo.h"
 #include "WebFileChooserCompletionImpl.h"
@@ -675,6 +684,21 @@ void ChromeClientImpl::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64
     ASSERT_NOT_REACHED();
 }
 
+#if ENABLE(INPUT_COLOR)
+PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient* chooserClient, const Color& initialColor)
+{
+    WebViewClient* client = m_webView->client();
+    if (!client)
+        return nullptr;
+    WebColorChooserClientImpl* chooserClientProxy = new WebColorChooserClientImpl(chooserClient);
+    WebColor webColor = static_cast<WebColor>(initialColor.rgb());
+    WebColorChooser* chooser = client->createColorChooser(chooserClientProxy, webColor);
+    if (!chooser)
+        return nullptr;
+    return adoptPtr(new ColorChooserProxy(adoptPtr(chooser)));
+}
+#endif
+
 void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
 {
     WebViewClient* client = m_webView->client();
index 1ca1294..2113ec1 100644 (file)
 
 namespace WebCore {
 class AccessibilityObject;
+#if ENABLE(INPUT_COLOR)
+class ColorChooser;
+class ColorChooserClient;
+#endif
 class Element;
 class FileChooser;
 class PopupContainer;
@@ -134,6 +138,9 @@ public:
     virtual bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&);
     virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*);
     virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*);
+#if ENABLE(INPUT_COLOR)
+    virtual PassOwnPtr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient*, const WebCore::Color&) OVERRIDE;
+#endif
     virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
     virtual void loadIconForFiles(const Vector<WTF::String>&, WebCore::FileIconLoader*);
 #if ENABLE(DIRECTORY_UPLOAD)
diff --git a/Source/WebKit/chromium/src/ColorChooserProxy.cpp b/Source/WebKit/chromium/src/ColorChooserProxy.cpp
new file mode 100644 (file)
index 0000000..dae1b12
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+#include "config.h"
+#include "ColorChooserProxy.h"
+
+#include "Color.h"
+#include "WebColorChooser.h"
+#include "platform/WebColor.h"
+
+#if ENABLE(INPUT_COLOR)
+
+namespace WebKit {
+
+ColorChooserProxy::ColorChooserProxy(PassOwnPtr<WebColorChooser> chooser) : m_chooser(chooser)
+{
+}
+
+ColorChooserProxy::~ColorChooserProxy()
+{
+}
+
+void ColorChooserProxy::setSelectedColor(const WebCore::Color& color)
+{
+    if (!m_chooser)
+        return;
+    WebColor webColor = static_cast<WebColor>(color.rgb());
+    m_chooser->setSelectedColor(webColor);
+}
+
+void ColorChooserProxy::endChooser()
+{
+    if (!m_chooser)
+        return;
+    m_chooser->endChooser();
+}
+
+}
+
+#endif // ENABLE(INPUT_COLOR)
similarity index 57%
rename from Source/WebCore/platform/ColorChooser.cpp
rename to Source/WebKit/chromium/src/ColorChooserProxy.h
index 173f3f8..56a9980 100644 (file)
@@ -6,13 +6,10 @@
  * are met:
  *
  * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
+ *     notice, this list of conditions and the following disclaimer.
  * 2.  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. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
+ *     documentation and/or other materials provided with the distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * 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.
- *
  */
 
-#include "config.h"
-#include "ColorChooser.h"
+#ifndef ColorChooserProxy_h
+#define ColorChooserProxy_h
 
+#include "ColorChooser.h"
+#include "WebColorChooser.h"
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 #if ENABLE(INPUT_COLOR)
 
-namespace WebCore {
-
-ColorChooserClient::~ColorChooserClient()
-{
-    discardChooser();
-}
-
-ColorChooser* ColorChooserClient::newColorChooser()
-{
-    discardChooser();
+namespace WebKit {
 
-    m_chooser = ColorChooser::create(this);
-    return m_chooser.get();
-}
+class ColorChooserProxy : public WebCore::ColorChooser {
+public:
+    ColorChooserProxy(PassOwnPtr<WebColorChooser>);
+    virtual ~ColorChooserProxy();
 
-void ColorChooserClient::discardChooser()
-{
-    if (m_chooser)
-        m_chooser->disconnectClient();
-    m_chooser.clear();
-}
+    virtual void setSelectedColor(const WebCore::Color&);
+    virtual void endChooser();
 
-inline ColorChooser::ColorChooser(ColorChooserClient* client)
-    : m_client(client)
-{
-}
+private:
+    OwnPtr<WebColorChooser> m_chooser;
+};
 
-PassRefPtr<ColorChooser> ColorChooser::create(ColorChooserClient* client)
-{
-    return adoptRef(new ColorChooser(client));
-}
-
-ColorChooser::~ColorChooser()
-{
-}
-
-void ColorChooser::didChooseColor(const Color& color)
-{
-    if (m_client)
-        m_client->didChooseColor(color);
-}
-
-void ColorChooser::didCleanup()
-{
-    if (m_client)
-        m_client->didCleanup();
-}
-
-}
+} // namespace WebKit
 
 #endif // ENABLE(INPUT_COLOR)
+
+#endif // ColorChooserProxy_h
diff --git a/Source/WebKit/chromium/src/WebColorChooserClientImpl.cpp b/Source/WebKit/chromium/src/WebColorChooserClientImpl.cpp
new file mode 100644 (file)
index 0000000..c4f8e69
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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.
+ */
+
+#include "config.h"
+#include "WebColorChooserClientImpl.h"
+
+#include "Color.h"
+#include "ColorChooserClient.h"
+
+#if ENABLE(INPUT_COLOR)
+
+namespace WebKit {
+
+WebColorChooserClientImpl::WebColorChooserClientImpl(WebCore::ColorChooserClient* client) : m_client(client)
+{
+}
+
+WebColorChooserClientImpl::~WebColorChooserClientImpl()
+{
+}
+
+void WebColorChooserClientImpl::didChooseColor(const WebColor& color)
+{
+    if (!m_client)
+        return;
+    m_client->didChooseColor(WebCore::Color(static_cast<WebCore::RGBA32>(color)));
+}
+
+void WebColorChooserClientImpl::didEndChooser()
+{
+    if (!m_client)
+        return;
+    m_client->didEndChooser();
+}
+
+}
+
+#endif // ENABLE(INPUT_COLOR)
diff --git a/Source/WebKit/chromium/src/WebColorChooserClientImpl.h b/Source/WebKit/chromium/src/WebColorChooserClientImpl.h
new file mode 100644 (file)
index 0000000..bf735d8
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS 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 APPLE OR ITS 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 WebColorChooserClientImpl_h
+#define WebColorChooserClientImpl_h
+
+#include "WebColorChooserClient.h"
+
+#if ENABLE(INPUT_COLOR)
+
+namespace WebCore {
+class ColorChooserClient;
+}
+
+namespace WebKit {
+
+class WebColorChooserClientImpl : public WebColorChooserClient {
+public:
+    WebColorChooserClientImpl(WebCore::ColorChooserClient*);
+    virtual ~WebColorChooserClientImpl();
+
+    virtual void didChooseColor(const WebColor&) OVERRIDE;
+    virtual void didEndChooser() OVERRIDE;
+
+private:
+    WebCore::ColorChooserClient* m_client;
+};
+
+}
+
+#endif // ENABLE(INPUT_COLOR)
+
+#endif // WebColorChooserClientImpl_h