Diff
Modified: trunk/Source/WebCore/ChangeLog (92591 => 92592)
--- trunk/Source/WebCore/ChangeLog 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/ChangeLog 2011-08-08 12:44:33 UTC (rev 92592)
@@ -1,3 +1,59 @@
+2011-08-08 Keishi Hattori <[email protected]>
+
+ Implement <input type=color> UI behavior WebCore part
+ https://bugs.webkit.org/show_bug.cgi?id=62619
+
+ Reviewed by Kent Tamura.
+
+ * WebCore.exp.in: Added __ZN7WebCore12ColorChooser7chooserEv and
+ __ZNK7WebCore12ColorChooser13colorSelectedERKNS_5ColorE
+ * WebCore.xcodeproj/project.pbxproj: Added ColorChooser.{h,cpp}
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::~ColorInputType): Added. Close color chooser. ex. when type attribute changes.
+ (WebCore::ColorInputType::valueAsColor): Added.
+ (WebCore::ColorInputType::setValueAsColor): Added.
+ (WebCore::ColorInputType::valueChanged): Update selected color in color chooser too.
+ (WebCore::ColorInputType::handleClickEvent): Opens color chooser.
+ (WebCore::ColorInputType::handleDOMActivateEvent): Called when element.click(). Open color chooser only
+ when it was initiated by a user interaction.
+ (WebCore::ColorInputType::detach): Close color chooser. Called when input element or its ancestors have "display:none"
+ or is removed from DOM.
+ (WebCore::ColorInputType::colorSelected): Callback from color chooser.
+ (WebCore::ColorInputType::isColorInputType): Returns true.
+ (WebCore::ColorInputType::closeColorChooserIfCurrentClient): Close color chooser if this input type is the current client of ColorChooser.
+ * html/ColorInputType.h:
+ * html/FileInputType.cpp:
+ * html/FileInputType.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::detach): Calls InputType::detach
+ * html/InputType.cpp:
+ (WebCore::InputType::chrome): Added. Used in FileInputType and ColorInputType.
+ (WebCore::InputType::detach): ColorInputType overrides this.
+ * html/InputType.h:
+ * loader/EmptyClients.h:
+ (WebCore::EmptyChromeClient::openColorChooser):
+ (WebCore::EmptyChromeClient::closeColorChooser):
+ (WebCore::EmptyChromeClient::setSelectedColorInColorChooser):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::transitionToCommitted): Close color chooser when navigating away from the page. We do this here
+ because ColorInputType::detach() is called seconds after the page transition so it is too slow.
+ * page/Chrome.cpp:
+ (WebCore::Chrome::openColorChooser): Added.
+ (WebCore::Chrome::closeColorChooser): Added.
+ (WebCore::Chrome::setSelectedColorInColorChooser): Added.
+ * page/Chrome.h:
+ * page/ChromeClient.h:
+ * platform/ColorChooser.cpp: Added.
+ (WebCore::ColorChooserClient::~ColorChooserClient): Disconnects itself from the ColorChooser.
+ (WebCore::ColorChooser::chooser): Get shared instance of ColorChooser.
+ (WebCore::ColorChooser::connectClient): Connects a ColorChooserClient that receives the colorSelected callbacks.
+ (WebCore::ColorChooser::disconnectClient): Disconnects the connectClient.
+ (WebCore::ColorChooser::colorSelected): Called from color chooser listener.
+ * platform/ColorChooser.h: Added.
+ (WebCore::ColorChooserClient::isColorInputType): Added.
+ (WebCore::ColorChooser::client): Added. Returns the current connected client.
+ (WebCore::ColorChooser::ColorChooser): Added.
+
2011-08-08 Shinya Kawanaka <[email protected]>
The input[type=number] element should be as wide as necessary to show the widest possible value.
Modified: trunk/Source/WebCore/WebCore.exp.in (92591 => 92592)
--- trunk/Source/WebCore/WebCore.exp.in 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-08-08 12:44:33 UTC (rev 92592)
@@ -1939,3 +1939,8 @@
__ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString
__ZN7WebCore14ResourceHandle12releaseProxyEv
#endif
+
+#if ENABLE(INPUT_COLOR)
+__ZN7WebCore12ColorChooser7chooserEv
+__ZNK7WebCore12ColorChooser13colorSelectedERKNS_5ColorE
+#endif
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (92591 => 92592)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-08-08 12:44:33 UTC (rev 92592)
@@ -5331,6 +5331,8 @@
C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */ = {isa = PBXBuildFile; fileRef = C0F2A43F13869A280066C534 /* preprocessor.pm */; settings = {ATTRIBUTES = (Private, ); }; };
C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
+ C330A22213EC196B0000B45B /* ColorChooser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C330A22013EC196B0000B45B /* ColorChooser.cpp */; };
+ C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; };
C50B561712119D23008B46E0 /* GroupSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = C50B561512119D23008B46E0 /* GroupSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
C50D0E820FF4272900AC2644 /* StorageNamespace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */; };
@@ -12037,6 +12039,8 @@
C0F2A43F13869A280066C534 /* preprocessor.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = preprocessor.pm; path = scripts/preprocessor.pm; sourceTree = "<group>"; };
C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEncodingDetectorICU.cpp; sourceTree = "<group>"; };
C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; };
+ C330A22013EC196B0000B45B /* ColorChooser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColorChooser.cpp; sourceTree = "<group>"; };
+ C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; };
C50B561512119D23008B46E0 /* GroupSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupSettings.h; sourceTree = "<group>"; };
C50D0E800FF4272900AC2644 /* StorageNamespace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageNamespace.cpp; sourceTree = "<group>"; };
@@ -19025,6 +19029,8 @@
89D08D9D12228451001241DF /* AsyncFileSystem.h */,
89D08D9E12228451001241DF /* AsyncFileSystemCallbacks.h */,
51E1ECB10C91C55600DC255B /* AutodrainedPool.h */,
+ C330A22013EC196B0000B45B /* ColorChooser.cpp */,
+ C330A22113EC196B0000B45B /* ColorChooser.h */,
BCC8CFCA0986CD2400140BF2 /* ColorData.gperf */,
41D015C90F4B5C71004A662F /* ContentType.cpp */,
41D015C80F4B5C71004A662F /* ContentType.h */,
@@ -20521,6 +20527,7 @@
93C441F00F813A1A00C1A634 /* CollectionCache.h in Headers */,
93C442000F813AE100C1A634 /* CollectionType.h in Headers */,
B27535670B053814002CE64F /* Color.h in Headers */,
+ C330A22313EC196B0000B45B /* ColorChooser.h in Headers */,
B22279630D00BF220071B782 /* ColorDistance.h in Headers */,
F55B3DB41251F12D003EF269 /* ColorInputType.h in Headers */,
EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */,
@@ -23816,6 +23823,7 @@
93C441EF0F813A1A00C1A634 /* CollectionCache.cpp in Sources */,
B27535660B053814002CE64F /* Color.cpp in Sources */,
0FCF33240F2B9715004B6795 /* ColorCG.cpp in Sources */,
+ C330A22213EC196B0000B45B /* ColorChooser.cpp in Sources */,
1ABA76C911D20E47004C201C /* ColorData.cpp in Sources */,
B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */,
F55B3DB31251F12D003EF269 /* ColorInputType.cpp in Sources */,
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (92591 => 92592)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -31,9 +31,12 @@
#include "config.h"
#include "ColorInputType.h"
+#include "Chrome.h"
#include "Color.h"
#include "HTMLDivElement.h"
#include "HTMLInputElement.h"
+#include "MouseEvent.h"
+#include "ScriptController.h"
#include "ShadowRoot.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h>
@@ -61,6 +64,11 @@
return adoptPtr(new ColorInputType(element));
}
+ColorInputType::~ColorInputType()
+{
+ closeColorChooserIfCurrentClient();
+}
+
bool ColorInputType::isColorControl() const
{
return true;
@@ -92,6 +100,16 @@
return proposedValue.lower();
}
+Color ColorInputType::valueAsColor() const
+{
+ return Color(element()->value());
+}
+
+void ColorInputType::setValueAsColor(const Color& color) const
+{
+ element()->setValue(color.serialized(), true);
+}
+
void ColorInputType::createShadowSubtree()
{
Document* document = element()->document();
@@ -111,8 +129,59 @@
void ColorInputType::valueChanged()
{
updateColorSwatch();
+ if (ColorChooser::chooser()->client() == this) {
+ if (Chrome* chrome = this->chrome())
+ chrome->setSelectedColorInColorChooser(valueAsColor());
+ }
}
+void ColorInputType::handleClickEvent(MouseEvent* event)
+{
+ if (event->isSimulated())
+ return;
+
+ if (element()->disabled() || element()->readOnly())
+ return;
+
+ if (Chrome* chrome = this->chrome()) {
+ ColorChooser::chooser()->connectClient(this);
+ chrome->openColorChooser(ColorChooser::chooser(), valueAsColor());
+ }
+ event->setDefaultHandled();
+}
+
+void ColorInputType::handleDOMActivateEvent(Event* event)
+{
+ if (element()->disabled() || element()->readOnly() || !element()->renderer())
+ return;
+
+ if (!ScriptController::processingUserGesture())
+ return;
+
+ if (Chrome* chrome = this->chrome()) {
+ ColorChooser::chooser()->connectClient(this);
+ chrome->openColorChooser(ColorChooser::chooser(), valueAsColor());
+ }
+ event->setDefaultHandled();
+}
+
+void ColorInputType::detach()
+{
+ closeColorChooserIfCurrentClient();
+}
+
+void ColorInputType::colorSelected(const Color& color)
+{
+ if (element()->disabled() || element()->readOnly())
+ return;
+ setValueAsColor(color);
+}
+
+bool ColorInputType::isColorInputType() const
+{
+ return true;
+}
+
void ColorInputType::updateColorSwatch()
{
HTMLElement* colorSwatch = shadowColorSwatch();
@@ -129,6 +198,14 @@
return shadow ? toHTMLElement(shadow->firstChild()->firstChild()) : 0;
}
+void ColorInputType::closeColorChooserIfCurrentClient() const
+{
+ if (ColorChooser::chooser()->client() != this)
+ return;
+ if (Chrome* chrome = this->chrome())
+ chrome->closeColorChooser();
+}
+
} // namespace WebCore
#endif // ENABLE(INPUT_COLOR)
Modified: trunk/Source/WebCore/html/ColorInputType.h (92591 => 92592)
--- trunk/Source/WebCore/html/ColorInputType.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/ColorInputType.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -31,16 +31,20 @@
#ifndef ColorInputType_h
#define ColorInputType_h
-#include "BaseButtonInputType.h"
+#include "ColorChooser.h"
+#include "InputType.h"
#if ENABLE(INPUT_COLOR)
namespace WebCore {
-class ColorInputType : public InputType {
+class ColorInputType : public InputType, public ColorChooserClient {
public:
static PassOwnPtr<InputType> create(HTMLInputElement*);
+ virtual ~ColorInputType();
+ void closeColorChooserIfCurrentClient() const;
+
private:
ColorInputType(HTMLInputElement* element) : InputType(element) { }
virtual bool isColorControl() const;
@@ -48,9 +52,18 @@
virtual bool supportsRequired() const;
virtual String fallbackValue();
virtual String sanitizeValue(const String&);
+ virtual Color valueAsColor() const;
+ virtual void setValueAsColor(const Color&) const;
virtual void createShadowSubtree();
virtual void valueChanged();
+ virtual void handleClickEvent(MouseEvent*);
+ virtual void handleDOMActivateEvent(Event*);
+ virtual void detach();
+ // ColorChooserClient implementation.
+ virtual void colorSelected(const Color&);
+ virtual bool isColorInputType() const;
+
void updateColorSwatch();
HTMLElement* shadowColorSwatch() const;
};
Modified: trunk/Source/WebCore/html/FileInputType.cpp (92591 => 92592)
--- trunk/Source/WebCore/html/FileInputType.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/FileInputType.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -33,7 +33,6 @@
#include "HTMLNames.h"
#include "Icon.h"
#include "LocalizedStrings.h"
-#include "Page.h"
#include "RenderFileUploadControl.h"
#include "ScriptController.h"
#include "ShadowRoot.h"
@@ -333,13 +332,6 @@
element()->renderer()->repaint();
}
-Chrome* FileInputType::chrome() const
-{
- if (Page* page = element()->document()->page())
- return page->chrome();
- return 0;
-}
-
void FileInputType::receiveDroppedFiles(const Vector<String>& paths)
{
HTMLInputElement* input = element();
Modified: trunk/Source/WebCore/html/FileInputType.h (92591 => 92592)
--- trunk/Source/WebCore/html/FileInputType.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/FileInputType.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -39,7 +39,6 @@
namespace WebCore {
-class Chrome;
class FileList;
class FileInputType : public BaseButtonInputType, private FileChooserClient, private FileIconLoaderClient {
@@ -77,7 +76,6 @@
void receiveDropForDirectoryUpload(const Vector<String>&);
#endif
void requestIcon(const Vector<String>&);
- Chrome* chrome() const;
RefPtr<FileList> m_fileList;
RefPtr<Icon> m_icon;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (92591 => 92592)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -887,6 +887,7 @@
{
HTMLTextFormControlElement::detach();
setFormControlValueMatchesRenderer(false);
+ m_inputType->detach();
}
String HTMLInputElement::altText() const
Modified: trunk/Source/WebCore/html/InputType.cpp (92591 => 92592)
--- trunk/Source/WebCore/html/InputType.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/InputType.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -48,6 +48,7 @@
#include "LocalizedStrings.h"
#include "MonthInputType.h"
#include "NumberInputType.h"
+#include "Page.h"
#include "PasswordInputType.h"
#include "RadioInputType.h"
#include "RangeInputType.h"
@@ -401,6 +402,13 @@
event->setDefaultHandled();
}
+Chrome* InputType::chrome() const
+{
+ if (Page* page = element()->document()->page())
+ return page->chrome();
+ return 0;
+}
+
bool InputType::canSetStringValue() const
{
return true;
@@ -429,6 +437,10 @@
{
}
+void InputType::detach()
+{
+}
+
void InputType::altAttributeChanged()
{
}
Modified: trunk/Source/WebCore/html/InputType.h (92591 => 92592)
--- trunk/Source/WebCore/html/InputType.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/html/InputType.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -41,6 +41,8 @@
namespace WebCore {
class BeforeTextInsertedEvent;
+class Chrome;
+class Color;
class DateComponents;
class Event;
class FileList;
@@ -91,7 +93,7 @@
#if ENABLE(INPUT_COLOR)
virtual bool isColorControl() const;
-#endif // ENABLE(INPUT_COLOR)
+#endif
virtual bool isCheckbox() const;
virtual bool isEmailField() const;
virtual bool isFileUpload() const;
@@ -206,6 +208,7 @@
virtual bool rendererIsNeeded();
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const;
virtual void attach();
+ virtual void detach();
virtual void minOrMaxAttributeChanged();
virtual void stepAttributeChanged();
virtual void altAttributeChanged();
@@ -262,6 +265,7 @@
void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
// We can't make this a static const data member because VC++ doesn't like it.
static double defaultStepBase() { return 0.0; }
+ Chrome* chrome() const;
private:
// Raw pointer because the HTMLInputElement object owns this InputType object.
Modified: trunk/Source/WebCore/loader/EmptyClients.h (92591 => 92592)
--- trunk/Source/WebCore/loader/EmptyClients.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/loader/EmptyClients.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -195,6 +195,12 @@
virtual void enumerateChosenDirectory(FileChooser*) { }
#endif
+#if ENABLE(INPUT_COLOR)
+ void openColorChooser(ColorChooser*, const Color&) { }
+ void closeColorChooser() { }
+ void setSelectedColorInColorChooser(const Color&) { }
+#endif
+
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) { }
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (92591 => 92592)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -100,6 +100,11 @@
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#include "ColorInputType.h"
+#endif
+
#if ENABLE(SHARED_WORKERS)
#include "SharedWorkerRepository.h"
#endif
@@ -1816,6 +1821,12 @@
if (m_frame->view())
m_frame->view()->scrollAnimator()->cancelAnimations();
+#if ENABLE(INPUT_COLOR)
+ ColorChooserClient* colorChooserClient = ColorChooser::chooser()->client();
+ if (colorChooserClient && colorChooserClient->isColorInputType())
+ static_cast<ColorInputType*>(colorChooserClient)->closeColorChooserIfCurrentClient();
+#endif
+
m_client->setCopiesOnScroll();
history()->updateForCommit();
Modified: trunk/Source/WebCore/page/Chrome.cpp (92591 => 92592)
--- trunk/Source/WebCore/page/Chrome.cpp 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/page/Chrome.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -52,6 +52,10 @@
#include "StorageNamespace.h"
#endif
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#endif
+
namespace WebCore {
using namespace HTMLNames;
@@ -467,6 +471,23 @@
}
#endif
+#if ENABLE(INPUT_COLOR)
+void Chrome::openColorChooser(ColorChooser* colorChooser, const Color& initialColor)
+{
+ m_client->openColorChooser(colorChooser, initialColor);
+}
+
+void Chrome::closeColorChooser()
+{
+ m_client->closeColorChooser();
+}
+
+void Chrome::setSelectedColorInColorChooser(const Color& color)
+{
+ m_client->setSelectedColorInColorChooser(color);
+}
+#endif
+
void Chrome::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
{
m_client->runOpenPanel(frame, fileChooser);
Modified: trunk/Source/WebCore/page/Chrome.h (92591 => 92592)
--- trunk/Source/WebCore/page/Chrome.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/page/Chrome.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -36,6 +36,9 @@
namespace WebCore {
class ChromeClient;
+#if ENABLE(INPUT_COLOR)
+ class ColorChooser;
+#endif
class FileChooser;
class FileIconLoader;
class FloatRect;
@@ -154,6 +157,12 @@
void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
+#if ENABLE(INPUT_COLOR)
+ void openColorChooser(ColorChooser*, const Color&);
+ void closeColorChooser();
+ void setSelectedColorInColorChooser(const Color&);
+#endif
+
void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
void loadIconForFiles(const Vector<String>&, FileIconLoader*);
#if ENABLE(DIRECTORY_UPLOAD)
Modified: trunk/Source/WebCore/page/ChromeClient.h (92591 => 92592)
--- trunk/Source/WebCore/page/ChromeClient.h 2011-08-08 12:16:58 UTC (rev 92591)
+++ trunk/Source/WebCore/page/ChromeClient.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -71,6 +71,10 @@
class GraphicsLayer;
#endif
+#if ENABLE(INPUT_COLOR)
+ class ColorChooser;
+#endif
+
#if ENABLE(NOTIFICATIONS)
class NotificationPresenter;
#endif
@@ -231,6 +235,12 @@
virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
+#if ENABLE(INPUT_COLOR)
+ virtual void openColorChooser(ColorChooser*, const Color&) = 0;
+ virtual void closeColorChooser() = 0;
+ virtual void setSelectedColorInColorChooser(const Color&) = 0;
+#endif
+
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
// Asynchronous request to load an icon for specified filenames.
virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
Added: trunk/Source/WebCore/platform/ColorChooser.cpp (0 => 92592)
--- trunk/Source/WebCore/platform/ColorChooser.cpp (rev 0)
+++ trunk/Source/WebCore/platform/ColorChooser.cpp 2011-08-08 12:44:33 UTC (rev 92592)
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ * 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.
+ *
+ * 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 "ColorChooser.h"
+
+#include <wtf/PassOwnPtr.h>
+
+#if ENABLE(INPUT_COLOR)
+
+namespace WebCore {
+
+ColorChooserClient::~ColorChooserClient()
+{
+ ColorChooser::chooser()->disconnectClient(this);
+}
+
+static ColorChooser* staticChooser = 0;
+
+ColorChooser* ColorChooser::chooser()
+{
+ if (!staticChooser)
+ staticChooser = adoptPtr(new ColorChooser()).leakPtr();
+ return staticChooser;
+}
+
+void ColorChooser::connectClient(ColorChooserClient* client)
+{
+ if (client != m_client)
+ m_client = client;
+}
+
+void ColorChooser::disconnectClient(ColorChooserClient* client)
+{
+ if (client == m_client)
+ m_client = 0;
+}
+
+void ColorChooser::colorSelected(const Color& color) const
+{
+ if (m_client)
+ m_client->colorSelected(color);
+}
+
+}
+
+#endif // ENABLE(INPUT_COLOR)
Added: trunk/Source/WebCore/platform/ColorChooser.h (0 => 92592)
--- trunk/Source/WebCore/platform/ColorChooser.h (rev 0)
+++ trunk/Source/WebCore/platform/ColorChooser.h 2011-08-08 12:44:33 UTC (rev 92592)
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ * 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.
+ *
+ * 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 ColorChooser_h
+#define ColorChooser_h
+
+#include "Color.h"
+
+#if ENABLE(INPUT_COLOR)
+
+namespace WebCore {
+
+class ColorChooser;
+
+class ColorChooserClient {
+public:
+ virtual ~ColorChooserClient();
+ virtual void colorSelected(const Color&) = 0;
+ virtual bool isColorInputType() const { return false; }
+};
+
+class ColorChooser {
+public:
+ static ColorChooser* chooser();
+
+ ColorChooserClient* client() const { return m_client; };
+ void connectClient(ColorChooserClient*);
+ void disconnectClient(ColorChooserClient*);
+
+ void colorSelected(const Color&) const;
+
+private:
+ ColorChooser()
+ : m_client(0)
+ { }
+
+ ColorChooserClient* m_client;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INPUT_COLOR)
+
+#endif // ColorChooser_h