[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
tkent at chromium.org
tkent at chromium.org
Tue Jan 5 23:57:02 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 9be41808c9ef1bc87bd0b7d51c9d616e8235de5e
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 21 06:20:29 2009 +0000
2009-12-20 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
A test for Date binding.
https://bugs.webkit.org/show_bug.cgi?id=32698
* fast/forms/input-valueasdate-expected.txt: Added.
* fast/forms/input-valueasdate.html: Added.
* fast/forms/script-tests/input-valueasdate.js: Added.
2009-12-20 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
Add support for JavaScriptCore Date binding.
https://bugs.webkit.org/show_bug.cgi?id=32698
This is needed for HTMLInputElement::valueAsDate and
HTMLTimeElement::valueAsDate.
A Date instance is mapped to a double value in C++.
- If null or undefined is set to a JavaScript property, C++ setter
function receives NaN.
- If a getter C++ function returns NaN or infinity, a JavaScript
property returns null.
Test: fast/forms/input-valueasdate.html
* bindings/js/JSDOMBinding.cpp:
(WebCore::jsDateOrNull): Implement the above.
(WebCore::valueToDate): ditto.
* bindings/js/JSDOMBinding.h: Declare them.
* bindings/scripts/CodeGeneratorJS.pm: Produce jsDateOrNull() or
valueToDate() for Date type.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::valueAsDate): Temporal implementation.
(WebCore::HTMLInputElement::setValueAsDate): ditto.
* html/HTMLInputElement.h:
* html/HTMLInputElement.idl: Declare valueAsDate.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52434 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 2c662d9..1b0a355 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-12-20 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ A test for Date binding.
+ https://bugs.webkit.org/show_bug.cgi?id=32698
+
+ * fast/forms/input-valueasdate-expected.txt: Added.
+ * fast/forms/input-valueasdate.html: Added.
+ * fast/forms/script-tests/input-valueasdate.js: Added.
+
2009-12-20 Alejandro G. Castro <alex at igalia.com>
Reviewed by Gustavo Noronha Silva.
diff --git a/LayoutTests/fast/forms/input-valueasdate-expected.txt b/LayoutTests/fast/forms/input-valueasdate-expected.txt
new file mode 100644
index 0000000..33a4b18
--- /dev/null
+++ b/LayoutTests/fast/forms/input-valueasdate-expected.txt
@@ -0,0 +1,27 @@
+Test HTMLInputElement::valueAsDate binding.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Unsuppported type:
+PASS input.valueAsDate is null
+PASS input.valueAsDate = date threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+
+Supported type:
+PASS valueAsDate != null is true
+PASS typeof valueAsDate is "object"
+PASS valueAsDate.constructor.name is "Date"
+Sets an Epoch Date:
+PASS input.value is "1970-01"
+PASS input.valueAsDate.getTime() is 0
+Sets a number 0:
+PASS input.value is "1970-01"
+PASS input.valueAsDate.getTime() is 0
+Sets other types:
+PASS input.valueAsDate = null threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS input.valueAsDate = undefined threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS input.valueAsDate = document threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/input-valueasdate.html b/LayoutTests/fast/forms/input-valueasdate.html
new file mode 100644
index 0000000..7d18ec6
--- /dev/null
+++ b/LayoutTests/fast/forms/input-valueasdate.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/input-valueasdate.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate.js b/LayoutTests/fast/forms/script-tests/input-valueasdate.js
new file mode 100644
index 0000000..779679a
--- /dev/null
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate.js
@@ -0,0 +1,35 @@
+description('Test HTMLInputElement::valueAsDate binding.');
+
+var input = document.createElement('input');
+var invalidStateError = 'Error: INVALID_STATE_ERR: DOM Exception 11';
+
+debug('Unsuppported type:');
+input.type = 'text';
+shouldBe('input.valueAsDate', 'null');
+shouldThrow('input.valueAsDate = date', 'invalidStateError');
+
+debug('');
+debug('Supported type:');
+input.type = 'month';
+input.value = '2009-12';
+var valueAsDate = input.valueAsDate;
+shouldBeTrue('valueAsDate != null');
+shouldBe('typeof valueAsDate', '"object"');
+shouldBe('valueAsDate.constructor.name', '"Date"');
+
+debug('Sets an Epoch Date:');
+var date = new Date();
+date.setTime(0);
+input.valueAsDate = date;
+shouldBe('input.value', '"1970-01"');
+shouldBe('input.valueAsDate.getTime()', '0');
+debug('Sets a number 0:');
+input.valueAsDate = 0;
+shouldBe('input.value', '"1970-01"');
+shouldBe('input.valueAsDate.getTime()', '0');
+debug('Sets other types:');
+shouldThrow('input.valueAsDate = null', 'invalidStateError');
+shouldThrow('input.valueAsDate = undefined', 'invalidStateError');
+shouldThrow('input.valueAsDate = document', 'invalidStateError');
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f9cc51d..f483184 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,36 @@
Reviewed by Darin Adler.
+ Add support for JavaScriptCore Date binding.
+ https://bugs.webkit.org/show_bug.cgi?id=32698
+
+ This is needed for HTMLInputElement::valueAsDate and
+ HTMLTimeElement::valueAsDate.
+
+ A Date instance is mapped to a double value in C++.
+ - If null or undefined is set to a JavaScript property, C++ setter
+ function receives NaN.
+ - If a getter C++ function returns NaN or infinity, a JavaScript
+ property returns null.
+
+ Test: fast/forms/input-valueasdate.html
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::jsDateOrNull): Implement the above.
+ (WebCore::valueToDate): ditto.
+ * bindings/js/JSDOMBinding.h: Declare them.
+ * bindings/scripts/CodeGeneratorJS.pm: Produce jsDateOrNull() or
+ valueToDate() for Date type.
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::valueAsDate): Temporal implementation.
+ (WebCore::HTMLInputElement::setValueAsDate): ditto.
+ * html/HTMLInputElement.h:
+ * html/HTMLInputElement.idl: Declare valueAsDate.
+
+2009-12-20 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
Introduce the followings:
- ::-webkit-inner-spin-button pseudo CSS selector
- ::-webkit-outer-spin-button pseudo CSS selector
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index 6faea27..ffa1d43 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -49,9 +49,11 @@
#include "ScriptController.h"
#include "Settings.h"
#include "XMLHttpRequestException.h"
+#include <runtime/DateInstance.h>
#include <runtime/Error.h>
#include <runtime/JSFunction.h>
#include <runtime/PrototypeFunction.h>
+#include <wtf/MathExtras.h>
#include <wtf/StdLibExtras.h>
#if ENABLE(SVG)
@@ -596,6 +598,22 @@ UString valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
return value.toString(exec);
}
+JSValue jsDateOrNull(ExecState* exec, double value)
+{
+ if (!isfinite(value))
+ return jsNull();
+ return new (exec) DateInstance(exec, value);
+}
+
+double valueToDate(ExecState* exec, JSValue value)
+{
+ if (value.isNumber())
+ return value.uncheckedGetNumber();
+ if (!value.inherits(&DateInstance::info))
+ return std::numeric_limits<double>::quiet_NaN();
+ return static_cast<DateInstance*>(value.toObject(exec))->internalNumber();
+}
+
void reportException(ExecState* exec, JSValue exception)
{
UString errorMessage = exception.toString(exec);
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 6928153..4d11872 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -356,6 +356,11 @@ namespace WebCore {
JSC::UString valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
+ // Returns a Date instance for the specified value, or null if the value is NaN or infinity.
+ JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
+ // NaN if the value can't be converted to a date.
+ double valueToDate(JSC::ExecState*, JSC::JSValue);
+
// FIXME: These are a stop-gap until all toJS calls can be converted to pass a globalObject
template <typename T>
inline JSC::JSValue toJS(JSC::ExecState* exec, T* ptr)
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 5e0f58e..a5e6bb6 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -187,6 +187,8 @@ sub AddIncludesForType
# reorganization, we won't need these special cases.
if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)
or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") {
+ } elsif ($type eq "Date") {
+ $implIncludes{"<runtime/DateInstance.h>"} = 1;
} elsif ($type =~ /SVGPathSeg/) {
$joinedName = $type;
$joinedName =~ s/Abs|Rel//;
@@ -1863,6 +1865,7 @@ sub JSValueToNative
return "$value.toFloat(exec)" if $type eq "float" or $type eq "SVGNumber";
return "$value.toInt32(exec)" if $type eq "unsigned long" or $type eq "long" or $type eq "unsigned short";
+ return "valueToDate(exec, $value)" if $type eq "Date";
return "static_cast<Range::CompareHow>($value.toInt32(exec))" if $type eq "CompareHow";
return "static_cast<SVGPaint::SVGPaintType>($value.toInt32(exec))" if $type eq "SVGPaintType";
@@ -1987,6 +1990,9 @@ sub NativeToJSValue
} elsif ($type eq "SerializedScriptValue") {
$implIncludes{"$type.h"} = 1;
return "$value->deserialize(exec)";
+ } elsif ($type eq "Date") {
+ $implIncludes{"<runtime/DateInstance.h>"} = 1;
+ return "jsDateOrNull(exec, $value)";
} else {
# Default, include header with same name.
$implIncludes{"JS$type.h"} = 1;
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index ffa4aac..b3b9b9c 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1374,6 +1374,24 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
updateValidity();
}
+double HTMLInputElement::valueAsDate() const
+{
+ // FIXME: This is a temporary implementation to check Date binding.
+ if (inputType() == MONTH)
+ return 0.0;
+ return std::numeric_limits<double>::quiet_NaN();
+}
+
+void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
+{
+ // FIXME: This is a temporary implementation to check Date binding.
+ if (!isnan(value) && !isinf(value) && inputType() == MONTH) {
+ setValue(String("1970-01"));
+ return;
+ }
+ ec = INVALID_STATE_ERR;
+}
+
String HTMLInputElement::placeholder() const
{
return getAttribute(placeholderAttr).string();
diff --git a/WebCore/html/HTMLInputElement.h b/WebCore/html/HTMLInputElement.h
index 53be5cc..2b7b28b 100644
--- a/WebCore/html/HTMLInputElement.h
+++ b/WebCore/html/HTMLInputElement.h
@@ -144,6 +144,9 @@ public:
virtual void setValue(const String&, bool sendChangeEvent = false);
virtual void setValueForUser(const String&);
+ double valueAsDate() const;
+ void setValueAsDate(double, ExceptionCode&);
+
virtual String placeholder() const;
virtual void setPlaceholder(const String&);
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index 2ac6674..78a403a 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -67,6 +67,10 @@ module html {
attribute [ConvertNullToNullString, JSCCustomGetter] DOMString type; // readonly dropped as part of DOM level 2
attribute [ConvertNullToNullString] DOMString useMap;
attribute [ConvertNullToNullString] DOMString value;
+#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT && !(defined(V8_BINDING) && V8_BINDING)
+ // FIXME: Add Date support for V8, Objective-C, and COM.
+ attribute Date valueAsDate setter raises(DOMException);
+#endif
#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
readonly attribute HTMLOptionElement selectedOption;
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list