Reviewed by Darin Adler.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Mar 2008 17:02:20 +0000 (17:02 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Mar 2008 17:02:20 +0000 (17:02 +0000)
        Remove kjs_dom.{h,cpp}.

        - Removed custom toAttr, which took a boolean ok, and teach CodeGeneratorJS.pm
          to us a null return value as an indication of failure. (This new logic is used
          for toVoidCallback as well.)
        - Move getRuntimeObject to kjs_html where a bunch of other runtime object related
          functions currently live.
        - Move checkNodeSecurity to kjs_binding, where other frame security functions
          currently live.
        - Remove getNodeConstructor.  It had no implementation.

        * GNUmakefile.am:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * bindings/js/JSAttrCustom.cpp:
        * bindings/js/JSCustomVoidCallback.cpp:
        (WebCore::toVoidCallback):
        * bindings/js/JSCustomVoidCallback.h:
        * bindings/js/JSDatabaseCustom.cpp:
        (WebCore::JSDatabase::changeVersion):
        (WebCore::JSDatabase::transaction):
        * bindings/js/JSElementCustom.cpp:
        (WebCore::JSElement::setAttributeNode):
        (WebCore::JSElement::setAttributeNodeNS):
        * bindings/js/JSEventTargetBase.cpp:
        (WebCore::toJS):
        * bindings/js/JSEventTargetBase.h:
        * bindings/js/JSHTMLAppletElementCustom.cpp:
        * bindings/js/JSHTMLElementCustom.cpp:
        * bindings/js/JSHTMLEmbedElementCustom.cpp:
        * bindings/js/JSHTMLFormElementCustom.cpp:
        * bindings/js/JSHTMLFrameElementCustom.cpp:
        * bindings/js/JSHTMLIFrameElementCustom.cpp:
        * bindings/js/JSHTMLObjectElementCustom.cpp:
        * bindings/js/JSNamedNodeMapCustom.cpp:
        * bindings/js/JSNamedNodesCollection.cpp:
        * bindings/js/JSNodeFilterCustom.cpp:
        * bindings/js/JSXSLTProcessor.cpp:
        * bindings/js/kjs_binding.cpp:
        (WebCore::checkNodeSecurity):
        * bindings/js/kjs_binding.h:
        * bindings/js/kjs_css.cpp:
        * bindings/js/kjs_dom.cpp: Removed.
        * bindings/js/kjs_dom.h: Removed.
        * bindings/js/kjs_events.cpp:
        * bindings/js/kjs_html.cpp:
        (WebCore::getRuntimeObject):
        * bindings/js/kjs_html.h:
        * bindings/js/kjs_window.cpp:
        * bindings/scripts/CodeGeneratorJS.pm:
        * dom/Attr.idl:
        * html/HTMLPlugInElement.cpp:
        * page/InspectorController.cpp:

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

37 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/bindings/js/JSAttrCustom.cpp
WebCore/bindings/js/JSCustomVoidCallback.cpp
WebCore/bindings/js/JSCustomVoidCallback.h
WebCore/bindings/js/JSDatabaseCustom.cpp
WebCore/bindings/js/JSElementCustom.cpp
WebCore/bindings/js/JSEventTargetBase.cpp
WebCore/bindings/js/JSEventTargetBase.h
WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
WebCore/bindings/js/JSHTMLElementCustom.cpp
WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
WebCore/bindings/js/JSHTMLFormElementCustom.cpp
WebCore/bindings/js/JSHTMLFrameElementCustom.cpp
WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp
WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
WebCore/bindings/js/JSNamedNodeMapCustom.cpp
WebCore/bindings/js/JSNamedNodesCollection.cpp
WebCore/bindings/js/JSNodeFilterCustom.cpp
WebCore/bindings/js/JSXSLTProcessor.cpp
WebCore/bindings/js/kjs_binding.cpp
WebCore/bindings/js/kjs_binding.h
WebCore/bindings/js/kjs_css.cpp
WebCore/bindings/js/kjs_dom.cpp [deleted file]
WebCore/bindings/js/kjs_dom.h [deleted file]
WebCore/bindings/js/kjs_events.cpp
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_html.h
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/scripts/CodeGeneratorJS.pm
WebCore/dom/Attr.idl
WebCore/html/HTMLPlugInElement.cpp
WebCore/page/InspectorController.cpp

index 30c4593..f4cef03 100644 (file)
@@ -1,3 +1,63 @@
+2008-03-04  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Remove kjs_dom.{h,cpp}.
+
+        - Removed custom toAttr, which took a boolean ok, and teach CodeGeneratorJS.pm
+          to us a null return value as an indication of failure. (This new logic is used
+          for toVoidCallback as well.)
+        - Move getRuntimeObject to kjs_html where a bunch of other runtime object related
+          functions currently live.
+        - Move checkNodeSecurity to kjs_binding, where other frame security functions 
+          currently live.
+        - Remove getNodeConstructor.  It had no implementation.
+
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * bindings/js/JSAttrCustom.cpp:
+        * bindings/js/JSCustomVoidCallback.cpp:
+        (WebCore::toVoidCallback):
+        * bindings/js/JSCustomVoidCallback.h:
+        * bindings/js/JSDatabaseCustom.cpp:
+        (WebCore::JSDatabase::changeVersion):
+        (WebCore::JSDatabase::transaction):
+        * bindings/js/JSElementCustom.cpp:
+        (WebCore::JSElement::setAttributeNode):
+        (WebCore::JSElement::setAttributeNodeNS):
+        * bindings/js/JSEventTargetBase.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSEventTargetBase.h:
+        * bindings/js/JSHTMLAppletElementCustom.cpp:
+        * bindings/js/JSHTMLElementCustom.cpp:
+        * bindings/js/JSHTMLEmbedElementCustom.cpp:
+        * bindings/js/JSHTMLFormElementCustom.cpp:
+        * bindings/js/JSHTMLFrameElementCustom.cpp:
+        * bindings/js/JSHTMLIFrameElementCustom.cpp:
+        * bindings/js/JSHTMLObjectElementCustom.cpp:
+        * bindings/js/JSNamedNodeMapCustom.cpp:
+        * bindings/js/JSNamedNodesCollection.cpp:
+        * bindings/js/JSNodeFilterCustom.cpp:
+        * bindings/js/JSXSLTProcessor.cpp:
+        * bindings/js/kjs_binding.cpp:
+        (WebCore::checkNodeSecurity):
+        * bindings/js/kjs_binding.h:
+        * bindings/js/kjs_css.cpp:
+        * bindings/js/kjs_dom.cpp: Removed.
+        * bindings/js/kjs_dom.h: Removed.
+        * bindings/js/kjs_events.cpp:
+        * bindings/js/kjs_html.cpp:
+        (WebCore::getRuntimeObject):
+        * bindings/js/kjs_html.h:
+        * bindings/js/kjs_window.cpp:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * dom/Attr.idl:
+        * html/HTMLPlugInElement.cpp:
+        * page/InspectorController.cpp:
+
 2008-03-04  Adam Roben  <aroben@apple.com>
 
         Win/Qt/GTK+/wx build fix after r30740
index 5fcfb37..45f0069 100644 (file)
@@ -498,7 +498,6 @@ webcore_sources += \
        WebCore/bindings/js/JSXSLTProcessor.cpp \
        WebCore/bindings/js/kjs_binding.cpp \
        WebCore/bindings/js/kjs_css.cpp \
-       WebCore/bindings/js/kjs_dom.cpp \
        WebCore/bindings/js/kjs_events.cpp \
        WebCore/bindings/js/kjs_html.cpp \
        WebCore/bindings/js/kjs_navigator.cpp \
index d9fb038..c47b291 100644 (file)
@@ -434,7 +434,6 @@ SOURCES += \
     bindings/js/JSXSLTProcessor.cpp \
     bindings/js/kjs_binding.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 b2c1b89..d24914b 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
-                                       RelativePath="..\bindings\js\kjs_dom.cpp"\r
-                                       >\r
-                               </File>\r
-                               <File\r
-                                       RelativePath="..\bindings\js\kjs_dom.h"\r
-                                       >\r
-                               </File>\r
-                               <File\r
                                        RelativePath="..\bindings\js\kjs_events.cpp"\r
                                        >\r
                                </File>\r
index 6c3d5e2..17b7166 100644 (file)
                93B70D6409EB0C7C009D8468 /* kjs_binding.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4809EB0C7C009D8468 /* kjs_binding.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93B70D6509EB0C7C009D8468 /* kjs_css.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4909EB0C7C009D8468 /* kjs_css.cpp */; };
                93B70D6609EB0C7C009D8468 /* kjs_css.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4A09EB0C7C009D8468 /* kjs_css.h */; };
-               93B70D6709EB0C7C009D8468 /* kjs_dom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4B09EB0C7C009D8468 /* kjs_dom.cpp */; };
-               93B70D6809EB0C7C009D8468 /* kjs_dom.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4C09EB0C7C009D8468 /* kjs_dom.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93B70D6909EB0C7C009D8468 /* kjs_events.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4D09EB0C7C009D8468 /* kjs_events.cpp */; };
                93B70D6A09EB0C7C009D8468 /* kjs_events.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D4E09EB0C7C009D8468 /* kjs_events.h */; };
                93B70D6B09EB0C7C009D8468 /* kjs_html.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D4F09EB0C7C009D8468 /* kjs_html.cpp */; };
                93B70D4809EB0C7C009D8468 /* kjs_binding.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_binding.h; sourceTree = "<group>"; };
                93B70D4909EB0C7C009D8468 /* kjs_css.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_css.cpp; sourceTree = "<group>"; };
                93B70D4A09EB0C7C009D8468 /* kjs_css.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_css.h; sourceTree = "<group>"; };
-               93B70D4B09EB0C7C009D8468 /* kjs_dom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_dom.cpp; sourceTree = "<group>"; };
-               93B70D4C09EB0C7C009D8468 /* kjs_dom.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_dom.h; sourceTree = "<group>"; };
                93B70D4D09EB0C7C009D8468 /* kjs_events.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_events.cpp; sourceTree = "<group>"; };
                93B70D4E09EB0C7C009D8468 /* kjs_events.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = kjs_events.h; sourceTree = "<group>"; };
                93B70D4F09EB0C7C009D8468 /* kjs_html.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = kjs_html.cpp; sourceTree = "<group>"; };
                                93B70D4809EB0C7C009D8468 /* kjs_binding.h */,
                                93B70D4909EB0C7C009D8468 /* kjs_css.cpp */,
                                93B70D4A09EB0C7C009D8468 /* kjs_css.h */,
-                               93B70D4B09EB0C7C009D8468 /* kjs_dom.cpp */,
-                               93B70D4C09EB0C7C009D8468 /* kjs_dom.h */,
                                93B70D4D09EB0C7C009D8468 /* kjs_events.cpp */,
                                93B70D4E09EB0C7C009D8468 /* kjs_events.h */,
                                93B70D4F09EB0C7C009D8468 /* kjs_html.cpp */,
                                93B70D6409EB0C7C009D8468 /* kjs_binding.h in Headers */,
                                93B70D6609EB0C7C009D8468 /* kjs_css.h in Headers */,
                                656581F109D1508D000E61D7 /* kjs_css.lut.h in Headers */,
-                               93B70D6809EB0C7C009D8468 /* kjs_dom.h in Headers */,
                                93B70D6A09EB0C7C009D8468 /* kjs_events.h in Headers */,
                                93B70D6C09EB0C7C009D8468 /* kjs_html.h in Headers */,
                                93B70D6E09EB0C7C009D8468 /* kjs_navigator.h in Headers */,
                                93309DE7099E64920056E581 /* htmlediting.cpp in Sources */,
                                93B70D6309EB0C7C009D8468 /* kjs_binding.cpp in Sources */,
                                93B70D6509EB0C7C009D8468 /* kjs_css.cpp in Sources */,
-                               93B70D6709EB0C7C009D8468 /* kjs_dom.cpp in Sources */,
                                93B70D6909EB0C7C009D8468 /* kjs_events.cpp in Sources */,
                                93B70D6B09EB0C7C009D8468 /* kjs_html.cpp in Sources */,
                                93B70D6D09EB0C7C009D8468 /* kjs_navigator.cpp in Sources */,
index 25443f7..8a3d8ba 100644 (file)
@@ -89,7 +89,6 @@ This file contains the list of files needed to build WebCore.
         bindings/js/JSXSLTProcessor.cpp
         bindings/js/kjs_binding.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 65b9117..c7d3848 100644 (file)
@@ -32,7 +32,6 @@
 #include "CSSHelper.h"
 #include "HTMLFrameElementBase.h"
 #include "HTMLNames.h"
-#include "kjs_dom.h"
 
 using namespace KJS;
 
index 1aaac01..bfed107 100644 (file)
@@ -100,10 +100,8 @@ void JSCustomVoidCallback::handleEvent()
     Document::updateDocumentsRendering();
 }
  
-VoidCallback* toVoidCallback(ExecState* exec, JSValue* value, bool& ok)
+VoidCallback* toVoidCallback(ExecState* exec, JSValue* value)
 {
-    ok = false;
-    
     JSObject* object = value->getObject();
     if (!object)
         return 0;
@@ -112,7 +110,6 @@ VoidCallback* toVoidCallback(ExecState* exec, JSValue* value, bool& ok)
     if (!frame)
         return 0;
     
-    ok = true;
     return new JSCustomVoidCallback(object, frame);
 }
 
index 1f97f39..8368698 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include <kjs/protect.h>
 #include <wtf/Forward.h>
 
-namespace KJS {
-    class JSObject;
-}
-
 namespace WebCore {
     
     class Frame;
-    class SQLError;
     
     class JSCustomVoidCallback : public VoidCallback {
     public:
@@ -53,8 +48,9 @@ namespace WebCore {
         KJS::ProtectedPtr<KJS::JSObject> m_callback;
         RefPtr<Frame> m_frame;
     };
-   
-    VoidCallback* toVoidCallback(KJS::ExecState*, KJS::JSValue*, bool& ok);
-}
+
+    VoidCallback* toVoidCallback(KJS::ExecState*, KJS::JSValue*);
+
+} // namespace WebCore
 
 #endif // JSCustomVoidCallback_h
index 1557a37..f99adbe 100644 (file)
@@ -75,9 +75,8 @@ JSValue* JSDatabase::changeVersion(ExecState* exec, const List& args)
     
     RefPtr<VoidCallback> successCallback;
     if (!args[4]->isNull()) {
-        bool ok;
-        successCallback = toVoidCallback(exec, args[4], ok);
-        if (!ok) {
+        successCallback = toVoidCallback(exec, args[4]);
+        if (!successCallback) {
             setDOMException(exec, TYPE_MISMATCH_ERR);
             return jsUndefined();
         }
@@ -115,9 +114,8 @@ JSValue* JSDatabase::transaction(ExecState* exec, const List& args)
 
     RefPtr<VoidCallback> successCallback;
     if (args.size() > 2 && !args[2]->isNull()) {
-        bool ok;
-        successCallback = toVoidCallback(exec, args[2], ok);
-        if (!ok) {
+        successCallback = toVoidCallback(exec, args[2]);
+        if (!successCallback) {
             setDOMException(exec, TYPE_MISMATCH_ERR);
             return jsUndefined();
         }
index 1feb769..aa55556 100644 (file)
@@ -34,7 +34,7 @@
 #include "ExceptionCode.h"
 #include "HTMLFrameElementBase.h"
 #include "HTMLNames.h"
-#include "kjs_dom.h"
+#include "JSAttr.h"
 
 using namespace KJS;
 
@@ -70,9 +70,8 @@ JSValue* JSElement::setAttribute(ExecState* exec, const List& args)
 JSValue* JSElement::setAttributeNode(ExecState* exec, const List& args)
 {
     ExceptionCode ec = 0;
-    bool newAttrOk;
-    Attr* newAttr = toAttr(args[0], newAttrOk);
-    if (!newAttrOk) {
+    Attr* newAttr = toAttr(args[0]);
+    if (!newAttr) {
         setDOMException(exec, TYPE_MISMATCH_ERR);
         return jsUndefined();
     }
@@ -105,9 +104,8 @@ JSValue* JSElement::setAttributeNS(ExecState* exec, const List& args)
 JSValue* JSElement::setAttributeNodeNS(ExecState* exec, const List& args)
 {
     ExceptionCode ec = 0;
-    bool newAttrOk;
-    Attr* newAttr = toAttr(args[0], newAttrOk);
-    if (!newAttrOk) {
+    Attr* newAttr = toAttr(args[0]);
+    if (!newAttr) {
         setDOMException(exec, TYPE_MISMATCH_ERR);
         return jsUndefined();
     }
index db95d8b..093e065 100644 (file)
 #include "JSEventTargetNode.h"
 #include "kjs_window.h"
 
+#if ENABLE(SVG)
+#include "JSSVGElementInstance.h"
+#endif
+
 #include "JSEventTargetBase.lut.h"
 
 using namespace KJS;
@@ -243,4 +247,30 @@ AtomicString eventNameForPropertyToken(int token)
     return AtomicString();
 }
 
+JSValue* toJS(ExecState* exec, EventTarget* target)
+{
+    if (!target)
+        return jsNull();
+    
+#if ENABLE(SVG)
+    // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
+    SVGElementInstance* instance = target->toSVGElementInstance();
+    if (instance)
+        return toJS(exec, instance);
+#endif
+    
+    Node* node = target->toNode();
+    if (node)
+        return toJS(exec, node);
+
+    if (XMLHttpRequest* xhr = target->toXMLHttpRequest())
+        // XMLHttpRequest is always created via JS, so we don't need to use cacheDOMObject() here.
+        return ScriptInterpreter::getDOMObject(xhr);
+
+    // There are two kinds of EventTargets: EventTargetNode and XMLHttpRequest.
+    // If SVG support is enabled, there is also SVGElementInstance.
+    ASSERT_NOT_REACHED();
+    return jsNull();
+}
+
 } // namespace WebCore
index 218ad18..62aa964 100644 (file)
@@ -150,6 +150,8 @@ namespace WebCore {
         }
     };
 
+    KJS::JSValue* toJS(KJS::ExecState*, EventTarget*);
+
 } // namespace WebCore
 
 #endif // JSEventTargetBase_h
index d34b8b5..7e78b08 100644 (file)
@@ -27,7 +27,6 @@
 #include "JSHTMLAppletElement.h"
 
 #include "HTMLAppletElement.h"
-#include "kjs_dom.h"
 #include "kjs_html.h"
 
 namespace WebCore {
index 755277a..81885d0 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "Document.h"
 #include "HTMLFormElement.h"
-#include "kjs_dom.h"
 
 namespace WebCore {
 
index 1224f2c..1cf67bc 100644 (file)
@@ -27,7 +27,6 @@
 #include "JSHTMLEmbedElement.h"
 
 #include "HTMLEmbedElement.h"
-#include "kjs_dom.h"
 #include "kjs_html.h"
 
 namespace WebCore {
index 8e24618..ce1f558 100644 (file)
@@ -29,7 +29,6 @@
 #include "HTMLCollection.h"
 #include "HTMLFormElement.h"
 #include "JSNamedNodesCollection.h"
-#include "kjs_dom.h"
 
 using namespace KJS;
 
index 792a8bf..9fccb44 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "CSSHelper.h"
 #include "HTMLFrameElement.h"
-#include "kjs_dom.h"
+#include "kjs_binding.h"
 
 using namespace KJS;
 
index 75e24d8..5645ebe 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "CSSHelper.h"
 #include "HTMLIFrameElement.h"
-#include "kjs_dom.h"
+#include "kjs_binding.h"
 
 using namespace KJS;
 
index 83e9b0d..5d4c03c 100644 (file)
@@ -27,7 +27,6 @@
 #include "JSHTMLObjectElement.h"
 
 #include "HTMLObjectElement.h"
-#include "kjs_dom.h"
 #include "kjs_html.h"
 
 namespace WebCore {
index 7cb60bf..1babc0a 100644 (file)
 #include "config.h"
 #include "JSNamedNodeMap.h"
 
+#include "JSNode.h"
 #include "NamedNodeMap.h"
+#include "Node.h"
+#include "PlatformString.h"
 #include "kjs_binding.h"
-#include "kjs_dom.h"
 
 using namespace KJS;
 
index 1fc008f..d2474cc 100644 (file)
@@ -27,9 +27,9 @@
 #include "JSNamedNodesCollection.h"
 
 #include "AtomicString.h"
+#include "JSNode.h"
 #include "NamedAttrMap.h"
 #include "Node.h"
-#include "kjs_dom.h"
 
 namespace WebCore {
 
index 413abf9..5ba0777 100644 (file)
 #include "config.h"
 #include "JSNodeFilter.h"
 
+#include "JSNode.h"
 #include "JSNodeFilterCondition.h"
 #include "NodeFilter.h"
 #include "kjs_binding.h"
-#include "kjs_dom.h"
 
 using namespace KJS;
 
index 7902f61..9aa38a2 100644 (file)
 
 #include "JSXSLTProcessor.h"
 
-#include "XSLTProcessor.h"
-#include "kjs_dom.h"
-#include "JSDocument.h"
 #include "Document.h"
 #include "DocumentFragment.h"
+#include "JSDocument.h"
+#include "XSLTProcessor.h"
 
 using namespace KJS;
 using namespace WebCore;
index 791ad4a..0ac97a6 100644 (file)
@@ -27,6 +27,7 @@
 #include "kjs_binding.h"
 
 #include "DOMCoreException.h"
+#include "Document.h"
 #include "EventException.h"
 #include "ExceptionCode.h"
 #include "HTMLImageElement.h"
@@ -341,6 +342,11 @@ void setDOMException(ExecState* exec, ExceptionCode ec)
     exec->setException(errorObject);
 }
 
+bool checkNodeSecurity(ExecState* exec, Node* node)
+{
+    return node && allowsAccessFromFrame(exec, node->document()->frame());
+}
+
 bool allowsAccessFromFrame(ExecState* exec, Frame* frame)
 {
     if (!frame)
index 9cdeddd..796a7e8 100644 (file)
@@ -134,6 +134,8 @@ namespace WebCore {
 
     template <typename T> inline KJS::JSValue* toJS(KJS::ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); }
 
+    bool checkNodeSecurity(KJS::ExecState*, Node*);
+
     // Helpers for Window, History, and Location classes to implement cross-domain policy.
     // Besides the cross-domain check, they need non-caching versions of staticFunctionGetter for
     // because we do not want current property values involved at all.
index e2ab70d..4e8af41 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "CSSPrimitiveValue.h"
 #include "JSCSSPrimitiveValue.h"
-#include "kjs_dom.h"
 
 #include "kjs_css.lut.h"
 
diff --git a/WebCore/bindings/js/kjs_dom.cpp b/WebCore/bindings/js/kjs_dom.cpp
deleted file mode 100644 (file)
index ee1d42b..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  Copyright (C) 2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2006 Jon Shier (jshier@iastate.edu)
- *  Copyright (C) 2004, 2005, 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
- *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "config.h"
-#include "kjs_dom.h"
-
-#include "Document.h"
-#include "EventTarget.h"
-#include "Frame.h"
-#include "HTMLNames.h"
-#include "HTMLPlugInElement.h"
-#include "JSAttr.h"
-#include "JSNode.h"
-#include "XMLHttpRequest.h"
-#include "kjs_events.h"
-#include "kjs_window.h"
-
-#if ENABLE(SVG)
-#include "JSSVGElementInstance.h"
-#endif
-
-#if USE(JAVASCRIPTCORE_BINDINGS)
-#include <bindings/runtime.h>
-#endif
-
-namespace WebCore {
-
-using namespace KJS;
-using namespace HTMLNames;
-
-Attr* toAttr(JSValue* val, bool& ok)
-{
-    if (!val || !val->isObject(&JSAttr::info)) {
-        ok = false;
-        return 0;
-    }
-
-    ok = true;
-    return static_cast<Attr*>(static_cast<JSNode*>(val)->impl());
-}
-
-bool checkNodeSecurity(ExecState* exec, Node* node)
-{
-    return node && allowsAccessFromFrame(exec, node->document()->frame());
-}
-
-JSValue* toJS(ExecState* exec, EventTarget* target)
-{
-    if (!target)
-        return jsNull();
-    
-#if ENABLE(SVG)
-    // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
-    SVGElementInstance* instance = target->toSVGElementInstance();
-    if (instance)
-        return toJS(exec, instance);
-#endif
-    
-    Node* node = target->toNode();
-    if (node)
-        return toJS(exec, node);
-
-    if (XMLHttpRequest* xhr = target->toXMLHttpRequest())
-        // XMLHttpRequest is always created via JS, so we don't need to use cacheDOMObject() here.
-        return ScriptInterpreter::getDOMObject(xhr);
-
-    // There are two kinds of EventTargets: EventTargetNode and XMLHttpRequest.
-    // If SVG support is enabled, there is also SVGElementInstance.
-    ASSERT(0);
-    return jsNull();
-}
-
-JSObject* getRuntimeObject(ExecState* exec, Node* n)
-{
-    if (!n)
-        return 0;
-
-#if USE(JAVASCRIPTCORE_BINDINGS)
-    if (n->hasTagName(objectTag) || n->hasTagName(embedTag) || n->hasTagName(appletTag)) {
-        HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(n);
-        if (plugInElement->getInstance() && plugInElement->getInstance()->rootObject())
-            // The instance is owned by the PlugIn element.
-            return KJS::Bindings::Instance::createRuntimeObject(plugInElement->getInstance());
-    }
-#endif
-
-    // If we don't have a runtime object return 0.
-    return 0;
-}
-
-} // namespace WebCore
diff --git a/WebCore/bindings/js/kjs_dom.h b/WebCore/bindings/js/kjs_dom.h
deleted file mode 100644 (file)
index 6e0f136..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *  Copyright (C) 2000 Harri Porten (porten@kde.org)
- *  Copyright (C) 2003, 2004, 2005, 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
- *  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef kjs_dom_h
-#define kjs_dom_h
-
-#include "JSNode.h"
-#include "Node.h"
-#include "kjs_binding.h"
-
-namespace WebCore {
-
-    class Attr;
-    class EventTarget;
-
-    Attr* toAttr(KJS::JSValue*, bool& ok);
-
-    bool checkNodeSecurity(KJS::ExecState*, Node*);
-    KJS::JSObject* getRuntimeObject(KJS::ExecState*, Node*);
-    KJS::JSValue* toJS(KJS::ExecState*, EventTarget*);
-    KJS::JSObject* getNodeConstructor(KJS::ExecState*);
-
-} // namespace WebCore
-
-#endif // kjs_dom_h
index e37e175..2ee2235 100644 (file)
@@ -32,7 +32,6 @@
 #include "JSEvent.h"
 #include "JSEventTargetNode.h"
 #include "Page.h"
-#include "kjs_dom.h"
 #include "kjs_proxy.h"
 #include "kjs_window.h"
 #include <kjs/function_object.h>
index 8f2c7c4..da78d6d 100644 (file)
 
 #include "Frame.h"
 #include "FrameLoader.h"
-#include "JSHTMLElement.h"
 #include "HTMLDocument.h"
 #include "HTMLImageElement.h"
+#include "HTMLNames.h"
+#include "JSHTMLElement.h"
 #include "kjs_proxy.h"
+#include "HTMLPlugInElement.h"
 
-namespace WebCore {
+#if USE(JAVASCRIPTCORE_BINDINGS)
+#include <bindings/runtime.h>
+#endif
 
 using namespace KJS;
 
+namespace WebCore {
+
+using namespace HTMLNames;
+
 ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* doc)
     : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
     , m_doc(doc)
@@ -80,6 +88,24 @@ JSObject* ImageConstructorImp::construct(ExecState*  exec, const List& list)
 
 // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
 
+JSObject* getRuntimeObject(ExecState* exec, Node* node)
+{
+    if (!node)
+        return 0;
+
+#if USE(JAVASCRIPTCORE_BINDINGS)
+    if (node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag)) {
+        HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node);
+        if (plugInElement->getInstance() && plugInElement->getInstance()->rootObject())
+            // The instance is owned by the PlugIn element.
+            return KJS::Bindings::Instance::createRuntimeObject(plugInElement->getInstance());
+    }
+#endif
+
+    // If we don't have a runtime object return 0.
+    return 0;
+}
+
 JSValue* runtimeObjectGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
 {
     JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(slot.slotBase());
index 4b519d2..d418357 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef kjs_html_h
 #define kjs_html_h
 
-#include "kjs_dom.h"
+#include "kjs_binding.h"
 
 namespace WebCore {
 
@@ -29,6 +29,7 @@ namespace WebCore {
     class HTMLCollection;
     class HTMLElement;
     class JSHTMLElement;
+    class Node;
 
     class ImageConstructorImp : public DOMObject {
     public:
@@ -45,6 +46,7 @@ namespace WebCore {
     // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
     // FIXME: Move these to a more appropriate place.
 
+    KJS::JSObject* getRuntimeObject(KJS::ExecState*, Node*);
     KJS::JSValue* runtimeObjectGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
     KJS::JSValue* runtimeObjectPropertyGetter(KJS::ExecState*, KJS::JSObject*, const KJS::Identifier&, const KJS::PropertySlot&);
     bool runtimeObjectCustomGetOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&, JSHTMLElement*, HTMLElement*);
index 8404224..b025460 100644 (file)
@@ -44,6 +44,7 @@
 #include "JSHTMLCollection.h"
 #include "JSHTMLOptionElementConstructor.h"
 #include "JSLocation.h"
+#include "JSNode.h"
 #include "JSXMLHttpRequest.h"
 #include "Logging.h"
 #include "MediaPlayer.h"
index 5df0c8a..6d97548 100644 (file)
@@ -949,12 +949,12 @@ sub GenerateImplementation
                 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"CustomGetter"}) {
                     push(@implContent, "        return $getterFunctionName(exec);\n");
                 } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) {
-                    $implIncludes{"kjs_dom.h"} = 1;
+                    $implIncludes{"kjs_binding.h"} = 1;
                     push(@implContent, "        $implClassName* imp = static_cast<$implClassName*>(impl());\n");
                     push(@implContent, "        return checkNodeSecurity(exec, imp->$getterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName()") . " : jsUndefined();\n");
                 } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) {
                     $implIncludes{"Document.h"} = 1;
-                    $implIncludes{"kjs_dom.h"} = 1;
+                    $implIncludes{"kjs_binding.h"} = 1;
                     push(@implContent, "        $implClassName* imp = static_cast<$implClassName*>(impl());\n");
                     push(@implContent, "        return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature,  0, $implClassName, $implClassNameForValueConversion, "imp->$getterFunctionName()") . " : jsUndefined();\n");
                 } elsif ($attribute->signature->type =~ /Constructor$/) {
@@ -1179,7 +1179,7 @@ sub GenerateImplementation
                 if ($function->signature->extendedAttributes->{"SVGCheckSecurityDocument"}) {
                     push(@implContent, "    if (!checkNodeSecurity(exec, imp->getSVGDocument(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n");
                     push(@implContent, "        return jsUndefined();\n");
-                    $implIncludes{"kjs_dom.h"} = 1;
+                    $implIncludes{"kjs_binding.h"} = 1;
                 }
 
                 my $paramIndex = 0;
@@ -1211,10 +1211,12 @@ sub GenerateImplementation
                         push(@implContent, "        resolver = customResolver.get();\n");
                         push(@implContent, "    }\n");
                     } else {
-                        push(@implContent, "    bool ${name}Ok;\n") if TypeCanFailConversion($parameter);
-                        push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args[$paramIndex]", TypeCanFailConversion($parameter) ? "${name}Ok" : undef) . ";\n");
+                        push(@implContent, "    " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args[$paramIndex]") . ";\n");
+
+                        # FIXME: can this be pushed down into the implementation?
                         if (TypeCanFailConversion($parameter)) {
-                            push(@implContent, "    if (!${name}Ok) {\n");
+                            $implIncludes{"ExceptionCode.h"} = 1;
+                            push(@implContent, "    if (!${name}) {\n");
                             push(@implContent, "        setDOMException(exec, TYPE_MISMATCH_ERR);\n");
                             push(@implContent, "        return jsUndefined();\n");
                             push(@implContent, "    }\n");
@@ -1434,8 +1436,6 @@ sub TypeCanFailConversion
 
     my $type = $codeGenerator->StripModule($signature->type);
 
-    $implIncludes{"ExceptionCode.h"} = 1 if $type eq "Attr";
-
     return $typeCanFailConversion{$type} if exists $typeCanFailConversion{$type};
 
     die "Don't know whether a JS value can fail conversion to type $type.";
@@ -1445,8 +1445,6 @@ sub JSValueToNative
 {
     my $signature = shift;
     my $value = shift;
-    my $okParam = shift;
-    my $maybeOkParam = $okParam ? ", ${okParam}" : "";
 
     my $type = $codeGenerator->StripModule($signature->type);
 
@@ -1470,19 +1468,10 @@ sub JSValueToNative
         return "toEventTargetNode($value)";
     }
 
-    if ($type eq "Attr") {
-        $implIncludes{"kjs_dom.h"} = 1;
-        return "toAttr($value${maybeOkParam})";
-    }
-
-    if ($type eq "VoidCallback") {
-        $implIncludes{"JSCustomVoidCallback.h"} = 1;
-        return "toVoidCallback(exec, $value${maybeOkParam})";
-    }
-
     $implIncludes{"FloatPoint.h"} = 1 if $type eq "SVGPoint";
     $implIncludes{"FloatRect.h"} = 1 if $type eq "SVGRect";
     $implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement";
+    $implIncludes{"JSCustomVoidCallback.h"} = 1 if $type eq "VoidCallback";
 
     # Default, assume autogenerated type conversion routines
     $implIncludes{"JS$type.h"} = 1;
@@ -1566,7 +1555,6 @@ sub NativeToJSValue
     if ($type eq "EventTarget") {
         $implIncludes{"EventTargetNode.h"} = 1;
         $implIncludes{"JSEventTargetNode.h"} = 1;
-        $implIncludes{"kjs_dom.h"} = 1;
     } elsif ($type eq "DOMWindow") {
         $implIncludes{"kjs_window.h"} = 1;
     } elsif ($type eq "DOMObject") {
index eeb064b..42ac04c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -22,6 +22,7 @@ module core {
 
     interface [
         GenerateConstructor,
+        GenerateNativeConverter,
         InterfaceUUID=EEE8E22B-22C3-4e50-95F4-5E0B8AAD8231,
         ImplementationUUID=41B16348-D8E7-4d21-BFDB-125705B7E91F
     ] Attr : EventTargetNode {
index 67d463d..9649b15 100644 (file)
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "HTMLNames.h"
+#include "JSNode.h"
 #include "Page.h"
 #include "RenderWidget.h"
 #include "Settings.h"
 #include "Widget.h"
-#include "kjs_dom.h"
 #include "kjs_proxy.h"
 
 #if USE(NPOBJECT)
index 6b48fc3..824e373 100644 (file)
@@ -45,6 +45,7 @@
 #include "HTMLFrameOwnerElement.h"
 #include "InspectorClient.h"
 #include "JSDOMWindow.h"
+#include "JSNode.h"
 #include "JSRange.h"
 #include "Page.h"
 #include "Range.h"
@@ -55,7 +56,6 @@
 #include "SystemTime.h"
 #include "TextEncoding.h"
 #include "TextIterator.h"
-#include "kjs_dom.h"
 #include "kjs_proxy.h"
 #include "kjs_window.h"
 #include <JavaScriptCore/APICast.h>