Reviewed and landed by Darin.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Aug 2005 08:28:01 +0000 (08:28 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 14 Aug 2005 08:28:01 +0000 (08:28 +0000)
        Test cases added:
        * layout-tests/dom/html/level2/events/dispatchEvent08-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent10-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt:
These pass now.

        * layout-tests/dom/html/level2/events/dispatchEvent11-expected.txt:
        * layout-tests/dom/html/level2/events/dispatchEvent13-expected.txt:
These fail someplace else now.

        * khtml/ecma/kjs_events.cpp:
        (KJS::JSAbstractEventListener::handleEvent):
Check if the listener has a "handleEvent" function property and
call that.

        * khtml/xml/dom_nodeimpl.cpp:
        (DOM::NodeImpl::dispatchGenericEvent):
A capturing event listener should not be triggered if an event is
dispatched directly to the node to which the listener has been added.

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

LayoutTests/dom/html/level2/events/dispatchEvent08-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent10-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent11-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent12-expected.txt
LayoutTests/dom/html/level2/events/dispatchEvent13-expected.txt
WebCore/ChangeLog-2005-08-23
WebCore/khtml/ecma/kjs_events.cpp
WebCore/khtml/xml/dom_nodeimpl.cpp

index f0d52e414ea01ae9688ad9c704b2328089c332b2..23e9af1a0570d082c2cdc15b4d23694e00f13b1e 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent08     
-Status:        failure
-Detail:        atCount: assertEquals failed, actual 0, expected 1.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent08
+Status:        Success
index 0903f42edacc7ad6da37821391ff32ed0ab3bf4f..46156801fb8e758c5e4338ff8518913a9b3b7207 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent10     
-Status:        failure
-Detail:        atCount: assertEquals failed, actual 0, expected 1.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent10
+Status:        Success
index bfc7703cd83df93c36f21b0e229072c035b457f6..b32d33208546898a93ae366686cfb1d006676e77 100644 (file)
@@ -1,2 +1,3 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent11
-Status:        Success
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent11     
+Status:        failure
+Detail:        eventCount: assertEquals failed, actual 1, expected 0.
index ec930d61f0c365021fe3d7d200ab02781ffddbc7..a241a227534963af1341dc662a647ce333210334 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent12     
-Status:        failure
-Detail:        eventCount: assertEquals failed, actual 0, expected 1.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent12
+Status:        Success
index 0bc9af637d49db9b06479765b82c6bcd36a801be..1bb095b864244034d93c6b317415e7adeb499eff 100644 (file)
@@ -1,3 +1,3 @@
 Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent13     
 Status:        failure
-Detail:        eventCount: assertEquals failed, actual 0, expected 1.
+Detail:        eventCount: assertEquals failed, actual 2, expected 1.
index 2e976f19656d5d0f40e48991f1d0a745e29e855a..ef755431e9ba197a88e0b5b3fdd64bfe75868245 100644 (file)
@@ -1,3 +1,27 @@
+2005-08-14  Anders Carlsson  <andersca@mac.com>
+
+        Reviewed and landed by Darin.
+
+        Test cases added:      
+        * layout-tests/dom/html/level2/events/dispatchEvent08-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent10-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt:
+       These pass now.
+       
+        * layout-tests/dom/html/level2/events/dispatchEvent11-expected.txt:
+        * layout-tests/dom/html/level2/events/dispatchEvent13-expected.txt:
+       These fail someplace else now.
+       
+        * khtml/ecma/kjs_events.cpp:
+        (KJS::JSAbstractEventListener::handleEvent):
+       Check if the listener has a "handleEvent" function property and
+       call that.
+       
+        * khtml/xml/dom_nodeimpl.cpp:
+        (DOM::NodeImpl::dispatchGenericEvent):
+       A capturing event listener should not be triggered if an event is
+       dispatched directly to the node to which the listener has been added.
+
 2005-08-14  Anders Carlsson  <andersca@mac.com>
 
         Reviewed and landed by Darin.
index 085a37816289772bfb90ba185a97a148d2983bab..e203840ec41d50780d25754e667bf8d7592a8120 100644 (file)
@@ -81,12 +81,24 @@ void JSAbstractEventListener::handleEvent(EventListenerEvent ele, bool isWindowE
   if (part)
       proxy = KJSProxy::proxy( part );
 
-  if (proxy && listener->implementsCall()) {
+  ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(proxy->interpreter());
+  ExecState *exec = interpreter->globalExec();
+  
+  bool hasHandleEvent = false;
+  ValueImp *handleEventFuncValue = 0;
+  ObjectImp *handleEventFunc = 0;
+  
+  handleEventFuncValue = listener->get(exec, "handleEvent");
+  if (handleEventFuncValue->isObject()) {      
+      handleEventFunc = static_cast<ObjectImp *>(handleEventFuncValue);
+            
+      if (handleEventFunc->implementsCall())
+          hasHandleEvent = true;
+  }
+  
+  if (proxy && (listener->implementsCall() || hasHandleEvent)) {
     ref();
 
-    ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(proxy->interpreter());
-    ExecState *exec = interpreter->globalExec();
-
     List args;
     args.append(getDOMEvent(exec,evt));
 
@@ -106,7 +118,11 @@ void JSAbstractEventListener::handleEvent(EventListenerEvent ele, bool isWindowE
     }
 
     Interpreter::lock();
-    ValueImp *retval = listener->call(exec, thisObj, args);
+    ValueImp *retval;
+    if (hasHandleEvent)
+        retval = handleEventFunc->call(exec, listener, args);
+    else
+        retval = listener->call(exec, thisObj, args);
     Interpreter::unlock();
 
     window->setCurrentEvent( 0 );
index 64b1e49b7977cefb93f0acca7a27b0dda7c52807..c8fa003fb33a3c36930bf37d054ccd4891cedb03 100644 (file)
@@ -560,10 +560,6 @@ bool NodeImpl::dispatchGenericEvent( EventImpl *evt, int &/*exceptioncode */)
         evt->setEventPhase(Event::AT_TARGET);
         evt->setCurrentTarget(it.current());
 
-       // Capturing first. -dwh
-        it.current()->handleLocalEvents(evt,true);
-
-       // Bubbling second. -dwh
        if (!evt->propagationStopped())
             it.current()->handleLocalEvents(evt,false);
     }