LayoutTests:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2007 20:58:15 +0000 (20:58 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2007 20:58:15 +0000 (20:58 +0000)
        Reviewed by Anders.

        Update test for http://bugs.webkit.org/show_bug.cgi?id=14028
        Finish autogenerating the JS bindings for Node

        * fast/dom/prototype-chain-expected.txt: DOMNodePrototype is no longer in the prototype chain.

WebCore:

        Reviewed by Anders.

        Patch for  http://bugs.webkit.org/show_bug.cgi?id=14028
        Finish autogenerating the JS bindings for Node

        * DerivedSources.make:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSHTMLElementWrapperFactory.cpp:
        (WebCore::createJSHTMLWrapper):
        * bindings/js/JSHTMLElementWrapperFactory.h:
        * bindings/js/JSHTMLOptionElementConstructor.cpp:
        * bindings/js/JSNamedNodeMapCustom.cpp:
        * bindings/js/JSNodeCustom.cpp:
        (WebCore::JSNode::insertBefore):
        (WebCore::JSNode::replaceChild):
        (WebCore::JSNode::removeChild):
        (WebCore::JSNode::appendChild):
        (WebCore::JSNode::mark):
        (WebCore::toJS):
        * bindings/js/JSSVGElementWrapperFactory.cpp:
        (WebCore::createJSSVGWrapper):
        * bindings/js/JSSVGElementWrapperFactory.h:
        * bindings/js/JSXSLTProcessor.cpp:
        (KJS::XSLTProcessorPrototypeFunction::callAsFunction):
        * bindings/js/kjs_binding.cpp:
        (KJS::ScriptInterpreter::getDOMNodeForDocument):
        (KJS::ScriptInterpreter::putDOMNodeForDocument):
        (KJS::ScriptInterpreter::markDOMNodesForDocument):
        (KJS::ScriptInterpreter::updateDOMNodeDocument):
        * bindings/js/kjs_binding.h:
        * bindings/js/kjs_dom.cpp:
        (WebCore::toAttr):
        * bindings/js/kjs_dom.h:
        * bindings/js/kjs_domnode.h: Removed.
        * bindings/objc/DOMUtility.mm:
        (KJS::createDOMWrapper):
        * bindings/scripts/CodeGeneratorJS.pm:
        * dom/Node.h:
        (WebCore::Node::parentElement):
        * dom/Node.idl:

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/prototype-chain-expected.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/WebCore.pro
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSHTMLElementWrapperFactory.cpp
WebCore/bindings/js/JSHTMLElementWrapperFactory.h
WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
WebCore/bindings/js/JSNamedNodeMapCustom.cpp
WebCore/bindings/js/JSNodeCustom.cpp
WebCore/bindings/js/JSSVGElementWrapperFactory.cpp
WebCore/bindings/js/JSSVGElementWrapperFactory.h
WebCore/bindings/js/JSXSLTProcessor.cpp
WebCore/bindings/js/kjs_binding.cpp
WebCore/bindings/js/kjs_binding.h
WebCore/bindings/js/kjs_dom.cpp
WebCore/bindings/js/kjs_dom.h
WebCore/bindings/js/kjs_domnode.h [deleted file]
WebCore/bindings/objc/DOMUtility.mm
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/dom/Node.h
WebCore/dom/Node.idl

index 6b32875bd1ee7f6733a83f7f6ea4096b2cb24809..2eef6ca3ac103cf0ab89f6aa38196f2698f91811 100644 (file)
@@ -1,3 +1,12 @@
+2007-06-07  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders.
+
+        Update test for http://bugs.webkit.org/show_bug.cgi?id=14028
+        Finish autogenerating the JS bindings for Node
+
+        * fast/dom/prototype-chain-expected.txt: DOMNodePrototype is no longer in the prototype chain.
+
 2007-06-06  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Hyatt.
index 911395d591c3486a269e6ba510db7a768056f5a4..63802c480621125cd4d498cf2aa296998271269a 100644 (file)
@@ -2,12 +2,10 @@ This page prints out the prototype chains of select DOM objects. Older versions
 
 NOTE: This test will start failing if you change the layout of a related prototype chain in WebCore. That does not necessarily mean that you have done something wrong; you may just need to check in new results.
 
------ [object HTMLDocument] (6 prototypes) -----
+----- [object HTMLDocument] (5 prototypes) -----
 
 [object Object]
 
-[object DOMNodePrototype]
-
 [object NodePrototype]
 
 [object EventTargetNodePrototype]
@@ -16,12 +14,10 @@ NOTE: This test will start failing if you change the layout of a related prototy
 
 [object HTMLDocumentPrototype]
 
------ [object HTMLDivElement] (7 prototypes) -----
+----- [object HTMLDivElement] (6 prototypes) -----
 
 [object Object]
 
-[object DOMNodePrototype]
-
 [object NodePrototype]
 
 [object EventTargetNodePrototype]
@@ -32,12 +28,10 @@ NOTE: This test will start failing if you change the layout of a related prototy
 
 [object HTMLDivElementPrototype]
 
------ [object HTMLFormElement] (7 prototypes) -----
+----- [object HTMLFormElement] (6 prototypes) -----
 
 [object Object]
 
-[object DOMNodePrototype]
-
 [object NodePrototype]
 
 [object EventTargetNodePrototype]
index 8f155a23d1d2e3d2ab95082f5256b8f2147aeb24..75026bdc6bc6a47402e2e0560a2c127c57c78661 100644 (file)
@@ -1,3 +1,47 @@
+2007-06-07  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders.
+
+        Patch for  http://bugs.webkit.org/show_bug.cgi?id=14028
+        Finish autogenerating the JS bindings for Node
+
+        * DerivedSources.make:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSHTMLElementWrapperFactory.cpp:
+        (WebCore::createJSHTMLWrapper):
+        * bindings/js/JSHTMLElementWrapperFactory.h:
+        * bindings/js/JSHTMLOptionElementConstructor.cpp:
+        * bindings/js/JSNamedNodeMapCustom.cpp:
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::JSNode::insertBefore):
+        (WebCore::JSNode::replaceChild):
+        (WebCore::JSNode::removeChild):
+        (WebCore::JSNode::appendChild):
+        (WebCore::JSNode::mark):
+        (WebCore::toJS):
+        * bindings/js/JSSVGElementWrapperFactory.cpp:
+        (WebCore::createJSSVGWrapper):
+        * bindings/js/JSSVGElementWrapperFactory.h:
+        * bindings/js/JSXSLTProcessor.cpp:
+        (KJS::XSLTProcessorPrototypeFunction::callAsFunction):
+        * bindings/js/kjs_binding.cpp:
+        (KJS::ScriptInterpreter::getDOMNodeForDocument):
+        (KJS::ScriptInterpreter::putDOMNodeForDocument):
+        (KJS::ScriptInterpreter::markDOMNodesForDocument):
+        (KJS::ScriptInterpreter::updateDOMNodeDocument):
+        * bindings/js/kjs_binding.h:
+        * bindings/js/kjs_dom.cpp:
+        (WebCore::toAttr):
+        * bindings/js/kjs_dom.h:
+        * bindings/js/kjs_domnode.h: Removed.
+        * bindings/objc/DOMUtility.mm:
+        (KJS::createDOMWrapper):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * dom/Node.h:
+        (WebCore::Node::parentElement):
+        * dom/Node.idl:
+
 2007-06-07  Sam Weinig  <sam@webkit.org>
 
         Another Gdk and Qt build fix.
index e76ac5c686eec55e554fa366e6b65b169d6d0f5d..5c4e53e72d97155184428b2f8de21cfec927d0fd 100644 (file)
@@ -549,7 +549,6 @@ all : \
     XMLNames.cpp \
     XPathGrammar.cpp \
     kjs_css.lut.h \
-    kjs_dom.lut.h \
     kjs_events.lut.h \
     kjs_html.lut.h \
     kjs_navigator.lut.h \
index eadb54d895d2a46e77f7fe73d8c4641274afe036..4437291e20abf3621805ce89d36392e3b34ea2cd 100644 (file)
@@ -141,7 +141,6 @@ LUT_FILES += \
     bindings/js/JSXMLHttpRequest.cpp \
     bindings/js/JSXSLTProcessor.cpp \
     bindings/js/kjs_css.cpp \
-    bindings/js/kjs_dom.cpp \
     bindings/js/kjs_events.cpp \
     bindings/js/kjs_html.cpp \
     bindings/js/kjs_navigator.cpp \
index 220b41a360cac5c24f408ac4954ef39c543864e7..cdc5b6730b17d2ebf6ac51a0e391fac0707d8478 100644 (file)
@@ -63,7 +63,6 @@
                14CF78A609F58CD800EB3665 /* JSCSSValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CF78A509F58CD800EB3665 /* JSCSSValue.h */; };
                14CF7B3309F6ECD700EB3665 /* JSCSSRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CF7B3109F6ECD700EB3665 /* JSCSSRule.cpp */; };
                14CF7B3409F6ECD700EB3665 /* JSCSSRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */; };
-               14D0C82509FF0EF5006B36D9 /* kjs_domnode.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D0C82409FF0EF5006B36D9 /* kjs_domnode.h */; };
                14D823520AF92A790004F057 /* Chrome.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D823500AF92A790004F057 /* Chrome.h */; settings = {ATTRIBUTES = (Private, ); }; };
                14D8238B0AF92DF60004F057 /* Chrome.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D8238A0AF92DF60004F057 /* Chrome.cpp */; };
                14D824080AF93AEB0004F057 /* ChromeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D824060AF93AEB0004F057 /* ChromeClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                656581EE09D1508D000E61D7 /* JSXMLHttpRequest.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581D709D1508D000E61D7 /* JSXMLHttpRequest.lut.h */; };
                656581F009D1508D000E61D7 /* JSXSLTProcessor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581D909D1508D000E61D7 /* JSXSLTProcessor.lut.h */; };
                656581F109D1508D000E61D7 /* kjs_css.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DA09D1508D000E61D7 /* kjs_css.lut.h */; };
-               656581F209D1508D000E61D7 /* kjs_dom.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DB09D1508D000E61D7 /* kjs_dom.lut.h */; };
                656581F309D1508D000E61D7 /* kjs_events.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DC09D1508D000E61D7 /* kjs_events.lut.h */; };
                656581F409D1508D000E61D7 /* kjs_html.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DD09D1508D000E61D7 /* kjs_html.lut.h */; };
                656581F509D1508D000E61D7 /* kjs_navigator.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */; };
                14CF7B3109F6ECD700EB3665 /* JSCSSRule.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSRule.cpp; sourceTree = "<group>"; };
                14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSRule.h; sourceTree = "<group>"; };
                14CF7C2009F7110600EB3665 /* KeyboardEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = KeyboardEvent.idl; sourceTree = "<group>"; };
-               14D0C82409FF0EF5006B36D9 /* kjs_domnode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_domnode.h; sourceTree = "<group>"; };
                14D823500AF92A790004F057 /* Chrome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chrome.h; sourceTree = "<group>"; };
                14D8238A0AF92DF60004F057 /* Chrome.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Chrome.cpp; sourceTree = "<group>"; };
                14D824060AF93AEB0004F057 /* ChromeClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChromeClient.h; sourceTree = "<group>"; };
                656581D709D1508D000E61D7 /* JSXMLHttpRequest.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXMLHttpRequest.lut.h; sourceTree = "<group>"; };
                656581D909D1508D000E61D7 /* JSXSLTProcessor.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSXSLTProcessor.lut.h; sourceTree = "<group>"; };
                656581DA09D1508D000E61D7 /* kjs_css.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_css.lut.h; sourceTree = "<group>"; };
-               656581DB09D1508D000E61D7 /* kjs_dom.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_dom.lut.h; sourceTree = "<group>"; };
                656581DC09D1508D000E61D7 /* kjs_events.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_events.lut.h; sourceTree = "<group>"; };
                656581DD09D1508D000E61D7 /* kjs_html.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_html.lut.h; sourceTree = "<group>"; };
                656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_navigator.lut.h; sourceTree = "<group>"; };
                                BCD9C2C40C17B6EC005C90A2 /* JSDOMExceptionConstructor.lut.h */,
                                BCD9C2C50C17B6EC005C90A2 /* JSEventTargetNode.lut.h */,
                                656581DA09D1508D000E61D7 /* kjs_css.lut.h */,
-                               656581DB09D1508D000E61D7 /* kjs_dom.lut.h */,
                                656581DC09D1508D000E61D7 /* kjs_events.lut.h */,
                                656581DD09D1508D000E61D7 /* kjs_html.lut.h */,
                                656581DE09D1508D000E61D7 /* kjs_navigator.lut.h */,
                                93B70D4A09EB0C7C009D8468 /* kjs_css.h */,
                                93B70D4B09EB0C7C009D8468 /* kjs_dom.cpp */,
                                93B70D4C09EB0C7C009D8468 /* kjs_dom.h */,
-                               14D0C82409FF0EF5006B36D9 /* kjs_domnode.h */,
                                93B70D4D09EB0C7C009D8468 /* kjs_events.cpp */,
                                93B70D4E09EB0C7C009D8468 /* kjs_events.h */,
                                93B70D4F09EB0C7C009D8468 /* kjs_html.cpp */,
                                656581EE09D1508D000E61D7 /* JSXMLHttpRequest.lut.h in Headers */,
                                656581F009D1508D000E61D7 /* JSXSLTProcessor.lut.h in Headers */,
                                656581F109D1508D000E61D7 /* kjs_css.lut.h in Headers */,
-                               656581F209D1508D000E61D7 /* kjs_dom.lut.h in Headers */,
                                656581F309D1508D000E61D7 /* kjs_events.lut.h in Headers */,
                                656581F409D1508D000E61D7 /* kjs_html.lut.h in Headers */,
                                656581F509D1508D000E61D7 /* kjs_navigator.lut.h in Headers */,
                                93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */,
                                BC066F6F09FEB2FA00C589A7 /* WebCoreTextRenderer.h in Headers */,
                                14DC0D3809FED073007B0235 /* JSNode.h in Headers */,
-                               14D0C82509FF0EF5006B36D9 /* kjs_domnode.h in Headers */,
                                142011B70A003133008303F9 /* JSCSSStyleDeclaration.h in Headers */,
                                BCC71A130A0FF94D0014EE6E /* GlyphBuffer.h in Headers */,
                                1A7629D60A07425100989F5B /* XPathGrammar.h in Headers */,
index 2da05e9764f4947e53c60a56a12c85d2ba0781e6..a736a7597e273b4af9ab5cf9f72aed9eac415515 100644 (file)
@@ -145,7 +145,7 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-typedef DOMNode* (*CreateHTMLElementWrapperFunction)(ExecState*, PassRefPtr<HTMLElement>);
+typedef JSNode* (*CreateHTMLElementWrapperFunction)(ExecState*, PassRefPtr<HTMLElement>);
 
 #define FOR_EACH_TAG(macro) \
     macro(a, Anchor) \
@@ -207,14 +207,14 @@ typedef DOMNode* (*CreateHTMLElementWrapperFunction)(ExecState*, PassRefPtr<HTML
     // end of macro
 
 #define CREATE_WRAPPER_FUNCTION(tag, name) \
-static DOMNode* create##name##Wrapper(ExecState* exec, PassRefPtr<HTMLElement> element) \
+static JSNode* create##name##Wrapper(ExecState* exec, PassRefPtr<HTMLElement> element) \
 { \
     return new JSHTML##name##Element(exec, static_cast<HTML##name##Element*>(element.get())); \
 }
 FOR_EACH_TAG(CREATE_WRAPPER_FUNCTION)
 #undef CREATE_WRAPPER_FUNCTION
 
-DOMNode* createJSHTMLWrapper(ExecState* exec, PassRefPtr<HTMLElement> element)
+JSNode* createJSHTMLWrapper(ExecState* exec, PassRefPtr<HTMLElement> element)
 {
     static HashMap<AtomicStringImpl*, CreateHTMLElementWrapperFunction> map;
     if (map.isEmpty()) {
index de4b473054484402e90bca9f9a37de4a5692f4b9..f386bc07fe1537736e654c455a9f567f4a8a5c9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2006 Apple Computer, Inc.
+ *  Copyright (C) 2006, 2007 Apple Inc. All ri
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 #include <wtf/Forward.h>
 
 namespace KJS {
-    class DOMNode;
     class ExecState;
 }
 
 namespace WebCore {
 
+    class JSNode;
     class HTMLElement;
-    KJS::DOMNode* createJSHTMLWrapper(KJS::ExecState*, PassRefPtr<HTMLElement>);
+
+    JSNode* createJSHTMLWrapper(KJS::ExecState*, PassRefPtr<HTMLElement>);
 
 }
 
index 4fe7a429e98357829e9209756f917b79ff3e813b..b1d2714a6bfccc749bb074016ec7116887e95387 100644 (file)
@@ -24,7 +24,6 @@
 #include "HTMLOptionElement.h"
 #include "JSHTMLOptionElement.h"
 #include "Text.h"
-#include "kjs_dom.h"
 
 namespace WebCore {
 
index 1363eed6c2b421377aa153778a2a0cd2406f0163..ae63a1210c798c93adb54bb71857c894c7f9d2ba 100644 (file)
@@ -27,8 +27,9 @@
 #include "JSNamedNodeMap.h"
 
 #include "NamedNodeMap.h"
-#include "kjs_dom.h"
+#include "PlatformString.h"
 #include "kjs_binding.h"
+#include "kjs_dom.h"
 
 namespace WebCore {
 
index b038764f2719d716722d5641773f7576e4a7c079..6a5ce1c5e0d4c603adb612ed35cc2412f5718dfb 100644 (file)
 
 namespace WebCore {
 
+typedef int ExpectionCode;
+
+KJS::JSValue* JSNode::insertBefore(KJS::ExecState* exec, const KJS::List& args)
+{
+    ExceptionCode ec = 0;
+    bool ok = impl()->insertBefore(toNode(args[0]), toNode(args[1]), ec);
+    KJS::setDOMException(exec, ec);
+    if (ok)
+        return args[0];
+    return KJS::jsNull();
+}
+
+KJS::JSValue* JSNode::replaceChild(KJS::ExecState* exec, const KJS::List& args)
+{
+    ExceptionCode ec = 0;
+    bool ok = impl()->replaceChild(toNode(args[0]), toNode(args[1]), ec);
+    KJS::setDOMException(exec, ec);
+    if (ok)
+        return args[1];
+    return KJS::jsNull();
+}
+
+KJS::JSValue* JSNode::removeChild(KJS::ExecState* exec, const KJS::List& args)
+{
+    ExceptionCode ec = 0;
+    bool ok = impl()->removeChild(toNode(args[0]), ec);
+    KJS::setDOMException(exec, ec);
+    if (ok)
+        return args[0];
+    return KJS::jsNull();
+}
+
+KJS::JSValue* JSNode::appendChild(KJS::ExecState* exec, const KJS::List& args)
+{
+    ExceptionCode ec = 0;
+    bool ok = impl()->appendChild(toNode(args[0]), ec);
+    KJS::setDOMException(exec, ec);
+    if (ok)
+        return args[0];
+    return KJS::jsNull();
+}
+
+void JSNode::mark()
+{
+    ASSERT(!marked());
+
+    Node* node = m_impl.get();
+
+    // Nodes in the document are kept alive by ScriptInterpreter::mark,
+    // so we have no special responsibilities and can just call the base class here.
+    if (node->inDocument()) {
+        DOMObject::mark();
+        return;
+    }
+
+    // This is a node outside the document, so find the root of the tree it is in,
+    // and start marking from there.
+    Node* root = node;
+    for (Node* current = m_impl.get(); current; current = current->parentNode())
+        root = current;
+
+    // If we're already marking this tree, then we can simply mark this wrapper
+    // by calling the base class; our caller is iterating the tree.
+    if (root->m_inSubtreeMark) {
+        DOMObject::mark();
+        return;
+    }
+
+    // Mark the whole tree; use the global set of roots to avoid reentering.
+    root->m_inSubtreeMark = true;
+    for (Node* nodeToMark = root; nodeToMark; nodeToMark = nodeToMark->traverseNextNode()) {
+        JSNode* wrapper = KJS::ScriptInterpreter::getDOMNodeForDocument(m_impl->document(), nodeToMark);
+        if (wrapper) {
+            if (!wrapper->marked())
+                wrapper->mark();
+        } else if (nodeToMark == node) {
+            // This is the case where the map from the document to wrappers has
+            // been cleared out, but a wrapper is being marked. For now, we'll
+            // let the rest of the tree of wrappers get collected, because we have
+            // no good way of finding them. Later we should test behavior of other
+            // browsers and see if we need to preserve other wrappers in this case.
+            if (!marked())
+                mark();
+        }
+    }
+    root->m_inSubtreeMark = false;
+
+    // Double check that we actually ended up marked. This assert caught problems in the past.
+    ASSERT(marked());
+}
+
 KJS::JSValue* toJS(KJS::ExecState* exec, PassRefPtr<Node> n)
 {
     Node* node = n.get(); 
@@ -70,7 +161,7 @@ KJS::JSValue* toJS(KJS::ExecState* exec, PassRefPtr<Node> n)
 
     KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter());
     Document* doc = node->document();
-    KJS::DOMNode* ret = interp->getDOMNodeForDocument(doc, node);
+    JSNode* ret = interp->getDOMNodeForDocument(doc, node);
     if (ret)
         return ret;
 
index 665c601a733711b74e7990a7900a6ff9c28935ec..aa0345bc3b49c5d2e40c5b33b70d63b5a30948d7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2006 Apple Computer, Inc.
+ *  Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -154,7 +154,7 @@ namespace WebCore {
 
 using namespace SVGNames;
 
-typedef DOMNode* (*CreateSVGElementWrapperFunction)(ExecState*, PassRefPtr<SVGElement>);
+typedef JSNode* (*CreateSVGElementWrapperFunction)(ExecState*, PassRefPtr<SVGElement>);
 
 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
 #define FOR_EACH_TAG(macro) \
@@ -261,14 +261,14 @@ typedef DOMNode* (*CreateSVGElementWrapperFunction)(ExecState*, PassRefPtr<SVGEl
 #endif
 
 #define CREATE_WRAPPER_FUNCTION(tag, name) \
-static DOMNode* create##name##Wrapper(ExecState* exec, PassRefPtr<SVGElement> element) \
+static JSNode* create##name##Wrapper(ExecState* exec, PassRefPtr<SVGElement> element) \
 { \
     return new JSSVG##name##Element(exec, static_cast<SVG##name##Element*>(element.get())); \
 }
 FOR_EACH_TAG(CREATE_WRAPPER_FUNCTION)
 #undef CREATE_WRAPPER_FUNCTION
 
-DOMNode* createJSSVGWrapper(ExecState* exec, PassRefPtr<SVGElement> element)
+JSNode* createJSSVGWrapper(ExecState* exec, PassRefPtr<SVGElement> element)
 {
     static HashMap<WebCore::AtomicStringImpl*, CreateSVGElementWrapperFunction> map;
     if (map.isEmpty()) {
index 3e75ddc65e9ee4e2a8bca73826d368116b29ec2d..cdaf3f723cc6269489a9fc15e5565333f97f4b45 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2006 Apple Computer, Inc.
+ *  Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
 #include <wtf/Forward.h>
 
 namespace KJS {
-    class DOMNode;
     class ExecState;
 }
 
 namespace WebCore {
+
+    class JSNode;
     class SVGElement;
-    KJS::DOMNode* createJSSVGWrapper(KJS::ExecState*, PassRefPtr<SVGElement>);
+
+    JSNode* createJSSVGWrapper(KJS::ExecState*, PassRefPtr<SVGElement>);
+
 }
 
 #endif // ENABLE(SVG)
 
-#endif
+#endif // JSSVGElementWrapperFactory_h
index cb4cdc520cb7ad36b6ff703027119da15b182194..9256c9feb5043781b2e84271ebc8bf071d331b87 100644 (file)
@@ -78,8 +78,8 @@ JSValue *XSLTProcessorPrototypeFunction::callAsFunction(ExecState *exec, JSObjec
         case JSXSLTProcessor::ImportStylesheet:
         {
             JSValue *nodeVal = args[0];
-            if (nodeVal->isObject(&DOMNode::info)) {
-                DOMNode *node = static_cast<DOMNode *>(nodeVal);
+            if (nodeVal->isObject(&JSNode::info)) {
+                JSNode* node = static_cast<JSNode*>(nodeVal);
                 processor.importStylesheet(node->impl());
                 return jsUndefined();
             }
@@ -90,8 +90,8 @@ JSValue *XSLTProcessorPrototypeFunction::callAsFunction(ExecState *exec, JSObjec
         {
             JSValue *nodeVal = args[0];
             JSValue *docVal = args[1];
-            if (nodeVal->isObject(&DOMNode::info) && docVal->isObject(&JSDocument::info)) {
-                Node* node = static_cast<DOMNode *>(nodeVal)->impl();
+            if (nodeVal->isObject(&JSNode::info) && docVal->isObject(&JSDocument::info)) {
+                Node* node = static_cast<JSNode*>(nodeVal)->impl();
                 Document* doc = static_cast<Document*>(static_cast<JSDocument *>(docVal)->impl());
                 return toJS(exec, processor.transformToFragment(node, doc).get());
             }
@@ -101,8 +101,8 @@ JSValue *XSLTProcessorPrototypeFunction::callAsFunction(ExecState *exec, JSObjec
         case JSXSLTProcessor::TransformToDocument:
         {
             JSValue *nodeVal = args[0];
-            if (nodeVal->isObject(&DOMNode::info)) {
-                DOMNode *node = static_cast<DOMNode *>(nodeVal);
+            if (nodeVal->isObject(&JSNode::info)) {
+                JSNode* node = static_cast<JSNode*>(nodeVal);
                 RefPtr<Document> resultDocument = processor.transformToDocument(node->impl());
                 if (resultDocument)
                     return toJS(exec, resultDocument.get());
index 334ad6ca76f0b3a8e72acc2849251c189602ec0f..c81ce50e7ebb7570f7424b4a731619edb6d13801 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
- *  Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ *  Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
  *  Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
  *
  *  This library is free software; you can redistribute it and/or
 #include "Event.h"
 #include "EventNames.h"
 #include "Frame.h"
+#include "JSNode.h"
 #include "Page.h"
 #include "PlatformString.h"
 #include "Range.h"
 #include "RangeException.h"
-#include "xmlhttprequest.h"
 #include "kjs_dom.h"
 #include "kjs_window.h"
+#include "xmlhttprequest.h"
 #include <kjs/collector.h>
 #include <wtf/HashMap.h>
 
@@ -55,7 +56,7 @@ using namespace EventNames;
 namespace KJS {
 
 typedef HashMap<void*, DOMObject*> DOMObjectMap;
-typedef HashMap<Node*, DOMNode*> NodeMap;
+typedef HashMap<Node*, JSNode*> NodeMap;
 typedef HashMap<Document*, NodeMap*> NodePerDocMap;
 
 // For debugging, keep a set of wrappers currently registered, and check that
@@ -154,10 +155,10 @@ void ScriptInterpreter::forgetDOMObject(void* objectHandle)
     domObjects().remove(objectHandle);
 }
 
-DOMNode* ScriptInterpreter::getDOMNodeForDocument(Document* document, Node* node)
+JSNode* ScriptInterpreter::getDOMNodeForDocument(Document* document, Node* node)
 {
     if (!document)
-        return static_cast<DOMNode*>(domObjects().get(node));
+        return static_cast<JSNode*>(domObjects().get(node));
     NodeMap* documentDict = domNodesPerDocument().get(document);
     if (documentDict)
         return documentDict->get(node);
@@ -176,7 +177,7 @@ void ScriptInterpreter::forgetDOMNodeForDocument(Document* document, Node* node)
         documentDict->remove(node);
 }
 
-void ScriptInterpreter::putDOMNodeForDocument(Document* document, Node* node, DOMNode* wrapper)
+void ScriptInterpreter::putDOMNodeForDocument(Document* document, Node* node, JSNode* wrapper)
 {
     ADD_WRAPPER(wrapper);
     if (!document) {
@@ -209,7 +210,7 @@ void ScriptInterpreter::markDOMNodesForDocument(Document* doc)
         NodeMap* nodeDict = dictIt->second;
         NodeMap::iterator nodeEnd = nodeDict->end();
         for (NodeMap::iterator nodeIt = nodeDict->begin(); nodeIt != nodeEnd; ++nodeIt) {
-            DOMNode* node = nodeIt->second;
+            JSNode* node = nodeIt->second;
             // don't mark wrappers for nodes that are no longer in the
             // document - they should not be saved if the node is not
             // otherwise reachable from JS.
@@ -230,7 +231,7 @@ ExecState* ScriptInterpreter::globalExec()
 void ScriptInterpreter::updateDOMNodeDocument(Node* node, Document* oldDoc, Document* newDoc)
 {
     ASSERT(oldDoc != newDoc);
-    DOMNode* wrapper = getDOMNodeForDocument(oldDoc, node);
+    JSNode* wrapper = getDOMNodeForDocument(oldDoc, node);
     if (wrapper) {
         REMOVE_WRAPPER(wrapper);
         putDOMNodeForDocument(newDoc, node, wrapper);
index ea718252f9169ae8195e2ae7f7b82244d29915f1..b97bad6bf9ba10385bcf763bd511a27a58e9aad7 100644 (file)
@@ -38,6 +38,7 @@ namespace WebCore {
     class Frame;
     class Node;
     class String;
+    class JSNode;
 
     typedef int ExceptionCode;
 }
@@ -60,8 +61,6 @@ namespace KJS {
 #endif
     };
 
-    class DOMNode;
-
     /**
      * We inherit from Interpreter, to save a pointer to the HTML part
      * that the interpreter runs for.
@@ -75,8 +74,8 @@ namespace KJS {
         static void putDOMObject(void* objectHandle, DOMObject*);
         static void forgetDOMObject(void* objectHandle);
 
-        static DOMNode *getDOMNodeForDocument(WebCore::Document*, WebCore::Node*);
-        static void putDOMNodeForDocument(WebCore::Document*, WebCore::Node*, DOMNode *nodeWrapper);
+        static WebCore::JSNode* getDOMNodeForDocument(WebCore::Document*, WebCore::Node*);
+        static void putDOMNodeForDocument(WebCore::Document*, WebCore::Node*, WebCore::JSNode* nodeWrapper);
         static void forgetDOMNodeForDocument(WebCore::Document*, WebCore::Node*);
         static void forgetAllDOMNodesForDocument(WebCore::Document*);
         static void updateDOMNodeDocument(WebCore::Node*, WebCore::Document* oldDoc, WebCore::Document* newDoc);
@@ -151,7 +150,7 @@ namespace KJS {
     WebCore::String valueToStringWithUndefinedOrNullCheck(ExecState*, JSValue*); // null String if the value is null or undefined
 
     template <typename T> inline JSValue* toJS(ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
-  
+
 } // namespace
 
 #endif
index fd026ae5ab423348779ed6d2f379be25a9e104c9..874af2871c0aba296072165b26ac0912ad21d4dd 100644 (file)
 #include "config.h"
 #include "kjs_dom.h"
 
-#include "CDATASection.h"
-#include "Comment.h"
-#include "DOMImplementation.h"
-#include "DocumentFragment.h"
-#include "DocumentType.h"
-#include "Element.h"
-#include "Entity.h"
-#include "EntityReference.h"
-#include "Event.h"
-#include "EventNames.h"
+#include "Document.h"
 #include "EventTarget.h"
-#include "ExceptionCode.h"
 #include "Frame.h"
-#include "HTMLDocument.h"
 #include "HTMLNames.h"
 #include "HTMLPlugInElement.h"
 #include "JSAttr.h"
-#include "JSCDATASection.h"
-#include "JSComment.h"
-#include "JSDOMImplementation.h"
-#include "JSDocumentFragment.h"
-#include "JSDocumentType.h"
-#include "JSElement.h"
-#include "JSEntity.h"
-#include "JSEntityReference.h"
-#include "JSHTMLDocument.h"
-#include "JSHTMLElementWrapperFactory.h"
-#include "JSNamedNodeMap.h"
 #include "JSNode.h"
-#include "JSNodeList.h"
-#include "JSNotation.h"
-#include "JSProcessingInstruction.h"
-#include "JSRange.h"
-#include "JSText.h"
-#include "NamedNodeMap.h"
-#include "NodeList.h"
-#include "Notation.h"
-#include "ProcessingInstruction.h"
-#include "Range.h"
-#include "RenderView.h"
-#include "kjs_css.h"
 #include "kjs_events.h"
 #include "kjs_window.h"
 #include "xmlhttprequest.h"
 
 #if ENABLE(SVG)
-#include "JSSVGDocument.h"
 #include "JSSVGElementInstance.h"
-#include "JSSVGElementWrapperFactory.h"
-#include "SVGDocument.h"
-#include "SVGElement.h"
 #endif
 
 #if USE(JAVASCRIPTCORE_BINDINGS)
 #include <JavaScriptCore/runtime_object.h>
 #endif
 
-using namespace WebCore;
-using namespace HTMLNames;
-using namespace EventNames;
-
-#include "kjs_dom.lut.h"
-
-namespace KJS {
-
-// -------------------------------------------------------------------------
-/* Source for DOMNodePrototypeTable. Use "make hashtables" to regenerate.
-@begin DOMNodePrototypeTable 25
-  insertBefore  DOMNode::InsertBefore   DontDelete|Function 2
-  replaceChild  DOMNode::ReplaceChild   DontDelete|Function 2
-  removeChild   DOMNode::RemoveChild    DontDelete|Function 1
-  appendChild   DOMNode::AppendChild    DontDelete|Function 1
-  hasAttributes DOMNode::HasAttributes  DontDelete|Function 0
-  hasChildNodes DOMNode::HasChildNodes  DontDelete|Function 0
-  cloneNode     DOMNode::CloneNode      DontDelete|Function 1
-# DOM2
-  normalize     DOMNode::Normalize      DontDelete|Function 0
-  isSupported   DOMNode::IsSupported    DontDelete|Function 2
-# DOM3
-  isSameNode    DOMNode::IsSameNode     DontDelete|Function 1
-  isEqualNode   DOMNode::IsEqualNode    DontDelete|Function 1
-  isDefaultNamespace    DOMNode::IsDefaultNamespace DontDelete|Function 1
-  lookupNamespaceURI    DOMNode::LookupNamespaceURI DontDelete|Function 1
-  lookupPrefix  DOMNode::LookupPrefix   DontDelete|Function 1
-@end
-*/
-KJS_IMPLEMENT_PROTOTYPE_FUNCTION(DOMNodePrototypeFunction)
-KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodePrototype, DOMNodePrototypeFunction)
-
-const ClassInfo DOMNode::info = { "Node", 0, &DOMNodeTable, 0 };
-
-DOMNode::DOMNode(ExecState* exec, Node* n)
-  : m_impl(n)
-{
-  setPrototype(DOMNodePrototype::self(exec));
-}
-
-DOMNode::~DOMNode()
-{
-  ScriptInterpreter::forgetDOMNodeForDocument(m_impl->document(), m_impl.get());
-}
-
-void DOMNode::mark()
-{
-  ASSERT(!marked());
-
-  Node* node = m_impl.get();
-
-  // Nodes in the document are kept alive by ScriptInterpreter::mark,
-  // so we have no special responsibilities and can just call the base class here.
-  if (node->inDocument()) {
-    DOMObject::mark();
-    return;
-  }
+namespace WebCore {
 
-  // This is a node outside the document, so find the root of the tree it is in,
-  // and start marking from there.
-  Node* root = node;
-  for (Node* current = m_impl.get(); current; current = current->parentNode()) {
-    root = current;
-  }
-
-  // If we're already marking this tree, then we can simply mark this wrapper
-  // by calling the base class; our caller is iterating the tree.
-  if (root->m_inSubtreeMark) {
-    DOMObject::mark();
-    return;
-  }
-
-  // Mark the whole tree; use the global set of roots to avoid reentering.
-  root->m_inSubtreeMark = true;
-  for (Node* nodeToMark = root; nodeToMark; nodeToMark = nodeToMark->traverseNextNode()) {
-    DOMNode *wrapper = ScriptInterpreter::getDOMNodeForDocument(m_impl->document(), nodeToMark);
-    if (wrapper) {
-      if (!wrapper->marked())
-        wrapper->mark();
-    } else if (nodeToMark == node) {
-      // This is the case where the map from the document to wrappers has
-      // been cleared out, but a wrapper is being marked. For now, we'll
-      // let the rest of the tree of wrappers get collected, because we have
-      // no good way of finding them. Later we should test behavior of other
-      // browsers and see if we need to preserve other wrappers in this case.
-      if (!marked())
-        mark();
-    }
-  }
-  root->m_inSubtreeMark = false;
-
-  // Double check that we actually ended up marked. This assert caught problems in the past.
-  ASSERT(marked());
-}
-
-/* Source for DOMNodeTable. Use "make hashtables" to regenerate.
-@begin DOMNodeTable 25
-  nodeName      DOMNode::NodeName       DontDelete|ReadOnly
-  nodeValue     DOMNode::NodeValue      DontDelete
-  nodeType      DOMNode::NodeType       DontDelete|ReadOnly
-  parentNode    DOMNode::ParentNode     DontDelete|ReadOnly
-  parentElement DOMNode::ParentElement  DontDelete|ReadOnly
-  childNodes    DOMNode::ChildNodes     DontDelete|ReadOnly
-  firstChild    DOMNode::FirstChild     DontDelete|ReadOnly
-  lastChild     DOMNode::LastChild      DontDelete|ReadOnly
-  previousSibling  DOMNode::PreviousSibling DontDelete|ReadOnly
-  nextSibling   DOMNode::NextSibling    DontDelete|ReadOnly
-  attributes    DOMNode::Attributes     DontDelete|ReadOnly
-  baseURI       DOMNode::BaseURI        DontDelete|ReadOnly
-  namespaceURI  DOMNode::NamespaceURI   DontDelete|ReadOnly
-# DOM2
-  prefix        DOMNode::Prefix         DontDelete
-  localName     DOMNode::LocalName      DontDelete|ReadOnly
-  ownerDocument DOMNode::OwnerDocument  DontDelete|ReadOnly
-# DOM3
-  textContent   DOMNode::TextContent    DontDelete
-@end
-*/
-bool DOMNode::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
-{
-  return getStaticValueSlot<DOMNode, DOMObject>(exec, &DOMNodeTable, this, propertyName, slot);
-}
-
-JSValue* DOMNode::getValueProperty(ExecState* exec, int token) const
-{
-  Node& node = *m_impl;
-  switch (token) {
-  case NodeName:
-    return jsStringOrNull(node.nodeName());
-  case NodeValue:
-    return jsStringOrNull(node.nodeValue());
-  case NodeType:
-    return jsNumber(node.nodeType());
-  case ParentNode:
-  case ParentElement: // IE only apparently
-    return toJS(exec,node.parentNode());
-  case ChildNodes:
-    return toJS(exec,node.childNodes().get());
-  case FirstChild:
-    return toJS(exec,node.firstChild());
-  case LastChild:
-    return toJS(exec,node.lastChild());
-  case PreviousSibling:
-    return toJS(exec,node.previousSibling());
-  case NextSibling:
-    return toJS(exec,node.nextSibling());
-  case Attributes:
-    return toJS(exec,node.attributes());
-  case BaseURI:
-    return jsStringOrNull(node.baseURI());
-  case NamespaceURI:
-    return jsStringOrNull(node.namespaceURI());
-  case Prefix:
-    return jsStringOrNull(node.prefix());
-  case LocalName:
-    return jsStringOrNull(node.localName());
-  case OwnerDocument:
-    return toJS(exec,node.ownerDocument());
-  case TextContent:
-    return jsStringOrNull(node.textContent());
-  }
-
-  return jsUndefined();
-}
-
-void DOMNode::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
-{
-    lookupPut<DOMNode,DOMObject>(exec, propertyName, value, attr, &DOMNodeTable, this);
-}
-
-void DOMNode::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
-{
-  DOMExceptionTranslator exception(exec);
-  Node& node = *m_impl;
-  switch (token) {
-  case NodeValue:
-    node.setNodeValue(valueToStringWithNullCheck(exec, value), exception);
-    break;
-  case Prefix:
-    node.setPrefix(valueToStringWithNullCheck(exec, value), exception);
-    break;
-  case TextContent:
-    node.setTextContent(valueToStringWithNullCheck(exec, value), exception);
-    break;
-  }
-}
-
-JSValue* DOMNodePrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List &args)
-{
-  if (!thisObj->inherits(&DOMNode::info))
-    return throwError(exec, TypeError);
-  DOMExceptionTranslator exception(exec);
-  Node& node = *static_cast<DOMNode*>(thisObj)->impl();
-  switch (id) {
-    case DOMNode::HasAttributes:
-      return jsBoolean(node.hasAttributes());
-    case DOMNode::HasChildNodes:
-      return jsBoolean(node.hasChildNodes());
-    case DOMNode::CloneNode:
-      return toJS(exec,node.cloneNode(args[0]->toBoolean(exec)));
-    case DOMNode::Normalize:
-      node.normalize();
-      return jsUndefined();
-    case DOMNode::IsSupported:
-        return jsBoolean(node.isSupported(args[0]->toString(exec),
-                                          valueToStringWithNullCheck(exec, args[1])));
-    case DOMNode::IsSameNode:
-        return jsBoolean(node.isSameNode(toNode(args[0])));
-    case DOMNode::IsEqualNode:
-        return jsBoolean(node.isEqualNode(toNode(args[0])));
-    case DOMNode::IsDefaultNamespace:
-        return jsBoolean(node.isDefaultNamespace(valueToStringWithNullCheck(exec, args[0])));
-    case DOMNode::LookupNamespaceURI:
-        return jsStringOrNull(node.lookupNamespaceURI(valueToStringWithNullCheck(exec, args[0])));
-    case DOMNode::LookupPrefix:
-        return jsStringOrNull(node.lookupPrefix(valueToStringWithNullCheck(exec, args[0])));
-    case DOMNode::AppendChild:
-      if (node.appendChild(toNode(args[0]), exception))
-        return args[0];
-      return jsNull();
-    case DOMNode::RemoveChild:
-      if (node.removeChild(toNode(args[0]), exception))
-        return args[0];
-      return jsNull();
-    case DOMNode::InsertBefore:
-      if (node.insertBefore(toNode(args[0]), toNode(args[1]), exception))
-        return args[0];
-      return jsNull();
-    case DOMNode::ReplaceChild:
-     if (node.replaceChild(toNode(args[0]), toNode(args[1]), exception))
-        return args[1];
-      return jsNull();
-  }
-
-  return jsUndefined();
-}
+using namespace KJS;
+using namespace HTMLNames;
 
 Attr* toAttr(JSValue* val, bool& ok)
 {
@@ -323,11 +53,9 @@ Attr* toAttr(JSValue* val, bool& ok)
     }
 
     ok = true;
-    return static_cast<Attr*>(static_cast<DOMNode*>(val)->impl());
+    return static_cast<Attr*>(static_cast<JSNode*>(val)->impl());
 }
 
-// -------------------------------------------------------------------------
-
 bool checkNodeSecurity(ExecState* exec, Node* n)
 {
   if (!n) 
@@ -385,4 +113,4 @@ JSValue* getRuntimeObject(ExecState* exec, Node* n)
     return 0;
 }
 
-} // namespace KJS
+} // namespace WebCore
index eff7bb612ee3ec5f6a3ea8da3574be562672934c..8d1e6209ea49f1dbadf6af7fbea79d367187207b 100644 (file)
 #include "JSNode.h"
 #include "Node.h"
 #include "kjs_binding.h"
-#include <wtf/Vector.h>
 
 namespace WebCore {
+
     class Attr;
     class EventTarget;
-}
-
-namespace KJS {
 
-  WebCore::Attr* toAttr(JSValue*, bool& ok);
+    Attr* toAttr(KJS::JSValue*, bool& ok);
 
-  bool checkNodeSecurity(ExecState*, WebCore::Node*);
-  JSValue* getRuntimeObject(ExecState*, WebCore::Node*);
-  JSValue* toJS(ExecState*, WebCore::EventTarget*);
-  JSObject* getNodeConstructor(ExecState*);
+    bool checkNodeSecurity(KJS::ExecState*, Node*);
+    KJS::JSValue* getRuntimeObject(KJS::ExecState*, Node*);
+    KJS::JSValue* toJS(KJS::ExecState*, EventTarget*);
+    KJS::JSObject* getNodeConstructor(KJS::ExecState*);
 
-} // namespace
+} // namespace WebCore
 
-#endif
+#endif // kjs_dom_h
diff --git a/WebCore/bindings/js/kjs_domnode.h b/WebCore/bindings/js/kjs_domnode.h
deleted file mode 100644 (file)
index 4383e61..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef kjs_domnode_h
-#define kjs_domnode_h
-
-#include <kjs_binding.h>
-#include <kjs/lookup.h>
-
-namespace WebCore {
-    class JSNode;
-}
-
-namespace KJS {
-
-KJS_DEFINE_PROTOTYPE(DOMNodePrototype)
-
-class DOMNode : public DOMObject {
-public:
-    virtual ~DOMNode();
-
-    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
-    JSValue *getValueProperty(ExecState*, int token) const;
-    virtual void mark();
-    virtual void put(ExecState*, const Identifier &propertyName, JSValue*, int attr = None);
-    void putValueProperty(ExecState*, int token, JSValue*, int attr);
-    WebCore::Node *impl() const { return m_impl.get(); }
-    virtual const ClassInfo* classInfo() const { return &info; }
-    static const ClassInfo info;
-
-    enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
-        ChildNodes, FirstChild, LastChild, PreviousSibling, NextSibling, BaseURI,
-        Attributes, NamespaceURI, Prefix, LocalName, OwnerDocument, InsertBefore,
-        ReplaceChild, RemoveChild, AppendChild, HasAttributes, HasChildNodes,
-        CloneNode, Normalize, IsSupported, Contains, IsSameNode, IsEqualNode, TextContent,
-        IsDefaultNamespace, LookupNamespaceURI, LookupPrefix
-    };
-    
-protected:
-    RefPtr<WebCore::Node> m_impl;
-
-private:
-    // Don't use this class directly -- use JSNode instead
-    friend class WebCore::JSNode;
-    DOMNode(ExecState*, WebCore::Node *n);
-};
-
-} // namespace KJS
-
-#endif
index a4db485b3f18b6fb9cfb7a00eaf1066ae40d8981..dfdcae720a59a21aedff82e87fcf6b12741361ab 100644 (file)
@@ -38,6 +38,7 @@
 #import "JSHTMLOptionsCollection.h"
 #import "JSMediaList.h"
 #import "JSNamedNodeMap.h"
+#import "JSNode.h"
 #import "JSNodeIterator.h"
 #import "JSNodeList.h"
 #import "JSRange.h"
@@ -48,7 +49,6 @@
 #import "Node.h"
 #import "WebScriptObjectPrivate.h"
 #import "kjs_css.h"
-#import "kjs_dom.h"
 #import "kjs_html.h"
 #import "kjs_window.h"
 #import <objc/objc-runtime.h>
@@ -79,6 +79,7 @@ static inline id createDOMWrapper(KJS::JSObject* object)
     WRAP(HTMLOptionsCollection)
     WRAP(MediaList)
     WRAP(NamedNodeMap)
+    WRAP(Node)
     WRAP(NodeList)
     WRAP(Range)
     WRAP(StyleSheet)
@@ -92,7 +93,6 @@ static inline id createDOMWrapper(KJS::JSObject* object)
             return [objc_getClass("DOM" #className) _wrap##className:static_cast<DOM##className*>(object)->impl()];
 
     WRAP(Event)
-    WRAP(Node)
     WRAP(RGBColor)
     WRAP(Rect)
     WRAP(StyleSheetList)
index cda2a834c286373d7595e5fd1573dbdde0fb996d..aed51c15d1d22b3f6542e1ee9787a25849e93bc6 100644 (file)
@@ -139,9 +139,7 @@ sub GetLegacyHeaderIncludes
 
     return "#include \"JSHTMLInputElementBase.h\"\n\n" if $legacyParent eq "JSHTMLInputElementBase";
     return "#include \"kjs_window.h\"\n\n" if $legacyParent eq "KJS::Window";
-    return "#include \"kjs_domnode.h\"\n\n" if $legacyParent eq "KJS::DOMNode";
     return "#include \"kjs_events.h\"\n\n" if $module eq "events";
-    return "#include \"kjs_dom.h\"\n\n" if $module eq "core";
     return "#include \"kjs_css.h\"\n\n" if $module eq "css";
     return "#include \"kjs_html.h\"\n\n" if $module eq "html";
 
@@ -771,19 +769,23 @@ sub GenerateImplementation
         push(@implContent, "${className}::~$className()\n");
 
         my $contextInterfaceName = CreateSVGContextInterfaceName($interfaceName);
+        push(@implContent, "{\n"); 
         if ($contextInterfaceName ne "") {
-            push(@implContent, "{\n    SVGDocumentExtensions::forgetGenericContext<$contextInterfaceName>(m_impl.get());\n");   
-            push(@implContent, "    ScriptInterpreter::forgetDOMObject(m_impl.get());\n}\n\n");
+            push(@implContent, "    SVGDocumentExtensions::forgetGenericContext<$contextInterfaceName>(m_impl.get());\n");   
+            push(@implContent, "    ScriptInterpreter::forgetDOMObject(m_impl.get());\n");
+        } elsif ($interfaceName eq "Node") {
+            push(@implContent, "    ScriptInterpreter::forgetDOMNodeForDocument(m_impl->document(), m_impl.get());\n");
         } else {
-            push(@implContent, "{\n    ScriptInterpreter::forgetDOMObject(m_impl.get());\n}\n\n");
+            push(@implContent, "    ScriptInterpreter::forgetDOMObject(m_impl.get());\n");
         }
+        push(@implContent, "}\n\n"); 
     }
 
     # Document needs a special destructor because it's a special case for caching. It needs
     # its own special handling rather than relying on the caching that Node normally does.
     if ($interfaceName eq "Document") {
         push(@implContent, "${className}::~$className()\n");
-        push(@implContent, "{\n    ScriptInterpreter::forgetDOMObject(static_cast<${implClassName}*>(m_impl.get()));\n}\n\n");
+        push(@implContent, "{\n    ScriptInterpreter::forgetDOMObject(static_cast<${implClassName}*>(impl()));\n}\n\n");
     }
 
     # Attributes
@@ -1428,6 +1430,10 @@ sub NativeToJSValue
         $implIncludes{"CSSMutableStyleDeclaration.h"} = 1;
     }
 
+    if ($type eq "NamedNodeMap") {
+        $implIncludes{"NamedAttrMap.h"} = 1;
+    }
+
     if ($type eq "EventTarget") {
         $implIncludes{"EventTargetNode.h"} = 1;
         $implIncludes{"JSEventTargetNode.h"} = 1;
index 3122e52298865a56c306c591c783a5d0c752e2a8..b306432699ae0291914711f9ce46d5a4cf63ca0a 100644 (file)
@@ -94,6 +94,7 @@ public:
     virtual void setNodeValue(const String&, ExceptionCode&);
     virtual NodeType nodeType() const = 0;
     Node* parentNode() const { return parent(); }
+    Node* parentElement() const { return parent(); } // IE extension
     Node* previousSibling() const { return m_previous; }
     Node* nextSibling() const { return m_next; }
     virtual PassRefPtr<NodeList> childNodes();
index 92b0d1d6df5236c8519e91d901fd2491d2f8dc70..2148a413bbd3db8c5dc7a31d76ad73a3e5df4803 100644 (file)
@@ -20,7 +20,7 @@
 
 module core {
 
-    interface [LegacyParent=KJS::DOMNode, GenerateConstructor, GenerateNativeConverter, GenerateToJS, ObjCCustomInternalImpl] Node {        
+    interface [CustomMarkFunction, GenerateConstructor, GenerateNativeConverter, GenerateToJS, ObjCCustomInternalImpl] Node {        
         // NodeType
         const unsigned short      ELEMENT_NODE                   = 1;
         const unsigned short      ATTRIBUTE_NODE                 = 2;
@@ -35,11 +35,10 @@ module core {
         const unsigned short      DOCUMENT_FRAGMENT_NODE         = 11;
         const unsigned short      NOTATION_NODE                  = 12;
 
-#if !defined(LANGUAGE_JAVASCRIPT)
-        readonly attribute DOMString        nodeName;
+        readonly attribute [ConvertNullStringTo=Null] DOMString        nodeName;
 
                  // FIXME: the spec says this can also raise on retrieval.
-                 attribute [ConvertNullToNullString] DOMString        nodeValue
+                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString        nodeValue
                      setter raises(DOMException);
 
         readonly attribute unsigned short   nodeType;
@@ -52,16 +51,17 @@ module core {
         readonly attribute NamedNodeMap     attributes;
         readonly attribute Document         ownerDocument;
 
-        [OldStyleObjC] Node insertBefore(in [Return] Node newChild, 
-                                         in Node refChild)
+        [OldStyleObjC, Custom] Node insertBefore(in [Return] Node newChild, 
+                                                 in Node refChild)
             raises(DOMException);
-        [OldStyleObjC] Node replaceChild(in Node newChild, 
-                                         in [Return] Node oldChild)
+        [OldStyleObjC, Custom] Node replaceChild(in Node newChild, 
+                                                 in [Return] Node oldChild)
             raises(DOMException);
-        Node               removeChild(in [Return] Node oldChild)
+        [Custom] Node               removeChild(in [Return] Node oldChild)
             raises(DOMException);
-        Node               appendChild(in [Return] Node newChild)
+        [Custom] Node               appendChild(in [Return] Node newChild)
             raises(DOMException);
+
         boolean            hasChildNodes();
         Node               cloneNode(in boolean deep);
         void               normalize();
@@ -69,28 +69,30 @@ module core {
         // Introduced in DOM Level 2:
 
         [OldStyleObjC] boolean isSupported(in DOMString feature, 
-                                           in DOMString version);
-        readonly attribute DOMString        namespaceURI;
-                 attribute [ConvertNullToNullString] DOMString        prefix
+                                           in [ConvertNullToNullString] DOMString version);
+
+        readonly attribute [ConvertNullStringTo=Null] DOMString        namespaceURI;
+                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString        prefix
                      setter raises(DOMException);
-        readonly attribute DOMString        localName;
+        readonly attribute [ConvertNullStringTo=Null] DOMString        localName;
+
         boolean            hasAttributes();
 
         // Introduced in DOM Level 3:
 
-        readonly attribute DOMString       baseURI;
+        readonly attribute [ConvertNullStringTo=Null] DOMString       baseURI;
 
                  // FIXME: the spec says this can also raise on retrieval.
-                 attribute [ConvertNullToNullString] DOMString       textContent
+                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString       textContent
                      setter raises(DOMException);
 
         boolean            isSameNode(in Node other);
         boolean            isEqualNode(in Node other);
-        DOMString          lookupPrefix(in DOMString namespaceURI);
-        boolean            isDefaultNamespace(in DOMString namespaceURI);
-        DOMString          lookupNamespaceURI(in DOMString prefix);
+        [ConvertNullStringTo=Null] DOMString          lookupPrefix(in [ConvertNullToNullString] DOMString namespaceURI);
+        boolean            isDefaultNamespace(in [ConvertNullToNullString] DOMString namespaceURI);
+        [ConvertNullStringTo=Null] DOMString          lookupNamespaceURI(in [ConvertNullToNullString] DOMString prefix);
 
-#if !defined(LANGUAGE_OBJECTIVE_C)
+#if 0
         // DocumentPosition
         const unsigned short      DOCUMENT_POSITION_DISCONNECTED = 0x01;
         const unsigned short      DOCUMENT_POSITION_PRECEDING    = 0x02;
@@ -108,12 +110,14 @@ module core {
                                        in DOMUserData data, 
                                        in UserDataHandler handler);
         DOMUserData        getUserData(in DOMString key);
-#endif /* !defined(LANGUAGE_OBJECTIVE_C) */
-#endif /* !defined(LANGUAGE_JAVASCRIPT) */
+#endif /* 0 */
+
+        // IE extentions
+        readonly attribute Node             parentElement;
 
 #if defined(LANGUAGE_OBJECTIVE_C)
         // Objective-C extensions
-        readonly attribute boolean         isContentEditable;
+        readonly attribute boolean          isContentEditable;
 #endif /* defined(LANGUAGE_OBJECTIVE_C) */
     };