Changeset 42671 in webkit
- Timestamp:
- Apr 20, 2009 8:27:03 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r42670 r42671 1 2009-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 1 15 2009-04-20 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> 2 16 -
trunk/WebCore/bindings/v8/V8AbstractEventListener.cpp
r42444 r42671 58 58 void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> context, Event* event, v8::Handle<v8::Value> jsEvent, bool isWindowEvent) 59 59 { 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. 62 61 v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event"); 63 62 v8::Local<v8::Value> returnValue; … … 65 64 { 66 65 // 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 that68 // throw exceptions are defined for 'event' using __defineGetter__ and __defineSetter__ on the global object).69 66 v8::TryCatch tryCatch; 70 67 tryCatch.SetVerbose(true); 71 68 72 69 // 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); 74 71 tryCatch.Reset(); 75 72 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); 81 75 tryCatch.Reset(); 82 76 … … 87 81 // Restore the old event. This must be done for all exit paths through this method. 88 82 if (savedEvent.IsEmpty()) 89 context->Global()->Set (eventSymbol, v8::Undefined());83 context->Global()->SetHiddenValue(eventSymbol, v8::Undefined()); 90 84 else 91 context->Global()->Set (eventSymbol, savedEvent);85 context->Global()->SetHiddenValue(eventSymbol, savedEvent); 92 86 tryCatch.Reset(); 93 87 } -
trunk/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
r42542 r42671 54 54 namespace WebCore { 55 55 56 ACCESSOR_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 66 ACCESSOR_GETTER(DOMWindowCrypto) 67 { 68 // TODO: Implement me. 69 return v8::Undefined(); 70 } 71 56 72 ACCESSOR_SETTER(DOMWindowLocation) 57 73 {
Note: See TracChangeset
for help on using the changeset viewer.