[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.17-1283-gcf603cf
pkasting at chromium.org
pkasting at chromium.org
Tue Jan 5 23:57:46 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e6872982b07a075fdf6aa90aa16e54a7a2ff008b
Author: pkasting at chromium.org <pkasting at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 21 21:26:43 2009 +0000
Add support for V8 Date binding.
https://bugs.webkit.org/show_bug.cgi?id=32699
Patch by Kent Tamura <tkent at chromium.org> on 2009-12-19
Reviewed by Adam Barth.
This implements the same behavior as the recent change of
CodeGeneratorJS.pm and JSDOMBinding.cpp.
* bindings/scripts/CodeGeneratorV8.pm:
Produce toWebCoreDate() or v8DateOrNull() for Date type.
* bindings/v8/V8Binding.cpp:
(WebCore::toWebCoreDate):
Converts a JavaScript object to a double representing Date.
(WebCore::v8DateOrNull):
Converts a double representing Date to a JavaScript Date object or null.
* bindings/v8/V8Binding.h: Declare toWebCoreDate() and v8DateOrNull().
* html/HTMLInputElement.idl: Delete V8_BINGIN exclusion for valueAsDate.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52454 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 59154ba..b773faa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2009-12-19 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Adam Barth.
+
+ Add support for V8 Date binding.
+ https://bugs.webkit.org/show_bug.cgi?id=32699
+
+ This implements the same behavior as the recent change of
+ CodeGeneratorJS.pm and JSDOMBinding.cpp.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ Produce toWebCoreDate() or v8DateOrNull() for Date type.
+ * bindings/v8/V8Binding.cpp:
+ (WebCore::toWebCoreDate):
+ Converts a JavaScript object to a double representing Date.
+ (WebCore::v8DateOrNull):
+ Converts a double representing Date to a JavaScript Date object or null.
+ * bindings/v8/V8Binding.h: Declare toWebCoreDate() and v8DateOrNull().
+ * html/HTMLInputElement.idl: Delete V8_BINGIN exclusion for valueAsDate.
+
2009-12-21 Darin Adler <darin at apple.com>
Reviewed by Mark Rowe.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 8ee35b3..f9a8e5a 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -156,7 +156,7 @@ sub AddIncludesForType
# When we're finished with the one-file-per-class
# reorganization, we won't need these special cases.
- if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)) {
+ if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type) or $type eq "Date") {
} elsif ($type =~ /SVGPathSeg/) {
$joinedName = $type;
$joinedName =~ s/Abs|Rel//;
@@ -1972,6 +1972,7 @@ sub GetNativeType
return "DOMTimeStamp" if $type eq "DOMTimeStamp";
return "unsigned" if $type eq "unsigned int";
return "Node*" if $type eq "EventTarget" and $isParameter;
+ return "double" if $type eq "Date";
return "String" if $type eq "DOMUserData"; # FIXME: Temporary hack?
@@ -2106,6 +2107,7 @@ sub JSValueToNative
return "toInt32($value${maybeOkParam})" if $type eq "unsigned long" or $type eq "unsigned short" or $type eq "long";
return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow";
return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType";
+ return "toWebCoreDate($value)" if $type eq "Date";
if ($type eq "DOMString" or $type eq "DOMUserData") {
return $value;
@@ -2368,6 +2370,10 @@ sub ReturnNativeToJSValue
return "return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::$classIndex, $value)";
}
+ if ($type eq "Date") {
+ return "return v8DateOrNull($value);";
+ }
+
else {
$implIncludes{"wtf/RefCounted.h"} = 1;
$implIncludes{"wtf/RefPtr.h"} = 1;
diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp
index 00286e5..d21e1f8 100644
--- a/WebCore/bindings/v8/V8Binding.cpp
+++ b/WebCore/bindings/v8/V8Binding.cpp
@@ -239,6 +239,17 @@ v8::Handle<v8::Value> v8StringOrFalse(const String& str)
return str.isNull() ? v8::Handle<v8::Value>(v8::False()) : v8::Handle<v8::Value>(v8String(str));
}
+double toWebCoreDate(v8::Handle<v8::Value> object)
+{
+ return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();
+}
+
+v8::Handle<v8::Value> v8DateOrNull(double value)
+{
+ if (isfinite(value))
+ return v8::Date::New(value);
+ return v8::Null();
+}
template <class S> struct StringTraits
{
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index f9f94d7..aa4a326 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -205,6 +205,10 @@ namespace WebCore {
v8::Handle<v8::Value> v8StringOrUndefined(const String& str);
v8::Handle<v8::Value> v8StringOrFalse(const String& str);
+
+ double toWebCoreDate(v8::Handle<v8::Value> object);
+
+ v8::Handle<v8::Value> v8DateOrNull(double value);
v8::Persistent<v8::FunctionTemplate> createRawTemplate();
diff --git a/WebCore/html/HTMLInputElement.idl b/WebCore/html/HTMLInputElement.idl
index 78a403a..d355d69 100644
--- a/WebCore/html/HTMLInputElement.idl
+++ b/WebCore/html/HTMLInputElement.idl
@@ -67,8 +67,8 @@ 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.
+#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
+ // FIXME: Add Date support for Objective-C and COM.
attribute Date valueAsDate setter raises(DOMException);
#endif
#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list