[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:42:09 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9cdb93aa8c75f3d03e0585e282bc7b1f579fb088
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed May 14 18:03:25 2003 +0000

            Reviewed by John.
    
    	- fixed 3240129 - REGRESSION: www.ezprints.com navigation buttons don't show up (window.addEventListener)
    
    	The problem here was that event handlers set using
    	window.addEventListener were set as regular event handlers on the
    	document object instead of as window event handlers - and the load
    	event does not fire properly that way.
    
    	The fix was to add support for both HTML and non-HTML window event
    	handlers. The old window event methods supported only "HTML"
    	handlers, but were not named as such.
    
            * khtml/ecma/kjs_window.cpp:
            (Window::setListener): Use setHTMLWindowEventListener.
            (Window::getListener): Use getHTMLWindowEventListener.
            (WindowFunc::tryCall): use addWindowEventListener and removeWindowEventListener
    	on the DocumentImpl instead of addEventListener and removeEventListener on the
    	Document.
            * khtml/html/html_baseimpl.cpp:
            (HTMLBodyElementImpl::parseAttribute): Use setHTMLWindowEventListener
    	instead of the old setWindowEventListener.
            * khtml/xml/dom_docimpl.cpp:
    	(DocumentImpl::defaultEventHandler): Don't stop after the first
    	window event handler - keep going, since there might now be more
    	than one for the same event.
            (DocumentImpl::setHTMLWindowEventListener): Renamed from setWindowEventListener.
            (DocumentImpl::getHTMLWindowEventListener): Renamed from getWindowEventListener.
            (DocumentImpl::removeHTMLWindowEventListener): Renamed from removeWindowEventListener.
            (DocumentImpl::addWindowEventListener): Implemented - support adding non-HTML window
    	event listeners, which, unlike html listeners, are nto exclusive - there may be more
    	than one.
            (DocumentImpl::removeWindowEventListener): Implemented.
            (DocumentImpl::hasWindowEventListener): Check if a window has any handler at all
    	for a prticular event.
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_nodeimpl.cpp:
            (NodeImpl::addEventListener): Add ref/deref pair to protect against last ref of listener
    	going away on remove. Correct comment about the removal.
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::canCachePage): Check for an UNLOAD event handler
    	using hasWindowEventListener instead of getHTMLWindowEventListener, to
    	check for even addListener-style unload handlers.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 32e1a13..98a3467 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,49 @@
+2003-05-13  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by John.
+
+	- fixed 3240129 - REGRESSION: www.ezprints.com navigation buttons don't show up (window.addEventListener)
+
+	The problem here was that event handlers set using
+	window.addEventListener were set as regular event handlers on the
+	document object instead of as window event handlers - and the load
+	event does not fire properly that way. 
+
+	The fix was to add support for both HTML and non-HTML window event
+	handlers. The old window event methods supported only "HTML"
+	handlers, but were not named as such.
+
+        * khtml/ecma/kjs_window.cpp:
+        (Window::setListener): Use setHTMLWindowEventListener.
+        (Window::getListener): Use getHTMLWindowEventListener.
+        (WindowFunc::tryCall): use addWindowEventListener and removeWindowEventListener
+	on the DocumentImpl instead of addEventListener and removeEventListener on the
+	Document.
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseAttribute): Use setHTMLWindowEventListener
+	instead of the old setWindowEventListener.
+        * khtml/xml/dom_docimpl.cpp:
+	(DocumentImpl::defaultEventHandler): Don't stop after the first
+	window event handler - keep going, since there might now be more
+	than one for the same event.
+        (DocumentImpl::setHTMLWindowEventListener): Renamed from setWindowEventListener.
+        (DocumentImpl::getHTMLWindowEventListener): Renamed from getWindowEventListener.
+        (DocumentImpl::removeHTMLWindowEventListener): Renamed from removeWindowEventListener.
+        (DocumentImpl::addWindowEventListener): Implemented - support adding non-HTML window
+	event listeners, which, unlike html listeners, are nto exclusive - there may be more
+	than one.
+        (DocumentImpl::removeWindowEventListener): Implemented.
+        (DocumentImpl::hasWindowEventListener): Check if a window has any handler at all
+	for a prticular event.
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::addEventListener): Add ref/deref pair to protect against last ref of listener
+	going away on remove. Correct comment about the removal.
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::canCachePage): Check for an UNLOAD event handler
+	using hasWindowEventListener instead of getHTMLWindowEventListener, to
+	check for even addListener-style unload handlers.
+
 2003-05-13  David Hyatt  <hyatt at apple.com>
 
 	Fix for 3222607.  divs that specify a fixed width should have
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 32e1a13..98a3467 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,49 @@
+2003-05-13  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by John.
+
+	- fixed 3240129 - REGRESSION: www.ezprints.com navigation buttons don't show up (window.addEventListener)
+
+	The problem here was that event handlers set using
+	window.addEventListener were set as regular event handlers on the
+	document object instead of as window event handlers - and the load
+	event does not fire properly that way. 
+
+	The fix was to add support for both HTML and non-HTML window event
+	handlers. The old window event methods supported only "HTML"
+	handlers, but were not named as such.
+
+        * khtml/ecma/kjs_window.cpp:
+        (Window::setListener): Use setHTMLWindowEventListener.
+        (Window::getListener): Use getHTMLWindowEventListener.
+        (WindowFunc::tryCall): use addWindowEventListener and removeWindowEventListener
+	on the DocumentImpl instead of addEventListener and removeEventListener on the
+	Document.
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseAttribute): Use setHTMLWindowEventListener
+	instead of the old setWindowEventListener.
+        * khtml/xml/dom_docimpl.cpp:
+	(DocumentImpl::defaultEventHandler): Don't stop after the first
+	window event handler - keep going, since there might now be more
+	than one for the same event.
+        (DocumentImpl::setHTMLWindowEventListener): Renamed from setWindowEventListener.
+        (DocumentImpl::getHTMLWindowEventListener): Renamed from getWindowEventListener.
+        (DocumentImpl::removeHTMLWindowEventListener): Renamed from removeWindowEventListener.
+        (DocumentImpl::addWindowEventListener): Implemented - support adding non-HTML window
+	event listeners, which, unlike html listeners, are nto exclusive - there may be more
+	than one.
+        (DocumentImpl::removeWindowEventListener): Implemented.
+        (DocumentImpl::hasWindowEventListener): Check if a window has any handler at all
+	for a prticular event.
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_nodeimpl.cpp:
+        (NodeImpl::addEventListener): Add ref/deref pair to protect against last ref of listener
+	going away on remove. Correct comment about the removal.
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::canCachePage): Check for an UNLOAD event handler
+	using hasWindowEventListener instead of getHTMLWindowEventListener, to
+	check for even addListener-style unload handlers.
+
 2003-05-13  David Hyatt  <hyatt at apple.com>
 
 	Fix for 3222607.  divs that specify a fixed width should have
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index 56cb7cd..bcb6547 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -981,7 +981,7 @@ void Window::setListener(ExecState *exec, int eventId, Value func)
   if (!doc)
     return;
 
-  doc->setWindowEventListener(eventId,getJSEventListener(func,true));
+  doc->setHTMLWindowEventListener(eventId,getJSEventListener(func,true));
 }
 
 Value Window::getListener(ExecState *exec, int eventId) const
@@ -992,7 +992,7 @@ Value Window::getListener(ExecState *exec, int eventId) const
   if (!doc)
     return Undefined();
 
-  DOM::EventListener *listener = doc->getWindowEventListener(eventId);
+  DOM::EventListener *listener = doc->getHTMLWindowEventListener(eventId);
   if (listener)
     return static_cast<JSEventListener*>(listener)->listenerObj();
   else
@@ -1481,8 +1481,8 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
 	
         JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
         if (listener) {
-            DOM::Document doc = part->document();
-            doc.addEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
+	    DOM::DocumentImpl* docimpl = static_cast<DOM::DocumentImpl *>(part->document().handle());
+            docimpl->addWindowEventListener(DOM::EventImpl::typeToId(args[0].toString(exec).string()),listener,args[2].toBoolean(exec));
         }
         return Undefined();
     }
@@ -1491,8 +1491,8 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
 	    return Undefined();
         JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
         if (listener) {
-            DOM::Document doc = part->document();
-            doc.removeEventListener(args[0].toString(exec).string(),listener,args[2].toBoolean(exec));
+	    DOM::DocumentImpl* docimpl = static_cast<DOM::DocumentImpl *>(part->document().handle());
+            docimpl->removeWindowEventListener(DOM::EventImpl::typeToId(args[0].toString(exec).string()),listener,args[2].toBoolean(exec));
         }
         return Undefined();
     }
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index a2376d6..8173f2a 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -130,23 +130,23 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     }
     case ATTR_ONLOAD:
-        getDocument()->setWindowEventListener(EventImpl::LOAD_EVENT,
+        getDocument()->setHTMLWindowEventListener(EventImpl::LOAD_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     case ATTR_ONUNLOAD:
-        getDocument()->setWindowEventListener(EventImpl::UNLOAD_EVENT,
+        getDocument()->setHTMLWindowEventListener(EventImpl::UNLOAD_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     case ATTR_ONBLUR:
-        getDocument()->setWindowEventListener(EventImpl::BLUR_EVENT,
+        getDocument()->setHTMLWindowEventListener(EventImpl::BLUR_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     case ATTR_ONFOCUS:
-        getDocument()->setWindowEventListener(EventImpl::FOCUS_EVENT,
+        getDocument()->setHTMLWindowEventListener(EventImpl::FOCUS_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     case ATTR_ONRESIZE:
-        getDocument()->setWindowEventListener(EventImpl::RESIZE_EVENT,
+        getDocument()->setHTMLWindowEventListener(EventImpl::RESIZE_EVENT,
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     case ATTR_NOSAVE:
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 68cfc54..856c98f 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2116,29 +2116,28 @@ void DocumentImpl::defaultEventHandler(EventImpl *evt)
     for (; it.current(); ++it) {
         if (it.current()->id == evt->id()) {
             it.current()->listener->handleEvent(ev, true);
-	    return;
 	}
     }
 }
 
-void DocumentImpl::setWindowEventListener(int id, EventListener *listener)
+void DocumentImpl::setHTMLWindowEventListener(int id, EventListener *listener)
 {
     // If we already have it we don't want removeWindowEventListener to delete it
     if (listener)
 	listener->ref();
-    removeWindowEventListener(id);
+    removeHTMLWindowEventListener(id);
     if (listener) {
-	RegisteredEventListener *rl = new RegisteredEventListener(static_cast<EventImpl::EventId>(id),listener,false);
-	m_windowEventListeners.append(rl);
+	addWindowEventListener(id, listener, false);
 	listener->deref();
     }
 }
 
-EventListener *DocumentImpl::getWindowEventListener(int id)
+EventListener *DocumentImpl::getHTMLWindowEventListener(int id)
 {
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
     for (; it.current(); ++it) {
-	if (it.current()->id == id) {
+	if (it.current()->id == id &&
+            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
 	    return it.current()->listener;
 	}
     }
@@ -2146,17 +2145,56 @@ EventListener *DocumentImpl::getWindowEventListener(int id)
     return 0;
 }
 
-void DocumentImpl::removeWindowEventListener(int id)
+void DocumentImpl::removeHTMLWindowEventListener(int id)
 {
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
     for (; it.current(); ++it) {
-	if (it.current()->id == id) {
+	if (it.current()->id == id &&
+            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
 	    m_windowEventListeners.removeRef(it.current());
 	    return;
 	}
     }
 }
 
+void DocumentImpl::addWindowEventListener(int id, EventListener *listener, const bool useCapture)
+{
+    listener->ref();
+
+    // remove existing identical listener set with identical arguments - the DOM2
+    // spec says that "duplicate instances are discarded" in this case.
+    removeWindowEventListener(id,listener,useCapture);
+
+    RegisteredEventListener *rl = new RegisteredEventListener(static_cast<EventImpl::EventId>(id), listener, useCapture);
+    m_windowEventListeners.append(rl);
+
+    listener->deref();
+}
+
+void DocumentImpl::removeWindowEventListener(int id, EventListener *listener, bool useCapture)
+{
+    RegisteredEventListener rl(static_cast<EventImpl::EventId>(id),listener,useCapture);
+
+    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
+    for (; it.current(); ++it)
+        if (*(it.current()) == rl) {
+            m_windowEventListeners.removeRef(it.current());
+            return;
+        }
+}
+
+bool DocumentImpl::hasWindowEventListener(int id)
+{
+    QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
+    for (; it.current(); ++it) {
+	if (it.current()->id == id) {
+	    return true;
+	}
+    }
+
+    return false;
+}
+
 EventListener *DocumentImpl::createHTMLEventListener(QString code)
 {
     return view()->part()->createHTMLEventListener(code);
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 40fce37..4a6b6b8 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -381,9 +381,14 @@ public:
     LocalStyleRefs* localStyleRefs() { return &m_localStyleRefs; }
 
     virtual void defaultEventHandler(EventImpl *evt);
-    virtual void setWindowEventListener(int id, EventListener *listener);
-    EventListener *getWindowEventListener(int id);
-    virtual void removeWindowEventListener(int id);
+    void setHTMLWindowEventListener(int id, EventListener *listener);
+    EventListener *getHTMLWindowEventListener(int id);
+    void removeHTMLWindowEventListener(int id);
+
+    void addWindowEventListener(int id, EventListener *listener, const bool useCapture);
+    void removeWindowEventListener(int id, EventListener *listener, bool useCapture);
+    bool hasWindowEventListener(int id);
+
     EventListener *createHTMLEventListener(QString code);
 
     /**
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 7883b01..2ec18f6 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -399,10 +399,14 @@ void NodeImpl::addEventListener(int id, EventListener *listener, const bool useC
 	m_regdListeners->setAutoDelete(true);
     }
 
-    // remove existing ones of the same type - ### is this correct (or do we ignore the new one?)
+    listener->ref();
+
+    // remove existing identical listener set with identical arguments - the DOM2
+    // spec says that "duplicate instances are discarded" in this case.
     removeEventListener(id,listener,useCapture);
 
     m_regdListeners->append(rl);
+    listener->deref();
 }
 
 void NodeImpl::removeEventListener(int id, EventListener *listener, bool useCapture)
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 4d9dead..2dfcec3 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -913,7 +913,7 @@ bool KWQKHTMLPart::canCachePage()
     if (d->m_doc &&
         (d->m_frames.count() ||
         parentPart() ||
-        d->m_doc->getWindowEventListener (EventImpl::UNLOAD_EVENT) ||
+        d->m_doc->hasWindowEventListener (EventImpl::UNLOAD_EVENT) ||
         d->m_doc->hasPasswordField())) {
         return false;
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list