[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 08:14:08 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit fbe116504cfaea20ea6041a8d661a0f0d905db60
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 20 00:46:23 2003 +0000

            Reviewed by John.
    
    	- fixed 3486998 - Implement asynchronous http loading for XMLHttpRequest
    
            * khtml/ecma/xmlhttprequest.cpp:
            (KJS::XMLHttpRequestQObject::XMLHttpRequestQObject): New QObject to use to
    	connect to signals.
            (KJS::XMLHttpRequestQObject::slotData): Call XMLHttpRequest.
            (KJS::XMLHttpRequestQObject::slotFinished): Ditto.
            (KJS::XMLHttpRequestQObject::slotRedirection): Ditto.
            (KJS::XMLHttpRequest::getValueProperty): Implemented, onrequeststatechange,
    	readyState and responseText.
            (KJS::XMLHttpRequest::putValue): Implemented onrequeststatechange.
            (KJS::XMLHttpRequest::XMLHttpRequest): Initialize new fields.
            (KJS::XMLHttpRequest::~XMLHttpRequest): Delete decoder.
            (KJS::XMLHttpRequest::changeState): Update state, and send event if needed.
            (KJS::XMLHttpRequest::open): Save the parameters.
            (KJS::XMLHttpRequest::send): Fire up a post or get job.
            (KJS::XMLHttpRequest::slotFinished): go to final state.
            (KJS::XMLHttpRequest::slotRedirection): Just stub for now.
            (KJS::XMLHttpRequest::slotData): Update state; decode & save data.
            (KJS::XMLHttpRequestProtoFunc::tryCall): Implemented open and send.
            * khtml/ecma/xmlhttprequest.h: Prototyped new stuff.
            * khtml/xml/dom2_eventsimpl.cpp:
            (EventImpl::typeToId): Added "readystatechange" event.
            (EventImpl::idToType): Ditto.
            * khtml/xml/dom2_eventsimpl.h: Ditto.
            * kwq/KWQLoader.h:
            * kwq/KWQLoader.mm:
            (KWQServeRequest): New variant that doesn't need a Request.
            * kwq/KWQSlot.mm:
            (KWQSlot::KWQSlot): Handle XMLHttpRequestQObject's slots.
            (KWQSlot::call): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d3f7929..663bd76 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,39 @@
+2003-11-19  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by John.
+
+	- fixed 3486998 - Implement asynchronous http loading for XMLHttpRequest
+	
+        * khtml/ecma/xmlhttprequest.cpp:
+        (KJS::XMLHttpRequestQObject::XMLHttpRequestQObject): New QObject to use to
+	connect to signals.
+        (KJS::XMLHttpRequestQObject::slotData): Call XMLHttpRequest.
+        (KJS::XMLHttpRequestQObject::slotFinished): Ditto.
+        (KJS::XMLHttpRequestQObject::slotRedirection): Ditto.
+        (KJS::XMLHttpRequest::getValueProperty): Implemented, onrequeststatechange,
+	readyState and responseText.
+        (KJS::XMLHttpRequest::putValue): Implemented onrequeststatechange.
+        (KJS::XMLHttpRequest::XMLHttpRequest): Initialize new fields.
+        (KJS::XMLHttpRequest::~XMLHttpRequest): Delete decoder.
+        (KJS::XMLHttpRequest::changeState): Update state, and send event if needed.
+        (KJS::XMLHttpRequest::open): Save the parameters.
+        (KJS::XMLHttpRequest::send): Fire up a post or get job.
+        (KJS::XMLHttpRequest::slotFinished): go to final state.
+        (KJS::XMLHttpRequest::slotRedirection): Just stub for now.
+        (KJS::XMLHttpRequest::slotData): Update state; decode & save data.
+        (KJS::XMLHttpRequestProtoFunc::tryCall): Implemented open and send.
+        * khtml/ecma/xmlhttprequest.h: Prototyped new stuff.
+        * khtml/xml/dom2_eventsimpl.cpp:
+        (EventImpl::typeToId): Added "readystatechange" event.
+        (EventImpl::idToType): Ditto.
+        * khtml/xml/dom2_eventsimpl.h: Ditto.
+        * kwq/KWQLoader.h:
+        * kwq/KWQLoader.mm:
+        (KWQServeRequest): New variant that doesn't need a Request.
+        * kwq/KWQSlot.mm:
+        (KWQSlot::KWQSlot): Handle XMLHttpRequestQObject's slots.
+        (KWQSlot::call): Ditto.
+
 2003-11-19  Richard Williamson   <rjw at apple.com>
 
 	More LiveConnect stuff.  With that patch we make the applet
diff --git a/WebCore/khtml/ecma/xmlhttprequest.cpp b/WebCore/khtml/ecma/xmlhttprequest.cpp
index 4e1128e..d5a53b2 100644
--- a/WebCore/khtml/ecma/xmlhttprequest.cpp
+++ b/WebCore/khtml/ecma/xmlhttprequest.cpp
@@ -18,16 +18,33 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#import "xmlhttprequest.h"
-#import "xmlhttprequest.lut.h"
+#include "xmlhttprequest.h"
+#include "xmlhttprequest.lut.h"
+#include "kjs_window.h"
+#include "kjs_events.h"
+
+#include "dom/dom_string.h"
+#include "misc/loader.h"
+#include "html/html_documentimpl.h"
+#include "xml/dom2_eventsimpl.h"
+
+#include "khtml_part.h"
+#include "khtmlview.h"
 
 #include <kdebug.h>
+#include <kio/job.h>
+#include <qobject.h>
+
+#ifdef APPLE_CHANGES
+#include "KWQLoader.h"
+#endif
 
 using namespace KJS;
+using khtml::Decoder;
 
 ////////////////////// XMLHttpRequest Object ////////////////////////
 
-/* Source for XMLHttpRequestProtoTable. Use "make hashtables" to regenerate.
+/* Source for XMLHttpRequestProtoTable.
 @begin XMLHttpRequestProtoTable 7
   abort			XMLHttpRequest::Abort			DontDelete|Function 0
   getAllResponseHeaders	XMLHttpRequest::GetAllResponseHeaders	DontDelete|Function 0
@@ -43,6 +60,33 @@ IMPLEMENT_PROTOTYPE(XMLHttpRequestProto,XMLHttpRequestProtoFunc)
 
 namespace KJS {
 
+XMLHttpRequestQObject::XMLHttpRequestQObject(XMLHttpRequest *_jsObject) 
+{
+  jsObject = _jsObject; 
+}
+
+#if APPLE_CHANGES
+void XMLHttpRequestQObject::slotData( KIO::Job* job, const char *data, int size )
+{
+  jsObject->slotData(job, data, size);
+}
+#else
+void XMLHttpRequestQObject::slotData( KIO::Job* job, const QByteArray &data )
+{
+  jsObject->slotData(job, data);
+}
+#endif
+
+void XMLHttpRequestQObject::slotFinished( KIO::Job* job )
+{
+  jsObject->slotFinished(job); 
+}
+
+void XMLHttpRequestQObject::slotRedirection( KIO::Job* job, const KURL& url)
+{ 
+  jsObject->slotRedirection( job, url ); 
+}
+
 XMLHttpRequestConstructorImp::XMLHttpRequestConstructorImp(ExecState *, const DOM::Document &d)
     : ObjectImp(), doc(d)
 {
@@ -60,7 +104,7 @@ Object XMLHttpRequestConstructorImp::construct(ExecState *exec, const List &)
 
 const ClassInfo XMLHttpRequest::info = { "XMLHttpRequest", 0, &XMLHttpRequestTable, 0 };
 
-/* Source for XMLHttpRequestTable. Use "make hashtables" to regenerate.
+/* Source for XMLHttpRequestTable.
 @begin XMLHttpRequestTable 6
   readyState		XMLHttpRequest::ReadyState		DontDelete|ReadOnly
   responseText		XMLHttpRequest::ResponseText		DontDelete|ReadOnly
@@ -80,9 +124,9 @@ Value XMLHttpRequest::getValueProperty(ExecState *, int token) const
 {
   switch (token) {
   case ReadyState:
-    return Undefined();
+    return Number(state);
   case ResponseText:
-    return Undefined();
+    return getStringOrNull(DOM::DOMString(response));
   case ResponseXML:
     return Undefined();
   case Status:
@@ -90,7 +134,11 @@ Value XMLHttpRequest::getValueProperty(ExecState *, int token) const
   case StatusText:
     return Undefined();
   case Onreadystatechange:
-    return Null();
+    if (onReadyStateChangeListener && onReadyStateChangeListener->listenerObjImp()) {
+      return onReadyStateChangeListener->listenerObj();
+    } else {
+      return Null();
+    }
   default:
     kdWarning() << "XMLHttpRequest::getValueProperty unhandled token " << token << endl;
     return Value();
@@ -106,23 +154,132 @@ void XMLHttpRequest::putValue(ExecState *exec, int token, const Value& value, in
 {
   switch(token) {
   case Onreadystatechange:
+    onReadyStateChangeListener = Window::retrieveActive(exec)->getJSEventListener(value, true);
+    if (onReadyStateChangeListener) onReadyStateChangeListener->ref();
     break;
   default:
     kdWarning() << "HTMLDocument::putValue unhandled token " << token << endl;
   }
 }
 
-void XMLHttpRequest::notifyFinished(khtml::CachedObject *)
+XMLHttpRequest::XMLHttpRequest(ExecState *exec, const DOM::Document &d)
+  : DOMObject(XMLHttpRequestProto::self(exec)),
+    qObject(new XMLHttpRequestQObject(this)),
+    doc(static_cast<DOM::DocumentImpl*>(d.handle())),
+    state(Uninitialized),
+    onReadyStateChangeListener(0),
+    async(true),
+    decoder(0)
 {
 }
 
-XMLHttpRequest::XMLHttpRequest(ExecState *exec, const DOM::Document &d)
-    : DOMObject(XMLHttpRequestProto::self(exec))
+XMLHttpRequest::~XMLHttpRequest()
 {
+  delete decoder;
 }
 
-XMLHttpRequest::~XMLHttpRequest()
+void XMLHttpRequest::changeState(XMLHttpRequestState newState)
+{
+  if (state != newState) {
+    state = newState;
+    
+    if (onReadyStateChangeListener != 0) {
+      DOM::Event ev = doc->view()->part()->document().createEvent("HTMLEvents");
+      ev.initEvent("readystatechange", true, true);
+      onReadyStateChangeListener->handleEvent(ev, true);
+    }
+  }
+}
+
+void XMLHttpRequest::open(const QString& _method, const KURL& _url, bool _async)
 {
+  method = _method;
+  url = _url;
+  async = _async;
+
+  changeState(Loading);
+}
+
+void XMLHttpRequest::send(const QString& _body)
+{
+  if (method.lower() == "post" && (url.protocol().lower() == "http" || url.protocol().lower() == "https") ) {
+      job = KIO::http_post( url, QCString(_body.utf8()), false );
+      job->addMetaData("content-type", "text/plain" );
+  }
+  else
+  {
+     job = KIO::get( url, false, false );
+  }
+
+  // FIXME: should set referrer? args.metaData().insert("referrer", d->m_pageReferrer);
+
+  qObject->connect( job, SIGNAL( result( KIO::Job* ) ),
+		    SLOT( slotFinished( KIO::Job* ) ) );
+#if APPLE_CHANGES
+  qObject->connect( job, SIGNAL( data( KIO::Job*, const char*, int ) ),
+		    SLOT( slotData( KIO::Job*, const char*, int ) ) );
+#else
+  qObject->connect( job, SIGNAL( data( KIO::Job*, const QByteArray& ) ),
+		    SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
+#endif
+  qObject->connect( job, SIGNAL(redirection(KIO::Job*, const KURL& ) ),
+		    SLOT( slotRedirection(KIO::Job*, const KURL&) ) );
+
+#ifdef APPLE_CHANGES
+  KWQServeRequest(khtml::Cache::loader(), doc->docLoader(), job);
+#else 
+  KIO::Scheduler::scheduleJob( job );
+#endif
+}
+
+void XMLHttpRequest::slotFinished(KIO::Job *)
+{
+  changeState(Completed);
+  job = 0;
+}
+
+void XMLHttpRequest::slotRedirection(KIO::Job*, const KURL& url)
+{
+}
+
+#if APPLE_CHANGES
+void XMLHttpRequest::slotData( KIO::Job* job, const char *data, int len )
+#else
+void XMLHttpRequest::slotData(KIO::Job*, const QByteArray &_data)
+#endif
+{
+  if (state < Loaded) {
+    // handle http headers here
+    changeState(Loaded);
+  }
+  
+#if !APPLE_CHANGES
+  const char *data = (const char *)_data.data();
+  int len = (int)_data.size();
+#endif
+
+  if ( decoder == NULL ) {
+    decoder = new Decoder;
+    if (!encoding.isNull())
+      decoder->setEncoding(encoding.latin1(), Decoder::EncodingFromHTTPHeader);
+    else {
+      // FIXME: Inherit the default encoding from the parent document?
+    }
+  }
+  if (len == 0)
+    return;
+
+  if (len == -1)
+    len = strlen(data);
+
+  QString decoded = decoder->decode(data, len);
+
+  if (decoded.isEmpty()) 
+    return;
+
+  response += decoded;
+
+  changeState(Interactive);
 }
 
 Value XMLHttpRequestProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
@@ -132,6 +289,9 @@ Value XMLHttpRequestProtoFunc::tryCall(ExecState *exec, Object &thisObj, const L
     exec->setException(err);
     return err;
   }
+
+  XMLHttpRequest *request = static_cast<XMLHttpRequest *>(thisObj.imp());
+
   switch (id) {
   case XMLHttpRequest::Abort:
     return Undefined();
@@ -139,10 +299,59 @@ Value XMLHttpRequestProtoFunc::tryCall(ExecState *exec, Object &thisObj, const L
     return Undefined();
   case XMLHttpRequest::GetResponseHeader:
     return Undefined();
-  case XMLHttpRequest::Open:
-    return Undefined();
+  case XMLHttpRequest::Open: 
+    {
+      if (args.size() < 2 || args.size() > 5) {
+	return Undefined();
+      }
+    
+      if (request->state != Uninitialized) {
+	return Undefined();
+      }
+
+      QString method = args[0].toString(exec).qstring();
+      KURL url = KURL(Window::retrieveActive(exec)->part()->htmlDocument().completeURL(args[1].toString(exec).qstring()).string());
+
+      bool async = true;
+      if (args.size() >= 3) {
+	async = args[2].toBoolean(exec);
+      }
+    
+      if (args.size() >= 4) {
+	url.setUser(args[3].toString(exec).qstring());
+      }
+      
+      if (args.size() >= 5) {
+	url.setPass(args[4].toString(exec).qstring());
+      }
+
+      request->open(method, url, async);
+
+      return Undefined();
+    }
   case XMLHttpRequest::Send:
-    return Undefined();
+    {
+      if (args.size() > 1) {
+	return Undefined();
+      }
+
+      if (request->state != Loading) {
+	return Undefined();
+      }
+
+      QString body;
+
+      if (args.size() >= 1) {
+	// serializing document not handled yet
+	if (!args[0].toObject(exec).inherits(&DOMDocument::info)) {
+	  body = args[0].toString(exec).qstring();
+	}
+      }
+
+      request->send(body);
+
+      return Undefined();
+    }
   case XMLHttpRequest::SetRequestHeader:
     return Undefined();
   }
diff --git a/WebCore/khtml/ecma/xmlhttprequest.h b/WebCore/khtml/ecma/xmlhttprequest.h
index c7b5094..ec570b8 100644
--- a/WebCore/khtml/ecma/xmlhttprequest.h
+++ b/WebCore/khtml/ecma/xmlhttprequest.h
@@ -23,10 +23,23 @@
 
 #include "ecma/kjs_binding.h"
 #include "ecma/kjs_dom.h"
-#include "misc/loader.h"
+#include "misc/decoder.h"
+#include "kio/jobclasses.h"
 
 namespace KJS {
 
+  class JSEventListener;
+  class XMLHttpRequestQObject;
+
+  // these exact numeric values are important because JS expects them
+  enum XMLHttpRequestState {
+    Uninitialized = 0,
+    Loading = 1,
+    Loaded = 2,
+    Interactive = 3,
+    Completed = 4
+  };
+
   class XMLHttpRequestConstructorImp : public ObjectImp {
   public:
     XMLHttpRequestConstructorImp(ExecState *exec, const DOM::Document &d);
@@ -36,7 +49,7 @@ namespace KJS {
     DOM::Document doc;
   };
 
-  class XMLHttpRequest : public DOMObject, public khtml::CachedObjectClient {
+  class XMLHttpRequest : public DOMObject {
   public:
     XMLHttpRequest(ExecState *, const DOM::Document &d);
     ~XMLHttpRequest();
@@ -44,12 +57,62 @@ namespace KJS {
     Value getValueProperty(ExecState *exec, int token) const;
     virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
     void putValue(ExecState *exec, int token, const Value& value, int /*attr*/);
-    void notifyFinished(khtml::CachedObject *);
     virtual bool toBoolean(ExecState *) const { return true; }
     virtual const ClassInfo* classInfo() const { return &info; }
     static const ClassInfo info;
     enum { Onreadystatechange, ReadyState, ResponseText, ResponseXML, Status, StatusText, Abort, GetAllResponseHeaders, GetResponseHeader, Open, Send, SetRequestHeader };
+
+  private:
+    friend class XMLHttpRequestProtoFunc;
+    friend class XMLHttpRequestQObject;
+
+    XMLHttpRequestQObject *qObject;
+
+#if APPLE_CHANGES
+    void slotData( KIO::Job* job, const char *data, int size );
+#else
+    void slotData( KIO::Job* job, const QByteArray &data );
+#endif
+    void slotFinished( KIO::Job* );
+    void slotRedirection( KIO::Job*, const KURL& );
+
+    void open(const QString& _method, const KURL& _url, bool _async);
+    void send(const QString& _body);
+
+    void changeState(XMLHttpRequestState newState);
+
+    QGuardedPtr<DOM::DocumentImpl> doc;
+    KIO::TransferJob * job;
+    XMLHttpRequestState state;
+    JSEventListener *onReadyStateChangeListener;
+    QString method;
+    KURL url;
+    bool async;
+
+    khtml::Decoder *decoder;
+    QString encoding;
+
+    QString response;
+  };
+
+
+  class XMLHttpRequestQObject : public QObject {
+    Q_OBJECT
+	
+  public:
+    XMLHttpRequestQObject(XMLHttpRequest *_jsObject);
+
+  public slots:
+#if APPLE_CHANGES
+    void slotData( KIO::Job* job, const char *data, int size );
+#else
+    void slotData( KIO::Job* job, const QByteArray &data );
+#endif
+    void slotFinished( KIO::Job* job );
+    void slotRedirection( KIO::Job* job, const KURL& url);
+
   private:
+    XMLHttpRequest *jsObject;
   };
 
 }; // namespace
diff --git a/WebCore/khtml/xml/dom2_eventsimpl.cpp b/WebCore/khtml/xml/dom2_eventsimpl.cpp
index 7720cd3..eb8177c 100644
--- a/WebCore/khtml/xml/dom2_eventsimpl.cpp
+++ b/WebCore/khtml/xml/dom2_eventsimpl.cpp
@@ -229,6 +229,8 @@ EventImpl::EventId EventImpl::typeToId(DOMString type)
 	return KEYUP_EVENT;
     else if (type == "textInput")
 	return TEXTINPUT_EVENT;
+    else if (type == "readystatechange")
+	return KHTML_READYSTATECHANGE_EVENT;
     // ignore: KHTML_DBLCLICK_EVENT
     // ignore: KHTML_CLICK_EVENT
     return UNKNOWN_EVENT;
@@ -316,6 +318,8 @@ DOMString EventImpl::idToType(EventImpl::EventId id)
             return "khtml_move";
         case KHTML_ORIGCLICK_MOUSEUP_EVENT:
             return "khtml_origclick_mouseup_event";
+        case KHTML_READYSTATECHANGE_EVENT:
+	    return "readystatechange";
 	default:
 	    return DOMString();
 	    break;
diff --git a/WebCore/khtml/xml/dom2_eventsimpl.h b/WebCore/khtml/xml/dom2_eventsimpl.h
index fd283cd..c6407be 100644
--- a/WebCore/khtml/xml/dom2_eventsimpl.h
+++ b/WebCore/khtml/xml/dom2_eventsimpl.h
@@ -91,7 +91,9 @@ public:
 	KHTML_ERROR_EVENT,
 	KEYPRESS_EVENT,
 	KHTML_MOVE_EVENT,
-	KHTML_ORIGCLICK_MOUSEUP_EVENT
+	KHTML_ORIGCLICK_MOUSEUP_EVENT,
+	// XMLHttpRequest events
+	KHTML_READYSTATECHANGE_EVENT
     };
 
     EventImpl();
diff --git a/WebCore/kwq/KWQLoader.h b/WebCore/kwq/KWQLoader.h
index a5c16e3..b424fd9 100644
--- a/WebCore/kwq/KWQLoader.h
+++ b/WebCore/kwq/KWQLoader.h
@@ -37,6 +37,7 @@ namespace KIO {
 }
 
 bool KWQServeRequest(khtml::Loader *, khtml::Request *, KIO::TransferJob *);
+bool KWQServeRequest(khtml::Loader *, khtml::DocLoader *, KIO::TransferJob *);
 void KWQCheckCacheObjectStatus(khtml::DocLoader *, khtml::CachedObject *);
 bool KWQCheckIfReloading(khtml::DocLoader *loader);
 void KWQRetainResponse(void *response);
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index daff1cd..c77388c 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -47,10 +47,15 @@ bool KWQServeRequest(Loader *loader, Request *request, TransferJob *job)
         request->m_docLoader->part()->baseURL().url().latin1(),
         request->object->url().string().latin1());
     
-    KWQKHTMLPart *part = static_cast<KWQKHTMLPart *>(request->m_docLoader->part());
+    return KWQServeRequest(loader, request->m_docLoader, job);
+}
+
+bool KWQServeRequest(Loader *loader, DocLoader *docLoader, TransferJob *job)
+{
+    KWQKHTMLPart *part = static_cast<KWQKHTMLPart *>(docLoader->part());
     WebCoreBridge *bridge = part->bridge();
 
-    part->didTellBridgeAboutLoad(request->object->url().string());
+    part->didTellBridgeAboutLoad(job->url().url());
 
     KWQ_BLOCK_EXCEPTIONS;
     KWQResourceLoader *resourceLoader = [[KWQResourceLoader alloc] initWithJob:job];
diff --git a/WebCore/kwq/KWQSlot.mm b/WebCore/kwq/KWQSlot.mm
index 4bd20af..0f9cbe5 100644
--- a/WebCore/kwq/KWQSlot.mm
+++ b/WebCore/kwq/KWQSlot.mm
@@ -32,6 +32,7 @@
 #import "kjs_window.h"
 #import "render_form.h"
 #import "render_layer.h"
+#import "xmlhttprequest.h"
 
 using DOM::DocumentImpl;
 using khtml::CachedObject;
@@ -47,6 +48,7 @@ using khtml::RenderWidget;
 using khtml::RenderScrollMediator;
 using KIO::Job;
 using KJS::WindowQObject;
+using KJS::XMLHttpRequestQObject;
 
 enum FunctionNumber {
     signalFinishedParsing,
@@ -71,10 +73,13 @@ enum FunctionNumber {
     slotTextChangedWithString_RenderFileButton,
     slotValueChanged,
     slotWidgetDestructed,
-    slotData,
-    slotRedirection,
+    slotData_Loader,
+    slotData_XMLHttpRequest,
+    slotRedirection_KHTMLPart,
+    slotRedirection_XMLHttpRequest,
     slotFinished_KHTMLPart,
     slotFinished_Loader,
+    slotFinished_XMLHttpRequest,
     slotReceivedResponse
 };
 
@@ -125,17 +130,27 @@ KWQSlot::KWQSlot(QObject *object, const char *member)
 	    m_function = slotTextChangedWithString_RenderFileButton;
 	}
     } else if (KWQNamesMatch(member, SLOT(slotData(KIO::Job *, const char *, int)))) {
-	ASSERT(dynamic_cast<khtml::Loader *>(object));
-	m_function = slotData;
+	ASSERT(dynamic_cast<Loader *>(object) || dynamic_cast<XMLHttpRequestQObject *>(object));
+	if (dynamic_cast<Loader *>(object)) {
+	    m_function = slotData_Loader;
+	} else {
+	    m_function = slotData_XMLHttpRequest;
+	}
     } else if (KWQNamesMatch(member, SLOT(slotRedirection(KIO::Job *, const KURL&)))) {
-	ASSERT(dynamic_cast<KHTMLPart *>(object));
-	m_function = slotRedirection;
+	ASSERT(dynamic_cast<KHTMLPart *>(object) || dynamic_cast<XMLHttpRequestQObject *>(object));
+	if (dynamic_cast<KHTMLPart *>(object)) {
+	    m_function = slotRedirection_KHTMLPart;
+	} else {
+	    m_function = slotRedirection_XMLHttpRequest;
+	}
     } else if (KWQNamesMatch(member, SLOT(slotFinished(KIO::Job *)))) {
-	ASSERT(dynamic_cast<khtml::Loader *>(object) || dynamic_cast<KHTMLPart *>(object));
+	ASSERT(dynamic_cast<khtml::Loader *>(object) || dynamic_cast<KHTMLPart *>(object) || dynamic_cast<XMLHttpRequestQObject *>(object));
 	if (dynamic_cast<khtml::Loader *>(object)) {
 	    m_function = slotFinished_Loader;
-	} else {
+	} else if (dynamic_cast<KHTMLPart *>(object)) {
 	    m_function = slotFinished_KHTMLPart;
+	} else {
+	    m_function = slotFinished_XMLHttpRequest;
 	}
     } else if (KWQNamesMatch(member, SLOT(slotReceivedResponse(KIO::Job *, void *)))) {
 	ASSERT(dynamic_cast<khtml::Loader *>(object));
@@ -253,6 +268,9 @@ void KWQSlot::call(Job *job) const
         case slotFinished_Loader:
             static_cast<Loader *>(m_object.pointer())->slotFinished(job);
             return;
+        case slotFinished_XMLHttpRequest:
+            static_cast<XMLHttpRequestQObject *>(m_object.pointer())->slotFinished(job);
+            return;
     }
     
     call();
@@ -265,9 +283,12 @@ void KWQSlot::call(Job *job, const char *data, int size) const
     }
     
     switch (m_function) {
-        case slotData:
+        case slotData_Loader:
 	    static_cast<Loader *>(m_object.pointer())->slotData(job, data, size);
 	    return;
+        case slotData_XMLHttpRequest:
+	    static_cast<XMLHttpRequestQObject *>(m_object.pointer())->slotData(job, data, size);
+	    return;
     }
 
     call();
@@ -280,9 +301,12 @@ void KWQSlot::call(Job *job, const KURL &url) const
     }
     
     switch (m_function) {
-        case slotRedirection:
+        case slotRedirection_KHTMLPart:
 	    static_cast<KHTMLPart *>(m_object.pointer())->slotRedirection(job, url);
 	    return;
+        case slotRedirection_XMLHttpRequest:
+	    static_cast<XMLHttpRequestQObject *>(m_object.pointer())->slotRedirection(job, url);
+	    return;
     }
 
     call();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list