Commit 116c68e4 authored by weinig@apple.com's avatar weinig@apple.com

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a7bf179f
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
......@@ -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 \
......
......@@ -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 \
......
......@@ -7895,14 +7895,6 @@
RelativePath="..\bindings\js\kjs_css.h"
>
</File>
<File
RelativePath="..\bindings\js\kjs_dom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\kjs_dom.h"
>
</File>
<File
RelativePath="..\bindings\js\kjs_events.cpp"
>
......
......@@ -1589,8 +1589,6 @@
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 */; };
......@@ -5826,8 +5824,6 @@
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>"; };
......@@ -11461,8 +11457,6 @@
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 */,
......@@ -14160,7 +14154,6 @@
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 */,
......@@ -15772,7 +15765,6 @@
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 */,
......@@ -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
......
......@@ -32,7 +32,6 @@
#include "CSSHelper.h"
#include "HTMLFrameElementBase.h"
#include "HTMLNames.h"
#include "kjs_dom.h"
using namespace KJS;
......
......@@ -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);
}
......
/*
* 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
......@@ -35,14 +35,9 @@
#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
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -31,6 +31,10 @@
#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
......@@ -150,6 +150,8 @@ namespace WebCore {
}
};
KJS::JSValue* toJS(KJS::ExecState*, EventTarget*);
} // namespace WebCore
#endif // JSEventTargetBase_h
......@@ -27,7 +27,6 @@
#include "JSHTMLAppletElement.h"
#include "HTMLAppletElement.h"
#include "kjs_dom.h"
#include "kjs_html.h"
namespace WebCore {
......
......@@ -28,7 +28,6 @@
#include "Document.h"
#include "HTMLFormElement.h"
#include "kjs_dom.h"
namespace WebCore {
......
......@@ -27,7 +27,6 @@
#include "JSHTMLEmbedElement.h"
#include "HTMLEmbedElement.h"
#include "kjs_dom.h"
#include "kjs_html.h"
namespace WebCore {
......
......@@ -29,7 +29,6 @@
#include "HTMLCollection.h"
#include "HTMLFormElement.h"
#include "JSNamedNodesCollection.h"
#include "kjs_dom.h"
using namespace KJS;
......
......@@ -31,7 +31,7 @@
#include "CSSHelper.h"
#include "HTMLFrameElement.h"
#include "kjs_dom.h"
#include "kjs_binding.h"
using namespace KJS;
......
......@@ -31,7 +31,7 @@
#include "CSSHelper.h"
#include "HTMLIFrameElement.h"
#include "kjs_dom.h"
#include "kjs_binding.h"
using namespace KJS;
......
......@@ -27,7 +27,6 @@
#include "JSHTMLObjectElement.h"
#include "HTMLObjectElement.h"
#include "kjs_dom.h"
#include "kjs_html.h"
namespace WebCore {
......
......@@ -26,9 +26,11 @@
#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;
......
......@@ -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 {
......
......@@ -26,10 +26,10 @@
#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;
......
......@@ -29,11 +29,10 @@
#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;
......
......@@ -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)
......
......@@ -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.
......
......@@ -26,7 +26,6 @@
#include "CSSPrimitiveValue.h"
#include "JSCSSPrimitiveValue.h"
#include "kjs_dom.h"
#include "kjs_css.lut.h"
......
/*
* 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
/*
* 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
......@@ -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>
......
......@@ -24,15 +24,23 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "JSHTMLElement.h"
#include "HTMLDocument.h"
#include "HTMLImageElement.h"
<