2009-04-06 Mike Belshe <mike@belshe.com>
authordglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Apr 2009 18:08:21 +0000 (18:08 +0000)
committerdglazkov@chromium.org <dglazkov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Apr 2009 18:08:21 +0000 (18:08 +0000)
        Reviewed by Dimitri Glazkov.

        https://bugs.webkit.org/show_bug.cgi?id=24978
        Use custom implementations of a few Node methods so that
        we don't over-aggressively create JS wrappers here.

        * bindings/v8/custom/V8NodeCustom.cpp: Added custom implementations.
        * dom/Node.idl: Removed JSC-specifier, making impl custom for V8 as well.

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

WebCore/ChangeLog
WebCore/bindings/v8/custom/V8NodeCustom.cpp
WebCore/dom/Node.idl

index 972f409..746ed88 100644 (file)
@@ -1,3 +1,14 @@
+2009-04-06  Mike Belshe  <mike@belshe.com>
+
+        Reviewed by Dimitri Glazkov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24978
+        Use custom implementations of a few Node methods so that
+        we don't over-aggressively create JS wrappers here.
+
+        * bindings/v8/custom/V8NodeCustom.cpp: Added custom implementations.
+        * dom/Node.idl: Removed JSC-specifier, making impl custom for V8 as well.
+
 2009-04-06  Dave Moore  <davemoore@google.com>
 
         Reviewed by Dimitri Glazkov.
index bf30414..e81e8b5 100644 (file)
@@ -37,6 +37,7 @@
 #include "V8Binding.h"
 #include "V8CustomBinding.h"
 #include "V8CustomEventListener.h"
+#include "V8Node.h"
 #include "V8Proxy.h"
 
 #include <wtf/RefPtr.h>
@@ -83,4 +84,77 @@ CALLBACK_FUNC_DECL(NodeRemoveEventListener)
     return v8::Undefined();
 }
 
+// This function is customized to take advantage of the optional 4th argument: shouldLazyAttach
+CALLBACK_FUNC_DECL(NodeInsertBefore)
+{
+    INC_STATS("DOM.Node.insertBefore");
+    v8::Handle<v8::Value> holder = args.Holder();
+    Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder);
+    ExceptionCode ec = 0;
+    Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0;
+    Node* refChild = V8Node::HasInstance(args[1]) ? V8Proxy::DOMWrapperToNode<Node>(args[1]) : 0;
+    bool success = imp->insertBefore(newChild, refChild, ec, true);
+    if (ec) {
+        V8Proxy::SetDOMException(ec);
+        return v8::Handle<v8::Value>();
+    }
+    if (success)
+        return args[0];
+    return v8::Null();
+}
+
+// This function is customized to take advantage of the optional 4th argument: shouldLazyAttach
+CALLBACK_FUNC_DECL(NodeReplaceChild)
+{
+    INC_STATS("DOM.Node.replaceChild");
+    v8::Handle<v8::Value> holder = args.Holder();
+    Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder);
+    ExceptionCode ec = 0;
+    Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0;
+    Node* oldChild = V8Node::HasInstance(args[1]) ? V8Proxy::DOMWrapperToNode<Node>(args[1]) : 0;
+    bool success = imp->replaceChild(newChild, oldChild, ec, true);
+    if (ec) {
+        V8Proxy::SetDOMException(ec);
+        return v8::Handle<v8::Value>();
+    }
+    if (success)
+        return args[1];
+    return v8::Null();
+}
+
+CALLBACK_FUNC_DECL(NodeRemoveChild)
+{
+    INC_STATS("DOM.Node.removeChild");
+    v8::Handle<v8::Value> holder = args.Holder();
+    Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder);
+    ExceptionCode ec = 0;
+    Node* oldChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0;
+    bool success = imp->removeChild(oldChild, ec);
+    if (ec) {
+        V8Proxy::SetDOMException(ec);
+        return v8::Handle<v8::Value>();
+    }
+    if (success)
+        return args[0];
+    return v8::Null();
+}
+
+// This function is customized to take advantage of the optional 4th argument: shouldLazyAttach
+CALLBACK_FUNC_DECL(NodeAppendChild)
+{
+    INC_STATS("DOM.Node.appendChild");
+    v8::Handle<v8::Value> holder = args.Holder();
+    Node* imp = V8Proxy::DOMWrapperToNode<Node>(holder);
+    ExceptionCode ec = 0;
+    Node* newChild = V8Node::HasInstance(args[0]) ? V8Proxy::DOMWrapperToNode<Node>(args[0]) : 0;
+    bool success = imp->appendChild(newChild, ec, true );
+    if (ec) {
+        V8Proxy::SetDOMException(ec);
+        return v8::Handle<v8::Value>();
+    }
+    if (success)
+        return args[0];
+    return v8::Null();
+}
+
 } // namespace WebCore
index c778236..e62bf70 100644 (file)
@@ -65,15 +65,15 @@ module core {
         readonly attribute NamedNodeMap     attributes;
         readonly attribute Document         ownerDocument;
 
-        [OldStyleObjC, JSCCustom] Node insertBefore(in [Return] Node newChild, 
+        [OldStyleObjC, Custom] Node insertBefore(in [Return] Node newChild,
                                                  in Node refChild)
             raises(DOMException);
-        [OldStyleObjC, JSCCustom] Node replaceChild(in Node newChild, 
+        [OldStyleObjC, Custom] Node replaceChild(in Node newChild,
                                                  in [Return] Node oldChild)
             raises(DOMExceptionJSC);
-        [JSCCustom] Node               removeChild(in [Return] Node oldChild)
+        [Custom] Node               removeChild(in [Return] Node oldChild)
             raises(DOMException);
-        [JSCCustom] Node               appendChild(in [Return] Node newChild)
+        [Custom] Node               appendChild(in [Return] Node newChild)
             raises(DOMException);
 
         boolean            hasChildNodes();