+2006-01-22 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by darin.
+
+ SVG needs to support "evt" instead of "event" in event handlers.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=5874
+
+ * svg/custom/evt-onload-expected.checksum: Added.
+ * svg/custom/evt-onload-expected.png: Added.
+ * svg/custom/evt-onload-expected.txt: Added.
+ * svg/custom/evt-onload.svg: Added.
+
2006-01-22 Darin Adler <darin@apple.com>
Reviewed by Maciej.
--- /dev/null
+778803df0a824ed8f2c7dfa07c56832e
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+ KCanvasContainer {svg} at (0,0) size 100x100
+ KCanvasItem {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
--- /dev/null
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="test(evt)">
+<script>
+function test(evt) {
+ if (evt)
+ document.getElementById("rect").setAttribute("fill", "green");
+}
+</script>
+<rect id="rect" width="100" height="100" fill="red"/>
+</svg>
\ No newline at end of file
+2006-01-22 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by darin.
+
+ SVG needs to support "evt" instead of "event" in event handlers.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=5874
+
+ * WebCore.xcodeproj/project.pbxproj: added new classes
+ * khtml/ecma/kjs_events.cpp:
+ * khtml/ecma/kjs_events.h:
+ * khtml/ecma/kjs_proxy.cpp:
+ (WebCore::KJSProxyImpl::createHTMLEventHandler): simplified
+ (WebCore::KJSProxyImpl::createSVGEventHandler): new
+ * khtml/ecma/kjs_proxy.h:
+ * khtml/ecma/kjs_window.cpp:
+ * khtml/ecma/kjs_window.h:
+ * khtml/xml/DocumentImpl.cpp:
+ (WebCore::DocumentImpl::createHTMLEventListener): simplified
+ (WebCore::DocumentImpl::createSVGEventListener): new
+ * khtml/xml/DocumentImpl.h:
+ * khtml/xml/NodeImpl.cpp:
+ (WebCore::NodeImpl::dispatchEvent): use RefPtr
+ * ksvg2/events/JSSVGLazyEventListener.cpp: Added.
+ (WebCore::JSSVGLazyEventListener::JSSVGLazyEventListener): added.
+ (WebCore::JSSVGLazyEventListener::eventParameterName): added.
+ * ksvg2/events/JSSVGLazyEventListener.h: Added.
+ * ksvg2/svg/SVGElementImpl.cpp:
+ (SVGElementImpl::parseMappedAttribute): use new SVG event handler
+ * ksvg2/svg/SVGSVGElementImpl.cpp:
+ (SVGSVGElementImpl::parseMappedAttribute): use new SVG event handler
+ * page/Frame.cpp: updated KJSProxyImpl namespace
+ * page/Frame.h: updated KJSProxyImpl namespace
+ * page/FramePrivate.h: updated KJSProxyImpl namespace
+
2006-01-22 Darin Adler <darin@apple.com>
Reviewed by Maciej.
A8DF4AEF0980C42C0052981B /* RenderTableSection.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE50980C42C0052981B /* RenderTableSection.h */; };
A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */; };
A8DF4AF10980C42C0052981B /* RenderTableCol.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF4AE70980C42C0052981B /* RenderTableCol.h */; };
+ A8DF5F49098448C70052981B /* JSSVGLazyEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8DF545D0983A7510052981B /* JSSVGLazyEventListener.cpp */; };
+ A8DF5F4A098448C80052981B /* JSSVGLazyEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A8DF545C0983A7510052981B /* JSSVGLazyEventListener.h */; };
A8FD8B86087CB44C00DC3707 /* KWQWMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A85D7A8C0879EC64006A9172 /* KWQWMatrix.cpp */; };
A8FD8B87087CB45700DC3707 /* KWQWMatrix.h in Headers */ = {isa = PBXBuildFile; fileRef = A85D7A8D0879EC64006A9172 /* KWQWMatrix.h */; };
A8FEFB0A0979F472005839FD /* RenderForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB080979F472005839FD /* RenderForeignObject.h */; };
A8DF4AE50980C42C0052981B /* RenderTableSection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableSection.h; sourceTree = "<group>"; };
A8DF4AE60980C42C0052981B /* RenderTableRow.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTableRow.cpp; sourceTree = "<group>"; };
A8DF4AE70980C42C0052981B /* RenderTableCol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderTableCol.h; sourceTree = "<group>"; };
+ A8DF545C0983A7510052981B /* JSSVGLazyEventListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGLazyEventListener.h; sourceTree = "<group>"; };
+ A8DF545D0983A7510052981B /* JSSVGLazyEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLazyEventListener.cpp; sourceTree = "<group>"; };
A8FEFB080979F472005839FD /* RenderForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderForeignObject.h; sourceTree = "<group>"; };
A8FEFB090979F472005839FD /* RenderForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderForeignObject.cpp; sourceTree = "<group>"; };
A8FEFB2F0979F4F6005839FD /* SVGForeignObjectElementImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGForeignObjectElementImpl.cpp; sourceTree = "<group>"; };
children = (
A8C0F7F5089701F300BA5114 /* SVGZoomEventImpl.cpp */,
A8C0F7F6089701F300BA5114 /* SVGZoomEventImpl.h */,
+ A8DF545D0983A7510052981B /* JSSVGLazyEventListener.cpp */,
+ A8DF545C0983A7510052981B /* JSSVGLazyEventListener.h */,
);
path = events;
sourceTree = "<group>";
A8DF4AF10980C42C0052981B /* RenderTableCol.h in Headers */,
E1F7F5610981AF570073BE6A /* JSXMLHttpRequest.h in Headers */,
E1F0424709839389006694EA /* xmlhttprequest.h in Headers */,
+ A8DF5F4A098448C80052981B /* JSSVGLazyEventListener.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
A8DF4AF00980C42C0052981B /* RenderTableRow.cpp in Sources */,
E1F7F5600981AF570073BE6A /* JSXMLHttpRequest.cpp in Sources */,
E1F0424609839389006694EA /* xmlhttprequest.cpp in Sources */,
+ A8DF5F49098448C70052981B /* JSSVGLazyEventListener.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include <kdebug.h>
-using namespace DOM;
+using namespace WebCore;
using namespace EventNames;
-using namespace khtml;
using namespace HTMLNames;
namespace KJS {
public:
JSLazyEventListener(const DOM::DOMString& code, Window*, DOM::NodeImpl*, int lineno = 0);
virtual JSObject *listenerObj() const;
- protected:
- virtual JSValue *eventParameterName() const;
private:
+ virtual JSValue *eventParameterName() const;
void parseCode() const;
mutable DOM::DOMString code;
#include "kjs_window.h"
#include "kjs_events.h"
#include "NodeImpl.h"
+#include "JSSVGLazyEventListener.h"
#include "Frame.h"
#include <kjs/collector.h>
-using namespace DOM;
using namespace KJS;
+namespace WebCore {
+
KJSProxyImpl::KJSProxyImpl(Frame *frame)
{
m_script = 0;
{
initScript();
JSLock lock;
- return KJS::Window::retrieveWindow(m_frame)->getJSLazyEventListener(code, node, m_handlerLineno);
+ return new JSLazyEventListener(code, KJS::Window::retrieveWindow(m_frame), node, m_handlerLineno);
+}
+
+#if SVG_SUPPORT
+EventListener *KJSProxyImpl::createSVGEventHandler(const DOMString& code, NodeImpl *node)
+{
+ initScript();
+ JSLock lock;
+ return new JSSVGLazyEventListener(code, KJS::Window::retrieveWindow(m_frame), node, m_handlerLineno);
}
+#endif
void KJSProxyImpl::finishedWithEvent(EventImpl *event)
{
userAgent.find(QString::fromLatin1("compatible")) == -1)
m_script->setCompatMode(Interpreter::NetscapeCompat);
}
+
+}
class Frame;
class QString;
-namespace DOM {
+namespace KJS {
+ class ScriptInterpreter;
+}
+
+namespace WebCore {
+
class DOMString;
class EventImpl;
class EventListener;
class NodeImpl;
-};
-
-namespace KJS {
- class ScriptInterpreter;
-}
class KJSProxyImpl {
public:
KJSProxyImpl(Frame*);
~KJSProxyImpl();
- QVariant evaluate(const DOM::DOMString& filename, int baseLine, const DOM::DOMString& code, DOM::NodeImpl*);
+ QVariant evaluate(const DOMString& filename, int baseLine, const DOMString& code, NodeImpl*);
void clear();
- DOM::EventListener* createHTMLEventHandler(const DOM::DOMString& code, DOM::NodeImpl*);
- void finishedWithEvent(DOM::EventImpl*);
+ EventListener* createHTMLEventHandler(const DOMString& code, NodeImpl*);
+#if SVG_SUPPORT
+ EventListener* createSVGEventHandler(const DOMString& code, NodeImpl*);
+#endif
+ void finishedWithEvent(EventImpl*);
KJS::ScriptInterpreter *interpreter();
void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; }
int m_handlerLineno;
};
+}
+
#endif
return new JSUnprotectedEventListener(object, this, html);
}
-JSLazyEventListener *Window::getJSLazyEventListener(const DOMString& code, DOM::NodeImpl *node, int lineNumber)
-{
- return new JSLazyEventListener(code, this, node, lineNumber);
-}
-
void Window::clear( ExecState *exec )
{
JSLock lock;
BarInfo *toolbar(ExecState*) const;
JSEventListener *getJSEventListener(JSValue*, bool html = false);
JSUnprotectedEventListener *getJSUnprotectedEventListener(JSValue*, bool html = false);
- JSLazyEventListener *getJSLazyEventListener(const DOM::DOMString& code, DOM::NodeImpl*, int lineno = 0);
void clear(ExecState *);
virtual UString toString(ExecState *) const;
EventListener *DocumentImpl::createHTMLEventListener(const DOMString& code, NodeImpl *node)
{
- if (frame()) {
- return frame()->createHTMLEventListener(code, node);
- } else {
- return NULL;
+ if (Frame *frm = frame()) {
+ if (KJSProxyImpl *proxy = frm->jScript())
+ return proxy->createHTMLEventHandler(code, node);
}
+ return 0;
}
+#if SVG_SUPPORT
+EventListener *DocumentImpl::createSVGEventListener(const DOMString& code, NodeImpl *node)
+{
+ if (Frame *frm = frame()) {
+ if (KJSProxyImpl *proxy = frm->jScript())
+ return proxy->createSVGEventHandler(code, node);
+ }
+ return 0;
+}
+#endif
+
void DocumentImpl::setHTMLWindowEventListener(const AtomicString& eventType, AttributeImpl* attr)
{
setHTMLWindowEventListener(eventType, createHTMLEventListener(attr->value(), 0));
EventListener *createHTMLEventListener(const DOMString& code, NodeImpl*);
+#if SVG_SUPPORT
+ // FIXME: Move to SVGDocumentExtensions, when that lands w/ animation
+ EventListener *createSVGEventListener(const DOMString& code, NodeImpl*);
+#endif
+
/**
* Searches through the document, starting from fromNode, for the next selectable element that comes after fromNode.
* The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab indexes
// FIXME: Much code in this class assumes document is non-null; it would be better to
// ensure that document can never be null.
Frame *frame = 0;
- FrameView *view = 0;
+ RefPtr<FrameView> view;
if (DocumentImpl *doc = getDocument()) {
frame = doc->frame();
view = doc->view();
- // Since event handling code could cause this object to be deleted, grab a reference to the view now
- if (view)
- view->ref();
- }
+ }
bool ret = dispatchGenericEvent( evt, exceptioncode );
if (tempEvent && frame && frame->jScript())
frame->jScript()->finishedWithEvent(evt);
- if (view)
- view->deref();
-
evt->deref();
return ret;
--- /dev/null
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "config.h"
+#if SVG_SUPPORT
+
+#include "JSSVGLazyEventListener.h"
+
+using namespace KJS;
+
+namespace WebCore {
+
+JSSVGLazyEventListener::JSSVGLazyEventListener(const DOMString& code, KJS::Window* win, NodeImpl* node, int lineno)
+ : JSLazyEventListener(code, win, node, lineno)
+{
+}
+
+JSValue *JSSVGLazyEventListener::eventParameterName() const
+{
+ static ProtectedPtr<JSValue> eventString = jsString("evt");
+ return eventString.get();
+}
+
+}
+
+#endif // SVG_SUPPORT
+
+// vim:ts=4:noet
--- /dev/null
+/*
+ Copyright (C) 2006 Apple Computer, Inc.
+
+ This file is part of the WebKit project
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef JSSVGLazyEventListener_H
+#define JSSVGLazyEventListener_H
+#if SVG_SUPPORT
+
+#include "kjs_events.h"
+
+namespace WebCore {
+
+ class JSSVGLazyEventListener : public KJS::JSLazyEventListener {
+ public:
+ JSSVGLazyEventListener(const DOMString& code, KJS::Window*, NodeImpl*, int lineno = 0);
+ private:
+ virtual KJS::JSValue *eventParameterName() const;
+ };
+}
+
+#endif // SVG_SUPPORT
+#endif
+
+// vim:ts=4:noet
{
// standard events
if (attr->name() == onclickAttr)
- setHTMLEventListener(clickEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(clickEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onmousedownAttr)
- setHTMLEventListener(mousedownEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(mousedownEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onmousemoveAttr)
- setHTMLEventListener(mousemoveEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(mousemoveEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onmouseoutAttr)
- setHTMLEventListener(mouseoutEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(mouseoutEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onmouseoverAttr)
- setHTMLEventListener(mouseoverEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(mouseoverEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onmouseupAttr)
- setHTMLEventListener(mouseupEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(mouseupEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onfocusAttr)
- setHTMLEventListener(DOMFocusInEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(DOMFocusInEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else if (attr->name() == onblurAttr)
- setHTMLEventListener(DOMFocusOutEvent, getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+ setHTMLEventListener(DOMFocusOutEvent, getDocument()->createSVGEventListener(attr->value().qstring(), this));
else
KDOM::StyledElementImpl::parseMappedAttribute(attr);
}
// Only handle events if we're the outermost <svg> element
QString value = attr->value().qstring();
if (attr->name() == onloadAttr)
- getDocument()->setHTMLWindowEventListener(loadEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(loadEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == onunloadAttr)
- getDocument()->setHTMLWindowEventListener(unloadEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(unloadEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == onabortAttr)
- getDocument()->setHTMLWindowEventListener(abortEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(abortEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == onerrorAttr)
- getDocument()->setHTMLWindowEventListener(errorEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(errorEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == onresizeAttr)
- getDocument()->setHTMLWindowEventListener(resizeEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(resizeEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == onscrollAttr)
- getDocument()->setHTMLWindowEventListener(scrollEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(scrollEvent, getDocument()->createSVGEventListener(value, this));
else if (attr->name() == SVGNames::onzoomAttr)
- getDocument()->setHTMLWindowEventListener(zoomEvent, getDocument()->createHTMLEventListener(value, this));
+ getDocument()->setHTMLWindowEventListener(zoomEvent, getDocument()->createSVGEventListener(value, this));
}
if (attr->name() == SVGNames::xAttr) {
x()->baseVal()->setValueAsString(value.impl());
d->m_activeFrame = 0;
}
-EventListener *Frame::createHTMLEventListener(const DOMString& code, NodeImpl *node)
-{
- if (KJSProxyImpl *proxy = jScript())
- return proxy->createHTMLEventHandler(code, node);
- return 0;
-}
-
Frame *Frame::opener()
{
return d->m_opener;
class FrameView;
class KHTMLPartBrowserExtension;
class KHTMLSettings;
-class KJSProxyImpl;
namespace KJS {
class PausedTimeouts;
class SelectionController;
class VisiblePosition;
class XMLTokenizer;
+ class KJSProxyImpl;
struct ChildFrame;
}
*/
QString requestFrameName();
- bool requestObject( WebCore::RenderPart *frame, const QString &url, const QString &serviceType,
- const QStringList ¶mNames = QStringList(), const QStringList ¶mValues = QStringList() );
-
- bool requestObject( WebCore::ChildFrame *child, const KURL &url, const WebCore::URLArgs &args = WebCore::URLArgs() );
-
- WebCore::EventListener *createHTMLEventListener(const WebCore::DOMString& code, WebCore::NodeImpl *node);
+ bool requestObject(WebCore::RenderPart *frame, const QString &url, const QString &serviceType,
+ const QStringList ¶mNames = QStringList(), const QStringList ¶mValues = QStringList());
+ bool requestObject(WebCore::ChildFrame *child, const KURL &url, const WebCore::URLArgs &args = WebCore::URLArgs());
public:
WebCore::DocumentImpl *document() const;
void cancelRedirection(bool newLoadInProgress = false);
public:
- KJSProxyImpl *jScript();
+ WebCore::KJSProxyImpl *jScript();
Frame *opener();
void setOpener(Frame *_opener);
bool openedByJS();
QString scheduledScript;
RefPtr<DOM::NodeImpl> scheduledScriptNode;
- KJSProxyImpl *m_jscript;
+ WebCore::KJSProxyImpl *m_jscript;
int m_runningScripts;
bool m_bJScriptEnabled :1;
bool m_bJavaEnabled :1;