Changeset 52454 in webkit


Ignore:
Timestamp:
Dec 21, 2009 1:26:43 PM (14 years ago)
Author:
pkasting@chromium.org
Message:

Add support for V8 Date binding.
https://bugs.webkit.org/show_bug.cgi?id=32699

Patch by Kent Tamura <tkent@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.
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52451 r52454  
     12009-12-19  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add support for V8 Date binding.
     6        https://bugs.webkit.org/show_bug.cgi?id=32699
     7
     8        This implements the same behavior as the recent change of
     9        CodeGeneratorJS.pm and JSDOMBinding.cpp.
     10
     11        * bindings/scripts/CodeGeneratorV8.pm:
     12          Produce toWebCoreDate() or v8DateOrNull() for Date type.
     13        * bindings/v8/V8Binding.cpp:
     14        (WebCore::toWebCoreDate):
     15          Converts a JavaScript object to a double representing Date.
     16        (WebCore::v8DateOrNull):
     17          Converts a double representing Date to a JavaScript Date object or null.
     18        * bindings/v8/V8Binding.h: Declare toWebCoreDate() and v8DateOrNull().
     19        * html/HTMLInputElement.idl: Delete V8_BINGIN exclusion for valueAsDate.
     20
    1212009-12-21  Darin Adler  <darin@apple.com>
    222
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r52373 r52454  
    157157    # When we're finished with the one-file-per-class
    158158    # reorganization, we won't need these special cases.
    159     if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)) {
     159    if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type) or $type eq "Date") {
    160160    } elsif ($type =~ /SVGPathSeg/) {
    161161        $joinedName = $type;
     
    19731973    return "unsigned" if $type eq "unsigned int";
    19741974    return "Node*" if $type eq "EventTarget" and $isParameter;
     1975    return "double" if $type eq "Date";
    19751976
    19761977    return "String" if $type eq "DOMUserData";  # FIXME: Temporary hack?
     
    21072108    return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow";
    21082109    return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType";
     2110    return "toWebCoreDate($value)" if $type eq "Date";
    21092111
    21102112    if ($type eq "DOMString" or $type eq "DOMUserData") {
     
    23692371    }
    23702372
     2373    if ($type eq "Date") {
     2374        return "return v8DateOrNull($value);";
     2375    }
     2376
    23712377    else {
    23722378        $implIncludes{"wtf/RefCounted.h"} = 1;
  • trunk/WebCore/bindings/v8/V8Binding.cpp

    r51707 r52454  
    240240}
    241241
     242double toWebCoreDate(v8::Handle<v8::Value> object)
     243{
     244    return (object->IsDate() || object->IsNumber()) ? object->NumberValue() : std::numeric_limits<double>::quiet_NaN();
     245}
     246
     247v8::Handle<v8::Value> v8DateOrNull(double value)
     248{
     249    if (isfinite(value))
     250        return v8::Date::New(value);
     251    return v8::Null();
     252}
    242253
    243254template <class S> struct StringTraits
  • trunk/WebCore/bindings/v8/V8Binding.h

    r52080 r52454  
    206206
    207207    v8::Handle<v8::Value> v8StringOrFalse(const String& str);
     208
     209    double toWebCoreDate(v8::Handle<v8::Value> object);
     210
     211    v8::Handle<v8::Value> v8DateOrNull(double value);
    208212   
    209213    v8::Persistent<v8::FunctionTemplate> createRawTemplate();
  • trunk/WebCore/html/HTMLInputElement.idl

    r52434 r52454  
    6868                 attribute [ConvertNullToNullString] DOMString useMap;
    6969                 attribute [ConvertNullToNullString] DOMString value;
    70 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT && !(defined(V8_BINDING) && V8_BINDING)
    71                  // FIXME: Add Date support for V8, Objective-C, and COM.
     70#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
     71                 // FIXME: Add Date support for Objective-C and COM.
    7272                 attribute Date            valueAsDate setter raises(DOMException);
    7373#endif
Note: See TracChangeset for help on using the changeset viewer.