Bug 32699 - [V8] Date binding support
Summary: [V8] Date binding support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://www.whatwg.org/specs/web-apps/...
Keywords:
Depends on: 32698
Blocks: 32697
  Show dependency treegraph
 
Reported: 2009-12-17 22:18 PST by Kent Tamura
Modified: 2009-12-21 13:27 PST (History)
4 users (show)

See Also:


Attachments
Proposed patch (3.78 KB, patch)
2009-12-18 01:38 PST, Kent Tamura
tkent: review-
Details | Formatted Diff | Diff
Proposed patch (5.49 KB, patch)
2009-12-19 21:17 PST, Kent Tamura
abarth: review+
abarth: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Tamura 2009-12-17 22:18:00 PST
HTML5's HTMLInputElement IDL has
>          attribute Date valueAsDate;

We need to support binding for Date.
Comment 1 Kent Tamura 2009-12-18 01:38:28 PST
Created attachment 45131 [details]
Proposed patch

Generated code for "Date valueAsDate setter raises(DOMException)" will be like:

  static v8::Handle<v8::Value> valueAsDateAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
    INC_STATS("DOM.HTMLInputElement.valueAsDate._get");
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = v8DOMWrapperToNode<HTMLInputElement>(info);
    double v = imp->valueAsDate();
    if (isnan(v) || isinf(v))
        return v8::Null();
    else
        return v8::Date::New(v);
  }

  static void valueAsDateAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
    INC_STATS("DOM.HTMLInputElement.valueAsDate._set");
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = v8DOMWrapperToNode<HTMLInputElement>(info);
    double v = value->IsDate() ? value->NumberValue() : std::numeric_limits<double>::quiet_NaN();
    ExceptionCode ec = 0;
    imp->setValueAsDate(v, ec);
    if (UNLIKELY(ec))
        V8Proxy::setDOMException(ec);
    return;
  }
Comment 2 Kent Tamura 2009-12-19 21:17:57 PST
Created attachment 45256 [details]
Proposed patch

Note: This depends on a patch in Bug#32698, and EWS will report a failure.
Comment 3 Kent Tamura 2009-12-19 21:19:29 PST
(In reply to comment #2)

Generated code for "Date valueAsDate setter raises(DOMException)" will be like:

  static v8::Handle<v8::Value> valueAsDateAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
    INC_STATS("DOM.HTMLInputElement.valueAsDate._get");
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = v8DOMWrapperToNode<HTMLInputElement>(info);
    return v8DateOrNull(imp->valueAsDate());;
  }

  static void valueAsDateAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
    INC_STATS("DOM.HTMLInputElement.valueAsDate._set");
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = v8DOMWrapperToNode<HTMLInputElement>(info);
    double v = toWebCoreDate(value);
    ExceptionCode ec = 0;
    imp->setValueAsDate(v, ec);
    if (UNLIKELY(ec))
        V8Proxy::setDOMException(ec);
    return;
  }
Comment 4 Adam Barth 2009-12-21 12:56:36 PST
Comment on attachment 45256 [details]
Proposed patch

This looks fine.  Please update the FIXME to match the patch:

"FIXME: Add Date support for V8, Objective-C, and COM."
Comment 5 Peter Kasting 2009-12-21 13:27:29 PST
Landed in r52454.