Changeset 42671 in webkit


Ignore:
Timestamp:
Apr 20, 2009 8:27:03 AM (15 years ago)
Author:
Dimitri Glazkov
Message:

2009-04-20 Eric Roman <eroman@chromium.org>

Reviewed by Dimitri Glazkov.

https://bugs.webkit.org/show_bug.cgi?id=25261
Implement the V8 binding for DOMWindow.event similarly to JSC, by using
the custom getter boilerplate from the IDL file.
Also, stub out DOMWindow.crypto which is defined by the idl.

  • bindings/v8/V8AbstractEventListener.cpp: (WebCore::V8AbstractEventListener::invokeEventHandler):
  • bindings/v8/custom/V8DOMWindowCustom.cpp: (WebCore::ACCESSOR_GETTER):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r42670 r42671  
     12009-04-20  Eric Roman  <eroman@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25261
     6        Implement the V8 binding for DOMWindow.event similarly to JSC, by using
     7        the custom getter boilerplate from the IDL file.
     8        Also, stub out DOMWindow.crypto which is defined by the idl.
     9
     10        * bindings/v8/V8AbstractEventListener.cpp:
     11        (WebCore::V8AbstractEventListener::invokeEventHandler):
     12        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     13        (WebCore::ACCESSOR_GETTER):
     14
    1152009-04-20  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    216
  • trunk/WebCore/bindings/v8/V8AbstractEventListener.cpp

    r42444 r42671  
    5858void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> context, Event* event, v8::Handle<v8::Value> jsEvent, bool isWindowEvent)
    5959{
    60     // For compatibility, we store the event object as a property on the window called "event".  Because this is the global namespace, we save away any
    61     // existing "event" property, and then restore it after executing the javascript handler.
     60    // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings.
    6261    v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
    6362    v8::Local<v8::Value> returnValue;
     
    6564    {
    6665        // Catch exceptions thrown in the event handler so they do not propagate to javascript code that caused the event to fire.
    67         // Setting and getting the 'event' property on the global object can throw exceptions as well (for instance if accessors that
    68         // throw exceptions are defined for 'event' using __defineGetter__ and __defineSetter__ on the global object).
    6966        v8::TryCatch tryCatch;
    7067        tryCatch.SetVerbose(true);
    7168
    7269        // Save the old 'event' property so we can restore it later.
    73         v8::Local<v8::Value> savedEvent = context->Global()->Get(eventSymbol);
     70        v8::Local<v8::Value> savedEvent = context->Global()->GetHiddenValue(eventSymbol);
    7471        tryCatch.Reset();
    7572
    76         // Make the event available in the window object.
    77         //
    78         // FIXME: This does not work as it does with jsc bindings if the window.event property is already set. We need to make sure that property
    79         // access is intercepted correctly.
    80         context->Global()->Set(eventSymbol, jsEvent);
     73        // Make the event available in the global object, so DOMWindow can expose it.
     74        context->Global()->SetHiddenValue(eventSymbol, jsEvent);
    8175        tryCatch.Reset();
    8276
     
    8781        // Restore the old event. This must be done for all exit paths through this method.
    8882        if (savedEvent.IsEmpty())
    89             context->Global()->Set(eventSymbol, v8::Undefined());
     83            context->Global()->SetHiddenValue(eventSymbol, v8::Undefined());
    9084        else
    91             context->Global()->Set(eventSymbol, savedEvent);
     85            context->Global()->SetHiddenValue(eventSymbol, savedEvent);
    9286        tryCatch.Reset();
    9387    }
  • trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r42542 r42671  
    5454namespace WebCore {
    5555
     56ACCESSOR_GETTER(DOMWindowEvent)
     57{
     58    v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
     59    v8::Local<v8::Context> context = v8::Context::GetCurrent();
     60    v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbol);
     61    if (jsEvent.IsEmpty())
     62        return v8::Undefined();
     63    return jsEvent;
     64}
     65
     66ACCESSOR_GETTER(DOMWindowCrypto)
     67{
     68    // TODO: Implement me.
     69    return v8::Undefined();
     70}
     71
    5672ACCESSOR_SETTER(DOMWindowLocation)
    5773{
Note: See TracChangeset for help on using the changeset viewer.