WebCore:
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Dec 2004 01:23:00 +0000 (01:23 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Dec 2004 01:23:00 +0000 (01:23 +0000)
Fixed:
<rdar://problem/3685766> WebDataSource is missing subresources when they use cached WebCore data
<rdar://problem/3722434> REGRESSION?: Assertion failure trying to drag image in iframe (itapema.sc.gov.br)

        Reviewed by darin.

        * khtml/misc/loader.cpp:
        (CachedObject::~CachedObject): release m_allData
        (CachedObject::setAllData): new
        (Loader::servePendingRequests): connect slotAllData
        (Loader::slotAllData): new
        (Cache::requestImage): tweak
        * khtml/misc/loader.h:
        (khtml::CachedObject::CachedObject): set allData to 0
        (khtml::CachedObject::allData): new
        * kwq/KWQKJobClasses.h:
        * kwq/KWQKJobClasses.mm:
        (KIO::TransferJob::TransferJob): set m_allData
        (KIO::TransferJob::emitAllData): new
        * kwq/KWQLoader.mm:
        (KWQCheckCacheObjectStatus): pass WebKit the data instead of the length of the resource
        * kwq/KWQResourceLoader.mm:
        (-[KWQResourceLoader finishWithData:]): renamed to pass all data for the resource
        * kwq/KWQSlot.mm:
        (KWQSlot::KWQSlot): support for slotAllData
        (KWQSlot::call):
        * kwq/WebCoreBridge.h:
        * kwq/WebCoreResourceLoader.h:

WebKit:

Fixed:
<rdar://problem/3685766> WebDataSource is missing subresources when they use cached WebCore data
<rdar://problem/3722434> REGRESSION?: Assertion failure trying to drag image in iframe (itapema.sc.gov.br)

        Reviewed by darin.

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge objectLoadedFromCacheWithURL:response:data:]): renamed to pass all data for the resource, moved delegate code to new method
        (-[WebBridge syncLoadResourceWithURL:customHeaders:postData:finalURL:responseHeaders:statusCode:]): call renamed method
        * WebCoreSupport.subproj/WebSubresourceClient.m:
        (-[WebSubresourceClient didFinishLoading]): call renamed method
        * WebView.subproj/WebFrame.m:
        (-[WebFrame _opened]): call _sendResourceLoadDelegateMessagesForURL:response:length:, not objectLoadedFromCacheWithURL:response:data:
        (-[WebFrame _internalLoadDelegate]):
        (-[WebFrame _sendResourceLoadDelegateMessagesForURL:response:length:]): moved from objectLoadedFromCacheWithURL:response:data:
        * WebView.subproj/WebFrameInternal.h:

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

22 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/khtml/misc/loader.cpp
WebCore/khtml/misc/loader.h
WebCore/kwq/KWQKJobClasses.h
WebCore/kwq/KWQKJobClasses.mm
WebCore/kwq/KWQLoader.h
WebCore/kwq/KWQLoader.mm
WebCore/kwq/KWQPixmap.h
WebCore/kwq/KWQPixmap.mm
WebCore/kwq/KWQResourceLoader.mm
WebCore/kwq/KWQSignal.h
WebCore/kwq/KWQSignal.mm
WebCore/kwq/KWQSlot.h
WebCore/kwq/KWQSlot.mm
WebCore/kwq/WebCoreBridge.h
WebCore/kwq/WebCoreResourceLoader.h
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebCoreSupport.subproj/WebSubresourceClient.m
WebKit/WebCoreSupport.subproj/WebSubresourceLoader.m
WebKit/WebView.subproj/WebFrame.m
WebKit/WebView.subproj/WebFrameInternal.h

index f7bf885..2767bb4 100644 (file)
@@ -1,3 +1,38 @@
+2004-11-30  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed:
+       <rdar://problem/3685766> WebDataSource is missing subresources when they use cached WebCore data
+       <rdar://problem/3722434> REGRESSION?: Assertion failure trying to drag image in iframe (itapema.sc.gov.br)
+
+        Reviewed by darin.
+
+        * khtml/misc/loader.cpp:
+        (CachedObject::~CachedObject): release m_allData
+        (CachedObject::setAllData): new
+        (Loader::servePendingRequests): connect slotAllData
+        (Loader::slotAllData): new
+        (Cache::requestImage): tweak
+        * khtml/misc/loader.h:
+        (khtml::CachedObject::CachedObject): set allData to 0
+        (khtml::CachedObject::allData): new
+        * kwq/KWQKJobClasses.h:
+        * kwq/KWQKJobClasses.mm:
+        (KIO::TransferJob::TransferJob): set m_allData
+        (KIO::TransferJob::emitAllData): new
+        * kwq/KWQLoader.mm:
+        (KWQCheckCacheObjectStatus): pass WebKit the data instead of the length of the resource
+        * kwq/KWQResourceLoader.mm:
+        (-[KWQResourceLoader finishWithData:]): renamed to pass all data for the resource
+        * kwq/KWQSlot.mm:
+        (KWQSlot::KWQSlot): support for slotAllData
+        (KWQSlot::call):
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreResourceLoader.h:
+
+2004-11-30  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by John.
+
 2004-11-30  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by John.
@@ -15,6 +50,7 @@
 
         Reviewed by John.
 
+>>>>>>> 1.3551
        - fix recent regression from collection perf fixes.
        
         * khtml/html/html_miscimpl.cpp:
index 2168446..3bd11a2 100644 (file)
@@ -4,7 +4,7 @@
     Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
     Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
     Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
-    Copyright (C) 2003 Apple Computer, Inc.
+    Copyright (C) 2004 Apple Computer, Inc.
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -89,7 +89,8 @@ CachedObject::~CachedObject()
     Cache::removeFromLRUList(this);
     m_deleted = true;
 #if APPLE_CHANGES
-    KWQReleaseResponse(m_response);
+    setResponse(0);
+    setAllData(0);
 #endif
 }
 
@@ -134,17 +135,6 @@ bool CachedObject::isExpired() const
     return (difftime(now, m_expireDate) >= 0);
 }
 
-#if APPLE_CHANGES
-
-void CachedObject::setResponse(void *response)
-{
-    KWQRetainResponse(response);
-    KWQReleaseResponse(m_response);
-    m_response = response;
-}
-
-#endif
-
 void CachedObject::setRequest(Request *_request)
 {
     if ( _request && !m_request )
@@ -252,8 +242,8 @@ void CachedCSSStyleSheet::checkNotify()
 
     CachedObjectClientWalker w(m_clients);
     while (CachedObjectClient *c = w.next()) {
-        if (m_response && !KWQIsResponseURLEqualToURL(m_response,m_url))
-            c->setStyleSheet(DOMString (KWQResponseURL(m_response)), m_sheet);
+        if (m_response && !KWQIsResponseURLEqualToURL(m_response, m_url))
+            c->setStyleSheet(DOMString(KWQResponseURL(m_response)), m_sheet);
         else
             c->setStyleSheet(m_url, m_sheet);
     }
@@ -1431,7 +1421,8 @@ void Loader::servePendingRequests()
 #if APPLE_CHANGES
   connect( job, SIGNAL( data( KIO::Job*, const char *, int)),
            SLOT( slotData( KIO::Job*, const char *, int)));
-  connect( job, SIGNAL( receivedResponse( KIO::Job *, void *)), SLOT( slotReceivedResponse( KIO::Job *, void *)) );
+  connect( job, SIGNAL( receivedResponse( KIO::Job *, NSURLResponse *)), SLOT( slotReceivedResponse( KIO::Job *, NSURLResponse *)) );
+  connect( job, SIGNAL( allData( KIO::Job *, NSData *)), SLOT( slotAllData( KIO::Job *, NSData *)) );
 
   if (KWQServeRequest(this, req, job))
       m_requestsLoading.insert(job, req);
@@ -1488,7 +1479,8 @@ kdDebug(6060) << "Loader::slotFinished, url = " << j->url().url() << " expires "
 }
 
 #if APPLE_CHANGES
-void Loader::slotReceivedResponse(KIO::Job* job, void *response)
+
+void Loader::slotReceivedResponse(KIO::Job* job, NSURLResponse *response)
 {
     Request *r = m_requestsLoading[job];
     ASSERT(r);
@@ -1496,6 +1488,15 @@ void Loader::slotReceivedResponse(KIO::Job* job, void *response)
     r->object->setResponse(response);
     r->object->setExpireDate(KWQCacheObjectExpiresTime(r->m_docLoader, response), false);
 }
+
+void Loader::slotAllData(KIO::Job* job, NSData *data)
+{
+    Request *r = m_requestsLoading[job];
+    ASSERT(r);
+    ASSERT(data);
+    r->object->setAllData(data);
+}
+
 #endif
 
 #if APPLE_CHANGES
@@ -1692,7 +1693,6 @@ CachedImage *Cache::requestImage( DocLoader* dl, const KURL & url, bool reload,
     }
 #endif
 
-
     CachedObject *o = 0;
     if (!reload)
         o = cache->find(url.url());
@@ -1889,7 +1889,8 @@ CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bo
 #endif
         return 0;
     }
-
+    
+    
 #ifdef CACHE_DEBUG
     if( o->status() == CachedObject::Pending )
         kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
index 00c7c81..e0b76ea 100644 (file)
@@ -3,7 +3,7 @@
 
     Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
     Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
-    Copyright (C) 2003 Apple Computer, Inc.
+    Copyright (C) 2004 Apple Computer, Inc.
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -68,7 +68,17 @@ namespace DOM
 };
 
 #if APPLE_CHANGES
+
 class KWQLoader;
+
+#if __OBJC__
+@class NSData;
+@class NSURLResponse;
+#else
+class NSData;
+class NSURLResponse;
+#endif
+
 #endif
 
 namespace khtml
@@ -131,6 +141,7 @@ namespace khtml
            m_request = 0;
 #if APPLE_CHANGES
         m_response = 0;
+        m_allData = 0;
 #endif            
            m_expireDate = _expireDate;
         m_deleted = false;
@@ -180,9 +191,12 @@ namespace khtml
         void setRequest(Request *_request);
 
 #if APPLE_CHANGES
-        void *response() { return m_response; }
-        void setResponse (void *response);
+        NSURLResponse *response() const { return m_response; }
+        void setResponse(NSURLResponse *response);
+        NSData *allData() const { return m_allData; }
+        void setAllData (NSData *data);
 #endif
+
         bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
 
        void setExpireDate(time_t _expireDate, bool changeHttpCache);
@@ -207,7 +221,8 @@ namespace khtml
         QString m_accept;
         Request *m_request;
 #if APPLE_CHANGES
-        void *m_response;
+        NSURLResponse *m_response;
+        NSData *m_allData;
 #endif
        Type m_type;
        Status m_status;
@@ -511,7 +526,8 @@ protected:
        void slotFinished( KIO::Job * );
 #if APPLE_CHANGES
        void slotData( KIO::Job *, const char *data, int size );
-        void slotReceivedResponse ( KIO::Job *, void *response );
+        void slotReceivedResponse ( KIO::Job *, NSURLResponse *response );
+        void slotAllData( KIO::Job *, NSData *data );
 #else
        void slotData( KIO::Job *, const QByteArray & );
 #endif
@@ -541,7 +557,7 @@ protected:
         * before using it.
         */
        static void init();
-
+        
        /**
         * Ask the cache for some url. Will return a cachedObject, and
         * load the requested data in case it's not cahced
index fe5664f..8627fac 100644 (file)
 
 #ifdef __OBJC__
 @class KWQResourceLoader;
+@class NSData;
+@class NSURLResponse;
 #else
 class KWQResourceLoader;
+class NSData;
+class NSURLResponse;
 #endif
 
 namespace khtml {
@@ -74,7 +78,8 @@ public:
     void emitData(const char *, int);
     void emitRedirection(const KURL &);
     void emitResult();
-    void emitReceivedResponse(void *);
+    void emitReceivedResponse(NSURLResponse *);
+    void emitAllData(NSData *);
 
     khtml::FormData postData() const;
     QString method() const;
@@ -89,6 +94,7 @@ private:
     KWQSignal m_redirection;
     KWQSignal m_result;
     KWQSignal m_receivedResponse;
+    KWQSignal m_allData;
 };
 
 } // namespace KIO
index 3049360..ff73d79 100644 (file)
@@ -52,7 +52,7 @@ public:
        , URL(kurl)
        , loader(nil)
        , method("GET")
-       , response(0)
+       , response(nil)
         , assembledResponseHeaders(true)
         , retrievedCharset(true)
     {
@@ -65,7 +65,7 @@ public:
        , loader(nil)
        , method("POST")
        , postData(_postData)
-       , response(0)
+       , response(nil)
        , assembledResponseHeaders(true)
         , retrievedCharset(true)
     {
@@ -73,7 +73,7 @@ public:
 
     ~TransferJobPrivate()
     {
-       KWQReleaseResponse(response);
+       KWQRelease(response);
         KWQRelease(metaData);
         KWQRelease(loader);
     }
@@ -85,7 +85,7 @@ public:
     QString method;
     FormData postData;
 
-    void *response;
+    NSURLResponse *response;
     bool assembledResponseHeaders;
     bool retrievedCharset;
     QString responseHeaders;
@@ -96,7 +96,8 @@ TransferJob::TransferJob(const KURL &url, bool reload)
       m_data(this, SIGNAL(data(KIO::Job*, const char*, int))),
       m_redirection(this, SIGNAL(redirection(KIO::Job*, const KURL&))),
       m_result(this, SIGNAL(result(KIO::Job*))),
-      m_receivedResponse(this, SIGNAL(receivedResponse(KIO::Job*, void *)))
+      m_receivedResponse(this, SIGNAL(receivedResponse(KIO::Job*, NSURLResponse *))),
+      m_allData(this, SIGNAL(allData(KIO::Job*, NSData *)))
 {
 }
 
@@ -105,7 +106,8 @@ TransferJob::TransferJob(const KURL &url, const FormData &postData)
       m_data(this, SIGNAL(data(KIO::Job*, const char*, int))),
       m_redirection(this, SIGNAL(redirection(KIO::Job*, const KURL&))),
       m_result(this, SIGNAL(result(KIO::Job*))),
-      m_receivedResponse(this, SIGNAL(receivedResponse(KIO::Job*, void *)))
+      m_receivedResponse(this, SIGNAL(receivedResponse(KIO::Job*, NSURLResponse *))),
+      m_allData(this, SIGNAL(allData(KIO::Job*, NSData *)))
 {
 }
 
@@ -142,7 +144,11 @@ QString TransferJob::errorText() const
 void TransferJob::assembleResponseHeaders() const
 {
     if (!d->assembledResponseHeaders) {
-       d->responseHeaders = QString::fromNSString((NSString *)KWQResponseHeaderString(d->response));
+        if ([d->response isKindOfClass:[NSHTTPURLResponse class]]) {
+            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)d->response;
+            NSDictionary *headers = [httpResponse allHeaderFields];
+            d->responseHeaders = QString::fromNSString(KWQHeaderStringFromDictionary(headers, [httpResponse statusCode]));
+        }
        d->assembledResponseHeaders = true;
     }
 }
@@ -150,7 +156,7 @@ void TransferJob::assembleResponseHeaders() const
 void TransferJob::retrieveCharset() const
 {
     if (!d->retrievedCharset) {
-        NSString *charset = (NSString *)KWQResponseTextEncodingName(d->response);
+        NSString *charset = [d->response textEncodingName];
         if (charset) {
             [d->metaData setObject:charset forKey:@"charset"];
         }
@@ -231,14 +237,19 @@ void TransferJob::emitResult()
     m_result.call(this);
 }
 
-void TransferJob::emitReceivedResponse(void *response)
+void TransferJob::emitReceivedResponse(NSURLResponse *response)
 {
     d->assembledResponseHeaders = false;
     d->retrievedCharset = false;
     d->response = response;
-    KWQRetainResponse(d->response);
+    KWQRetain(d->response);
 
     m_receivedResponse.call(this, response);
 }
 
+void TransferJob::emitAllData(NSData *data)
+{
+    m_allData.call(this, data);
+}
+
 } // namespace KIO
index 5893ee2..694212a 100644 (file)
 #include "KWQCString.h"
 #include "KWQSignal.h"
 
+#if __OBJC__
+@class NSDictionary;
+@class NSString;
+@class NSURLResponse;
+#else
+class NSDictionary;
+class NSString;
+class NSURLResponse;
+#endif
+
 namespace khtml {
     class CachedObject;
     class DocLoader;
@@ -48,15 +58,12 @@ QByteArray KWQServeSynchronousRequest(khtml::Loader *, khtml::DocLoader *, KIO::
 
 void KWQCheckCacheObjectStatus(khtml::DocLoader *, khtml::CachedObject *);
 bool KWQCheckIfReloading(khtml::DocLoader *loader);
-void KWQRetainResponse(void *response);
-void KWQReleaseResponse(void *response);
-bool KWQIsResponseURLEqualToURL(void *response, const DOM::DOMString &m_url);
-QString KWQResponseURL(void *response);
-void *KWQResponseMIMEType(void *response);
-void *KWQResponseTextEncodingName(void *response);
-void *KWQResponseHeaderString(void *response);
+bool KWQIsResponseURLEqualToURL(NSURLResponse *response, const DOM::DOMString &m_url);
+QString KWQResponseURL(NSURLResponse *response);
+NSString *KWQResponseMIMEType(NSURLResponse *response);
 int KWQNumberOfPendingOrLoadingRequests(khtml::DocLoader *dl);
-time_t KWQCacheObjectExpiresTime(khtml::DocLoader *docLoader, void *response);
+time_t KWQCacheObjectExpiresTime(khtml::DocLoader *docLoader, NSURLResponse *response);
+NSString *KWQHeaderStringFromDictionary(NSDictionary *headers, int statusCode);
 
 class KWQLoader
 {
index c5f9cba..ce17807 100644 (file)
@@ -139,7 +139,7 @@ bool KWQServeRequest(Loader *loader, DocLoader *docLoader, TransferJob *job)
     return true;
 }
 
-static NSString *KWQHeaderStringFromDictionary(NSDictionary *headers, int statusCode)
+NSString *KWQHeaderStringFromDictionary(NSDictionary *headers, int statusCode)
 {
     NSMutableString *headerString = [[NSMutableString alloc] init];
     [headerString appendString:[NSString stringWithFormat:@"HTTP/1.0 %d OK\n", statusCode]];
@@ -246,35 +246,20 @@ void KWQCheckCacheObjectStatus(DocLoader *loader, CachedObject *cachedObject)
 
     if (!part->haveToldBridgeAboutLoad(urlString)) {
        WebCoreBridge *bridge = part->bridge();
-       CachedImage *cachedImage = dynamic_cast<CachedImage *>(cachedObject);
 
        KWQ_BLOCK_EXCEPTIONS;
        [bridge objectLoadedFromCacheWithURL:KURL(cachedObject->url().string()).getNSURL()
-               response:(id)cachedObject->response()
-               size:cachedImage ? cachedImage->dataSize() : cachedObject->size()];
+                                    response:(NSURLResponse *)cachedObject->response()
+                                        data:(NSData *)cachedObject->allData()];
        KWQ_UNBLOCK_EXCEPTIONS;
 
        part->didTellBridgeAboutLoad(urlString);
     }
 }
 
-void KWQRetainResponse(void *response)
-{
-    // There's no way a retain can raise
-    KWQRetain((id)response);
-}
-
-void KWQReleaseResponse(void *response)
-{
-    // A release could raise if it deallocs.
-    KWQ_BLOCK_EXCEPTIONS;
-    KWQRelease((id)response);
-    KWQ_UNBLOCK_EXCEPTIONS;
-}
-
 #define LOCAL_STRING_BUFFER_SIZE 1024
 
-bool KWQIsResponseURLEqualToURL(void *response, const DOM::DOMString &m_url)
+bool KWQIsResponseURLEqualToURL(NSURLResponse *response, const DOM::DOMString &m_url)
 {
     unichar _buffer[LOCAL_STRING_BUFFER_SIZE];
     unichar *urlStringCharacters;
@@ -305,7 +290,7 @@ bool KWQIsResponseURLEqualToURL(void *response, const DOM::DOMString &m_url)
     return ret;
 }
 
-QString KWQResponseURL(void *response)
+QString KWQResponseURL(NSURLResponse *response)
 {
     KWQ_BLOCK_EXCEPTIONS;
 
@@ -321,7 +306,7 @@ QString KWQResponseURL(void *response)
     return NULL;
 }
 
-void *KWQResponseMIMEType(void *response)
+NSString *KWQResponseMIMEType(NSURLResponse *response)
 {
     KWQ_BLOCK_EXCEPTIONS;
     return [(NSURLResponse *)response MIMEType];
@@ -330,32 +315,7 @@ void *KWQResponseMIMEType(void *response)
     return NULL;
 }
 
-void *KWQResponseTextEncodingName(void *response)
-{
-    KWQ_BLOCK_EXCEPTIONS;
-    return [(NSURLResponse *)response textEncodingName];
-    KWQ_UNBLOCK_EXCEPTIONS;
-
-    return NULL;
-}
-
-void *KWQResponseHeaderString(void *response)
-{
-    KWQ_BLOCK_EXCEPTIONS;
-    NSURLResponse *nsResponse = (NSURLResponse *)response;
-    if ([nsResponse isKindOfClass:[NSHTTPURLResponse class]]) {
-       NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)nsResponse;
-       NSDictionary *headers = [httpResponse allHeaderFields];
-
-       return KWQHeaderStringFromDictionary(headers, [httpResponse statusCode]);
-    }
-
-    KWQ_UNBLOCK_EXCEPTIONS;
-
-    return NULL;
-}
-
-time_t KWQCacheObjectExpiresTime(khtml::DocLoader *docLoader, void *response)
+time_t KWQCacheObjectExpiresTime(khtml::DocLoader *docLoader, NSURLResponse *response)
 {
     KWQ_BLOCK_EXCEPTIONS;
     
@@ -374,3 +334,27 @@ KWQLoader::KWQLoader(Loader *loader)
     , _requestFailed(loader, SIGNAL(requestFailed(khtml::DocLoader *, khtml::CachedObject *)))
 {
 }
+
+namespace khtml {
+    
+void CachedObject::setResponse(NSURLResponse *response)
+{
+    KWQRetain(response);
+    KWQ_BLOCK_EXCEPTIONS;
+    KWQRelease(m_response);
+    KWQ_UNBLOCK_EXCEPTIONS;
+
+    m_response = response;
+}
+
+void CachedObject::setAllData(NSData *allData)
+{
+    KWQRetain(allData);
+    KWQ_BLOCK_EXCEPTIONS;
+    KWQRelease(m_allData);
+    KWQ_UNBLOCK_EXCEPTIONS;
+
+    m_allData = allData;
+}
+
+} // namespace
index 30094df..e4f6f3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,13 +53,13 @@ QPixmap *KWQLoadPixmap(const char *name);
 class QPixmap : public QPaintDevice, public Qt {
 public:
     QPixmap();
-    QPixmap(void *MIMEType);
+    QPixmap(NSString *MIMEType);
     QPixmap(const QSize&);
     QPixmap(const QByteArray&);
-    QPixmap(const QByteArray&, void *MIMEType);
+    QPixmap(const QByteArray&, NSString *MIMEType);
     QPixmap(int, int);
+    //QPixmap(WebCoreImageRendererPtr);
     QPixmap(const QPixmap &);
-    QPixmap(WebCoreImageRendererPtr);
     ~QPixmap();
     
     bool isNull() const;
index de228cf..cf94aa2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -43,50 +43,53 @@ bool canRenderImageType(const QString &type)
 QPixmap::QPixmap()
 {
     imageRenderer = nil;
-    MIMEType = 0;
+    MIMEType = nil;
     needCopyOnWrite = false;
 }
 
+#if 0
+
 QPixmap::QPixmap(WebCoreImageRendererPtr r)
 {
     imageRenderer = KWQRetain(r);
-    MIMEType = 0;
+    MIMEType = nil;
     needCopyOnWrite = false;
 }
 
+#endif
 
-QPixmap::QPixmap(void *MIME)
+QPixmap::QPixmap(NSString *MIME)
 {
     imageRenderer = nil;
-    MIMEType = (NSString *)[((NSString *)MIME) copy];
+    MIMEType = KWQRetainNSRelease([MIME copy]);
     needCopyOnWrite = false;
 }
 
 QPixmap::QPixmap(const QSize &sz)
 {
     imageRenderer = KWQRetain([[WebCoreImageRendererFactory sharedFactory] imageRendererWithSize:NSMakeSize(sz.width(), sz.height())]);
-    MIMEType = 0;
+    MIMEType = nil;
     needCopyOnWrite = false;
 }
 
 QPixmap::QPixmap(const QByteArray &bytes)
 {
     imageRenderer = KWQRetain([[WebCoreImageRendererFactory sharedFactory] imageRendererWithBytes:bytes.data() length:bytes.size()]);
-    MIMEType = 0;
+    MIMEType = nil;
     needCopyOnWrite = false;
 }
 
-QPixmap::QPixmap(const QByteArray &bytes, void *MIME)
+QPixmap::QPixmap(const QByteArray &bytes, NSString *MIME)
 {
-    MIMEType = (NSString *)[((NSString *)MIME) copy];
-    imageRenderer = KWQRetain([[WebCoreImageRendererFactory sharedFactory] imageRendererWithBytes:bytes.data() length:bytes.size() MIMEType:(NSString *)MIMEType]);
+    MIMEType = KWQRetainNSRelease([MIME copy]);
+    imageRenderer = KWQRetain([[WebCoreImageRendererFactory sharedFactory] imageRendererWithBytes:bytes.data() length:bytes.size() MIMEType:MIMEType]);
     needCopyOnWrite = false;
 }
 
 QPixmap::QPixmap(int w, int h)
 {
     imageRenderer = KWQRetain([[WebCoreImageRendererFactory sharedFactory] imageRendererWithSize:NSMakeSize(w, h)]);
-    MIMEType = 0;
+    MIMEType = nil;
     needCopyOnWrite = false;
 }
 
index 75f12a5..3116757 100644 (file)
@@ -111,10 +111,11 @@ using KIO::TransferJob;
     [self finishJobAndHandle];
 }
 
-- (void)finish
+- (void)finishWithData:(NSData *)data
 {
     ASSERT(_job);
     ASSERT(_handle);
+    _job->emitAllData(data);
     [self finishJobAndHandle];
 }
 
index bdf56c7..9b59c91 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,7 +45,8 @@ public:
     void call(khtml::DocLoader *, khtml::CachedObject *) const;
     void call(KIO::Job *, const char *data, int size) const;
     void call(KIO::Job *, const KURL &) const;
-    void call(KIO::Job *, void *) const;
+    void call(KIO::Job *, NSData *) const;
+    void call(KIO::Job *, NSURLResponse *) const;
     
 private:
     // forbid copying and assignment
index 8b6196e..2ed63df 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -173,7 +173,7 @@ void KWQSignal::call(Job *j, const KURL &u) const
     }
 }
 
-void KWQSignal::call(Job *j, void *d) const
+void KWQSignal::call(Job *j, NSData *d) const
 {
     if (!_object->_signalsBlocked) {
         KWQObjectSenderScope senderScope(_object);
@@ -185,3 +185,14 @@ void KWQSignal::call(Job *j, void *d) const
     }
 }
 
+void KWQSignal::call(Job *j, NSURLResponse *r) const
+{
+    if (!_object->_signalsBlocked) {
+        KWQObjectSenderScope senderScope(_object);
+        QValueList<KWQSlot> copiedSlots(_slots);
+        QValueListConstIterator<KWQSlot> end = copiedSlots.end();
+        for (QValueListConstIterator<KWQSlot> it = copiedSlots.begin(); it != end; ++it) {
+            (*it).call(j, r);
+        }
+    }
+}
index 3e79b3c..855dc50 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "KWQGuardedPtr.h"
 
+#if __OBJC__
+@class NSData;
+@class NSURLResponse;
+#else
+class NSData;
+class NSURLResponse;
+#endif
+
 class QString;
 class KURL;
 
@@ -59,7 +67,8 @@ public:
     void call(khtml::DocLoader *, khtml::CachedObject *) const;
     void call(KIO::Job *, const char *, int) const;
     void call(KIO::Job *, const KURL &) const;
-    void call(KIO::Job *, void *) const;
+    void call(KIO::Job *, NSData *) const;
+    void call(KIO::Job *, NSURLResponse *) const;
 
     friend bool operator==(const KWQSlot &, const KWQSlot &);
 
index 0b06bb4..9ebd0de 100644 (file)
@@ -83,7 +83,8 @@ enum FunctionNumber {
     slotFinished_KHTMLPart,
     slotFinished_Loader,
     slotFinished_XMLHttpRequest,
-    slotReceivedResponse
+    slotReceivedResponse,
+    slotAllData
 };
 
 KWQSlot::KWQSlot(QObject *object, const char *member)
@@ -157,9 +158,12 @@ KWQSlot::KWQSlot(QObject *object, const char *member)
        } else {
            m_function = slotFinished_XMLHttpRequest;
        }
-    } else if (KWQNamesMatch(member, SLOT(slotReceivedResponse(KIO::Job *, void *)))) {
+    } else if (KWQNamesMatch(member, SLOT(slotReceivedResponse(KIO::Job *, NSURLResponse *)))) {
        ASSERT(dynamic_cast<khtml::Loader *>(object));
        m_function = slotReceivedResponse;
+    } else if (KWQNamesMatch(member, SLOT(slotAllData(KIO::Job *, NSData *)))) {
+       ASSERT(dynamic_cast<khtml::Loader *>(object));
+       m_function = slotAllData;
     } else {
         ERROR("trying to create a slot for unknown member %s", member);
         return;
@@ -319,7 +323,22 @@ void KWQSlot::call(Job *job, const KURL &url) const
     call();
 }
 
-void KWQSlot::call(KIO::Job *job, void *response) const
+void KWQSlot::call(KIO::Job *job, NSData *data) const
+{
+    if (m_object.isNull()) {
+        return;
+    }
+    
+    switch (m_function) {
+        case slotAllData:
+           static_cast<Loader *>(m_object.pointer())->slotAllData(job, data);
+           return;
+    }
+    
+    call();
+}
+
+void KWQSlot::call(KIO::Job *job, NSURLResponse *response) const
 {
     if (m_object.isNull()) {
         return;
@@ -330,7 +349,7 @@ void KWQSlot::call(KIO::Job *job, void *response) const
            static_cast<Loader *>(m_object.pointer())->slotReceivedResponse(job, response);
            return;
     }
-
+    
     call();
 }
 
index 6f9d236..f3196df 100644 (file)
@@ -444,7 +444,7 @@ typedef enum {
 
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders;
 - (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders postData:(NSArray *)data;
-- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response:(id)response size:(unsigned)bytes;
+- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response:(NSURLResponse *)response data:(NSData *)data;
 
 - (NSData *)syncLoadResourceWithURL:(NSURL *)URL customHeaders:(NSDictionary *)requestHeaders postData:(NSArray *)postData finalURL:(NSURL **)finalNSURL responseHeaders:(NSDictionary **)responseHeaderDict statusCode:(int *)statusCode;
 
index 42f3ba3..a6c9242 100644 (file)
@@ -32,9 +32,9 @@
 
 - (void)addData:(NSData *)data;
 
-// Either finish, reportError, or cancel must be called before the
+// Either finishWithData:, reportError, or cancel must be called before the
 // loader is released, but never more than one.
-- (void)finish;
+- (void)finishWithData:(NSData *)data;
 - (void)reportError;
 - (void)cancel;
 
index b035239..488b5ba 100644 (file)
@@ -1,3 +1,22 @@
+2004-11-30  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed:
+       <rdar://problem/3685766> WebDataSource is missing subresources when they use cached WebCore data
+       <rdar://problem/3722434> REGRESSION?: Assertion failure trying to drag image in iframe (itapema.sc.gov.br)
+
+        Reviewed by darin.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge objectLoadedFromCacheWithURL:response:data:]): renamed to pass all data for the resource, moved delegate code to new method
+        (-[WebBridge syncLoadResourceWithURL:customHeaders:postData:finalURL:responseHeaders:statusCode:]): call renamed method
+        * WebCoreSupport.subproj/WebSubresourceClient.m:
+        (-[WebSubresourceClient didFinishLoading]): call renamed method
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame _opened]): call _sendResourceLoadDelegateMessagesForURL:response:length:, not objectLoadedFromCacheWithURL:response:data:
+        (-[WebFrame _internalLoadDelegate]):
+        (-[WebFrame _sendResourceLoadDelegateMessagesForURL:response:length:]): moved from objectLoadedFromCacheWithURL:response:data:
+        * WebView.subproj/WebFrameInternal.h:
+
 2004-11-29  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index 918447a..4c80482 100644 (file)
 #import <WebKit/WebBasePluginPackage.h>
 #import <WebKit/WebBaseResourceHandleDelegate.h>
 #import <WebKit/WebDataSourcePrivate.h>
-#import <WebKit/WebDefaultResourceLoadDelegate.h>
 #import <WebKit/WebDefaultUIDelegate.h>
 #import <WebKit/WebEditingDelegate.h>
 #import <WebKit/WebFileButton.h>
 #import <WebKit/WebFormDelegate.h>
+#import <WebKit/WebFrameInternal.h>
 #import <WebKit/WebFrameLoadDelegate.h>
-#import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebFrameViewInternal.h>
 #import <WebKit/WebHistoryItemPrivate.h>
 #import <WebKit/WebHTMLRepresentationPrivate.h>
@@ -41,7 +40,7 @@
 #import <WebKit/WebPluginViewFactoryPrivate.h>
 #import <WebKit/WebNetscapePluginDocumentView.h>
 #import <WebKit/WebPreferencesPrivate.h>
-#import <WebKit/WebResourceLoadDelegate.h>
+#import <WebKit/WebResource.h>
 #import <WebKit/WebSubresourceClient.h>
 #import <WebKit/WebViewInternal.h>
 #import <WebKit/WebViewPrivate.h>
@@ -443,42 +442,18 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
                                         forDataSource:[self dataSource]];
 }
 
-- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response: response size:(unsigned)bytes
+- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response:(NSURLResponse *)response data:(NSData *)data
 {
-    ASSERT(_frame != nil);
-    ASSERT(response != nil);
-
-    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:URL];
-    WebView *wv = [_frame webView];
-    id delegate = [wv resourceLoadDelegate];
-    id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
-    id identifier;
-    WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
+    WebResource *resource = [[WebResource alloc] initWithData:data
+                                                          URL:URL
+                                                     MIMEType:[response MIMEType]
+                                             textEncodingName:[response textEncodingName]
+                                                    frameName:nil];
+    ASSERT(resource != nil);
+    [[self dataSource] addSubresource:resource];
+    [resource release];
     
-    // No chance for delegate to modify request, so we don't send a willSendRequest:redirectResponse: message.
-    if (implementations.delegateImplementsIdentifierForRequest)
-        identifier = [delegate webView:wv identifierForInitialRequest: request fromDataSource: [self dataSource]];
-    else
-        identifier = [sharedDelegate webView:wv identifierForInitialRequest:request fromDataSource:[self dataSource]];
-    
-    if (implementations.delegateImplementsDidReceiveResponse)
-        [delegate webView:wv resource: identifier didReceiveResponse: response fromDataSource: [self dataSource]];
-    else
-        [sharedDelegate webView:wv resource: identifier didReceiveResponse: response fromDataSource: [self dataSource]];
-
-    if (implementations.delegateImplementsDidReceiveContentLength)
-        [delegate webView:wv resource: identifier didReceiveContentLength: bytes fromDataSource: [self dataSource]];
-    else
-        [sharedDelegate webView:wv resource: identifier didReceiveContentLength: bytes fromDataSource: [self dataSource]];
-
-    if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
-        [delegate webView:wv resource: identifier didFinishLoadingFromDataSource: [self dataSource]];
-    else
-        [sharedDelegate webView:wv resource: identifier didFinishLoadingFromDataSource: [self dataSource]];
-    
-    [[_frame webView] _finishedLoadingResourceFromDataSource:[self dataSource]];
-
-    [request release];
+    [_frame _sendResourceLoadDelegateMessagesForURL:URL response:response length:[data length]];    
 }
 
 - (NSData *)syncLoadResourceWithURL:(NSURL *)URL customHeaders:(NSDictionary *)requestHeaders postData:(NSArray *)postData finalURL:(NSURL **)finalURL responseHeaders:(NSDictionary **)responseHeaderDict statusCode:(int *)statusCode
@@ -529,7 +504,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
     }
 
     // notify the delegates
-    [self objectLoadedFromCacheWithURL:URL response:response size:[result length]];
+    [self objectLoadedFromCacheWithURL:URL response:response data:result];
 
     return result;
 }
index e0de2b9..d78e79c 100644 (file)
     // Calling _removeSubresourceClient will likely result in a call to release, so we must retain.
     [self retain];
     
-    [loader finish];
+    [loader finishWithData:[self resourceData]];
     
     [dataSource _removeSubresourceClient:self];
     
index e0de2b9..d78e79c 100644 (file)
     // Calling _removeSubresourceClient will likely result in a call to release, so we must retain.
     [self retain];
     
-    [loader finish];
+    [loader finishWithData:[self resourceData]];
     
     [dataSource _removeSubresourceClient:self];
     
index 6a07f58..f975b16 100644 (file)
@@ -11,6 +11,7 @@
 #import <WebKit/WebBridge.h>
 #import <WebKit/WebDataProtocol.h>
 #import <WebKit/WebDataSourcePrivate.h>
+#import <WebKit/WebDefaultResourceLoadDelegate.h>
 #import <WebKit/WebDefaultUIDelegate.h>
 #import <WebKit/WebDocumentInternal.h>
 #import <WebKit/WebFrameLoadDelegate.h>
@@ -31,6 +32,7 @@
 #import <WebKit/WebPlugin.h>
 #import <WebKit/WebPluginController.h>
 #import <WebKit/WebPluginDocumentView.h>
+#import <WebKit/WebResourceLoadDelegate.h>
 #import <WebKit/WebResourcePrivate.h>
 #import <WebKit/WebViewInternal.h>
 #import <WebKit/WebUIDelegate.h>
@@ -996,9 +998,9 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
         int i, count = [responses count];
         for (i = 0; i < count; i++){
             response = [responses objectAtIndex: i];
-            [_private->bridge objectLoadedFromCacheWithURL:[response URL]
-                    response: response
-                    size: [response expectedContentLength]];
+            [self _sendResourceLoadDelegateMessagesForURL:[response URL]
+                                                 response:response
+                                                   length:[response expectedContentLength]];
         }
         
         // Release the resources kept in the page cache.  They will be
@@ -2497,6 +2499,44 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
     return _private->internalLoadDelegate;
 }
 
+- (void)_sendResourceLoadDelegateMessagesForURL:(NSURL *)URL response:(NSURLResponse *)response length:(unsigned)length
+{
+    ASSERT(response != nil);
+    
+    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:URL];
+    WebView *wv = [self webView];
+    id delegate = [wv resourceLoadDelegate];
+    id sharedDelegate = [WebDefaultResourceLoadDelegate sharedResourceLoadDelegate];
+    id identifier;
+    WebResourceDelegateImplementationCache implementations = [wv _resourceLoadDelegateImplementations];
+    WebDataSource *dataSource = [self dataSource];
+    
+    // No chance for delegate to modify request, so we don't send a willSendRequest:redirectResponse: message.
+    if (implementations.delegateImplementsIdentifierForRequest)
+        identifier = [delegate webView:wv identifierForInitialRequest: request fromDataSource:dataSource];
+    else
+        identifier = [sharedDelegate webView:wv identifierForInitialRequest:request fromDataSource:dataSource];
+    
+    if (implementations.delegateImplementsDidReceiveResponse)
+        [delegate webView:wv resource: identifier didReceiveResponse: response fromDataSource:dataSource];
+    else
+        [sharedDelegate webView:wv resource: identifier didReceiveResponse: response fromDataSource:dataSource];
+    
+    if (implementations.delegateImplementsDidReceiveContentLength)
+        [delegate webView:wv resource: identifier didReceiveContentLength:length fromDataSource:dataSource];
+    else
+        [sharedDelegate webView:wv resource: identifier didReceiveContentLength:length fromDataSource:dataSource];
+    
+    if (implementations.delegateImplementsDidFinishLoadingFromDataSource)
+        [delegate webView:wv resource: identifier didFinishLoadingFromDataSource:dataSource];
+    else
+        [sharedDelegate webView:wv resource: identifier didFinishLoadingFromDataSource:dataSource];
+    
+    [wv _finishedLoadingResourceFromDataSource:dataSource];
+    
+    [request release];
+}
+
 @end
 
 @implementation WebFormState : NSObject
index 9581bed..6b7188f 100644 (file)
@@ -7,6 +7,7 @@
 - (void)_updateDrawsBackground;
 - (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
 - (id)_internalLoadDelegate;
+- (void)_sendResourceLoadDelegateMessagesForURL:(NSURL *)URL response:(NSURLResponse *)response length:(unsigned)length;
 
 @end