+2010-04-27 Adam Barth <abarth@webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ Remove custom bindings for TreeWalker
+ https://bugs.webkit.org/show_bug.cgi?id=38182
+
+ This custom code is just CallWith=ScriptState.
+
+ * WebCore.gypi:
+ * bindings/js/JSTreeWalkerCustom.cpp:
+ (WebCore::JSTreeWalker::markChildren):
+ * bindings/scripts/CodeGeneratorJS.pm:
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/scripts/test/TestObj.idl:
+ * bindings/v8/custom/V8TreeWalkerCustom.cpp: Removed.
+ * dom/TreeWalker.idl:
+
2010-04-27 Eric Seidel <eric@webkit.org>
Reviewed by Adam Barth.
'bindings/v8/custom/V8SharedWorkerCustom.cpp',
'bindings/v8/custom/V8StyleSheetCustom.cpp',
'bindings/v8/custom/V8StyleSheetListCustom.cpp',
- 'bindings/v8/custom/V8TreeWalkerCustom.cpp',
'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp',
'bindings/v8/custom/V8WebKitPointConstructor.cpp',
'bindings/v8/custom/V8WebSocketCustom.cpp',
if (NodeFilter* filter = m_impl->filter())
filter->markAggregate(markStack);
}
-
-JSValue JSTreeWalker::parentNode(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->parentNode(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::firstChild(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->firstChild(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::lastChild(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->lastChild(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::nextSibling(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->nextSibling(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::previousSibling(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->previousSibling(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::previousNode(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->previousNode(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
-
-JSValue JSTreeWalker::nextNode(ExecState* exec, const ArgList&)
-{
- Node* node = impl()->nextNode(exec);
- if (exec->hadException())
- return jsUndefined();
- return toJS(exec, node);
-}
}
}
my $callWith = $function->signature->extendedAttributes->{"CallWith"};
- if ($callWith && $callWith eq "DynamicFrame") {
- push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n");
- push(@implContent, " if (!dynamicFrame)\n");
- push(@implContent, " return jsUndefined();\n");
+ if ($callWith) {
+ my $callWithArg = "COMPILE_ASSERT(false)";
+ if ($callWith eq "DynamicFrame") {
+ push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n");
+ push(@implContent, " if (!dynamicFrame)\n");
+ push(@implContent, " return jsUndefined();\n");
+ $callWithArg = "dynamicFrame";
+ } elsif ($callWith eq "ScriptState") {
+ $callWithArg = "exec";
+ }
$functionString .= ", " if $paramIndex;
- $functionString .= "dynamicFrame";
+ $functionString .= $callWithArg;
$paramIndex++;
}
push(@implContent, $indent . "return jsUndefined();\n");
} else {
push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThisObj") . ";\n");
+ $callWith = $function->signature->extendedAttributes->{"CallWith"};
+ if ($callWith and $callWith eq "ScriptState") {
+ push(@implContent, $indent . "if (exec->hadException())\n");
+ push(@implContent, $indent . " return jsUndefined();\n");
+ }
push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions};
if ($podType and not $function->signature->extendedAttributes->{"Immutable"}) {
}
my $index = 0;
+ my $hasScriptState = 0;
my $callWith = $function->signature->extendedAttributes->{"CallWith"};
- if ($callWith && $callWith eq "DynamicFrame") {
- $result .= $indent . "Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();\n";
- $result .= $indent . "if (!enteredFrame)\n";
- $result .= $indent . " return v8::Undefined();\n";
+ if ($callWith) {
+ my $callWithArg = "COMPILE_ASSERT(false)";
+ if ($callWith eq "DynamicFrame") {
+ $result .= $indent . "Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();\n";
+ $result .= $indent . "if (!enteredFrame)\n";
+ $result .= $indent . " return v8::Undefined();\n";
+ $callWithArg = "enteredFrame";
+ } elsif ($callWith eq "ScriptState") {
+ $result .= $indent . "EmptyScriptState state;\n";
+ $callWithArg = "&state";
+ $hasScriptState = 1;
+ }
$functionString .= ", " if $index;
- $functionString .= "enteredFrame";
+ $functionString .= $callWithArg;
$index++;
$numberOfParameters++
}
$result .= $indent . GetNativeType($returnType, 0) . " result = *imp;\n" . $indent . "$functionString;\n";
} elsif ($returnsListItemPodType) {
$result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $functionString;\n";
- } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) {
+ } elsif ($hasScriptState or @{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) {
$result .= $indent . $nativeReturnType . " result = $functionString;\n";
} else {
# Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
$returnIsRef = 0;
}
+ if ($hasScriptState) {
+ $result .= $indent . "if (state.hadException())\n";
+ $result .= $indent . " return throwError(state.exception());\n"
+ }
+
if (@{$function->raisesExceptions}) {
- $result .= $indent . "if (UNLIKELY(ec))\n" . $indent . " goto fail;\n";
+ $result .= $indent . "if (UNLIKELY(ec))\n";
+ $result .= $indent . " goto fail;\n";
}
# If the return type is a POD type, separate out the wrapper generation
}
void
+webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self)
+{
+ g_return_if_fail (self);
+ WebCore::TestObj * item = WebKit::core(self);
+ item->withScriptStateVoid();
+
+}
+
+WebKitDOMTestObj*
+webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self)
+{
+ g_return_val_if_fail (self, 0);
+ WebCore::TestObj * item = WebKit::core(self);
+ PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj());
+ WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get()));
+ return res;
+
+}
+
+void
webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt)
{
g_return_if_fail (self);
webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad (WebKitDOMTestObj *self, glong int_arg, glong optional_arg);
WEBKIT_API void
+webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self);
+
+WEBKIT_API WebKitDOMTestObj*
+webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self);
+
+WEBKIT_API void
webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt);
WEBKIT_API void
#define THUNK_GENERATOR(generator)
#endif
-static const HashTableValue JSTestObjPrototypeTableValues[19] =
+static const HashTableValue JSTestObjPrototypeTableValues[21] =
{
{ "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) },
{ "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
{ "withDynamicFrameAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
{ "withDynamicFrameAndUserGesture", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) },
{ "withDynamicFrameAndUserGestureASAD", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) },
+ { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) },
+ { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) },
{ "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) },
{ "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
{ "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) },
return jsUndefined();
}
+JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
+{
+ UNUSED_PARAM(args);
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwError(exec, TypeError);
+ JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue));
+ TestObj* imp = static_cast<TestObj*>(castedThisObj->impl());
+
+ imp->withScriptStateVoid(exec);
+ return jsUndefined();
+}
+
+JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
+{
+ UNUSED_PARAM(args);
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwError(exec, TypeError);
+ JSTestObj* castedThisObj = static_cast<JSTestObj*>(asObject(thisValue));
+ TestObj* imp = static_cast<TestObj*>(castedThisObj->impl());
+
+
+ JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->withScriptStateObj(exec)));
+ if (exec->hadException())
+ return jsUndefined();
+ return result;
+}
+
JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
UNUSED_PARAM(args);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
+JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
+JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);
- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg;
- (void)withDynamicFrameAndUserGesture:(int)intArg;
- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg;
+- (void)withScriptStateVoid;
+- (DOMTestObj *)withScriptStateObj;
- (void)methodWithOptionalArg:(int)opt;
- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt;
- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2;
IMPL->withDynamicFrameAndUserGestureASAD(intArg, optionalArg);
}
+- (void)withScriptStateVoid
+{
+ IMPL->withScriptStateVoid();
+}
+
+- (DOMTestObj *)withScriptStateObj
+{
+ return kit(WTF::getPtr(IMPL->withScriptStateObj()));
+}
+
- (void)methodWithOptionalArg:(int)opt
{
IMPL->methodWithOptionalArg(opt);
[CallWith=DynamicFrame] void withDynamicFrameAndOptionalArg(in long intArg, in [Optional] long optionalArg);
[NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGesture(in long intArg);
[NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGestureASAD(in long intArg, in [Optional] long optionalArg);
+ [CallWith=ScriptState] void withScriptStateVoid();
+ [CallWith=ScriptState] TestObj withScriptStateObj();
// 'Optional' extended attribute
void methodWithOptionalArg(in [Optional] long opt);
return v8::Handle<v8::Value>();
}
+static v8::Handle<v8::Value> withScriptStateVoidCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestObj.withScriptStateVoid");
+ TestObj* imp = V8TestObj::toNative(args.Holder());
+ EmptyScriptState state;
+ imp->withScriptStateVoid(&state);
+ if (state->hadException())
+ return throwError(state->exception());
+ return v8::Handle<v8::Value>();
+}
+
+static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestObj.withScriptStateObj");
+ TestObj* imp = V8TestObj::toNative(args.Holder());
+ EmptyScriptState state;
+ RefPtr<TestObj> result = imp->withScriptStateObj(&state);
+ if (state->hadException())
+ return throwError(state->exception());
+ return toV8(result.release());
+}
+
static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestObj.methodWithOptionalArg");
{"withDynamicFrameAndOptionalArg", TestObjInternal::withDynamicFrameAndOptionalArgCallback},
{"withDynamicFrameAndUserGesture", TestObjInternal::withDynamicFrameAndUserGestureCallback},
{"withDynamicFrameAndUserGestureASAD", TestObjInternal::withDynamicFrameAndUserGestureASADCallback},
+ {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback},
+ {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback},
{"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback},
{"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback},
{"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback},
+++ /dev/null
-/*
- * Copyright (C) 2007-2009 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER 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 "V8TreeWalker.h"
-
-#include "Node.h"
-#include "ScriptState.h"
-#include "TreeWalker.h"
-
-#include "V8Binding.h"
-#include "V8Node.h"
-#include "V8Proxy.h"
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptState* state)
-{
- if (state->hadException())
- return throwError(state->exception());
-
- if (!object)
- return v8::Null();
-
- return toV8(object);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.parentNode()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->parentNode(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.firstChild()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->firstChild(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.lastChild()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->lastChild(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.nextNode()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->nextNode(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.previousNode()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->previousNode(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.nextSibling()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->nextSibling(&state);
- return toV8Object(result.release(), &state);
-}
-
-v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& args)
-{
- INC_STATS("DOM.TreeWalker.previousSibling()");
- TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder());
-
- EmptyScriptState state;
- RefPtr<Node> result = treeWalker->previousSibling(&state);
- return toV8Object(result.release(), &state);
-}
-
-} // namespace WebCore
attribute Node currentNode
setter raises(DOMException);
- [Custom] Node parentNode();
- [Custom] Node firstChild();
- [Custom] Node lastChild();
- [Custom] Node previousSibling();
- [Custom] Node nextSibling();
- [Custom] Node previousNode();
- [Custom] Node nextNode();
+ [CallWith=ScriptState] Node parentNode();
+ [CallWith=ScriptState] Node firstChild();
+ [CallWith=ScriptState] Node lastChild();
+ [CallWith=ScriptState] Node previousSibling();
+ [CallWith=ScriptState] Node nextSibling();
+ [CallWith=ScriptState] Node previousNode();
+ [CallWith=ScriptState] Node nextNode();
};
}