2009-07-21 Jian Li <jianli@chromium.org>
authorjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2009 22:57:51 +0000 (22:57 +0000)
committerjianli@chromium.org <jianli@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2009 22:57:51 +0000 (22:57 +0000)
        Reviewed by David Levin.

        [V8] Add V8 bindings for onerror in WorkerContext.
        https://bugs.webkit.org/show_bug.cgi?id=27518

        * bindings/v8/custom/V8CustomBinding.h:
        * bindings/v8/custom/V8WorkerContextCustom.cpp:
        (WebCore::ACCESSOR_GETTER):
        (WebCore::ACCESSOR_SETTER):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@46199 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bindings/v8/custom/V8CustomBinding.h
WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp

index 546a6de..2ce59e8 100644 (file)
@@ -1,5 +1,17 @@
 2009-07-21  Jian Li  <jianli@chromium.org>
 
+        Reviewed by David Levin.
+
+        [V8] Add V8 bindings for onerror in WorkerContext.
+        https://bugs.webkit.org/show_bug.cgi?id=27518
+
+        * bindings/v8/custom/V8CustomBinding.h:
+        * bindings/v8/custom/V8WorkerContextCustom.cpp:
+        (WebCore::ACCESSOR_GETTER):
+        (WebCore::ACCESSOR_SETTER):
+
+2009-07-21  Jian Li  <jianli@chromium.org>
+
         Fix the incorrect patch being landed for bug 27516 that has already been reviewed.
         https://bugs.webkit.org/show_bug.cgi?id=27516
 
index 5cec902..7febab0 100644 (file)
@@ -481,6 +481,7 @@ namespace WebCore {
         DECLARE_CALLBACK(WorkerConstructor);
 
         DECLARE_PROPERTY_ACCESSOR_GETTER(WorkerContextSelf);
+        DECLARE_PROPERTY_ACCESSOR(WorkerContextOnerror);
         DECLARE_PROPERTY_ACCESSOR(WorkerContextOnmessage);
         DECLARE_CALLBACK(WorkerContextImportScripts);
         DECLARE_CALLBACK(WorkerContextSetTimeout);
index cd08b4d..45f5f44 100644 (file)
@@ -53,6 +53,45 @@ ACCESSOR_GETTER(WorkerContextSelf)
     return WorkerContextExecutionProxy::WorkerContextToV8Object(workerContext);
 }
 
+ACCESSOR_GETTER(WorkerContextOnerror)
+{
+    INC_STATS(L"DOM.WorkerContext.onerror._get");
+    WorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder());
+    if (workerContext->onerror()) {
+        V8WorkerContextEventListener* listener = static_cast<V8WorkerContextEventListener*>(workerContext->onerror());
+        v8::Local<v8::Object> v8Listener = listener->getListenerObject();
+        return v8Listener;
+    }
+    return v8::Undefined();
+}
+
+ACCESSOR_SETTER(WorkerContextOnerror)
+{
+    INC_STATS(L"DOM.WorkerContext.onerror._set");
+    WorkerContext* workerContext = V8DOMWrapper::convertToNativeObject<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder());
+    V8WorkerContextEventListener* oldListener = static_cast<V8WorkerContextEventListener*>(workerContext->onerror());
+    if (value->IsNull()) {
+        if (workerContext->onerror()) {
+            v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
+            removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerContextRequestCacheIndex);
+        }
+
+        // Clear the listener.
+        workerContext->setOnerror(0);
+    } else {
+        RefPtr<V8EventListener> listener = workerContext->script()->proxy()->findOrCreateEventListener(v8::Local<v8::Object>::Cast(value), false, false);
+        if (listener) {
+            if (oldListener) {
+                v8::Local<v8::Object> oldV8Listener = oldListener->getListenerObject();
+                removeHiddenDependency(info.Holder(), oldV8Listener, V8Custom::kWorkerContextRequestCacheIndex);
+            }
+
+            workerContext->setOnerror(listener);
+            createHiddenDependency(info.Holder(), value, V8Custom::kWorkerContextRequestCacheIndex);
+        }
+    }
+}
+
 ACCESSOR_GETTER(WorkerContextOnmessage)
 {
     INC_STATS(L"DOM.WorkerContext.onmessage._get");