Reviewed by NOBODY.
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 01:23:13 +0000 (01:23 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2007 01:23:13 +0000 (01:23 +0000)
        Add files missing from previous commit.

        * html/VoidCallback.cpp: Added.
        (VoidCallback::VoidCallback):
        (VoidCallback::~VoidCallback):
        (VoidCallback::handleEvent):
        (VoidCallback::execute):
        (VoidCallback::operator==):
        (WebCore::toVoidCallback):
        * html/VoidCallback.h: Added.
        * html/VoidCallback.idl: Added.

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

WebCore/ChangeLog
WebCore/html/VoidCallback.cpp [new file with mode: 0644]
WebCore/html/VoidCallback.h [new file with mode: 0644]
WebCore/html/VoidCallback.idl [new file with mode: 0644]

index 9803e23afaca46ebb36001899dae71c1fa42db81..0cc37c43d8e14d3c64fabd18bd806128abb4b1a8 100644 (file)
@@ -1,3 +1,19 @@
+2007-10-30  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by NOBODY.
+
+        Add missing files.
+
+        * html/VoidCallback.cpp: Added.
+        (VoidCallback::VoidCallback):
+        (VoidCallback::~VoidCallback):
+        (VoidCallback::handleEvent):
+        (VoidCallback::execute):
+        (VoidCallback::operator==):
+        (WebCore::toVoidCallback):
+        * html/VoidCallback.h: Added.
+        * html/VoidCallback.idl: Added.
+
 2007-10-30  David Kilzer  <ddkilzer@webkit.org>
 
         Generated files missing from WebCore's Xcode project file
diff --git a/WebCore/html/VoidCallback.cpp b/WebCore/html/VoidCallback.cpp
new file mode 100644 (file)
index 0000000..d029d0f
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#include "VoidCallback.h"
+
+#include "CString.h"
+#include "Frame.h"
+#include "Page.h"
+#include "kjs_proxy.h"
+#include "kjs_window.h"
+
+using namespace WebCore;
+using namespace KJS;
+
+VoidCallback::VoidCallback(JSValue* func)
+{
+    m_func = func;
+}
+
+VoidCallback::~VoidCallback()
+{
+}
+
+void VoidCallback::handleEvent()
+{
+}
+
+void VoidCallback::execute(Frame* frame)
+{
+    if (!frame)
+        return;
+    
+    if (!m_func)
+        return;
+    
+    KJS::JSObject* window = Window::retrieveWindow(frame);
+    if (!window)
+        return;
+    
+    KJSProxy* scriptProxy = frame->scriptProxy();
+    if (!scriptProxy)
+        return;
+    
+    RefPtr<ScriptInterpreter> interpreter = scriptProxy->interpreter();
+    
+    JSLock lock;
+    ExecState* exec = interpreter->globalExec();
+    ASSERT(window == interpreter->globalObject());
+    interpreter->startTimeoutCheck();
+    static_cast<JSObject*>(m_func)->call(exec, window, List());
+    interpreter->stopTimeoutCheck();
+    if (exec->hadException()) {
+        JSObject* exception = exec->exception()->toObject(exec);
+        exec->clearException();
+        String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
+        int lineNumber = exception->get(exec, "line")->toInt32(exec);
+        if (Interpreter::shouldPrintExceptions())
+            printf("(VoidCallback):%s\n", message.utf8().data());
+        if (Page* page = frame->page())
+            page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, lineNumber, String());
+    }
+}
+
+bool VoidCallback::operator==(const VoidCallback& o) const
+{
+    return m_func == o.m_func;
+}
+
+VoidCallback* WebCore::toVoidCallback(JSValue* func)
+{
+    if (!func->isObject() || !static_cast<JSObject*>(func)->implementsCall())
+        return new VoidCallback(0);
+    return new VoidCallback(func);
+}
+
diff --git a/WebCore/html/VoidCallback.h b/WebCore/html/VoidCallback.h
new file mode 100644 (file)
index 0000000..b47e90f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef VoidCallback_h
+#define VoidCallback_h
+
+#include <kjs/protect.h>
+#include "Shared.h"
+#include "wtf/PassRefPtr.h"
+
+namespace WebCore {
+
+class Frame;
+    
+class VoidCallback : public Shared<VoidCallback> {
+public:
+    VoidCallback(KJS::JSValue* func);
+    virtual ~VoidCallback();
+    
+    void handleEvent();
+    
+    void execute(Frame* frame);
+    
+    bool operator==(const VoidCallback&) const;
+    
+private:
+    KJS::JSValue* m_func;
+};
+
+VoidCallback* toVoidCallback(KJS::JSValue*);
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/html/VoidCallback.idl b/WebCore/html/VoidCallback.idl
new file mode 100644 (file)
index 0000000..3682cf7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+module html {
+    interface [CustomNativeConverter] VoidCallback {
+        void handleEvent();
+    };
+}