[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
kocienda
kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:51:13 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 4a1d9f2706bfa84f2f747011b0e275010f59c806
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Oct 31 21:29:11 2001 +0000
A collection of changes focusing on rendering and loading:
- Images now load
- Removed loader.cpp; added KWQKloader.cpp
- Reworked some of the API in WCURI land
- Assorted other small changes anf fixes
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/Makefile.rules.in b/WebCore/Makefile.rules.in
index 9cbe7fb..5009c61 100644
--- a/WebCore/Makefile.rules.in
+++ b/WebCore/Makefile.rules.in
@@ -35,7 +35,10 @@ $(filter %.o,$(CMOBJECTS)): %.o: %.m
$(filter %.o,$(CXXOBJECTS)): %.o: %.cpp
$(CXX) $(CXXFLAGS) -I$(TOPSRCDIR) -c $< -o $@
-.SUFFIXES: .cpp .h .c .mm .m
+.SUFFIXES: .cpp .h .c .mm .m .p
+
+.h.p:
+ $(CC) -precomp $(CCPRECOMPFLAGS) -I$(TOPSRCDIR) $*.h -o $*.p
.cpp.o:
$(CXX) $(CXXFLAGS) -I$(TOPSRCDIR) -c $< -o $@
diff --git a/WebCore/Makefile.vars.in b/WebCore/Makefile.vars.in
index 5c75d42..b2cf18b 100644
--- a/WebCore/Makefile.vars.in
+++ b/WebCore/Makefile.vars.in
@@ -51,6 +51,7 @@ BASELDFLAGS = @LDFLAGS@
BASEYACCFLAGS = @YACCFLAGS@
BASELEXFLAGS = @LEXFLAGS@
BASEDYLIBFLAGS = @DYLIBFLAGS@
+BASECCPRECOMPFLAGS = @CXXFLAGS@
ARFLAGS = $(BASEARFLAGS)
CFLAGS = $(BASECFLAGS)
@@ -60,6 +61,7 @@ LDFLAGS = $(BASELDFLAGS)
YACCFLAGS = $(BASEYACCFLAGS)
LEXFLAGS = $(BASELEXFLAGS)
DYLIBFLAGS = $(BASEDYLIBFLAGS)
+CCPRECOMPFLAGS = $(BASECCPRECOMPFLAGS)
DEPFLAGS = $(BASECXXFLAGS)
diff --git a/WebCore/include/WCURICache.h b/WebCore/include/WCURICache.h
index 0c406e0..7cf89ac 100644
--- a/WebCore/include/WCURICache.h
+++ b/WebCore/include/WCURICache.h
@@ -4,14 +4,13 @@
#import <Foundation/Foundation.h>
-#import <WCURICacheJobID.h>
-
@protocol WCURICache
--(NSString *)requestWithURL:(NSURL *)url requestor:(id)requestor;
--(NSString *)requestWithString:(NSString *)uriString requestor:(id)requestor;
+-(NSString *)requestWithURL:(NSURL *)url requestor:(id)requestor userData:(void *)userData;
+-(NSString *)requestWithString:(NSString *)uriString requestor:(id)requestor userData:(void *)userData;
--(void)cancelRequest:(id <WCURICacheJobID>)jobID;
+-(void)cancelRequestWithURL:(NSURL *)url requestor:(id)requestor;
+-(void)cancelRequestWithString:(NSString *)uriString requestor:(id)requestor;
-(void)cancelAllRequestsWithURL:(NSURL *)url;
-(void)cancelAllRequestsWithString:(NSString *)uriString;
diff --git a/WebCore/include/WCURICacheData.h b/WebCore/include/WCURICacheData.h
index bfb1e80..d173687 100644
--- a/WebCore/include/WCURICacheData.h
+++ b/WebCore/include/WCURICacheData.h
@@ -4,16 +4,14 @@
#import <Foundation/Foundation.h>
-#import <WCURICacheJobID.h>
-
@protocol WCURICacheData
--(id <WCURICacheJobID>)jobID;
+-(id)jobID;
-(id)status;
-(id)error;
-(NSURL *)url;
-(unsigned char *)cacheData;
-(int)cacheDataSize;
--(void *)userInfo;
+-(void *)userData;
@end
diff --git a/WebCore/khtml/misc/Makefile.in b/WebCore/khtml/misc/Makefile.in
index 756e622..0de5941 100644
--- a/WebCore/khtml/misc/Makefile.in
+++ b/WebCore/khtml/misc/Makefile.in
@@ -76,10 +76,6 @@ $(LIBRARY): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBRARY) $(CXXOBJECTS)
$(RANLIB) $(LIBRARY)
-loader.cpp: loader.moc
-loader.moc:
- touch loader.moc
-
khtmldata.h:
touch $@
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index 11ec956..fd25e47 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -66,6 +66,7 @@ namespace khtml
{
class CachedObject;
class Request;
+ class LoaderPrivate;
/**
* @internal
@@ -366,9 +367,15 @@ namespace khtml
void requestDone( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
void requestFailed( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
+#ifdef _KWQ_
+ public:
+ void slotFinished( KIO::Job * );
+ void slotData( KIO::Job *, const char *data, int size );
+#else
protected slots:
void slotFinished( KIO::Job * );
void slotData( KIO::Job *, const QByteArray & );
+#endif
private:
void servePendingRequests();
@@ -378,6 +385,13 @@ namespace khtml
#ifdef HAVE_LIBJPEG
KJPEGFormatType m_jpegloader;
#endif
+#ifdef _KWQ_
+#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+ LoaderPrivate *d;
+#else
+ void *d;
+#endif // __APPLE__, __OBJC__, __cplusplus
+#endif // _KWQ_
};
/**
diff --git a/WebCore/kwq/KWQKGlobal.h b/WebCore/kwq/KWQKGlobal.h
index 4742402..4295c2f 100644
--- a/WebCore/kwq/KWQKGlobal.h
+++ b/WebCore/kwq/KWQKGlobal.h
@@ -37,6 +37,7 @@ class KCharsets;
class KLocale;
class KStandardDirs;
class KConfig;
+class KWQStaticStringDict;
#define kMin(a, b) ((a) < (b) ? (a) : (b))
#define kMax(a, b) ((a) > (b) ? (a) : (b))
@@ -51,6 +52,8 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+ static KWQStaticStringDict *staticStringDict;
+
// static member functions -------------------------------------------------
static KInstance *instance();
diff --git a/WebCore/kwq/KWQKGlobal.mm b/WebCore/kwq/KWQKGlobal.mm
index 0edf4f2..5e64591 100644
--- a/WebCore/kwq/KWQKGlobal.mm
+++ b/WebCore/kwq/KWQKGlobal.mm
@@ -27,6 +27,8 @@
#include <kconfig.h>
#include <kglobal.h>
+#include <qdict.h>
+
#define Fixed MacFixed
#define Rect MacRect
#define Boolean MacBoolean
@@ -35,6 +37,14 @@
#undef Rect
#undef Boolean
+class KWQStaticStringDict : public QDict<QString>
+{
+public:
+ KWQStaticStringDict() : QDict<QString>() { };
+};
+
+KWQStaticStringDict *KGlobal::staticStringDict = 0;
+
KInstance *KGlobal::instance()
{
_logNotYetImplemented();
@@ -65,11 +75,16 @@ KConfig *KGlobal::config()
return new KConfig("foo");
}
-
-
-const QString &KGlobal::staticQString(const QString &)
+const QString &KGlobal::staticQString(const QString &str)
{
- _logNotYetImplemented();
+ if (!staticStringDict) {
+ staticStringDict = new KWQStaticStringDict;
+ }
+ QString *result = staticStringDict->find(str);
+ if (!result)
+ {
+ result = new QString(str);
+ staticStringDict->insert(str, result);
+ }
+ return *result;
}
-
-
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index c22c487..6e01c7c 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -205,10 +205,8 @@ bool KHTMLPart::openURL( const KURL &url )
cache = WCGetDefaultURICache();
nsurl = [NSString stringWithCString:url.url().latin1()];
- id jobID = [cache requestWithString:nsurl requestor:d->m_recv];
+ id jobID = [cache requestWithString:nsurl requestor:d->m_recv userData:nil];
- NSLog(@"part: %@", jobID);
-
return true;
}
@@ -457,9 +455,10 @@ void KHTMLPart::setBaseURL( const KURL &url )
KURL KHTMLPart::baseURL() const
{
- // FIXME!
- _logPartiallyImplemented();
- return KURL();
+ if (d->m_workingURL.isEmpty()) {
+ return KURL();
+ }
+ return d->m_workingURL;
}
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index c22c487..6e01c7c 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -205,10 +205,8 @@ bool KHTMLPart::openURL( const KURL &url )
cache = WCGetDefaultURICache();
nsurl = [NSString stringWithCString:url.url().latin1()];
- id jobID = [cache requestWithString:nsurl requestor:d->m_recv];
+ id jobID = [cache requestWithString:nsurl requestor:d->m_recv userData:nil];
- NSLog(@"part: %@", jobID);
-
return true;
}
@@ -457,9 +455,10 @@ void KHTMLPart::setBaseURL( const KURL &url )
KURL KHTMLPart::baseURL() const
{
- // FIXME!
- _logPartiallyImplemented();
- return KURL();
+ if (d->m_workingURL.isEmpty()) {
+ return KURL();
+ }
+ return d->m_workingURL;
}
diff --git a/WebCore/kwq/KWQKHTMLSettings.h b/WebCore/kwq/KWQKHTMLSettings.h
index fc6a9a0..a5b26da 100644
--- a/WebCore/kwq/KWQKHTMLSettings.h
+++ b/WebCore/kwq/KWQKHTMLSettings.h
@@ -73,6 +73,7 @@ public:
private:
QValueList<int> m_fontSizes;
+ QString m_fontFamilies;
};
#endif
diff --git a/WebCore/kwq/KWQKHTMLSettings.mm b/WebCore/kwq/KWQKHTMLSettings.mm
index daf5a1c..ade5168 100644
--- a/WebCore/kwq/KWQKHTMLSettings.mm
+++ b/WebCore/kwq/KWQKHTMLSettings.mm
@@ -38,6 +38,15 @@ KHTMLSettings::KHTMLSettings()
m_fontSizes << 16;
m_fontSizes << 18;
m_fontSizes << 20;
+
+ // set available font families...ask the system
+
+ NSFontManager *sharedFontManager;
+ NSArray *array;
+
+ sharedFontManager = [NSFontManager sharedFontManager];
+ array = [sharedFontManager availableFontFamilies];
+ m_fontFamilies = NSSTRING_TO_QSTRING([array componentsJoinedByString:@","]);
}
QString KHTMLSettings::stdFontName() const
@@ -108,7 +117,7 @@ int KHTMLSettings::minFontSize() const
QString KHTMLSettings::availableFamilies() const
{
- _logNotYetImplemented();
+ return m_fontFamilies;
}
diff --git a/WebCore/kwq/KWQKImageIO.mm b/WebCore/kwq/KWQKImageIO.mm
index 8a72726..dc4e076 100644
--- a/WebCore/kwq/KWQKImageIO.mm
+++ b/WebCore/kwq/KWQKImageIO.mm
@@ -35,4 +35,8 @@ void KImageIO::registerFormats()
QStringList KImageIO::mimeTypes(Mode mode=Writing)
{
+ // FIXME: need real implementation
+ QStringList mimeList;
+ mimeList.append ( "image/gif" );
+ return mimeList;
}
diff --git a/WebCore/kwq/KWQKJob.mm b/WebCore/kwq/KWQKJob.mm
index 64fb272..229ceec 100644
--- a/WebCore/kwq/KWQKJob.mm
+++ b/WebCore/kwq/KWQKJob.mm
@@ -36,7 +36,6 @@ TransferJob *get(const KURL &url, bool reload=false, bool showProgressInfo=true)
TransferJob *result;
result = new TransferJob(url, reload, showProgressInfo);
- result->begin();
return result;
}
diff --git a/WebCore/kwq/KWQKJobClasses.h b/WebCore/kwq/KWQKJobClasses.h
index a09ac43..5f51556 100644
--- a/WebCore/kwq/KWQKJobClasses.h
+++ b/WebCore/kwq/KWQKJobClasses.h
@@ -158,20 +158,27 @@ public:
void addMetaData(const QString &key, const QString &value);
void kill(bool quietly=TRUE);
- // this is special sauce for our implementation
- void begin();
+#ifdef _KWQ_
+#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+ void begin(id requestor, void *userData);
+#else
+ void begin(void *requestor, void *userData);
+#endif
+#endif
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+#ifdef _KWQ_
private:
KURL _url;
bool _reload;
bool _showProgressInfo;
int _status;
TransferJobPrivate *d;
+#endif
// add copy constructor
// this private declaration prevents copying
diff --git a/WebCore/kwq/KWQKJobClasses.mm b/WebCore/kwq/KWQKJobClasses.mm
index 1d8d3aa..a2d36bb 100644
--- a/WebCore/kwq/KWQKJobClasses.mm
+++ b/WebCore/kwq/KWQKJobClasses.mm
@@ -23,6 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <kwqdebug.h>
+
#include <qstring.h>
#include <jobclasses.h>
@@ -40,6 +42,8 @@ Job::~Job()
int Job::error()
{
+ _logNotYetImplemented();
+ return 0;
}
@@ -73,7 +77,7 @@ friend class TransferJob;
public:
TransferJobPrivate(TransferJob *parent, KURL &kurl) {
- metaData = [[NSMutableDictionary alloc] initWithCapacity:37];
+ metaData = [[NSMutableDictionary alloc] initWithCapacity:17];
// FIXME: create NSURL for now, later KURL and NSURL should play better together
NSString *string = [NSString stringWithCString:kurl.url().latin1()];
@@ -83,14 +87,13 @@ public:
~TransferJobPrivate() {
[metaData autorelease];
[url autorelease];
- [jobID autorelease];
}
private:
TransferJob *parent;
NSMutableDictionary *metaData;
NSURL *url;
- id <WCURICacheJobID> jobID;
+ id requestor;
};
// class TransferJob ===========================================================
@@ -145,17 +148,17 @@ void TransferJob::kill(bool quietly=TRUE)
id <WCURICache> uriCache;
uriCache = WCGetDefaultURICache();
- [uriCache cancelRequest:d->jobID];
+ [uriCache cancelRequestWithURL:d->url requestor:d->requestor];
}
-void TransferJob::begin()
+void TransferJob::begin(id requestor, void *userData)
{
id <WCURICache> uriCache;
uriCache = WCGetDefaultURICache();
//FIXME: load uri
- //[uriCache requestWithURL:d->url requestor:];
+ d->requestor = requestor;
+ [uriCache requestWithURL:d->url requestor:requestor userData:userData];
}
} // namespace KIO
-
diff --git a/WebCore/src/kdelibs/khtml/misc/loader.cpp b/WebCore/kwq/KWQKloader.mm
similarity index 91%
copy from WebCore/src/kdelibs/khtml/misc/loader.cpp
copy to WebCore/kwq/KWQKloader.mm
index a97ab03..685e256 100644
--- a/WebCore/src/kdelibs/khtml/misc/loader.cpp
+++ b/WebCore/kwq/KWQKloader.mm
@@ -26,7 +26,7 @@
#undef CACHE_DEBUG
//#define CACHE_DEBUG
-#include "loader.h"
+#include <loader.h>
// up to which size is a picture for sure cacheable
#define MAXCACHEABLE 40*1024
@@ -527,7 +527,16 @@ const QPixmap &CachedImage::pixmap( ) const
QSize CachedImage::pixmap_size() const
{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ //return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ if (m) {
+ return m->framePixmap().size();
+ }
+ else if (p) {
+ return p->size();
+ }
+ else {
+ return QSize();
+ }
}
@@ -631,9 +640,9 @@ void CachedImage::movieStatus(int status)
}
}
-void CachedImage::movieResize(const QSize& /*s*/)
+void CachedImage::movieResize(const QSize &s)
{
-// do_notify(m->framePixmap(), QRect());
+// do_notify(m->framePixmap(), s);
}
void CachedImage::setShowAnimations( bool enable )
@@ -671,6 +680,9 @@ void CachedImage::clear()
void CachedImage::data ( QBuffer &_buffer, bool eof )
{
+ // FIXME!!!
+ bool UseQPixmapForImageLoading = TRUE;
+
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
#endif
@@ -679,7 +691,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
typeChecked = true;
- if ( formatType ) // movie format exists
+ if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
{
imgSource = new ImageSource( _buffer.buffer());
m = new QMovie( imgSource, 8192 );
@@ -700,7 +712,10 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
// QMovie currently doesn't support all kinds of image formats
// so we need to use a QPixmap here when we finished loading the complete
// picture and display it then all at once.
- if(typeChecked && !formatType)
+
+
+ // FIXME: this is a hack put in place until the QMovie stuff works right
+ if(UseQPixmapForImageLoading || (typeChecked && !formatType))
{
#ifdef CACHE_DEBUG
kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
@@ -881,14 +896,76 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
// ------------------------------------------------------------------------------------------
+// Class LoaderNotificationReceiver ==============================================================
+
+ at interface LoaderNotificationReceiver : NSObject
+{
+ @public
+ Loader *m_loader;
+}
+
+-(id)initWithLoader:(Loader *)loader;
+
+ at end
+
+ at implementation LoaderNotificationReceiver
+
+-(id)initWithLoader:(Loader *)loader
+{
+ m_loader = loader;
+}
+
+-(void)cacheDataAvailable:(NSNotification *)notification
+{
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
+}
+
+-(void)cacheFinished:(NSNotification *)notification
+{
+ // FIXME: need an implementation for this
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotFinished(job);
+}
+
+ at end
+
+namespace khtml {
+
+class LoaderPrivate
+{
+friend class Loader;
+public:
+ LoaderPrivate(Loader *parent)
+ {
+ _parent = parent;
+ m_recv = [[LoaderNotificationReceiver alloc] initWithLoader:parent];
+ }
+
+ ~LoaderPrivate()
+ {
+ [m_recv release];
+ }
+
+private:
+ Loader *_parent;
+ LoaderNotificationReceiver *m_recv;
+};
+
+} // namespace khtml
+
Loader::Loader() : QObject()
{
m_requestsPending.setAutoDelete( true );
m_requestsLoading.setAutoDelete( true );
+ d = new LoaderPrivate(this);
}
Loader::~Loader()
{
+ delete d;
}
void Loader::load(CachedObject *object, const DOMString &baseURL, bool incremental)
@@ -911,6 +988,11 @@ void Loader::servePendingRequests()
kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
#endif
+#ifdef _KWQ_
+ KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+ m_requestsLoading.insert(job, req);
+ job->begin(d->m_recv, job);
+#else
KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
if (!req->object->accept().isEmpty())
@@ -924,6 +1006,8 @@ void Loader::servePendingRequests()
KIO::Scheduler::scheduleJob( job );
m_requestsLoading.insert(job, req);
+#endif
+
}
void Loader::slotFinished( KIO::Job* job )
@@ -955,6 +1039,26 @@ void Loader::slotFinished( KIO::Job* job )
servePendingRequests();
}
+#ifdef _KWQ_
+void Loader::slotData( KIO::Job*job, const char *data, int size )
+{
+ Request *r = m_requestsLoading[job];
+ if(!r) {
+ kdDebug( 6060 ) << "got data for unknown request!" << endl;
+ return;
+ }
+
+ if ( !r->m_buffer.isOpen() )
+ r->m_buffer.open( IO_WriteOnly );
+
+ r->m_buffer.writeBlock( data, size );
+
+ if(r->incremental)
+ r->object->data( r->m_buffer, false );
+}
+
+
+#else
void Loader::slotData( KIO::Job*job, const QByteArray &data )
{
Request *r = m_requestsLoading[job];
@@ -971,6 +1075,7 @@ void Loader::slotData( KIO::Job*job, const QByteArray &data )
if(r->incremental)
r->object->data( r->m_buffer, false );
}
+#endif
int Loader::numRequests( const DOMString &baseURL ) const
{
@@ -1031,6 +1136,10 @@ void Loader::cancelRequests( const DOMString &baseURL )
if ( lIt.current()->m_baseURL == baseURL )
{
//kdDebug( 6060 ) << "cancelling loading request for " << lIt.current()->object->url().string() << endl;
+ //KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
+ //Cache::removeCacheEntry( lIt.current()->object );
+ //m_requestsLoading.remove( lIt.currentKey() );
+ //job->kill();
KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
Cache::removeCacheEntry( lIt.current()->object );
m_requestsLoading.remove( lIt.currentKey() );
@@ -1109,8 +1218,13 @@ void Cache::clear()
CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, const DOMString &baseUrl, bool reload, int _expireDate )
{
+
+ fprintf(stderr, "!!! Cache::requestImage: url = %s\n", url.string().latin1());
+ fprintf(stderr, "!!! Cache::requestImage: baseUrl = %s\n", baseUrl.string().latin1());
+
// this brings the _url to a standard form...
KURL kurl = completeURL( url, baseUrl );
+ fprintf(stderr, "!!! Cache::requestImage: complete url = %s\n", kurl.url().latin1());
if( kurl.isMalformed() )
{
#ifdef CACHE_DEBUG
@@ -1128,6 +1242,7 @@ CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, co
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
CachedImage *im = new CachedImage(kurl.url(), baseUrl, reload, _expireDate);
+ fprintf(stderr, "!!! Cache::requestImage: im->baseURL() = %s\n", im->baseURL().string().latin1());
if ( dl && dl->autoloadImages() ) Cache::loader()->load(im, im->baseURL(), true);
cache->insert( kurl.url(), im );
lru->append( kurl.url() );
@@ -1279,7 +1394,7 @@ void Cache::flush(bool force)
--it; // Update iterator, we might delete the current entry later on.
CachedObject *o = cache->find( url );
- if( !o->canDelete() || o->status() == CachedObject::Persistent ) {
+ if( !o || !o->canDelete() || o->status() == CachedObject::Persistent ) {
continue; // image is still used or cached permanently
// in this case don't count it for the size of the cache.
}
@@ -1378,6 +1493,3 @@ void Cache::removeCacheEntry( CachedObject *object )
if ( object->canDelete() )
delete object;
}
-
-
-#include "loader.moc"
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/kwq/KWQLoader.mm
similarity index 91%
rename from WebCore/khtml/misc/loader.cpp
rename to WebCore/kwq/KWQLoader.mm
index a97ab03..685e256 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/kwq/KWQLoader.mm
@@ -26,7 +26,7 @@
#undef CACHE_DEBUG
//#define CACHE_DEBUG
-#include "loader.h"
+#include <loader.h>
// up to which size is a picture for sure cacheable
#define MAXCACHEABLE 40*1024
@@ -527,7 +527,16 @@ const QPixmap &CachedImage::pixmap( ) const
QSize CachedImage::pixmap_size() const
{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ //return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ if (m) {
+ return m->framePixmap().size();
+ }
+ else if (p) {
+ return p->size();
+ }
+ else {
+ return QSize();
+ }
}
@@ -631,9 +640,9 @@ void CachedImage::movieStatus(int status)
}
}
-void CachedImage::movieResize(const QSize& /*s*/)
+void CachedImage::movieResize(const QSize &s)
{
-// do_notify(m->framePixmap(), QRect());
+// do_notify(m->framePixmap(), s);
}
void CachedImage::setShowAnimations( bool enable )
@@ -671,6 +680,9 @@ void CachedImage::clear()
void CachedImage::data ( QBuffer &_buffer, bool eof )
{
+ // FIXME!!!
+ bool UseQPixmapForImageLoading = TRUE;
+
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
#endif
@@ -679,7 +691,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
typeChecked = true;
- if ( formatType ) // movie format exists
+ if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
{
imgSource = new ImageSource( _buffer.buffer());
m = new QMovie( imgSource, 8192 );
@@ -700,7 +712,10 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
// QMovie currently doesn't support all kinds of image formats
// so we need to use a QPixmap here when we finished loading the complete
// picture and display it then all at once.
- if(typeChecked && !formatType)
+
+
+ // FIXME: this is a hack put in place until the QMovie stuff works right
+ if(UseQPixmapForImageLoading || (typeChecked && !formatType))
{
#ifdef CACHE_DEBUG
kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
@@ -881,14 +896,76 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
// ------------------------------------------------------------------------------------------
+// Class LoaderNotificationReceiver ==============================================================
+
+ at interface LoaderNotificationReceiver : NSObject
+{
+ @public
+ Loader *m_loader;
+}
+
+-(id)initWithLoader:(Loader *)loader;
+
+ at end
+
+ at implementation LoaderNotificationReceiver
+
+-(id)initWithLoader:(Loader *)loader
+{
+ m_loader = loader;
+}
+
+-(void)cacheDataAvailable:(NSNotification *)notification
+{
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
+}
+
+-(void)cacheFinished:(NSNotification *)notification
+{
+ // FIXME: need an implementation for this
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotFinished(job);
+}
+
+ at end
+
+namespace khtml {
+
+class LoaderPrivate
+{
+friend class Loader;
+public:
+ LoaderPrivate(Loader *parent)
+ {
+ _parent = parent;
+ m_recv = [[LoaderNotificationReceiver alloc] initWithLoader:parent];
+ }
+
+ ~LoaderPrivate()
+ {
+ [m_recv release];
+ }
+
+private:
+ Loader *_parent;
+ LoaderNotificationReceiver *m_recv;
+};
+
+} // namespace khtml
+
Loader::Loader() : QObject()
{
m_requestsPending.setAutoDelete( true );
m_requestsLoading.setAutoDelete( true );
+ d = new LoaderPrivate(this);
}
Loader::~Loader()
{
+ delete d;
}
void Loader::load(CachedObject *object, const DOMString &baseURL, bool incremental)
@@ -911,6 +988,11 @@ void Loader::servePendingRequests()
kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
#endif
+#ifdef _KWQ_
+ KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+ m_requestsLoading.insert(job, req);
+ job->begin(d->m_recv, job);
+#else
KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
if (!req->object->accept().isEmpty())
@@ -924,6 +1006,8 @@ void Loader::servePendingRequests()
KIO::Scheduler::scheduleJob( job );
m_requestsLoading.insert(job, req);
+#endif
+
}
void Loader::slotFinished( KIO::Job* job )
@@ -955,6 +1039,26 @@ void Loader::slotFinished( KIO::Job* job )
servePendingRequests();
}
+#ifdef _KWQ_
+void Loader::slotData( KIO::Job*job, const char *data, int size )
+{
+ Request *r = m_requestsLoading[job];
+ if(!r) {
+ kdDebug( 6060 ) << "got data for unknown request!" << endl;
+ return;
+ }
+
+ if ( !r->m_buffer.isOpen() )
+ r->m_buffer.open( IO_WriteOnly );
+
+ r->m_buffer.writeBlock( data, size );
+
+ if(r->incremental)
+ r->object->data( r->m_buffer, false );
+}
+
+
+#else
void Loader::slotData( KIO::Job*job, const QByteArray &data )
{
Request *r = m_requestsLoading[job];
@@ -971,6 +1075,7 @@ void Loader::slotData( KIO::Job*job, const QByteArray &data )
if(r->incremental)
r->object->data( r->m_buffer, false );
}
+#endif
int Loader::numRequests( const DOMString &baseURL ) const
{
@@ -1031,6 +1136,10 @@ void Loader::cancelRequests( const DOMString &baseURL )
if ( lIt.current()->m_baseURL == baseURL )
{
//kdDebug( 6060 ) << "cancelling loading request for " << lIt.current()->object->url().string() << endl;
+ //KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
+ //Cache::removeCacheEntry( lIt.current()->object );
+ //m_requestsLoading.remove( lIt.currentKey() );
+ //job->kill();
KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
Cache::removeCacheEntry( lIt.current()->object );
m_requestsLoading.remove( lIt.currentKey() );
@@ -1109,8 +1218,13 @@ void Cache::clear()
CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, const DOMString &baseUrl, bool reload, int _expireDate )
{
+
+ fprintf(stderr, "!!! Cache::requestImage: url = %s\n", url.string().latin1());
+ fprintf(stderr, "!!! Cache::requestImage: baseUrl = %s\n", baseUrl.string().latin1());
+
// this brings the _url to a standard form...
KURL kurl = completeURL( url, baseUrl );
+ fprintf(stderr, "!!! Cache::requestImage: complete url = %s\n", kurl.url().latin1());
if( kurl.isMalformed() )
{
#ifdef CACHE_DEBUG
@@ -1128,6 +1242,7 @@ CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, co
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
CachedImage *im = new CachedImage(kurl.url(), baseUrl, reload, _expireDate);
+ fprintf(stderr, "!!! Cache::requestImage: im->baseURL() = %s\n", im->baseURL().string().latin1());
if ( dl && dl->autoloadImages() ) Cache::loader()->load(im, im->baseURL(), true);
cache->insert( kurl.url(), im );
lru->append( kurl.url() );
@@ -1279,7 +1394,7 @@ void Cache::flush(bool force)
--it; // Update iterator, we might delete the current entry later on.
CachedObject *o = cache->find( url );
- if( !o->canDelete() || o->status() == CachedObject::Persistent ) {
+ if( !o || !o->canDelete() || o->status() == CachedObject::Persistent ) {
continue; // image is still used or cached permanently
// in this case don't count it for the size of the cache.
}
@@ -1378,6 +1493,3 @@ void Cache::removeCacheEntry( CachedObject *object )
if ( object->canDelete() )
delete object;
}
-
-
-#include "loader.moc"
diff --git a/WebCore/src/kdelibs/khtml/misc/loader.cpp b/WebCore/kwq/KWQLoaderImpl.mm
similarity index 91%
copy from WebCore/src/kdelibs/khtml/misc/loader.cpp
copy to WebCore/kwq/KWQLoaderImpl.mm
index a97ab03..685e256 100644
--- a/WebCore/src/kdelibs/khtml/misc/loader.cpp
+++ b/WebCore/kwq/KWQLoaderImpl.mm
@@ -26,7 +26,7 @@
#undef CACHE_DEBUG
//#define CACHE_DEBUG
-#include "loader.h"
+#include <loader.h>
// up to which size is a picture for sure cacheable
#define MAXCACHEABLE 40*1024
@@ -527,7 +527,16 @@ const QPixmap &CachedImage::pixmap( ) const
QSize CachedImage::pixmap_size() const
{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ //return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ if (m) {
+ return m->framePixmap().size();
+ }
+ else if (p) {
+ return p->size();
+ }
+ else {
+ return QSize();
+ }
}
@@ -631,9 +640,9 @@ void CachedImage::movieStatus(int status)
}
}
-void CachedImage::movieResize(const QSize& /*s*/)
+void CachedImage::movieResize(const QSize &s)
{
-// do_notify(m->framePixmap(), QRect());
+// do_notify(m->framePixmap(), s);
}
void CachedImage::setShowAnimations( bool enable )
@@ -671,6 +680,9 @@ void CachedImage::clear()
void CachedImage::data ( QBuffer &_buffer, bool eof )
{
+ // FIXME!!!
+ bool UseQPixmapForImageLoading = TRUE;
+
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
#endif
@@ -679,7 +691,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
typeChecked = true;
- if ( formatType ) // movie format exists
+ if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
{
imgSource = new ImageSource( _buffer.buffer());
m = new QMovie( imgSource, 8192 );
@@ -700,7 +712,10 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
// QMovie currently doesn't support all kinds of image formats
// so we need to use a QPixmap here when we finished loading the complete
// picture and display it then all at once.
- if(typeChecked && !formatType)
+
+
+ // FIXME: this is a hack put in place until the QMovie stuff works right
+ if(UseQPixmapForImageLoading || (typeChecked && !formatType))
{
#ifdef CACHE_DEBUG
kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
@@ -881,14 +896,76 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
// ------------------------------------------------------------------------------------------
+// Class LoaderNotificationReceiver ==============================================================
+
+ at interface LoaderNotificationReceiver : NSObject
+{
+ @public
+ Loader *m_loader;
+}
+
+-(id)initWithLoader:(Loader *)loader;
+
+ at end
+
+ at implementation LoaderNotificationReceiver
+
+-(id)initWithLoader:(Loader *)loader
+{
+ m_loader = loader;
+}
+
+-(void)cacheDataAvailable:(NSNotification *)notification
+{
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
+}
+
+-(void)cacheFinished:(NSNotification *)notification
+{
+ // FIXME: need an implementation for this
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotFinished(job);
+}
+
+ at end
+
+namespace khtml {
+
+class LoaderPrivate
+{
+friend class Loader;
+public:
+ LoaderPrivate(Loader *parent)
+ {
+ _parent = parent;
+ m_recv = [[LoaderNotificationReceiver alloc] initWithLoader:parent];
+ }
+
+ ~LoaderPrivate()
+ {
+ [m_recv release];
+ }
+
+private:
+ Loader *_parent;
+ LoaderNotificationReceiver *m_recv;
+};
+
+} // namespace khtml
+
Loader::Loader() : QObject()
{
m_requestsPending.setAutoDelete( true );
m_requestsLoading.setAutoDelete( true );
+ d = new LoaderPrivate(this);
}
Loader::~Loader()
{
+ delete d;
}
void Loader::load(CachedObject *object, const DOMString &baseURL, bool incremental)
@@ -911,6 +988,11 @@ void Loader::servePendingRequests()
kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
#endif
+#ifdef _KWQ_
+ KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+ m_requestsLoading.insert(job, req);
+ job->begin(d->m_recv, job);
+#else
KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
if (!req->object->accept().isEmpty())
@@ -924,6 +1006,8 @@ void Loader::servePendingRequests()
KIO::Scheduler::scheduleJob( job );
m_requestsLoading.insert(job, req);
+#endif
+
}
void Loader::slotFinished( KIO::Job* job )
@@ -955,6 +1039,26 @@ void Loader::slotFinished( KIO::Job* job )
servePendingRequests();
}
+#ifdef _KWQ_
+void Loader::slotData( KIO::Job*job, const char *data, int size )
+{
+ Request *r = m_requestsLoading[job];
+ if(!r) {
+ kdDebug( 6060 ) << "got data for unknown request!" << endl;
+ return;
+ }
+
+ if ( !r->m_buffer.isOpen() )
+ r->m_buffer.open( IO_WriteOnly );
+
+ r->m_buffer.writeBlock( data, size );
+
+ if(r->incremental)
+ r->object->data( r->m_buffer, false );
+}
+
+
+#else
void Loader::slotData( KIO::Job*job, const QByteArray &data )
{
Request *r = m_requestsLoading[job];
@@ -971,6 +1075,7 @@ void Loader::slotData( KIO::Job*job, const QByteArray &data )
if(r->incremental)
r->object->data( r->m_buffer, false );
}
+#endif
int Loader::numRequests( const DOMString &baseURL ) const
{
@@ -1031,6 +1136,10 @@ void Loader::cancelRequests( const DOMString &baseURL )
if ( lIt.current()->m_baseURL == baseURL )
{
//kdDebug( 6060 ) << "cancelling loading request for " << lIt.current()->object->url().string() << endl;
+ //KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
+ //Cache::removeCacheEntry( lIt.current()->object );
+ //m_requestsLoading.remove( lIt.currentKey() );
+ //job->kill();
KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
Cache::removeCacheEntry( lIt.current()->object );
m_requestsLoading.remove( lIt.currentKey() );
@@ -1109,8 +1218,13 @@ void Cache::clear()
CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, const DOMString &baseUrl, bool reload, int _expireDate )
{
+
+ fprintf(stderr, "!!! Cache::requestImage: url = %s\n", url.string().latin1());
+ fprintf(stderr, "!!! Cache::requestImage: baseUrl = %s\n", baseUrl.string().latin1());
+
// this brings the _url to a standard form...
KURL kurl = completeURL( url, baseUrl );
+ fprintf(stderr, "!!! Cache::requestImage: complete url = %s\n", kurl.url().latin1());
if( kurl.isMalformed() )
{
#ifdef CACHE_DEBUG
@@ -1128,6 +1242,7 @@ CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, co
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
CachedImage *im = new CachedImage(kurl.url(), baseUrl, reload, _expireDate);
+ fprintf(stderr, "!!! Cache::requestImage: im->baseURL() = %s\n", im->baseURL().string().latin1());
if ( dl && dl->autoloadImages() ) Cache::loader()->load(im, im->baseURL(), true);
cache->insert( kurl.url(), im );
lru->append( kurl.url() );
@@ -1279,7 +1394,7 @@ void Cache::flush(bool force)
--it; // Update iterator, we might delete the current entry later on.
CachedObject *o = cache->find( url );
- if( !o->canDelete() || o->status() == CachedObject::Persistent ) {
+ if( !o || !o->canDelete() || o->status() == CachedObject::Persistent ) {
continue; // image is still used or cached permanently
// in this case don't count it for the size of the cache.
}
@@ -1378,6 +1493,3 @@ void Cache::removeCacheEntry( CachedObject *object )
if ( object->canDelete() )
delete object;
}
-
-
-#include "loader.moc"
diff --git a/WebCore/kwq/Makefile.in b/WebCore/kwq/Makefile.in
index 00c6804..07b3233 100644
--- a/WebCore/kwq/Makefile.in
+++ b/WebCore/kwq/Makefile.in
@@ -121,6 +121,7 @@ MMOBJECTS = \
KWQCString.o \
KWQRegion.o \
KWQDateTime.o \
+ KWQKloader.o \
$(NULL)
MOBJECTS = \
diff --git a/WebCore/kwq/kdecore/kglobal.h b/WebCore/kwq/kdecore/kglobal.h
index 4742402..4295c2f 100644
--- a/WebCore/kwq/kdecore/kglobal.h
+++ b/WebCore/kwq/kdecore/kglobal.h
@@ -37,6 +37,7 @@ class KCharsets;
class KLocale;
class KStandardDirs;
class KConfig;
+class KWQStaticStringDict;
#define kMin(a, b) ((a) < (b) ? (a) : (b))
#define kMax(a, b) ((a) > (b) ? (a) : (b))
@@ -51,6 +52,8 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+ static KWQStaticStringDict *staticStringDict;
+
// static member functions -------------------------------------------------
static KInstance *instance();
diff --git a/WebCore/kwq/khtml/khtml_settings.h b/WebCore/kwq/khtml/khtml_settings.h
index fc6a9a0..a5b26da 100644
--- a/WebCore/kwq/khtml/khtml_settings.h
+++ b/WebCore/kwq/khtml/khtml_settings.h
@@ -73,6 +73,7 @@ public:
private:
QValueList<int> m_fontSizes;
+ QString m_fontFamilies;
};
#endif
diff --git a/WebCore/kwq/kio/jobclasses.h b/WebCore/kwq/kio/jobclasses.h
index a09ac43..5f51556 100644
--- a/WebCore/kwq/kio/jobclasses.h
+++ b/WebCore/kwq/kio/jobclasses.h
@@ -158,20 +158,27 @@ public:
void addMetaData(const QString &key, const QString &value);
void kill(bool quietly=TRUE);
- // this is special sauce for our implementation
- void begin();
+#ifdef _KWQ_
+#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+ void begin(id requestor, void *userData);
+#else
+ void begin(void *requestor, void *userData);
+#endif
+#endif
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+#ifdef _KWQ_
private:
KURL _url;
bool _reload;
bool _showProgressInfo;
int _status;
TransferJobPrivate *d;
+#endif
// add copy constructor
// this private declaration prevents copying
diff --git a/WebCore/kwq/tests/qt/Makefile.in b/WebCore/kwq/tests/qt/Makefile.in
index 3ac7bca..24206e8 100644
--- a/WebCore/kwq/tests/qt/Makefile.in
+++ b/WebCore/kwq/tests/qt/Makefile.in
@@ -62,6 +62,8 @@ CMMFLAGS = $(BASECMMFLAGS)
LIBS = objc-dummy.o \
-framework Cocoa \
+ -F/symroots \
+ -framework WebKit \
-lwebcore \
$(NULL)
diff --git a/WebCore/kwq/tests/qt/qstring-test.cpp b/WebCore/kwq/tests/qt/qstring-test.cpp
index 6cf69c3..98e264a 100644
--- a/WebCore/kwq/tests/qt/qstring-test.cpp
+++ b/WebCore/kwq/tests/qt/qstring-test.cpp
@@ -219,7 +219,5 @@ int main() {
//cout << (c4 >= s33) << endl;
cout << (s33 >= s34) << endl;
-
-
return 0;
}
diff --git a/WebCore/src/kdelibs/khtml/misc/Makefile.in b/WebCore/src/kdelibs/khtml/misc/Makefile.in
index 756e622..0de5941 100644
--- a/WebCore/src/kdelibs/khtml/misc/Makefile.in
+++ b/WebCore/src/kdelibs/khtml/misc/Makefile.in
@@ -76,10 +76,6 @@ $(LIBRARY): $(OBJECTS)
$(AR) $(ARFLAGS) $(LIBRARY) $(CXXOBJECTS)
$(RANLIB) $(LIBRARY)
-loader.cpp: loader.moc
-loader.moc:
- touch loader.moc
-
khtmldata.h:
touch $@
diff --git a/WebCore/src/kdelibs/khtml/misc/loader.h b/WebCore/src/kdelibs/khtml/misc/loader.h
index 11ec956..fd25e47 100644
--- a/WebCore/src/kdelibs/khtml/misc/loader.h
+++ b/WebCore/src/kdelibs/khtml/misc/loader.h
@@ -66,6 +66,7 @@ namespace khtml
{
class CachedObject;
class Request;
+ class LoaderPrivate;
/**
* @internal
@@ -366,9 +367,15 @@ namespace khtml
void requestDone( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
void requestFailed( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
+#ifdef _KWQ_
+ public:
+ void slotFinished( KIO::Job * );
+ void slotData( KIO::Job *, const char *data, int size );
+#else
protected slots:
void slotFinished( KIO::Job * );
void slotData( KIO::Job *, const QByteArray & );
+#endif
private:
void servePendingRequests();
@@ -378,6 +385,13 @@ namespace khtml
#ifdef HAVE_LIBJPEG
KJPEGFormatType m_jpegloader;
#endif
+#ifdef _KWQ_
+#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+ LoaderPrivate *d;
+#else
+ void *d;
+#endif // __APPLE__, __OBJC__, __cplusplus
+#endif // _KWQ_
};
/**
diff --git a/WebCore/src/kwq/KWQKGlobal.mm b/WebCore/src/kwq/KWQKGlobal.mm
index 0edf4f2..5e64591 100644
--- a/WebCore/src/kwq/KWQKGlobal.mm
+++ b/WebCore/src/kwq/KWQKGlobal.mm
@@ -27,6 +27,8 @@
#include <kconfig.h>
#include <kglobal.h>
+#include <qdict.h>
+
#define Fixed MacFixed
#define Rect MacRect
#define Boolean MacBoolean
@@ -35,6 +37,14 @@
#undef Rect
#undef Boolean
+class KWQStaticStringDict : public QDict<QString>
+{
+public:
+ KWQStaticStringDict() : QDict<QString>() { };
+};
+
+KWQStaticStringDict *KGlobal::staticStringDict = 0;
+
KInstance *KGlobal::instance()
{
_logNotYetImplemented();
@@ -65,11 +75,16 @@ KConfig *KGlobal::config()
return new KConfig("foo");
}
-
-
-const QString &KGlobal::staticQString(const QString &)
+const QString &KGlobal::staticQString(const QString &str)
{
- _logNotYetImplemented();
+ if (!staticStringDict) {
+ staticStringDict = new KWQStaticStringDict;
+ }
+ QString *result = staticStringDict->find(str);
+ if (!result)
+ {
+ result = new QString(str);
+ staticStringDict->insert(str, result);
+ }
+ return *result;
}
-
-
diff --git a/WebCore/src/kwq/KWQKHTMLPart.mm b/WebCore/src/kwq/KWQKHTMLPart.mm
index c22c487..6e01c7c 100644
--- a/WebCore/src/kwq/KWQKHTMLPart.mm
+++ b/WebCore/src/kwq/KWQKHTMLPart.mm
@@ -205,10 +205,8 @@ bool KHTMLPart::openURL( const KURL &url )
cache = WCGetDefaultURICache();
nsurl = [NSString stringWithCString:url.url().latin1()];
- id jobID = [cache requestWithString:nsurl requestor:d->m_recv];
+ id jobID = [cache requestWithString:nsurl requestor:d->m_recv userData:nil];
- NSLog(@"part: %@", jobID);
-
return true;
}
@@ -457,9 +455,10 @@ void KHTMLPart::setBaseURL( const KURL &url )
KURL KHTMLPart::baseURL() const
{
- // FIXME!
- _logPartiallyImplemented();
- return KURL();
+ if (d->m_workingURL.isEmpty()) {
+ return KURL();
+ }
+ return d->m_workingURL;
}
diff --git a/WebCore/src/kwq/KWQKHTMLSettings.mm b/WebCore/src/kwq/KWQKHTMLSettings.mm
index daf5a1c..ade5168 100644
--- a/WebCore/src/kwq/KWQKHTMLSettings.mm
+++ b/WebCore/src/kwq/KWQKHTMLSettings.mm
@@ -38,6 +38,15 @@ KHTMLSettings::KHTMLSettings()
m_fontSizes << 16;
m_fontSizes << 18;
m_fontSizes << 20;
+
+ // set available font families...ask the system
+
+ NSFontManager *sharedFontManager;
+ NSArray *array;
+
+ sharedFontManager = [NSFontManager sharedFontManager];
+ array = [sharedFontManager availableFontFamilies];
+ m_fontFamilies = NSSTRING_TO_QSTRING([array componentsJoinedByString:@","]);
}
QString KHTMLSettings::stdFontName() const
@@ -108,7 +117,7 @@ int KHTMLSettings::minFontSize() const
QString KHTMLSettings::availableFamilies() const
{
- _logNotYetImplemented();
+ return m_fontFamilies;
}
diff --git a/WebCore/src/kwq/KWQKImageIO.mm b/WebCore/src/kwq/KWQKImageIO.mm
index 8a72726..dc4e076 100644
--- a/WebCore/src/kwq/KWQKImageIO.mm
+++ b/WebCore/src/kwq/KWQKImageIO.mm
@@ -35,4 +35,8 @@ void KImageIO::registerFormats()
QStringList KImageIO::mimeTypes(Mode mode=Writing)
{
+ // FIXME: need real implementation
+ QStringList mimeList;
+ mimeList.append ( "image/gif" );
+ return mimeList;
}
diff --git a/WebCore/src/kwq/KWQKJob.mm b/WebCore/src/kwq/KWQKJob.mm
index 64fb272..229ceec 100644
--- a/WebCore/src/kwq/KWQKJob.mm
+++ b/WebCore/src/kwq/KWQKJob.mm
@@ -36,7 +36,6 @@ TransferJob *get(const KURL &url, bool reload=false, bool showProgressInfo=true)
TransferJob *result;
result = new TransferJob(url, reload, showProgressInfo);
- result->begin();
return result;
}
diff --git a/WebCore/src/kwq/KWQKjobclasses.mm b/WebCore/src/kwq/KWQKjobclasses.mm
index 1d8d3aa..a2d36bb 100644
--- a/WebCore/src/kwq/KWQKjobclasses.mm
+++ b/WebCore/src/kwq/KWQKjobclasses.mm
@@ -23,6 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <kwqdebug.h>
+
#include <qstring.h>
#include <jobclasses.h>
@@ -40,6 +42,8 @@ Job::~Job()
int Job::error()
{
+ _logNotYetImplemented();
+ return 0;
}
@@ -73,7 +77,7 @@ friend class TransferJob;
public:
TransferJobPrivate(TransferJob *parent, KURL &kurl) {
- metaData = [[NSMutableDictionary alloc] initWithCapacity:37];
+ metaData = [[NSMutableDictionary alloc] initWithCapacity:17];
// FIXME: create NSURL for now, later KURL and NSURL should play better together
NSString *string = [NSString stringWithCString:kurl.url().latin1()];
@@ -83,14 +87,13 @@ public:
~TransferJobPrivate() {
[metaData autorelease];
[url autorelease];
- [jobID autorelease];
}
private:
TransferJob *parent;
NSMutableDictionary *metaData;
NSURL *url;
- id <WCURICacheJobID> jobID;
+ id requestor;
};
// class TransferJob ===========================================================
@@ -145,17 +148,17 @@ void TransferJob::kill(bool quietly=TRUE)
id <WCURICache> uriCache;
uriCache = WCGetDefaultURICache();
- [uriCache cancelRequest:d->jobID];
+ [uriCache cancelRequestWithURL:d->url requestor:d->requestor];
}
-void TransferJob::begin()
+void TransferJob::begin(id requestor, void *userData)
{
id <WCURICache> uriCache;
uriCache = WCGetDefaultURICache();
//FIXME: load uri
- //[uriCache requestWithURL:d->url requestor:];
+ d->requestor = requestor;
+ [uriCache requestWithURL:d->url requestor:requestor userData:userData];
}
} // namespace KIO
-
diff --git a/WebCore/src/kdelibs/khtml/misc/loader.cpp b/WebCore/src/kwq/KWQKloader.mm
similarity index 91%
rename from WebCore/src/kdelibs/khtml/misc/loader.cpp
rename to WebCore/src/kwq/KWQKloader.mm
index a97ab03..685e256 100644
--- a/WebCore/src/kdelibs/khtml/misc/loader.cpp
+++ b/WebCore/src/kwq/KWQKloader.mm
@@ -26,7 +26,7 @@
#undef CACHE_DEBUG
//#define CACHE_DEBUG
-#include "loader.h"
+#include <loader.h>
// up to which size is a picture for sure cacheable
#define MAXCACHEABLE 40*1024
@@ -527,7 +527,16 @@ const QPixmap &CachedImage::pixmap( ) const
QSize CachedImage::pixmap_size() const
{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ //return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
+ if (m) {
+ return m->framePixmap().size();
+ }
+ else if (p) {
+ return p->size();
+ }
+ else {
+ return QSize();
+ }
}
@@ -631,9 +640,9 @@ void CachedImage::movieStatus(int status)
}
}
-void CachedImage::movieResize(const QSize& /*s*/)
+void CachedImage::movieResize(const QSize &s)
{
-// do_notify(m->framePixmap(), QRect());
+// do_notify(m->framePixmap(), s);
}
void CachedImage::setShowAnimations( bool enable )
@@ -671,6 +680,9 @@ void CachedImage::clear()
void CachedImage::data ( QBuffer &_buffer, bool eof )
{
+ // FIXME!!!
+ bool UseQPixmapForImageLoading = TRUE;
+
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
#endif
@@ -679,7 +691,7 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
typeChecked = true;
- if ( formatType ) // movie format exists
+ if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
{
imgSource = new ImageSource( _buffer.buffer());
m = new QMovie( imgSource, 8192 );
@@ -700,7 +712,10 @@ void CachedImage::data ( QBuffer &_buffer, bool eof )
// QMovie currently doesn't support all kinds of image formats
// so we need to use a QPixmap here when we finished loading the complete
// picture and display it then all at once.
- if(typeChecked && !formatType)
+
+
+ // FIXME: this is a hack put in place until the QMovie stuff works right
+ if(UseQPixmapForImageLoading || (typeChecked && !formatType))
{
#ifdef CACHE_DEBUG
kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
@@ -881,14 +896,76 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
// ------------------------------------------------------------------------------------------
+// Class LoaderNotificationReceiver ==============================================================
+
+ at interface LoaderNotificationReceiver : NSObject
+{
+ @public
+ Loader *m_loader;
+}
+
+-(id)initWithLoader:(Loader *)loader;
+
+ at end
+
+ at implementation LoaderNotificationReceiver
+
+-(id)initWithLoader:(Loader *)loader
+{
+ m_loader = loader;
+}
+
+-(void)cacheDataAvailable:(NSNotification *)notification
+{
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotData(job, (const char *)[data cacheData], [data cacheDataSize]);
+}
+
+-(void)cacheFinished:(NSNotification *)notification
+{
+ // FIXME: need an implementation for this
+ id <WCURICacheData> data = [notification object];
+ KIO::Job *job = static_cast<KIO::Job *>([data userData]);
+ m_loader->slotFinished(job);
+}
+
+ at end
+
+namespace khtml {
+
+class LoaderPrivate
+{
+friend class Loader;
+public:
+ LoaderPrivate(Loader *parent)
+ {
+ _parent = parent;
+ m_recv = [[LoaderNotificationReceiver alloc] initWithLoader:parent];
+ }
+
+ ~LoaderPrivate()
+ {
+ [m_recv release];
+ }
+
+private:
+ Loader *_parent;
+ LoaderNotificationReceiver *m_recv;
+};
+
+} // namespace khtml
+
Loader::Loader() : QObject()
{
m_requestsPending.setAutoDelete( true );
m_requestsLoading.setAutoDelete( true );
+ d = new LoaderPrivate(this);
}
Loader::~Loader()
{
+ delete d;
}
void Loader::load(CachedObject *object, const DOMString &baseURL, bool incremental)
@@ -911,6 +988,11 @@ void Loader::servePendingRequests()
kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
#endif
+#ifdef _KWQ_
+ KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+ m_requestsLoading.insert(job, req);
+ job->begin(d->m_recv, job);
+#else
KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
if (!req->object->accept().isEmpty())
@@ -924,6 +1006,8 @@ void Loader::servePendingRequests()
KIO::Scheduler::scheduleJob( job );
m_requestsLoading.insert(job, req);
+#endif
+
}
void Loader::slotFinished( KIO::Job* job )
@@ -955,6 +1039,26 @@ void Loader::slotFinished( KIO::Job* job )
servePendingRequests();
}
+#ifdef _KWQ_
+void Loader::slotData( KIO::Job*job, const char *data, int size )
+{
+ Request *r = m_requestsLoading[job];
+ if(!r) {
+ kdDebug( 6060 ) << "got data for unknown request!" << endl;
+ return;
+ }
+
+ if ( !r->m_buffer.isOpen() )
+ r->m_buffer.open( IO_WriteOnly );
+
+ r->m_buffer.writeBlock( data, size );
+
+ if(r->incremental)
+ r->object->data( r->m_buffer, false );
+}
+
+
+#else
void Loader::slotData( KIO::Job*job, const QByteArray &data )
{
Request *r = m_requestsLoading[job];
@@ -971,6 +1075,7 @@ void Loader::slotData( KIO::Job*job, const QByteArray &data )
if(r->incremental)
r->object->data( r->m_buffer, false );
}
+#endif
int Loader::numRequests( const DOMString &baseURL ) const
{
@@ -1031,6 +1136,10 @@ void Loader::cancelRequests( const DOMString &baseURL )
if ( lIt.current()->m_baseURL == baseURL )
{
//kdDebug( 6060 ) << "cancelling loading request for " << lIt.current()->object->url().string() << endl;
+ //KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
+ //Cache::removeCacheEntry( lIt.current()->object );
+ //m_requestsLoading.remove( lIt.currentKey() );
+ //job->kill();
KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
Cache::removeCacheEntry( lIt.current()->object );
m_requestsLoading.remove( lIt.currentKey() );
@@ -1109,8 +1218,13 @@ void Cache::clear()
CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, const DOMString &baseUrl, bool reload, int _expireDate )
{
+
+ fprintf(stderr, "!!! Cache::requestImage: url = %s\n", url.string().latin1());
+ fprintf(stderr, "!!! Cache::requestImage: baseUrl = %s\n", baseUrl.string().latin1());
+
// this brings the _url to a standard form...
KURL kurl = completeURL( url, baseUrl );
+ fprintf(stderr, "!!! Cache::requestImage: complete url = %s\n", kurl.url().latin1());
if( kurl.isMalformed() )
{
#ifdef CACHE_DEBUG
@@ -1128,6 +1242,7 @@ CachedImage *Cache::requestImage( const DocLoader* dl, const DOMString & url, co
kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
#endif
CachedImage *im = new CachedImage(kurl.url(), baseUrl, reload, _expireDate);
+ fprintf(stderr, "!!! Cache::requestImage: im->baseURL() = %s\n", im->baseURL().string().latin1());
if ( dl && dl->autoloadImages() ) Cache::loader()->load(im, im->baseURL(), true);
cache->insert( kurl.url(), im );
lru->append( kurl.url() );
@@ -1279,7 +1394,7 @@ void Cache::flush(bool force)
--it; // Update iterator, we might delete the current entry later on.
CachedObject *o = cache->find( url );
- if( !o->canDelete() || o->status() == CachedObject::Persistent ) {
+ if( !o || !o->canDelete() || o->status() == CachedObject::Persistent ) {
continue; // image is still used or cached permanently
// in this case don't count it for the size of the cache.
}
@@ -1378,6 +1493,3 @@ void Cache::removeCacheEntry( CachedObject *object )
if ( object->canDelete() )
delete object;
}
-
-
-#include "loader.moc"
diff --git a/WebCore/src/kwq/Makefile.in b/WebCore/src/kwq/Makefile.in
index 00c6804..07b3233 100644
--- a/WebCore/src/kwq/Makefile.in
+++ b/WebCore/src/kwq/Makefile.in
@@ -121,6 +121,7 @@ MMOBJECTS = \
KWQCString.o \
KWQRegion.o \
KWQDateTime.o \
+ KWQKloader.o \
$(NULL)
MOBJECTS = \
diff --git a/WebCore/src/kwq/kdecore/kglobal.h b/WebCore/src/kwq/kdecore/kglobal.h
index 4742402..4295c2f 100644
--- a/WebCore/src/kwq/kdecore/kglobal.h
+++ b/WebCore/src/kwq/kdecore/kglobal.h
@@ -37,6 +37,7 @@ class KCharsets;
class KLocale;
class KStandardDirs;
class KConfig;
+class KWQStaticStringDict;
#define kMin(a, b) ((a) < (b) ? (a) : (b))
#define kMax(a, b) ((a) > (b) ? (a) : (b))
@@ -51,6 +52,8 @@ public:
// enums -------------------------------------------------------------------
// constants ---------------------------------------------------------------
+ static KWQStaticStringDict *staticStringDict;
+
// static member functions -------------------------------------------------
static KInstance *instance();
diff --git a/WebCore/src/kwq/khtml/khtml_settings.h b/WebCore/src/kwq/khtml/khtml_settings.h
index fc6a9a0..a5b26da 100644
--- a/WebCore/src/kwq/khtml/khtml_settings.h
+++ b/WebCore/src/kwq/khtml/khtml_settings.h
@@ -73,6 +73,7 @@ public:
private:
QValueList<int> m_fontSizes;
+ QString m_fontFamilies;
};
#endif
diff --git a/WebCore/src/kwq/kio/jobclasses.h b/WebCore/src/kwq/kio/jobclasses.h
index a09ac43..5f51556 100644
--- a/WebCore/src/kwq/kio/jobclasses.h
+++ b/WebCore/src/kwq/kio/jobclasses.h
@@ -158,20 +158,27 @@ public:
void addMetaData(const QString &key, const QString &value);
void kill(bool quietly=TRUE);
- // this is special sauce for our implementation
- void begin();
+#ifdef _KWQ_
+#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
+ void begin(id requestor, void *userData);
+#else
+ void begin(void *requestor, void *userData);
+#endif
+#endif
// operators ---------------------------------------------------------------
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
+#ifdef _KWQ_
private:
KURL _url;
bool _reload;
bool _showProgressInfo;
int _status;
TransferJobPrivate *d;
+#endif
// add copy constructor
// this private declaration prevents copying
diff --git a/WebCore/src/kwq/tests/qt/Makefile.in b/WebCore/src/kwq/tests/qt/Makefile.in
index 3ac7bca..24206e8 100644
--- a/WebCore/src/kwq/tests/qt/Makefile.in
+++ b/WebCore/src/kwq/tests/qt/Makefile.in
@@ -62,6 +62,8 @@ CMMFLAGS = $(BASECMMFLAGS)
LIBS = objc-dummy.o \
-framework Cocoa \
+ -F/symroots \
+ -framework WebKit \
-lwebcore \
$(NULL)
diff --git a/WebCore/src/kwq/tests/qt/qstring-test.cpp b/WebCore/src/kwq/tests/qt/qstring-test.cpp
index 6cf69c3..98e264a 100644
--- a/WebCore/src/kwq/tests/qt/qstring-test.cpp
+++ b/WebCore/src/kwq/tests/qt/qstring-test.cpp
@@ -219,7 +219,5 @@ int main() {
//cout << (c4 >= s33) << endl;
cout << (s33 >= s34) << endl;
-
-
return 0;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list