Changeset 58330 in webkit
- Timestamp:
- Apr 27, 2010 1:26:16 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r58324 r58330 1 2010-04-27 Adam Barth <abarth@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 Remove copy/paste addEventListener "custom" bindings via code generation 6 https://bugs.webkit.org/show_bug.cgi?id=38210 7 8 It's somewhat lame to special case addEventListener and 9 removeEventListener in the code generator, but it saves a large amount 10 of boilerplate "custom" bindings code. 11 12 Idea shamelessly stolen from the V8 code generator. 13 14 This patch points to some good refactoring opportunities in 15 CodeGeneratorJS.pm, but I'm going to hold off on those for a future 16 patch. By generating test coverage for the code generator, we make 17 these future refactorings easier. 18 19 * bindings/js/JSAbstractWorkerCustom.cpp: 20 * bindings/js/JSDOMApplicationCacheCustom.cpp: 21 * bindings/js/JSDesktopNotificationsCustom.cpp: 22 * bindings/js/JSEventSourceCustom.cpp: 23 * bindings/js/JSMessagePortCustom.cpp: 24 * bindings/js/JSNodeCustom.cpp: 25 * bindings/js/JSSVGElementInstanceCustom.cpp: 26 * bindings/js/JSWebSocketCustom.cpp: 27 * bindings/js/JSWorkerContextCustom.cpp: 28 * bindings/js/JSXMLHttpRequestCustom.cpp: 29 * bindings/js/JSXMLHttpRequestUploadCustom.cpp: 30 * bindings/scripts/CodeGeneratorJS.pm: 31 * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: 32 * bindings/scripts/test/GObject/WebKitDOMTestObj.h: 33 * bindings/scripts/test/JS/JSTestObj.cpp: 34 (WebCore::): 35 (WebCore::jsTestObjPrototypeFunctionAddEventListener): 36 (WebCore::jsTestObjPrototypeFunctionRemoveEventListener): 37 * bindings/scripts/test/JS/JSTestObj.h: 38 * bindings/scripts/test/ObjC/DOMTestObj.h: 39 * bindings/scripts/test/ObjC/DOMTestObj.mm: 40 (-[DOMTestObj addEventListener:listener:useCapture:]): 41 (-[DOMTestObj removeEventListener:listener:useCapture:]): 42 * bindings/scripts/test/TestObj.idl: 43 * bindings/scripts/test/V8/V8TestObj.cpp: 44 (WebCore::TestObjInternal::addEventListenerCallback): 45 (WebCore::TestObjInternal::removeEventListenerCallback): 46 (WebCore::): 47 * dom/MessagePort.idl: 48 * dom/Node.idl: 49 * loader/appcache/DOMApplicationCache.idl: 50 * notifications/Notification.idl: 51 * page/EventSource.idl: 52 * svg/SVGElementInstance.idl: 53 * websockets/WebSocket.idl: 54 * workers/AbstractWorker.idl: 55 * workers/WorkerContext.idl: 56 * xml/XMLHttpRequest.idl: 57 * xml/XMLHttpRequestUpload.idl: 58 1 59 2010-04-27 Sam Weinig <sam@webkit.org> 2 60 -
trunk/WebCore/bindings/js/JSAbstractWorkerCustom.cpp
r57766 r58330 45 45 namespace WebCore { 46 46 47 JSValue JSAbstractWorker::addEventListener(ExecState* exec, const ArgList& args) 48 { 49 JSValue listener = args.at(1); 50 if (!listener.isObject()) 51 return jsUndefined(); 52 53 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); 54 return jsUndefined(); 55 } 56 57 JSValue JSAbstractWorker::removeEventListener(ExecState* exec, const ArgList& args) 58 { 59 JSValue listener = args.at(1); 60 if (!listener.isObject()) 61 return jsUndefined(); 62 63 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); 64 return jsUndefined(); 65 } 47 // FIXME: Remove this file. 66 48 67 49 } // namespace WebCore -
trunk/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp
r57766 r58330 86 86 #endif // ENABLE(APPLICATION_CACHE_DYNAMIC_ENTRIES) 87 87 88 JSValue JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& args)89 {90 JSValue listener = args.at(1);91 if (!listener.isObject())92 return jsUndefined();93 94 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));95 return jsUndefined();96 }97 98 JSValue JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgList& args)99 {100 JSValue listener = args.at(1);101 if (!listener.isObject())102 return jsUndefined();103 104 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));105 return jsUndefined();106 }107 108 88 } // namespace WebCore 109 89 -
trunk/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
r57769 r58330 62 62 } 63 63 64 JSValue JSNotification::addEventListener(ExecState* exec, const ArgList& args)65 {66 JSValue listener = args.at(1);67 if (!listener.isObject())68 return jsUndefined();69 70 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));71 return jsUndefined();72 }73 74 JSValue JSNotification::removeEventListener(ExecState* exec, const ArgList& args)75 {76 JSValue listener = args.at(1);77 if (!listener.isObject())78 return jsUndefined();79 80 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));81 return jsUndefined();82 }83 84 85 64 } // namespace 86 65 -
trunk/WebCore/bindings/js/JSEventSourceCustom.cpp
r57766 r58330 44 44 namespace WebCore { 45 45 46 JSValue JSEventSource::addEventListener(ExecState* exec, const ArgList& args) 47 { 48 JSValue listener = args.at(1); 49 if (!listener.isObject()) 50 return jsUndefined(); 51 52 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); 53 return jsUndefined(); 54 } 55 56 JSValue JSEventSource::removeEventListener(ExecState* exec, const ArgList& args) 57 { 58 JSValue listener = args.at(1); 59 if (!listener.isObject()) 60 return jsUndefined(); 61 62 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); 63 return jsUndefined(); 64 } 46 // FIXME: Remove this file. 65 47 66 48 } // namespace WebCore -
trunk/WebCore/bindings/js/JSMessagePortCustom.cpp
r57766 r58330 53 53 } 54 54 55 JSValue JSMessagePort::addEventListener(ExecState* exec, const ArgList& args)56 {57 JSValue listener = args.at(1);58 if (!listener.isObject())59 return jsUndefined();60 61 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));62 return jsUndefined();63 }64 65 JSValue JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args)66 {67 JSValue listener = args.at(1);68 if (!listener.isObject())69 return jsUndefined();70 71 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));72 return jsUndefined();73 }74 75 55 JSC::JSValue JSMessagePort::postMessage(JSC::ExecState* exec, const JSC::ArgList& args) 76 56 { -
trunk/WebCore/bindings/js/JSNodeCustom.cpp
r57766 r58330 170 170 } 171 171 172 JSValue JSNode::addEventListener(ExecState* exec, const ArgList& args)173 {174 JSValue listener = args.at(1);175 if (!listener.isObject())176 return jsUndefined();177 178 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));179 return jsUndefined();180 }181 182 JSValue JSNode::removeEventListener(ExecState* exec, const ArgList& args)183 {184 JSValue listener = args.at(1);185 if (!listener.isObject())186 return jsUndefined();187 188 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));189 return jsUndefined();190 }191 192 172 void JSNode::pushEventHandlerScope(ExecState*, ScopeChain&) const 193 173 { -
trunk/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp
r57766 r58330 47 47 } 48 48 49 JSValue JSSVGElementInstance::addEventListener(ExecState* exec, const ArgList& args)50 {51 JSValue listener = args.at(1);52 if (!listener.isObject())53 return jsUndefined();54 55 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));56 return jsUndefined();57 }58 59 JSValue JSSVGElementInstance::removeEventListener(ExecState* exec, const ArgList& args)60 {61 JSValue listener = args.at(1);62 if (!listener.isObject())63 return jsUndefined();64 65 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));66 return jsUndefined();67 }68 69 49 void JSSVGElementInstance::pushEventHandlerScope(ExecState*, ScopeChain&) const 70 50 { -
trunk/WebCore/bindings/js/JSWebSocketCustom.cpp
r57766 r58330 60 60 } 61 61 62 JSValue JSWebSocket::addEventListener(ExecState* exec, const ArgList& args)63 {64 JSValue listener = args.at(1);65 if (!listener.isObject())66 return jsUndefined();67 68 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));69 return jsUndefined();70 }71 72 JSValue JSWebSocket::removeEventListener(ExecState* exec, const ArgList& args)73 {74 JSValue listener = args.at(1);75 if (!listener.isObject())76 return jsUndefined();77 78 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));79 return jsUndefined();80 }81 82 62 } // namespace WebCore 83 63 -
trunk/WebCore/bindings/js/JSWorkerContextCustom.cpp
r57766 r58330 117 117 } 118 118 119 JSValue JSWorkerContext::addEventListener(ExecState* exec, const ArgList& args)120 {121 JSValue listener = args.at(1);122 if (!listener.isObject())123 return jsUndefined();124 125 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));126 return jsUndefined();127 }128 129 JSValue JSWorkerContext::removeEventListener(ExecState* exec, const ArgList& args)130 {131 JSValue listener = args.at(1);132 if (!listener.isObject())133 return jsUndefined();134 135 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));136 return jsUndefined();137 }138 139 119 JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args) 140 120 { -
trunk/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
r57766 r58330 154 154 } 155 155 156 JSValue JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args)157 {158 JSValue listener = args.at(1);159 if (!listener.isObject())160 return jsUndefined();161 162 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));163 return jsUndefined();164 }165 166 JSValue JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& args)167 {168 JSValue listener = args.at(1);169 if (!listener.isObject())170 return jsUndefined();171 172 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));173 return jsUndefined();174 }175 176 156 JSValue JSXMLHttpRequest::responseText(ExecState* exec) const 177 157 { -
trunk/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp
r57766 r58330 52 52 } 53 53 54 JSValue JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args)55 {56 JSValue listener = args.at(1);57 if (!listener.isObject())58 return jsUndefined();59 60 impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec));61 return jsUndefined();62 }63 64 JSValue JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args)65 {66 JSValue listener = args.at(1);67 if (!listener.isObject())68 return jsUndefined();69 70 impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));71 return jsUndefined();72 }73 74 54 } // namespace WebCore -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r58298 r58330 120 120 open($DEPS, ">$depsFileName") || die "Couldn't open file $depsFileName"; 121 121 } 122 } 123 124 sub GenerateEventListenerCall 125 { 126 my $className = shift; 127 my $functionName = shift; 128 my $passRefPtrHandling = ($functionName eq "add") ? "" : ".get()"; 129 130 $implIncludes{"JSEventListener.h"} = 1; 131 132 my @GenerateEventListenerImpl = (); 133 push(@GenerateEventListenerImpl, <<END); 134 JSValue listener = args.at(1); 135 if (!listener.isObject()) 136 return jsUndefined(); 137 imp->${functionName}EventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThisObj, false, currentWorld(exec))$passRefPtrHandling, args.at(2).toBoolean(exec)); 138 return jsUndefined(); 139 END 140 return @GenerateEventListenerImpl; 122 141 } 123 142 … … 1694 1713 } 1695 1714 1696 my $paramIndex = 0; 1697 my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; 1698 1699 my $hasOptionalArguments = 0; 1700 1701 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 1702 push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); 1703 $implIncludes{"ScriptCallStack.h"} = 1; 1715 if ($function->signature->name eq "addEventListener") { 1716 push(@implContent, GenerateEventListenerCall($className, "add")); 1717 } elsif ($function->signature->name eq "removeEventListener") { 1718 push(@implContent, GenerateEventListenerCall($className, "remove")); 1719 } else { 1720 my $paramIndex = 0; 1721 my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; 1722 1723 my $hasOptionalArguments = 0; 1724 1725 if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { 1726 push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); 1727 $implIncludes{"ScriptCallStack.h"} = 1; 1728 } 1729 1730 my $callWith = $function->signature->extendedAttributes->{"CallWith"}; 1731 if ($callWith) { 1732 my $callWithArg = "COMPILE_ASSERT(false)"; 1733 if ($callWith eq "DynamicFrame") { 1734 push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n"); 1735 push(@implContent, " if (!dynamicFrame)\n"); 1736 push(@implContent, " return jsUndefined();\n"); 1737 $callWithArg = "dynamicFrame"; 1738 } elsif ($callWith eq "ScriptState") { 1739 $callWithArg = "exec"; 1740 } 1741 $functionString .= ", " if $paramIndex; 1742 $functionString .= $callWithArg; 1743 $paramIndex++; 1744 } 1745 1746 foreach my $parameter (@{$function->parameters}) { 1747 if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { 1748 push(@implContent, "\n int argsCount = args.size();\n"); 1749 $hasOptionalArguments = 1; 1750 } 1751 1752 if ($hasOptionalArguments) { 1753 push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); 1754 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); 1755 push(@implContent, " }\n\n"); 1756 } 1757 1758 my $name = $parameter->name; 1759 1760 if ($parameter->type eq "XPathNSResolver") { 1761 push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); 1762 push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n"); 1763 push(@implContent, " if (!resolver) {\n"); 1764 push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n"); 1765 push(@implContent, " if (exec->hadException())\n"); 1766 push(@implContent, " return jsUndefined();\n"); 1767 push(@implContent, " resolver = customResolver.get();\n"); 1768 push(@implContent, " }\n"); 1769 } else { 1770 push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n"); 1771 1772 # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. 1773 # But this needs to be done in the bindings, because the type is unsigned and the fact that it 1774 # was negative will be lost by the time we're inside the DOM. 1775 if ($parameter->extendedAttributes->{"IsIndex"}) { 1776 $implIncludes{"ExceptionCode.h"} = 1; 1777 push(@implContent, " if ($name < 0) {\n"); 1778 push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); 1779 push(@implContent, " return jsUndefined();\n"); 1780 push(@implContent, " }\n"); 1781 } 1782 } 1783 1784 $functionString .= ", " if $paramIndex; 1785 1786 if ($parameter->type eq "NodeFilter") { 1787 $functionString .= "$name.get()"; 1788 } else { 1789 $functionString .= $name; 1790 } 1791 $paramIndex++; 1792 } 1793 1794 if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { 1795 $functionString .= ", " if $paramIndex; 1796 $functionString .= "processingUserGesture(exec)"; 1797 $paramIndex++; 1798 } 1799 1800 push(@implContent, "\n"); 1801 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName); 1704 1802 } 1705 1706 my $callWith = $function->signature->extendedAttributes->{"CallWith"};1707 if ($callWith) {1708 my $callWithArg = "COMPILE_ASSERT(false)";1709 if ($callWith eq "DynamicFrame") {1710 push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n");1711 push(@implContent, " if (!dynamicFrame)\n");1712 push(@implContent, " return jsUndefined();\n");1713 $callWithArg = "dynamicFrame";1714 } elsif ($callWith eq "ScriptState") {1715 $callWithArg = "exec";1716 }1717 $functionString .= ", " if $paramIndex;1718 $functionString .= $callWithArg;1719 $paramIndex++;1720 }1721 1722 foreach my $parameter (@{$function->parameters}) {1723 if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) {1724 push(@implContent, "\n int argsCount = args.size();\n");1725 $hasOptionalArguments = 1;1726 }1727 1728 if ($hasOptionalArguments) {1729 push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n");1730 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName);1731 push(@implContent, " }\n\n");1732 }1733 1734 my $name = $parameter->name;1735 1736 if ($parameter->type eq "XPathNSResolver") {1737 push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n");1738 push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n");1739 push(@implContent, " if (!resolver) {\n");1740 push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n");1741 push(@implContent, " if (exec->hadException())\n");1742 push(@implContent, " return jsUndefined();\n");1743 push(@implContent, " resolver = customResolver.get();\n");1744 push(@implContent, " }\n");1745 } else {1746 push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n");1747 1748 # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.1749 # But this needs to be done in the bindings, because the type is unsigned and the fact that it1750 # was negative will be lost by the time we're inside the DOM.1751 if ($parameter->extendedAttributes->{"IsIndex"}) {1752 $implIncludes{"ExceptionCode.h"} = 1;1753 push(@implContent, " if ($name < 0) {\n");1754 push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n");1755 push(@implContent, " return jsUndefined();\n");1756 push(@implContent, " }\n");1757 }1758 }1759 1760 $functionString .= ", " if $paramIndex;1761 1762 if ($parameter->type eq "NodeFilter") {1763 $functionString .= "$name.get()";1764 } else {1765 $functionString .= $name;1766 }1767 $paramIndex++;1768 }1769 1770 if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {1771 $functionString .= ", " if $paramIndex;1772 $functionString .= "processingUserGesture(exec)";1773 $paramIndex++;1774 }1775 1776 push(@implContent, "\n");1777 GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName);1778 1803 } 1779 1804 push(@implContent, "}\n\n"); -
trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
r58298 r58330 141 141 142 142 /* TODO: custom function webkit_dom_test_obj_custom_args_and_exception */ 143 144 145 /* TODO: event function webkit_dom_test_obj_add_event_listener */ 146 147 148 /* TODO: event function webkit_dom_test_obj_remove_event_listener */ 143 149 144 150 void -
trunk/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
r58298 r58330 70 70 71 71 /* TODO: custom function webkit_dom_test_obj_custom_args_and_exception */ 72 73 74 /* TODO: event function webkit_dom_test_obj_add_event_listener */ 75 76 77 /* TODO: event function webkit_dom_test_obj_remove_event_listener */ 72 78 73 79 WEBKIT_API void -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r58298 r58330 22 22 #include "JSTestObj.h" 23 23 24 #include "JSEventListener.h" 24 25 #include "JSTestObj.h" 25 26 #include "JSlog.h" … … 129 130 #endif 130 131 131 static const HashTableValue JSTestObjPrototypeTableValues[2 1] =132 static const HashTableValue JSTestObjPrototypeTableValues[23] = 132 133 { 133 134 { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, … … 141 142 { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, 142 143 { "customArgsAndException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, 144 { "addEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, 145 { "removeEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, 143 146 { "withDynamicFrame", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, 144 147 { "withDynamicFrameAndArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, … … 489 492 } 490 493 494 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 495 { 496 UNUSED_PARAM(args); 497 if (!thisValue.inherits(&JSTestObj::s_info)) 498 return throwError(exec, TypeError); 499 JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue)); 500 TestObj* imp = static_cast<TestObj*>(castedThisObj->impl()); 501 JSValue listener = args.at(1); 502 if (!listener.isObject()) 503 return jsUndefined(); 504 imp->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThisObj, false, currentWorld(exec)), args.at(2).toBoolean(exec)); 505 return jsUndefined(); 506 } 507 508 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 509 { 510 UNUSED_PARAM(args); 511 if (!thisValue.inherits(&JSTestObj::s_info)) 512 return throwError(exec, TypeError); 513 JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue)); 514 TestObj* imp = static_cast<TestObj*>(castedThisObj->impl()); 515 JSValue listener = args.at(1); 516 if (!listener.isObject()) 517 return jsUndefined(); 518 imp->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThisObj, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); 519 return jsUndefined(); 520 } 521 491 522 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) 492 523 { -
trunk/WebCore/bindings/scripts/test/JS/JSTestObj.h
r58298 r58330 96 96 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 97 97 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 98 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 99 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 98 100 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); 99 101 JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); -
trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
r58298 r58330 32 32 @class DOMlog; 33 33 @class NSString; 34 @protocol DOMEventListener; 34 35 35 36 @interface DOMTestObj : DOMObject … … 61 62 - (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; 62 63 - (void)customArgsAndException:(DOMlog *)intArg; 64 - (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; 65 - (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; 63 66 - (void)withDynamicFrame; 64 67 - (void)withDynamicFrameAndArg:(int)intArg; -
trunk/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
r58298 r58330 38 38 #import "DOMTestObjInternal.h" 39 39 #import "DOMlogInternal.h" 40 #import "EventListener.h" 40 41 #import "ExceptionHandlers.h" 41 42 #import "KURL.h" 43 #import "ObjCEventListener.h" 42 44 #import "TestObj.h" 43 45 #import "ThreadCheck.h" … … 207 209 IMPL->customArgsAndException(core(intArg), ec); 208 210 WebCore::raiseOnDOMError(ec); 211 } 212 213 - (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture 214 { 215 RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); 216 IMPL->addEventListener(type, WTF::getPtr(nativeEventListener), useCapture); 217 } 218 219 - (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture 220 { 221 RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); 222 IMPL->removeEventListener(type, WTF::getPtr(nativeEventListener), useCapture); 209 223 } 210 224 -
trunk/WebCore/bindings/scripts/test/TestObj.idl
r58298 r58330 61 61 raises(DOMException); 62 62 63 void addEventListener(in DOMString type, 64 in EventListener listener, 65 in boolean useCapture); 66 void removeEventListener(in DOMString type, 67 in EventListener listener, 68 in boolean useCapture); 69 63 70 // 'CallWith' extended attribute 64 71 [CallWith=DynamicFrame] void withDynamicFrame(); -
trunk/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
r58315 r58330 254 254 V8Proxy::setDOMException(ec); 255 255 return v8::Handle<v8::Value>(); 256 } 257 258 static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args) 259 { 260 INC_STATS("DOM.TestObj.addEventListener()"); 261 RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate); 262 if (listener) { 263 V8TestObj::toNative(args.Holder())->addEventListener(v8ValueToAtomicWebCoreString(args[0]), listener, args[2]->BooleanValue()); 264 createHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); 265 } 266 return v8::Undefined(); 267 } 268 269 static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args) 270 { 271 INC_STATS("DOM.TestObj.removeEventListener()"); 272 RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly); 273 if (listener) { 274 V8TestObj::toNative(args.Holder())->removeEventListener(v8ValueToAtomicWebCoreString(args[0]), listener.get(), args[2]->BooleanValue()); 275 removeHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); 276 } 277 return v8::Undefined(); 256 278 } 257 279 … … 483 505 {"customMethod", V8TestObj::customMethodCallback}, 484 506 {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, 507 {"addEventListener", TestObjInternal::addEventListenerCallback}, 508 {"removeEventListener", TestObjInternal::removeEventListenerCallback}, 485 509 {"withDynamicFrame", TestObjInternal::withDynamicFrameCallback}, 486 510 {"withDynamicFrameAndArg", TestObjInternal::withDynamicFrameAndArgCallback}, -
trunk/WebCore/dom/MessagePort.idl
r55096 r58330 44 44 45 45 // EventTarget interface 46 [JSCCustom]void addEventListener(in DOMString type,47 48 49 [JSCCustom]void removeEventListener(in DOMString type,50 51 46 void addEventListener(in DOMString type, 47 in EventListener listener, 48 in boolean useCapture); 49 void removeEventListener(in DOMString type, 50 in EventListener listener, 51 in boolean useCapture); 52 52 boolean dispatchEvent(in Event evt) 53 53 raises(EventException); -
trunk/WebCore/dom/Node.idl
r58108 r58330 135 135 #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C 136 136 #if !defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT 137 [JSCCustom]void addEventListener(in DOMString type,138 139 140 [JSCCustom]void removeEventListener(in DOMString type,141 142 137 void addEventListener(in DOMString type, 138 in EventListener listener, 139 in boolean useCapture); 140 void removeEventListener(in DOMString type, 141 in EventListener listener, 142 in boolean useCapture); 143 143 boolean dispatchEvent(in Event event) 144 144 raises(EventException); -
trunk/WebCore/loader/appcache/DOMApplicationCache.idl
r55096 r58330 56 56 57 57 // EventTarget interface 58 [JSCCustom]void addEventListener(in DOMString type,59 60 61 [JSCCustom]void removeEventListener(in DOMString type,62 63 58 void addEventListener(in DOMString type, 59 in EventListener listener, 60 in boolean useCapture); 61 void removeEventListener(in DOMString type, 62 in EventListener listener, 63 in boolean useCapture); 64 64 boolean dispatchEvent(in Event evt) 65 65 raises(EventException); -
trunk/WebCore/notifications/Notification.idl
r55096 r58330 44 44 45 45 // EventTarget interface 46 [JSCCustom]void addEventListener(in DOMString type,47 48 49 [JSCCustom]void removeEventListener(in DOMString type,50 51 46 void addEventListener(in DOMString type, 47 in EventListener listener, 48 in boolean useCapture); 49 void removeEventListener(in DOMString type, 50 in EventListener listener, 51 in boolean useCapture); 52 52 boolean dispatchEvent(in Event evt) 53 53 raises(EventException); -
trunk/WebCore/page/EventSource.idl
r55096 r58330 54 54 55 55 // EventTarget interface 56 [JSCCustom]void addEventListener(in DOMString type,57 58 59 [JSCCustom]void removeEventListener(in DOMString type,60 61 56 void addEventListener(in DOMString type, 57 in EventListener listener, 58 in boolean useCapture); 59 void removeEventListener(in DOMString type, 60 in EventListener listener, 61 in boolean useCapture); 62 62 boolean dispatchEvent(in Event evt) 63 63 raises(EventException); -
trunk/WebCore/svg/SVGElementInstance.idl
r55096 r58330 91 91 attribute [DontEnum] EventListener onunload; 92 92 93 [JSCCustom]void addEventListener(in DOMString type,94 95 96 [JSCCustom]void removeEventListener(in DOMString type,97 98 93 void addEventListener(in DOMString type, 94 in EventListener listener, 95 in boolean useCapture); 96 void removeEventListener(in DOMString type, 97 in EventListener listener, 98 in boolean useCapture); 99 99 boolean dispatchEvent(in Event event) 100 100 raises(EventException); -
trunk/WebCore/websockets/WebSocket.idl
r55573 r58330 58 58 59 59 // EventTarget interface 60 [JSCCustom]void addEventListener(in DOMString type,61 62 63 [JSCCustom]void removeEventListener(in DOMString type,64 65 60 void addEventListener(in DOMString type, 61 in EventListener listener, 62 in boolean useCapture); 63 void removeEventListener(in DOMString type, 64 in EventListener listener, 65 in boolean useCapture); 66 66 boolean dispatchEvent(in Event evt) 67 67 raises(EventException); -
trunk/WebCore/workers/AbstractWorker.idl
r55096 r58330 39 39 attribute EventListener onerror; 40 40 41 [JSCCustom]void addEventListener(in DOMString type,42 43 44 [JSCCustom]void removeEventListener(in DOMString type,45 46 41 void addEventListener(in DOMString type, 42 in EventListener listener, 43 in boolean useCapture); 44 void removeEventListener(in DOMString type, 45 in EventListener listener, 46 in boolean useCapture); 47 47 boolean dispatchEvent(in Event evt) 48 48 raises(EventException); -
trunk/WebCore/workers/WorkerContext.idl
r57704 r58330 63 63 64 64 // EventTarget interface 65 [JSCCustom]void addEventListener(in DOMString type,66 67 68 [JSCCustom]void removeEventListener(in DOMString type,69 70 65 void addEventListener(in DOMString type, 66 in EventListener listener, 67 in boolean useCapture); 68 void removeEventListener(in DOMString type, 69 in EventListener listener, 70 in boolean useCapture); 71 71 boolean dispatchEvent(in Event evt) 72 72 raises(EventException); -
trunk/WebCore/xml/XMLHttpRequest.idl
r55096 r58330 92 92 93 93 // EventTarget interface 94 [JSCCustom]void addEventListener(in DOMString type,95 96 97 [JSCCustom]void removeEventListener(in DOMString type,98 99 94 void addEventListener(in DOMString type, 95 in EventListener listener, 96 in boolean useCapture); 97 void removeEventListener(in DOMString type, 98 in EventListener listener, 99 in boolean useCapture); 100 100 boolean dispatchEvent(in Event evt) 101 101 raises(EventException); -
trunk/WebCore/xml/XMLHttpRequestUpload.idl
r55096 r58330 43 43 44 44 // EventTarget interface 45 [JSCCustom]void addEventListener(in DOMString type,46 47 48 [JSCCustom]void removeEventListener(in DOMString type,49 50 45 void addEventListener(in DOMString type, 46 in EventListener listener, 47 in boolean useCapture); 48 void removeEventListener(in DOMString type, 49 in EventListener listener, 50 in boolean useCapture); 51 51 boolean dispatchEvent(in Event evt) 52 52 raises(EventException);
Note: See TracChangeset
for help on using the changeset viewer.