Reviewed by Vicki.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2005 22:42:40 +0000 (22:42 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2005 22:42:40 +0000 (22:42 +0000)
<rdar://problem/4003774> REGRESSION(125-181): JavaScript problems @ Yankee/Dixie quiz

Reworked how scopes are set up for event handlers to match other
browser. This includes the following changes:

- Special scope entries are set up at the time the event handler
is created, not at the time it fires.

- Special scope is only set up for event handlers set in the html
source through an html attribute, not for handlers set using
addEventHandler or setting JS properties like onclick through
JavaScript.

- Special scope is based on the DOM node on which the handler is
an attribute, not the event target.

This fixes the regression while allowing the fix to
<rdar://problem/3798453> (DIG: getting variable with same name as
DOM element attribute gets attribute value instead) to keep
working correctly.

* khtml/ecma/kjs_events.cpp:
        (JSEventListener::handleEvent):
        (JSLazyEventListener::JSLazyEventListener):
        (JSLazyEventListener::parseCode):
        * khtml/ecma/kjs_events.h:
        * khtml/ecma/kjs_proxy.cpp:
        (KJSProxyImpl::createHTMLEventHandler):
        * khtml/ecma/kjs_proxy.h:
        * khtml/ecma/kjs_window.cpp:
        (Window::getJSLazyEventListener):
        * khtml/ecma/kjs_window.h:
        * khtml/html/html_baseimpl.cpp:
        (HTMLBodyElementImpl::parseHTMLAttribute):
        (HTMLFrameElementImpl::parseHTMLAttribute):
        (HTMLFrameSetElementImpl::parseHTMLAttribute):
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::parseHTMLAttribute):
        * khtml/html/html_formimpl.cpp:
        (DOM::HTMLFormElementImpl::parseHTMLAttribute):
        (DOM::HTMLButtonElementImpl::parseHTMLAttribute):
        (DOM::HTMLInputElementImpl::parseHTMLAttribute):
        (DOM::HTMLLabelElementImpl::parseHTMLAttribute):
        (DOM::HTMLSelectElementImpl::parseHTMLAttribute):
        (DOM::HTMLTextAreaElementImpl::parseHTMLAttribute):
        * khtml/html/html_imageimpl.cpp:
        (HTMLImageElementImpl::parseHTMLAttribute):
        * khtml/html/html_objectimpl.cpp:
        (HTMLObjectElementImpl::parseHTMLAttribute):
        * khtml/khtml_part.cpp:
        (KHTMLPart::createHTMLEventListener):
        * khtml/khtml_part.h:
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::createHTMLEventListener):
        * khtml/xml/dom_docimpl.h:

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

16 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_events.cpp
WebCore/khtml/ecma/kjs_events.h
WebCore/khtml/ecma/kjs_proxy.cpp
WebCore/khtml/ecma/kjs_proxy.h
WebCore/khtml/ecma/kjs_window.cpp
WebCore/khtml/ecma/kjs_window.h
WebCore/khtml/html/html_baseimpl.cpp
WebCore/khtml/html/html_elementimpl.cpp
WebCore/khtml/html/html_formimpl.cpp
WebCore/khtml/html/html_imageimpl.cpp
WebCore/khtml/html/html_objectimpl.cpp
WebCore/khtml/khtml_part.cpp
WebCore/khtml/khtml_part.h
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_docimpl.h

index 6354c1793bbcffc41488fb9f7a26dfa31e993197..e2cd7ef6dbe7c46285b181749288fac8fe527cad 100644 (file)
@@ -1,3 +1,63 @@
+2005-03-01  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Vicki.
+
+       <rdar://problem/4003774> REGRESSION(125-181): JavaScript problems @ Yankee/Dixie quiz
+        
+       Reworked how scopes are set up for event handlers to match other
+       browser. This includes the following changes:
+
+       - Special scope entries are set up at the time the event handler
+       is created, not at the time it fires.
+
+       - Special scope is only set up for event handlers set in the html
+       source through an html attribute, not for handlers set using
+       addEventHandler or setting JS properties like onclick through
+       JavaScript.
+
+       - Special scope is based on the DOM node on which the handler is
+       an attribute, not the event target.
+
+       This fixes the regression while allowing the fix to
+       <rdar://problem/3798453> (DIG: getting variable with same name as
+       DOM element attribute gets attribute value instead) to keep
+       working correctly.
+       
+       * khtml/ecma/kjs_events.cpp:
+        (JSEventListener::handleEvent):
+        (JSLazyEventListener::JSLazyEventListener):
+        (JSLazyEventListener::parseCode):
+        * khtml/ecma/kjs_events.h:
+        * khtml/ecma/kjs_proxy.cpp:
+        (KJSProxyImpl::createHTMLEventHandler):
+        * khtml/ecma/kjs_proxy.h:
+        * khtml/ecma/kjs_window.cpp:
+        (Window::getJSLazyEventListener):
+        * khtml/ecma/kjs_window.h:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseHTMLAttribute):
+        (HTMLFrameElementImpl::parseHTMLAttribute):
+        (HTMLFrameSetElementImpl::parseHTMLAttribute):
+        * khtml/html/html_elementimpl.cpp:
+        (HTMLElementImpl::parseHTMLAttribute):
+        * khtml/html/html_formimpl.cpp:
+        (DOM::HTMLFormElementImpl::parseHTMLAttribute):
+        (DOM::HTMLButtonElementImpl::parseHTMLAttribute):
+        (DOM::HTMLInputElementImpl::parseHTMLAttribute):
+        (DOM::HTMLLabelElementImpl::parseHTMLAttribute):
+        (DOM::HTMLSelectElementImpl::parseHTMLAttribute):
+        (DOM::HTMLTextAreaElementImpl::parseHTMLAttribute):
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::parseHTMLAttribute):
+        * khtml/html/html_objectimpl.cpp:
+        (HTMLObjectElementImpl::parseHTMLAttribute):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::createHTMLEventListener):
+        * khtml/khtml_part.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::createHTMLEventListener):
+        * khtml/xml/dom_docimpl.h:
+
 2005-03-01  David Harrison  <harrison@apple.com>
 
         Reviewed by Chris.
index 6b223379f2be6ddb051c7a9f08dcde92f61213a2..9769f042d657b45f38e3bcaec4705a8742c9e894 100644 (file)
@@ -36,6 +36,7 @@ using namespace KJS;
 
 using DOM::KeyboardEvent;
 using DOM::EventImpl;
+using DOM::NodeImpl;
 
 // -------------------------------------------------------------------------
 
@@ -78,9 +79,12 @@ void JSEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
     List args;
     args.append(getDOMEvent(exec,evt));
 
-    // Add the event's target element to the scope
-    // (and the document, and the form - see KJS::HTMLElement::eventHandlerScope)
-    ScopeChain oldScope = listener.scope();
+    Window *window = static_cast<Window*>(win.imp());
+    // Set the event we're handling in the Window object
+    window->setCurrentEvent( &evt );
+    // ... and in the interpreter
+    interpreter->setCurrentEvent( &evt );
+
     Object thisObj;
     if (isWindowEvent) {
         thisObj = win;
@@ -88,28 +92,12 @@ void JSEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
         KJS::Interpreter::lock();
         thisObj = Object::dynamicCast(getDOMNode(exec,evt.currentTarget()));
         KJS::Interpreter::unlock();
-        if ( !thisObj.isNull() ) {
-            ScopeChain scope;
-            KJS::Interpreter::lock();
-            static_cast<DOMNode*>(thisObj.imp())->pushEventHandlerScope(exec, scope);
-            KJS::Interpreter::unlock();
-            scope.push(oldScope);
-            listener.setScope( scope );
-        }
     }
 
-    Window *window = static_cast<Window*>(win.imp());
-    // Set the event we're handling in the Window object
-    window->setCurrentEvent( &evt );
-    // ... and in the interpreter
-    interpreter->setCurrentEvent( &evt );
-
     KJS::Interpreter::lock();
     Value retval = listener.call(exec, thisObj, args);
     KJS::Interpreter::unlock();
 
-    listener.setScope( oldScope );
-
     window->setCurrentEvent( 0 );
     interpreter->setCurrentEvent( 0 );
 #if APPLE_CHANGES
@@ -155,12 +143,20 @@ Object JSEventListener::listenerObj() const
   return listener; 
 }
 
-JSLazyEventListener::JSLazyEventListener(QString _code, const Object &_win, bool _html, int lineno)
-  : JSEventListener(Object(), _win, _html),
+JSLazyEventListener::JSLazyEventListener(QString _code, const Object &_win, NodeImpl *_originalNode, int lineno)
+  : JSEventListener(Object(), _win, true),
     code(_code),
     parsed(false)
 {
         lineNumber = lineno;
+
+        // We don't retain the original node, because we assume it
+        // will stay alive as long as this handler object is around
+        // and we need to avoid a reference cycle. If JS transfers
+        // this handler to another node, parseCode will be called and
+        // then originalNode is no longer needed.
+
+        originalNode = _originalNode;
 }
 
 void JSLazyEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
@@ -202,12 +198,28 @@ void JSLazyEventListener::parseCode() const
       listener = constr.construct(exec, args, sourceURL, lineNumber); // ### is globalExec ok ?
 
       KJS::Interpreter::unlock();
-      
-      if ( exec->hadException() ) {
+
+      if (exec->hadException()) {
        exec->clearException();
 
        // failed to parse, so let's just make this listener a no-op
        listener = Object();
+      } else {
+        // Add the event's home element to the scope
+        // (and the document, and the form - see KJS::HTMLElement::eventHandlerScope)
+        ScopeChain scope = listener.scope();
+        
+        KJS::Interpreter::lock();
+        Object thisObj = Object::dynamicCast(getDOMNode(exec, originalNode));
+        KJS::Interpreter::unlock();
+        
+        if (!thisObj.isNull()) {
+          KJS::Interpreter::lock();
+          static_cast<DOMNode*>(thisObj.imp())->pushEventHandlerScope(exec, scope);
+          KJS::Interpreter::unlock();
+          
+          listener.setScope(scope);
+        }
       }
     }
 
index bfd7e4f690bee25882c3dae4cc67cbc39acfb926..e3f65f1334f5f019c2bb5171bce8539e2be438c9 100644 (file)
@@ -50,7 +50,7 @@ namespace KJS {
 
   class JSLazyEventListener : public JSEventListener {
   public:
-    JSLazyEventListener(QString _code, const Object &_win, bool _html = false, int lineno = 0);
+    JSLazyEventListener(QString _code, const Object &_win, DOM::NodeImpl *node, int lineno = 0);
     virtual void handleEvent(DOM::Event &evt, bool isWindowEvent);
     Object listenerObj() const;
     
@@ -60,6 +60,7 @@ namespace KJS {
     mutable QString code;
     mutable bool parsed;
     int lineNumber;
+    DOM::NodeImpl *originalNode;
   };
 
 
index d1ea9832d2209384250cec65f20bc31a87b84489..b315e021461dd2ea6e03d767d5dda4688a9fb5c9 100644 (file)
@@ -40,7 +40,7 @@ public:
   virtual ~KJSProxyImpl();
   virtual QVariant evaluate(QString filename, int baseLine, const QString&str, const DOM::Node &n);
   virtual void clear();
-  virtual DOM::EventListener *createHTMLEventHandler(QString sourceUrl, QString code);
+  virtual DOM::EventListener *createHTMLEventHandler(QString sourceUrl, QString code, DOM::NodeImpl *node);
   virtual void finishedWithEvent(const DOM::Event &event);
   virtual KJS::ScriptInterpreter *interpreter();
 
@@ -162,7 +162,7 @@ void KJSProxyImpl::clear() {
   }
 }
 
-DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QString code)
+DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QString code, DOM::NodeImpl *node)
 {
 #ifdef KJS_DEBUGGER
   if (KJSDebugWin::instance())
@@ -172,7 +172,7 @@ DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QStr
 #endif
 
   initScript();
-  return KJS::Window::retrieveWindow(m_part)->getJSLazyEventListener(code,true,m_handlerLineno);
+  return KJS::Window::retrieveWindow(m_part)->getJSLazyEventListener(code,node,m_handlerLineno);
 }
 
 void KJSProxyImpl::finishedWithEvent(const DOM::Event &event)
index f8b813b0a3aeeb8461a5181d6cea01e685f4107b..e6da7ebb0ad8579aad03bb775c907e3f060209ba 100644 (file)
@@ -32,6 +32,7 @@ namespace DOM {
   class Node;
   class EventListener;
   class Event;
+  class NodeImpl;
 };
 
 namespace KJS {
@@ -50,7 +51,7 @@ public:
   virtual ~KJSProxy() { }
   virtual QVariant evaluate(QString filename, int baseLine, const QString &, const DOM::Node &n) = 0;
   virtual void clear() = 0;
-  virtual DOM::EventListener *createHTMLEventHandler(QString sourceUrl, QString code) = 0;
+  virtual DOM::EventListener *createHTMLEventHandler(QString sourceUrl, QString code, DOM::NodeImpl *node) = 0;
   virtual void finishedWithEvent(const DOM::Event &event) = 0;
   virtual KJS::Interpreter *interpreter() = 0;
 
index 1edb603e2b1b64d04530be0751d0c07aa074b168..9f84643b7ca1aab416e0f384554bd2540c134333 100644 (file)
@@ -1276,9 +1276,9 @@ JSEventListener *Window::getJSEventListener(const Value& val, bool html)
   return new JSEventListener(Object(listenerObject), Object(this), html);
 }
 
-JSLazyEventListener *Window::getJSLazyEventListener(const QString& code, bool html, int lineNumber)
+JSLazyEventListener *Window::getJSLazyEventListener(const QString& code, DOM::NodeImpl *node, int lineNumber)
 {
-  return new JSLazyEventListener(code, Object(this), html, lineNumber);
+  return new JSLazyEventListener(code, Object(this), node, lineNumber);
 }
 
 void Window::clear( ExecState *exec )
index e4fcdd37b9865d18600b4102ab9da7ebfb9a4172..bdb6dbbc142dd21c74d49c0446af956b334badd0 100644 (file)
@@ -115,7 +115,7 @@ namespace KJS {
     BarInfo *statusbar(ExecState *exec) const;
     BarInfo *toolbar(ExecState *exec) const;
     JSEventListener *getJSEventListener(const Value &val, bool html = false);
-    JSLazyEventListener *getJSLazyEventListener(const QString &code, bool html = false, int lineno = 0);
+    JSLazyEventListener *getJSLazyEventListener(const QString &code, DOM::NodeImpl *node, int lineno = 0);
     void clear( ExecState *exec );
     virtual UString toString(ExecState *exec) const;
 
index f59c2712be86dfc01dec9f75402c2a085e4ac1ad..da633c9795499f6f49103116c9b11a62dc767dc9 100644 (file)
@@ -168,27 +168,27 @@ void HTMLBodyElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
     }
     case ATTR_ONLOAD:
         getDocument()->setHTMLWindowEventListener(EventImpl::LOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONUNLOAD:
         getDocument()->setHTMLWindowEventListener(EventImpl::UNLOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         getDocument()->setHTMLWindowEventListener(EventImpl::BLUR_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONFOCUS:
         getDocument()->setHTMLWindowEventListener(EventImpl::FOCUS_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONRESIZE:
         getDocument()->setHTMLWindowEventListener(EventImpl::RESIZE_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONSCROLL:
         getDocument()->setHTMLWindowEventListener(EventImpl::SCROLL_EVENT,
-                                                  getDocument()->createHTMLEventListener(attr->value().string()));
+                                                  getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_NOSAVE:
        break;
@@ -389,11 +389,11 @@ void HTMLFrameElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONLOAD:
         setHTMLEventListener(EventImpl::LOAD_EVENT,
-                                getDocument()->createHTMLEventListener(attr->value().string()));
+                                getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONUNLOAD:
         setHTMLEventListener(EventImpl::UNLOAD_EVENT,
-                                getDocument()->createHTMLEventListener(attr->value().string()));
+                                getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLElementImpl::parseHTMLAttribute(attr);
@@ -590,11 +590,11 @@ void HTMLFrameSetElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONLOAD:
         setHTMLEventListener(EventImpl::LOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONUNLOAD:
         setHTMLEventListener(EventImpl::UNLOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLElementImpl::parseHTMLAttribute(attr);
index 95c22ac683b64d4b20c4fefbfaea278345e340cf..62c50a05d5f5bb3f2adc43a1206e506291d0c226 100644 (file)
@@ -434,111 +434,111 @@ void HTMLElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 // standard events
     case ATTR_ONCLICK:
        setHTMLEventListener(EventImpl::KHTML_CLICK_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCONTEXTMENU:
        setHTMLEventListener(EventImpl::CONTEXTMENU_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDBLCLICK:
        setHTMLEventListener(EventImpl::KHTML_DBLCLICK_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONMOUSEDOWN:
         setHTMLEventListener(EventImpl::MOUSEDOWN_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONMOUSEMOVE:
         setHTMLEventListener(EventImpl::MOUSEMOVE_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONMOUSEOUT:
         setHTMLEventListener(EventImpl::MOUSEOUT_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONMOUSEOVER:
         setHTMLEventListener(EventImpl::MOUSEOVER_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONMOUSEUP:
         setHTMLEventListener(EventImpl::MOUSEUP_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::DOMFOCUSIN_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONKEYDOWN:
         setHTMLEventListener(EventImpl::KEYDOWN_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
        break;
     case ATTR_ONKEYPRESS:
         setHTMLEventListener(EventImpl::KEYPRESS_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
        break;
     case ATTR_ONKEYUP:
         setHTMLEventListener(EventImpl::KEYUP_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONSCROLL:
         setHTMLEventListener(EventImpl::SCROLL_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBEFORECUT:
         setHTMLEventListener(EventImpl::BEFORECUT_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCUT:
         setHTMLEventListener(EventImpl::CUT_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBEFORECOPY:
         setHTMLEventListener(EventImpl::BEFORECOPY_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCOPY:
         setHTMLEventListener(EventImpl::COPY_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBEFOREPASTE:
         setHTMLEventListener(EventImpl::BEFOREPASTE_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONPASTE:
         setHTMLEventListener(EventImpl::PASTE_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;        
     case ATTR_ONDRAGENTER:
         setHTMLEventListener(EventImpl::DRAGENTER_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDRAGOVER:
         setHTMLEventListener(EventImpl::DRAGOVER_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDRAGLEAVE:
         setHTMLEventListener(EventImpl::DRAGLEAVE_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDROP:
         setHTMLEventListener(EventImpl::DROP_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDRAGSTART:
         setHTMLEventListener(EventImpl::DRAGSTART_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDRAG:
         setHTMLEventListener(EventImpl::DRAG_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONDRAGEND:
         setHTMLEventListener(EventImpl::DRAGEND_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONSELECTSTART:
         setHTMLEventListener(EventImpl::SELECTSTART_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
         // other misc attributes
     default:
index 990947194c321d75a7a7c7f0f49cb0e88e48865c..b8a0ee7f5cb3c6749b8d30132340405188e02874 100644 (file)
@@ -671,11 +671,11 @@ void HTMLFormElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONSUBMIT:
         setHTMLEventListener(EventImpl::SUBMIT_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONRESET:
         setHTMLEventListener(EventImpl::RESET_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_NAME:
        {
@@ -1129,11 +1129,11 @@ void HTMLButtonElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         setHTMLEventListener(EventImpl::BLUR_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
@@ -1582,30 +1582,30 @@ void HTMLInputElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         setHTMLEventListener(EventImpl::BLUR_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONSELECT:
         setHTMLEventListener(EventImpl::SELECT_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCHANGE:
         setHTMLEventListener(EventImpl::CHANGE_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONINPUT:
         setHTMLEventListener(EventImpl::INPUT_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
 #if APPLE_CHANGES
     // Search field and slider attributes all just cause updateFromElement to be called through style
     // recalcing.
     case ATTR_ONSEARCH:
         setHTMLEventListener(EventImpl::SEARCH_EVENT,
-                             getDocument()->createHTMLEventListener(attr->value().string()));
+                             getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_RESULTS:
         m_maxResults = !attr->isNull() ? attr->value().toInt() : -1;
@@ -2139,11 +2139,11 @@ void HTMLLabelElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
     {
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         setHTMLEventListener(EventImpl::BLUR_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLElementImpl::parseHTMLAttribute(attr);
@@ -2469,15 +2469,15 @@ void HTMLSelectElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         setHTMLEventListener(EventImpl::BLUR_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCHANGE:
         setHTMLEventListener(EventImpl::CHANGE_EVENT,
-            getDocument()->createHTMLEventListener(attr->value().string()));
+            getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
@@ -3028,19 +3028,19 @@ void HTMLTextAreaElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONBLUR:
         setHTMLEventListener(EventImpl::BLUR_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONSELECT:
         setHTMLEventListener(EventImpl::SELECT_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONCHANGE:
         setHTMLEventListener(EventImpl::CHANGE_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
         HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
index b4a4ae5d7eeb241e4f1f86bc9a3753f662f41485..f6f6e51aae4588cc64944fc89bb7426877f0a474 100644 (file)
@@ -226,15 +226,15 @@ void HTMLImageElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
         break;
     case ATTR_ONABORT: // ### add support for this
         setHTMLEventListener(EventImpl::ABORT_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONERROR:
         setHTMLEventListener(EventImpl::ERROR_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONLOAD:
         setHTMLEventListener(EventImpl::LOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_NOSAVE:
        break;
index f115348578b238537330528f072b1e918c1396a8..d0638fb8e6a8df29c297ef25a40ed486ca7554d3 100644 (file)
@@ -484,11 +484,11 @@ void HTMLObjectElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
       break;
     case ATTR_ONLOAD: // ### support load/unload on object elements
         setHTMLEventListener(EventImpl::LOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     case ATTR_ONUNLOAD:
         setHTMLEventListener(EventImpl::UNLOAD_EVENT,
-           getDocument()->createHTMLEventListener(attr->value().string()));
+           getDocument()->createHTMLEventListener(attr->value().string(), this));
         break;
     default:
       HTMLElementImpl::parseHTMLAttribute( attr );
index 4df8a3f61f92d4bb07c3bcd021b9614f97dd6e7d..9c601e4bf7a5a0543a5bbf9640b105c0ed7bfc44 100644 (file)
@@ -5250,14 +5250,14 @@ DOM::Node KHTMLPart::activeNode() const
     return DOM::Node(d->m_doc?d->m_doc->focusNode():0);
 }
 
-DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code )
+DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code, NodeImpl *node )
 {
   KJSProxy *proxy = jScript();
 
   if (!proxy)
     return 0;
 
-  return proxy->createHTMLEventHandler( m_url.url(), code );
+  return proxy->createHTMLEventHandler( m_url.url(), code, node );
 }
 
 KHTMLPart *KHTMLPart::opener()
index 8b615fcb299af94181684313e40f2dfa35f28269..f7dbadbd44564779592c1f3936967d291fcc0738 100644 (file)
@@ -1287,7 +1287,7 @@ private:
 
   bool requestObject( khtml::ChildFrame *child, const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
 
-  DOM::EventListener *createHTMLEventListener( QString code );
+  DOM::EventListener *createHTMLEventListener( QString code, DOM::NodeImpl *node );
 
 public:
   DOM::DocumentImpl *xmlDocImpl() const;
index e3c5aeb1139ea17028b0150c32b477ade4e40395..09beac00a98ad7f10f30fca89ac9603696380581 100644 (file)
@@ -2726,10 +2726,10 @@ bool DocumentImpl::hasWindowEventListener(int id)
     return false;
 }
 
-EventListener *DocumentImpl::createHTMLEventListener(QString code)
+EventListener *DocumentImpl::createHTMLEventListener(QString code, NodeImpl *node)
 {
     if (part()) {
-       return part()->createHTMLEventListener(code);
+       return part()->createHTMLEventListener(code, node);
     } else {
        return NULL;
     }
index c5ab23c4a5a677be8d0cfc876e9f80f91bfe938a..67173c71a99d36c08a8423466068af8ab9ff1094 100644 (file)
@@ -464,7 +464,7 @@ public:
     void removeWindowEventListener(int id, EventListener *listener, bool useCapture);
     bool hasWindowEventListener(int id);
 
-    EventListener *createHTMLEventListener(QString code);
+    EventListener *createHTMLEventListener(QString code, NodeImpl *node);
     
     /**
      * Searches through the document, starting from fromNode, for the next selectable element that comes after fromNode.