Diff
Modified: trunk/LayoutTests/ChangeLog (94157 => 94158)
--- trunk/LayoutTests/ChangeLog 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/LayoutTests/ChangeLog 2011-08-31 08:08:29 UTC (rev 94158)
@@ -1,3 +1,13 @@
+2011-08-31 Keishi Hattori <[email protected]>
+
+ input color: onchange event is not fired when changing color from color chooser
+ https://bugs.webkit.org/show_bug.cgi?id=66848
+
+ Reviewed by Kent Tamura.
+
+ * fast/forms/color/input-color-onchange-event-expected.txt: Added.
+ * fast/forms/color/input-color-onchange-event.html: Added. Tests if change event is fired when user selects color from color chooser.
+
2011-08-31 Philippe Normand <[email protected]>
Unreviewed, GTK rebaseline after r94147.
Added: trunk/LayoutTests/fast/forms/color/input-color-onchange-event-expected.txt (0 => 94158)
--- trunk/LayoutTests/fast/forms/color/input-color-onchange-event-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/color/input-color-onchange-event-expected.txt 2011-08-31 08:08:29 UTC (rev 94158)
@@ -0,0 +1,8 @@
+Test if change event fires properly when color chooser changes. Bug 66848
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+value changed to #ff0000
+PASS input.value is "#ff0000"
+
Added: trunk/LayoutTests/fast/forms/color/input-color-onchange-event.html (0 => 94158)
--- trunk/LayoutTests/fast/forms/color/input-color-onchange-event.html (rev 0)
+++ trunk/LayoutTests/fast/forms/color/input-color-onchange-event.html 2011-08-31 08:08:29 UTC (rev 94158)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test if change event fires properly when color chooser changes. Bug 66848');
+
+var input = document.createElement('input');
+input.type = 'color';
+input.value = '#000000';
+input._onchange_ = function() {
+ debug("value changed to " + input.value);
+ finishJSTest();
+};
+if (!internals.connectColorChooserClient(input))
+ testFailed("Could not connect ColorChooserClient.");
+internals.selectColorInColorChooser('#ff0000');
+// input.onchange should be called
+internals.selectColorInColorChooser('#ff0000');
+// input.onchange should not be called
+shouldBe('input.value', '"#ff0000"');
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (94157 => 94158)
--- trunk/Source/WebCore/ChangeLog 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/ChangeLog 2011-08-31 08:08:29 UTC (rev 94158)
@@ -1,3 +1,24 @@
+2011-08-31 Keishi Hattori <[email protected]>
+
+ input color: onchange event is not fired when changing color from color chooser
+ https://bugs.webkit.org/show_bug.cgi?id=66848
+
+ Reviewed by Kent Tamura.
+
+ Test: fast/forms/color/input-color-onchange-event.html
+
+ * WebCore.exp.in: Added calls used in Internals.cpp.
+ * html/ColorInputType.cpp:
+ (WebCore::ColorInputType::colorSelected): Dispatch change event.
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::connectToColorChooser): Added. Called from Internals::connectColorChooserClient.
+ * html/HTMLInputElement.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::connectColorChooserClient): Added. Connects element as client to color chooser.
+ (WebCore::Internals::selectColorInColorChooser): Added. Simulate color selection in color chooser.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2011-08-31 Kentaro Hara <[email protected]>
Implement Web IDL Constructor extended attribute in IDLParser.pm and CodeGeneratorV8.pm.
Modified: trunk/Source/WebCore/WebCore.exp.in (94157 => 94158)
--- trunk/Source/WebCore/WebCore.exp.in 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/WebCore.exp.in 2011-08-31 08:08:29 UTC (rev 94158)
@@ -1922,4 +1922,6 @@
#if ENABLE(INPUT_COLOR)
__ZN7WebCore12ColorChooser7chooserEv
__ZNK7WebCore12ColorChooser13colorSelectedERKNS_5ColorE
+__ZN7WebCore5ColorC1ERKN3WTF6StringE
+__ZN7WebCore16HTMLInputElement21connectToColorChooserEv
#endif
Modified: trunk/Source/WebCore/html/ColorInputType.cpp (94157 => 94158)
--- trunk/Source/WebCore/html/ColorInputType.cpp 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/html/ColorInputType.cpp 2011-08-31 08:08:29 UTC (rev 94158)
@@ -167,10 +167,11 @@
void ColorInputType::colorSelected(const Color& color)
{
- if (element()->disabled() || element()->readOnly())
+ if (element()->disabled() || element()->readOnly() || color == valueAsColor())
return;
element()->setValueFromRenderer(color.serialized());
updateColorSwatch();
+ element()->dispatchFormControlChangeEvent();
}
bool ColorInputType::isColorInputType() const
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (94157 => 94158)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2011-08-31 08:08:29 UTC (rev 94158)
@@ -56,6 +56,11 @@
#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#include "ColorInputType.h"
+#endif
+
using namespace std;
namespace WebCore {
@@ -1471,6 +1476,16 @@
return m_inputType->supportsValidation() && HTMLTextFormControlElement::recalcWillValidate();
}
+#if ENABLE(INPUT_COLOR)
+bool HTMLInputElement::connectToColorChooser()
+{
+ if (!m_inputType->isColorControl())
+ return false;
+ ColorChooser::chooser()->connectClient(static_cast<ColorInputType*>(m_inputType.get()));
+ return true;
+}
+#endif
+
#if ENABLE(DATALIST)
HTMLElement* HTMLInputElement::list() const
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (94157 => 94158)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2011-08-31 08:08:29 UTC (rev 94158)
@@ -228,6 +228,11 @@
bool isConformToInputMask(const String&) const;
#endif
+#if ENABLE(INPUT_COLOR)
+ // For test purposes.
+ bool connectToColorChooser();
+#endif
+
static const int maximumLength;
protected:
Modified: trunk/Source/WebCore/testing/Internals.cpp (94157 => 94158)
--- trunk/Source/WebCore/testing/Internals.cpp 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/testing/Internals.cpp 2011-08-31 08:08:29 UTC (rev 94158)
@@ -46,6 +46,10 @@
#include "ShadowContentElement.h"
#include "ShadowRoot.h"
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#endif
+
namespace WebCore {
const char* Internals::internalsId = "internals";
@@ -163,6 +167,23 @@
WebCore::memoryCache()->setDisabled(disabled);
}
+#if ENABLE(INPUT_COLOR)
+bool Internals::connectColorChooserClient(Element* element)
+{
+ if (!element->hasTagName(HTMLNames::inputTag))
+ return false;
+ HTMLInputElement* inputElement = element->toInputElement();
+ if (!inputElement)
+ return false;
+ return inputElement->connectToColorChooser();
+}
+
+void Internals::selectColorInColorChooser(const String& colorValue)
+{
+ ColorChooser::chooser()->colorSelected(Color(colorValue));
+}
+#endif
+
#if ENABLE(INSPECTOR)
void Internals::setInspectorResourcesDataSizeLimits(Document* document, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode& ec)
{
Modified: trunk/Source/WebCore/testing/Internals.h (94157 => 94158)
--- trunk/Source/WebCore/testing/Internals.h 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/testing/Internals.h 2011-08-31 08:08:29 UTC (rev 94158)
@@ -60,6 +60,11 @@
Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
void disableMemoryCache(bool disabled);
+#if ENABLE(INPUT_COLOR)
+ bool connectColorChooserClient(Element*);
+ void selectColorInColorChooser(const String& colorValue);
+#endif
+
#if ENABLE(INSPECTOR)
void setInspectorResourcesDataSizeLimits(Document*, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&);
#else
Modified: trunk/Source/WebCore/testing/Internals.idl (94157 => 94158)
--- trunk/Source/WebCore/testing/Internals.idl 2011-08-31 07:38:05 UTC (rev 94157)
+++ trunk/Source/WebCore/testing/Internals.idl 2011-08-31 08:08:29 UTC (rev 94158)
@@ -39,6 +39,11 @@
Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
void disableMemoryCache(in boolean disabled);
+#if defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR
+ boolean connectColorChooserClient(in Element element);
+ void selectColorInColorChooser(in DOMString colorValue);
+#endif
+
void setInspectorResourcesDataSizeLimits(in Document document, in long maximumResourcesContentSize, in long maximumSingleResourceContentSize) raises(DOMException);
ClientRect boundingBox(in Element element) raises(DOMException);