Reviewed by Sam.
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 23:53:19 +0000 (23:53 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2007 23:53:19 +0000 (23:53 +0000)
        Make the VoidCallback DOM interface behave more like our other DOM interfaces.

        * bindings/js/JSCustomVoidCallback.h: Added.
        * bindings/js/JSCustomVoidCallback.cpp: Added.
        (WebCore::JSCustomVoidCallback::JSCustomVoidCallback):
        (WebCore::JSCustomVoidCallback::handleEvent):
        VoidCallback implementation that wraps a JS object.

        (WebCore::toVoidCallback):
        New method that creates a VoidCallback implementation given a JS object.

        * bindings/scripts/CodeGeneratorJS.pm:
        Specify that VoidCallback can fail conversion and add a custom conversion function.

        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::movieCuePointReached):
        Call handleEvent on the callback.

        (WebCore::HTMLMediaElement::removeCuePoint):
        Comment out parts of this method, it has already been removed in the HTML5 spec and it relies
        on overriding VoidCallback equality.

        * html/VoidCallback.cpp: Removed.

        * html/VoidCallback.h:
        (WebCore::VoidCallback::VoidCallback):
        (WebCore::VoidCallback::~VoidCallback):
        Make this an abstract class with a pure virtual handleEvent method.

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSCustomVoidCallback.cpp [new file with mode: 0644]
WebCore/bindings/js/JSCustomVoidCallback.h [new file with mode: 0644]
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/html/HTMLMediaElement.cpp
WebCore/html/VoidCallback.cpp [deleted file]
WebCore/html/VoidCallback.h

index e668391ef8edba28f3175ada05b8de1129b12ee5..8475033703dee1b8f6b4406e0bcfa149c969cc8f 100644 (file)
@@ -1,3 +1,36 @@
+2007-11-15  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam.
+
+        Make the VoidCallback DOM interface behave more like our other DOM interfaces.
+        
+        * bindings/js/JSCustomVoidCallback.h: Added.
+        * bindings/js/JSCustomVoidCallback.cpp: Added.
+        (WebCore::JSCustomVoidCallback::JSCustomVoidCallback):
+        (WebCore::JSCustomVoidCallback::handleEvent):
+        VoidCallback implementation that wraps a JS object.
+        
+        (WebCore::toVoidCallback):
+        New method that creates a VoidCallback implementation given a JS object.
+        
+        * bindings/scripts/CodeGeneratorJS.pm:
+        Specify that VoidCallback can fail conversion and add a custom conversion function.
+        
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::movieCuePointReached):
+        Call handleEvent on the callback.
+        
+        (WebCore::HTMLMediaElement::removeCuePoint):
+        Comment out parts of this method, it has already been removed in the HTML5 spec and it relies
+        on overriding VoidCallback equality.
+        
+        * html/VoidCallback.cpp: Removed.
+        
+        * html/VoidCallback.h:
+        (WebCore::VoidCallback::VoidCallback):
+        (WebCore::VoidCallback::~VoidCallback):
+        Make this an abstract class with a pure virtual handleEvent method.
+        
 2007-11-15  Adam Roben  <aroben@apple.com>
 
         Fix <rdar://5485108> Type-select while a <select> menu is open doesn't work
index 8d0d8eee0a991a8c2393701475460f9808eee962..9befcc188443437f7cc298d1c07923fac80c191d 100644 (file)
                1A2E6E7B0CC556D5004A2062 /* SQLiteAuthorizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E790CC556D5004A2062 /* SQLiteAuthorizer.h */; };
                1A2E6FA40CC5795D004A2062 /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6FA30CC5795D004A2062 /* ThreadingPthreads.cpp */; };
                1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */; };
+               1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */; };
                1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */; };
                1A494BFB0A122F4400FDAFC1 /* JSHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */; };
                1A494E340A12358B00FDAFC1 /* JSHTMLDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A494E320A12358A00FDAFC1 /* JSHTMLDocument.cpp */; };
                E44613B00CD6331000FADA75 /* TimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = E446139E0CD6331000FADA75 /* TimeRanges.h */; };
                E44613B10CD6331000FADA75 /* TimeRanges.idl in Resources */ = {isa = PBXBuildFile; fileRef = E446139F0CD6331000FADA75 /* TimeRanges.idl */; };
                E44613B20CD6331000FADA75 /* VoidCallback.idl in Resources */ = {isa = PBXBuildFile; fileRef = E44613A00CD6331000FADA75 /* VoidCallback.idl */; };
-               E44613B50CD6344E00FADA75 /* VoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44613B30CD6344E00FADA75 /* VoidCallback.cpp */; };
                E44613B60CD6344E00FADA75 /* VoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = E44613B40CD6344E00FADA75 /* VoidCallback.h */; };
                E44613E30CD6819F00FADA75 /* Movie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B41E0C0CBF90BD00AF2ECE /* Movie.cpp */; };
                E44613E40CD681A200FADA75 /* Movie.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B41E0D0CBF90BD00AF2ECE /* Movie.h */; };
                E44614190CD6826900FADA75 /* JSMediaError.h in Headers */ = {isa = PBXBuildFile; fileRef = E44614110CD6826900FADA75 /* JSMediaError.h */; };
                E446141A0CD6826900FADA75 /* JSTimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44614120CD6826900FADA75 /* JSTimeRanges.cpp */; };
                E446141B0CD6826900FADA75 /* JSTimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = E44614130CD6826900FADA75 /* JSTimeRanges.h */; };
-               E446141C0CD6826900FADA75 /* JSVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E44614140CD6826900FADA75 /* JSVoidCallback.cpp */; };
-               E446141D0CD6826900FADA75 /* JSVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = E44614150CD6826900FADA75 /* JSVoidCallback.h */; };
                E44614370CD689C400FADA75 /* JSHTMLAudioElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B4237D0CBFB73C00AF2ECE /* JSHTMLAudioElement.cpp */; };
                E44614380CD689C500FADA75 /* JSHTMLAudioElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E4B4237E0CBFB73C00AF2ECE /* JSHTMLAudioElement.h */; };
                E44614390CD689C700FADA75 /* JSHTMLMediaElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B4237F0CBFB73C00AF2ECE /* JSHTMLMediaElement.cpp */; };
                1A2E6E790CC556D5004A2062 /* SQLiteAuthorizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLiteAuthorizer.h; path = sql/SQLiteAuthorizer.h; sourceTree = "<group>"; };
                1A2E6FA30CC5795D004A2062 /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadingPthreads.cpp; path = pthreads/ThreadingPthreads.cpp; sourceTree = "<group>"; };
                1A3178920B20A81600316987 /* SubresourceLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceLoaderClient.h; sourceTree = "<group>"; };
+               1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomVoidCallback.h; sourceTree = "<group>"; };
+               1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomVoidCallback.cpp; sourceTree = "<group>"; };
                1A494BBB0A122DCD00FDAFC1 /* HTMLElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLElement.idl; sourceTree = "<group>"; };
                1A494BF80A122F4400FDAFC1 /* JSHTMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElement.cpp; sourceTree = "<group>"; };
                1A494BF90A122F4400FDAFC1 /* JSHTMLElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLElement.h; sourceTree = "<group>"; };
                E446139E0CD6331000FADA75 /* TimeRanges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeRanges.h; sourceTree = "<group>"; };
                E446139F0CD6331000FADA75 /* TimeRanges.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TimeRanges.idl; sourceTree = "<group>"; };
                E44613A00CD6331000FADA75 /* VoidCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VoidCallback.idl; sourceTree = "<group>"; };
-               E44613B30CD6344E00FADA75 /* VoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoidCallback.cpp; sourceTree = "<group>"; };
                E44613B40CD6344E00FADA75 /* VoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoidCallback.h; sourceTree = "<group>"; };
                E446140E0CD6826900FADA75 /* JSHTMLVideoElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLVideoElement.cpp; sourceTree = "<group>"; };
                E446140F0CD6826900FADA75 /* JSHTMLVideoElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLVideoElement.h; sourceTree = "<group>"; };
                E44614110CD6826900FADA75 /* JSMediaError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaError.h; sourceTree = "<group>"; };
                E44614120CD6826900FADA75 /* JSTimeRanges.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTimeRanges.cpp; sourceTree = "<group>"; };
                E44614130CD6826900FADA75 /* JSTimeRanges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTimeRanges.h; sourceTree = "<group>"; };
-               E44614140CD6826900FADA75 /* JSVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVoidCallback.cpp; sourceTree = "<group>"; };
-               E44614150CD6826900FADA75 /* JSVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVoidCallback.h; sourceTree = "<group>"; };
                E4B41E010CBF8EAA00AF2ECE /* ProgressEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressEvent.cpp; sourceTree = "<group>"; };
                E4B41E020CBF8EAA00AF2ECE /* ProgressEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressEvent.h; sourceTree = "<group>"; };
                E4B41E030CBF8EAA00AF2ECE /* ProgressEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ProgressEvent.idl; sourceTree = "<group>"; };
                                E446139D0CD6331000FADA75 /* TimeRanges.cpp */,
                                E446139E0CD6331000FADA75 /* TimeRanges.h */,
                                E446139F0CD6331000FADA75 /* TimeRanges.idl */,
-                               E44613B30CD6344E00FADA75 /* VoidCallback.cpp */,
                                E44613B40CD6344E00FADA75 /* VoidCallback.h */,
                                E44613A00CD6331000FADA75 /* VoidCallback.idl */,
                        );
                                E44614110CD6826900FADA75 /* JSMediaError.h */,
                                E44614120CD6826900FADA75 /* JSTimeRanges.cpp */,
                                E44614130CD6826900FADA75 /* JSTimeRanges.h */,
-                               E44614140CD6826900FADA75 /* JSVoidCallback.cpp */,
-                               E44614150CD6826900FADA75 /* JSVoidCallback.h */,
                        );
                        name = HTML;
                        sourceTree = "<group>";
                                51EC92600CE90DD400F90308 /* JSCustomSQLTransactionCallback.h */,
                                51EC92610CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.cpp */,
                                51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
+                               1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
+                               1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
                                BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
                                BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
                                BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
                                E446141B0CD6826900FADA75 /* JSTimeRanges.h in Headers */,
                                1A750D5D0A90DEE1000FF215 /* JSTreeWalker.h in Headers */,
                                A86629CF09DA2B47009633A5 /* JSUIEvent.h in Headers */,
-                               E446141D0CD6826900FADA75 /* JSVoidCallback.h in Headers */,
                                65DF320609D1CC60000BE325 /* JSWheelEvent.h in Headers */,
                                93B70D5E09EB0C7C009D8468 /* JSXMLHttpRequest.h in Headers */,
                                656581EE09D1508D000E61D7 /* JSXMLHttpRequest.lut.h in Headers */,
                                BCB16C2D0979C3BD00467741 /* loader.h in Headers */,
                                93309DF8099E64920056E581 /* markup.h in Headers */,
                                93309E1E099E64920056E581 /* visible_units.h in Headers */,
+                               1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1A750D5C0A90DEE1000FF215 /* JSTreeWalker.cpp in Sources */,
                                516BB7940CE91E6800512F79 /* JSTreeWalkerCustom.cpp in Sources */,
                                A86629D009DA2B48009633A5 /* JSUIEvent.cpp in Sources */,
-                               E446141C0CD6826900FADA75 /* JSVoidCallback.cpp in Sources */,
                                65DF320509D1CC60000BE325 /* JSWheelEvent.cpp in Sources */,
                                93B70D5D09EB0C7C009D8468 /* JSXMLHttpRequest.cpp in Sources */,
                                1ACE53F60A8D19470022947D /* JSXMLSerializer.cpp in Sources */,
                                D086FE9909D53AAB005BC74D /* UnlinkCommand.cpp in Sources */,
                                65DF326109D1E199000BE325 /* UserAgentStyleSheetsData.cpp in Sources */,
                                93309E1F099E64920056E581 /* VisiblePosition.cpp in Sources */,
-                               E44613B50CD6344E00FADA75 /* VoidCallback.cpp in Sources */,
                                B2E27C500B0F2AE600F17C7B /* WKArithmeticFilter.m in Sources */,
                                B2E27C530B0F2AE600F17C7B /* WKComponentMergeFilter.m in Sources */,
                                B2E27C560B0F2AE600F17C7B /* WKDiffuseLightingFilter.m in Sources */,
                                BCB16C2C0979C3BD00467741 /* loader.cpp in Sources */,
                                93309DF7099E64920056E581 /* markup.cpp in Sources */,
                                93309E1D099E64920056E581 /* visible_units.cpp in Sources */,
+                               1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/bindings/js/JSCustomVoidCallback.cpp b/WebCore/bindings/js/JSCustomVoidCallback.cpp
new file mode 100644 (file)
index 0000000..86eea6a
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 "JSCustomVoidCallback.h"
+
+#include "CString.h"
+#include "DOMWindow.h"
+#include "Frame.h"
+#include "kjs_binding.h"
+#include "kjs_proxy.h"
+#include "kjs_window.h"
+#include "Page.h"
+
+namespace WebCore {
+    
+using namespace KJS;
+    
+JSCustomVoidCallback::JSCustomVoidCallback(JSObject* callback, Frame* frame)
+    : m_callback(callback)
+    , m_frame(frame)
+{
+}
+    
+void JSCustomVoidCallback::handleEvent()
+{
+    ASSERT(m_callback);
+    ASSERT(m_frame);
+       
+    KJSProxy* proxy = m_frame->scriptProxy();
+    if (!proxy)
+        return;
+        
+    ScriptInterpreter* interpreter = proxy->interpreter();
+    ExecState* exec = interpreter->globalExec();
+        
+    KJS::JSLock lock;
+        
+    JSValue* handleEventFuncValue = m_callback->get(exec, "handleEvent");
+    JSObject* handleEventFunc = 0;
+    if (handleEventFuncValue->isObject()) {
+        handleEventFunc = static_cast<JSObject*>(handleEventFuncValue);
+        if (!handleEventFunc->implementsCall())
+            handleEventFunc = 0;
+    }
+        
+    if (!handleEventFunc && !m_callback->implementsCall()) {
+        // FIXME: Should an exception be thrown here?
+        return;
+    }
+        
+    RefPtr<JSCustomVoidCallback> protect(this);
+        
+    List args;
+    
+    interpreter->startTimeoutCheck();
+    if (handleEventFunc)
+        handleEventFunc->call(exec, m_callback, args);
+    else
+        m_callback->call(exec, m_callback, args);
+    interpreter->stopTimeoutCheck();
+        
+    if (exec->hadException()) {
+        JSObject* exception = exec->exception()->toObject(exec);
+        String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
+        int lineNumber = exception->get(exec, "line")->toInt32(exec);
+        String sourceURL = exception->get(exec, "sourceURL")->toString(exec);
+        if (Interpreter::shouldPrintExceptions())
+            printf("VoidCallback: %s\n", message.utf8().data());
+        if (Page* page = m_frame->page())
+            page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, lineNumber, sourceURL);
+        exec->clearException();            
+    }
+        
+    Document::updateDocumentsRendering();
+}
+VoidCallback* toVoidCallback(ExecState* exec, JSValue* value, bool& ok)
+{
+    ok = false;
+    
+    JSObject* object = value->getObject();
+    if (!object)
+        return 0;
+    
+    Frame* frame = Window::retrieveActive(exec)->impl()->frame();
+    if (!frame)
+        return 0;
+    
+    ok = true;
+    return new JSCustomVoidCallback(object, frame);
+}
+
+}
diff --git a/WebCore/bindings/js/JSCustomVoidCallback.h b/WebCore/bindings/js/JSCustomVoidCallback.h
new file mode 100644 (file)
index 0000000..1f97f39
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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 JSCustomVoidCallback_h
+#define JSCustomVoidCallback_h
+
+#include "VoidCallback.h"
+
+#include <kjs/object.h>
+#include <kjs/protect.h>
+#include <wtf/Forward.h>
+
+namespace KJS {
+    class JSObject;
+}
+
+namespace WebCore {
+    
+    class Frame;
+    class SQLError;
+    
+    class JSCustomVoidCallback : public VoidCallback {
+    public:
+        JSCustomVoidCallback(KJS::JSObject* callback, Frame*);
+        
+        virtual void handleEvent();
+    private:
+        KJS::ProtectedPtr<KJS::JSObject> m_callback;
+        RefPtr<Frame> m_frame;
+    };
+   
+    VoidCallback* toVoidCallback(KJS::ExecState*, KJS::JSValue*, bool& ok);
+}
+
+#endif // JSCustomVoidCallback_h
index 0a4b03661a0e63f26846831bf89c216dfa2deb7f..6d185cfe222da3e04a4086de40dd7eac45016389 100644 (file)
@@ -1353,8 +1353,9 @@ sub TypeCanFailConversion
                 $type eq "HTMLOptionElement" or
                 $type eq "unsigned short" or # or can it?
                 $type eq "CompareHow" or # or can it?
-                $type eq "SVGPaintType" or # or can it?
-                $type eq "VoidCallback";
+                $type eq "SVGPaintType"; # or can it?
+
+    return 1 if $type eq "VoidCallback";
 
     if ($type eq "unsigned long" or $type eq "long" or $type eq "Attr") {
         $implIncludes{"ExceptionCode.h"} = 1;
@@ -1407,8 +1408,8 @@ sub JSValueToNative
     }
 
     if ($type eq "VoidCallback") {
-        $implIncludes{"VoidCallback.h"} = 1;
-        return "toVoidCallback($value)";
+        $implIncludes{"JSCustomVoidCallback.h"} = 1;
+        return "toVoidCallback(exec, $value${maybeOkParam})";
     }
 
     # Default, assume autogenerated type conversion routines
index b1059b9089a4d662d0e37b77b384d3789a612190..9760d9489bc990804c7f72dafa759611e4c904f9 100644 (file)
@@ -873,7 +873,7 @@ void HTMLMediaElement::movieCuePointReached(Movie*, float cueTime)
     for (unsigned n = 0; n < callbackVector->size(); n++) {
         CallbackEntry ce = (*callbackVector)[n];
         if (ce.m_voidCallback) 
-            ce.m_voidCallback->execute(document()->frame());
+            ce.m_voidCallback->handleEvent();
     }      
 }
 
@@ -894,23 +894,9 @@ void HTMLMediaElement::addCuePoint(float time, VoidCallback* voidCallback, bool
 
 void HTMLMediaElement::removeCuePoint(float time, VoidCallback* callback)
 {
-    if (time < 0 || !isfinite(time))
-        return;
-    CallbackVector* callbackVector = m_cuePoints.get(time);
-    if (callbackVector) {
-        for (unsigned n = 0; n < callbackVector->size(); n++) {
-            if (*(*callbackVector)[n].m_voidCallback == *callback) {
-                callbackVector->remove(n);
-                break;
-            }
-        }
-        if (!callbackVector->size()) {
-            delete callbackVector;
-            m_cuePoints.remove(time);
-            if (m_movie)
-                m_movie->removeCuePoint(time);
-        }
-    }
+    // FIXME: This method be removed entirely. The body has been removed
+    // because it used to contain code that compared VoidCallbacks for equality
+    // and the new VoidCallback interface doesn't allow that.
 }
 
 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const
diff --git a/WebCore/html/VoidCallback.cpp b/WebCore/html/VoidCallback.cpp
deleted file mode 100644 (file)
index 03c9b03..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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();
-    List args;
-    static_cast<JSObject*>(m_func)->call(exec, window, args);
-    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);
-}
-
index b77da4728d87171dde20df09fb270cae0a2b55ba..8c09447897ee48bc6352df82587eac1da4e088d4 100644 (file)
@@ -36,21 +36,12 @@ class Frame;
     
 class VoidCallback : public RefCounted<VoidCallback> {
 public:
-    VoidCallback(KJS::JSValue* func);
-    virtual ~VoidCallback();
+    VoidCallback() { }
+    virtual ~VoidCallback() { }
     
-    void handleEvent();
-    
-    void execute(Frame* frame);
-    
-    bool operator==(const VoidCallback&) const;
-    
-private:
-    KJS::JSValue* m_func;
+    virtual void handleEvent() = 0;
 };
 
-VoidCallback* toVoidCallback(KJS::JSValue*);
-
 } // namespace WebCore
 
 #endif