[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:15:46 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 8e5c5e3680f2b38cf1b6dea95ec33aef7d1376a7
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu May 30 21:52:06 2002 +0000
WebCore:
Cut down our copied and pasted code even more.
* WebCore.exp: Change what's exported for things that moved from
KHTMLPart into KWQKHTMLPartImpl.
* khtml/.cvsignore:
* khtml/css/.cvsignore:
* khtml/dom/.cvsignore:
* khtml/ecma/.cvsignore:
* khtml/html/.cvsignore:
* khtml/java/.cvsignore:
* khtml/misc/.cvsignore:
* khtml/rendering/.cvsignore:
* khtml/xml/.cvsignore:
Some .cvsignore hygiene.
* khtml/khtml_part.cpp: Use a lot more of this file, rather than using a copy inside
the kwq directory. Now we have KWQKHTMLPartImpl for the part that does need to be in kwq.
* khtml/khtml_part.h: Add KWQKHTMLPartImpl pointer, remove most of the other APPLE_CHANGES.
* khtml/khtmlpart_p.h: Remove almost all of the APPLE_CHANGES.
* kwq/KWQKHTMLPart.mm: Changed everything from being part of KHTMLPart to be a separate
KWQKHTMLPartImpl class. Minimized copied and pasted code; still more to do.
* kwq/KWQKHTMLPartImpl.h: Added. Interface so KHTMLPart can call into kwq as necessary.
* khtml/misc/Makefile.am: Added loader.cpp.
* khtml/misc/loader.cpp: Added from KDE 3.0. Rolled most of the changes from KWQKloader.mm
in here. The kwq-specific part is now in a KWQLoaderImpl class.
* khtml/misc/loader.h: Replace LoaderPrivate with KWQLoaderImpl.
* khtml/misc/loader.moc: Added empty file.
* kwq/KWQKloader.mm: Changed everything to be a separate KWQLoaderImpl class.
Minimized copied and pasted code.
* kwq/KWQLoaderImpl.h: Added. Interface so loader can call into kwq as necessary.
* kwq/loader.moc: Removed empty file.
* kwq/kparts/historyprovider.h: Add HistoryProvider::insert.
* kwq/KWQKHistoryProvider.mm: Add HistoryProvider::insert.
* kwq/KWQKLocale.mm: (KLocale::language): Simplify.
* kwq/KWQListBox.h:
* kwq/KWQNSTextField.h:
Use import instead of include for Cocoa.h.
* kwq/KWQScrollView.mm: (QScrollView::contentsToViewport): Implement this.
* kwq/external.h: Add declarations so this can be included cleanly.
* kwq/khtml/khtml_pagecache.h: Put a no-op cache in here so we don't have to do so
many APPLE_CHANGES ifdefs.
* kwq/kparts/part.h: Put ref/deref and event/customEvent in here so they don't need
to be added to KHTMLPart.
* kwq/kio/scheduler.h: Add <qtimer.h> include to help us build (not sure if it's
really needed.
* kwq/kparts/partmanager.h: Add <qdatetime.h> include to help us build (not sure if it's
really needed.
WebKit:
Use methods in KWQKHTMLPartImpl that were moved there from KHTMLPart.
* WebView.subproj/IFMainURLHandleClient.mm:
(-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
(-[IFMainURLHandleClient processData:isComplete:allDataReceived:]):
* WebView.subproj/IFWebDataSource.mm:
(-[IFWebDataSource documentText]):
* WebView.subproj/IFWebDataSourcePrivate.mm:
(-[IFWebDataSource _setController:]):
* WebView.subproj/IFWebFramePrivate.mm:
(-[IFWebFrame _isLoadComplete]):
* WebView.subproj/IFWebView.mm:
(-[IFWebView provisionalDataSourceChanged:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 2376839..6e6071a 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,63 @@
+2002-05-30 Darin Adler <darin at apple.com>
+
+ Cut down our copied and pasted code even more.
+
+ * WebCore.exp: Change what's exported for things that moved from
+ KHTMLPart into KWQKHTMLPartImpl.
+
+ * khtml/.cvsignore:
+ * khtml/css/.cvsignore:
+ * khtml/dom/.cvsignore:
+ * khtml/ecma/.cvsignore:
+ * khtml/html/.cvsignore:
+ * khtml/java/.cvsignore:
+ * khtml/misc/.cvsignore:
+ * khtml/rendering/.cvsignore:
+ * khtml/xml/.cvsignore:
+ Some .cvsignore hygiene.
+
+ * khtml/khtml_part.cpp: Use a lot more of this file, rather than using a copy inside
+ the kwq directory. Now we have KWQKHTMLPartImpl for the part that does need to be in kwq.
+ * khtml/khtml_part.h: Add KWQKHTMLPartImpl pointer, remove most of the other APPLE_CHANGES.
+ * khtml/khtmlpart_p.h: Remove almost all of the APPLE_CHANGES.
+ * kwq/KWQKHTMLPart.mm: Changed everything from being part of KHTMLPart to be a separate
+ KWQKHTMLPartImpl class. Minimized copied and pasted code; still more to do.
+ * kwq/KWQKHTMLPartImpl.h: Added. Interface so KHTMLPart can call into kwq as necessary.
+
+ * khtml/misc/Makefile.am: Added loader.cpp.
+ * khtml/misc/loader.cpp: Added from KDE 3.0. Rolled most of the changes from KWQKloader.mm
+ in here. The kwq-specific part is now in a KWQLoaderImpl class.
+ * khtml/misc/loader.h: Replace LoaderPrivate with KWQLoaderImpl.
+ * khtml/misc/loader.moc: Added empty file.
+ * kwq/KWQKloader.mm: Changed everything to be a separate KWQLoaderImpl class.
+ Minimized copied and pasted code.
+ * kwq/KWQLoaderImpl.h: Added. Interface so loader can call into kwq as necessary.
+ * kwq/loader.moc: Removed empty file.
+
+ * kwq/kparts/historyprovider.h: Add HistoryProvider::insert.
+ * kwq/KWQKHistoryProvider.mm: Add HistoryProvider::insert.
+
+ * kwq/KWQKLocale.mm: (KLocale::language): Simplify.
+
+ * kwq/KWQListBox.h:
+ * kwq/KWQNSTextField.h:
+ Use import instead of include for Cocoa.h.
+
+ * kwq/KWQScrollView.mm: (QScrollView::contentsToViewport): Implement this.
+
+ * kwq/external.h: Add declarations so this can be included cleanly.
+
+ * kwq/khtml/khtml_pagecache.h: Put a no-op cache in here so we don't have to do so
+ many APPLE_CHANGES ifdefs.
+
+ * kwq/kparts/part.h: Put ref/deref and event/customEvent in here so they don't need
+ to be added to KHTMLPart.
+
+ * kwq/kio/scheduler.h: Add <qtimer.h> include to help us build (not sure if it's
+ really needed.
+ * kwq/kparts/partmanager.h: Add <qdatetime.h> include to help us build (not sure if it's
+ really needed.
+
=== Alexander-7 ===
2002-05-29 Richard Williamson <rjw at apple.com>
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 2376839..6e6071a 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,63 @@
+2002-05-30 Darin Adler <darin at apple.com>
+
+ Cut down our copied and pasted code even more.
+
+ * WebCore.exp: Change what's exported for things that moved from
+ KHTMLPart into KWQKHTMLPartImpl.
+
+ * khtml/.cvsignore:
+ * khtml/css/.cvsignore:
+ * khtml/dom/.cvsignore:
+ * khtml/ecma/.cvsignore:
+ * khtml/html/.cvsignore:
+ * khtml/java/.cvsignore:
+ * khtml/misc/.cvsignore:
+ * khtml/rendering/.cvsignore:
+ * khtml/xml/.cvsignore:
+ Some .cvsignore hygiene.
+
+ * khtml/khtml_part.cpp: Use a lot more of this file, rather than using a copy inside
+ the kwq directory. Now we have KWQKHTMLPartImpl for the part that does need to be in kwq.
+ * khtml/khtml_part.h: Add KWQKHTMLPartImpl pointer, remove most of the other APPLE_CHANGES.
+ * khtml/khtmlpart_p.h: Remove almost all of the APPLE_CHANGES.
+ * kwq/KWQKHTMLPart.mm: Changed everything from being part of KHTMLPart to be a separate
+ KWQKHTMLPartImpl class. Minimized copied and pasted code; still more to do.
+ * kwq/KWQKHTMLPartImpl.h: Added. Interface so KHTMLPart can call into kwq as necessary.
+
+ * khtml/misc/Makefile.am: Added loader.cpp.
+ * khtml/misc/loader.cpp: Added from KDE 3.0. Rolled most of the changes from KWQKloader.mm
+ in here. The kwq-specific part is now in a KWQLoaderImpl class.
+ * khtml/misc/loader.h: Replace LoaderPrivate with KWQLoaderImpl.
+ * khtml/misc/loader.moc: Added empty file.
+ * kwq/KWQKloader.mm: Changed everything to be a separate KWQLoaderImpl class.
+ Minimized copied and pasted code.
+ * kwq/KWQLoaderImpl.h: Added. Interface so loader can call into kwq as necessary.
+ * kwq/loader.moc: Removed empty file.
+
+ * kwq/kparts/historyprovider.h: Add HistoryProvider::insert.
+ * kwq/KWQKHistoryProvider.mm: Add HistoryProvider::insert.
+
+ * kwq/KWQKLocale.mm: (KLocale::language): Simplify.
+
+ * kwq/KWQListBox.h:
+ * kwq/KWQNSTextField.h:
+ Use import instead of include for Cocoa.h.
+
+ * kwq/KWQScrollView.mm: (QScrollView::contentsToViewport): Implement this.
+
+ * kwq/external.h: Add declarations so this can be included cleanly.
+
+ * kwq/khtml/khtml_pagecache.h: Put a no-op cache in here so we don't have to do so
+ many APPLE_CHANGES ifdefs.
+
+ * kwq/kparts/part.h: Put ref/deref and event/customEvent in here so they don't need
+ to be added to KHTMLPart.
+
+ * kwq/kio/scheduler.h: Add <qtimer.h> include to help us build (not sure if it's
+ really needed.
+ * kwq/kparts/partmanager.h: Add <qdatetime.h> include to help us build (not sure if it's
+ really needed.
+
=== Alexander-7 ===
2002-05-29 Richard Williamson <rjw at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 2376839..6e6071a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,63 @@
+2002-05-30 Darin Adler <darin at apple.com>
+
+ Cut down our copied and pasted code even more.
+
+ * WebCore.exp: Change what's exported for things that moved from
+ KHTMLPart into KWQKHTMLPartImpl.
+
+ * khtml/.cvsignore:
+ * khtml/css/.cvsignore:
+ * khtml/dom/.cvsignore:
+ * khtml/ecma/.cvsignore:
+ * khtml/html/.cvsignore:
+ * khtml/java/.cvsignore:
+ * khtml/misc/.cvsignore:
+ * khtml/rendering/.cvsignore:
+ * khtml/xml/.cvsignore:
+ Some .cvsignore hygiene.
+
+ * khtml/khtml_part.cpp: Use a lot more of this file, rather than using a copy inside
+ the kwq directory. Now we have KWQKHTMLPartImpl for the part that does need to be in kwq.
+ * khtml/khtml_part.h: Add KWQKHTMLPartImpl pointer, remove most of the other APPLE_CHANGES.
+ * khtml/khtmlpart_p.h: Remove almost all of the APPLE_CHANGES.
+ * kwq/KWQKHTMLPart.mm: Changed everything from being part of KHTMLPart to be a separate
+ KWQKHTMLPartImpl class. Minimized copied and pasted code; still more to do.
+ * kwq/KWQKHTMLPartImpl.h: Added. Interface so KHTMLPart can call into kwq as necessary.
+
+ * khtml/misc/Makefile.am: Added loader.cpp.
+ * khtml/misc/loader.cpp: Added from KDE 3.0. Rolled most of the changes from KWQKloader.mm
+ in here. The kwq-specific part is now in a KWQLoaderImpl class.
+ * khtml/misc/loader.h: Replace LoaderPrivate with KWQLoaderImpl.
+ * khtml/misc/loader.moc: Added empty file.
+ * kwq/KWQKloader.mm: Changed everything to be a separate KWQLoaderImpl class.
+ Minimized copied and pasted code.
+ * kwq/KWQLoaderImpl.h: Added. Interface so loader can call into kwq as necessary.
+ * kwq/loader.moc: Removed empty file.
+
+ * kwq/kparts/historyprovider.h: Add HistoryProvider::insert.
+ * kwq/KWQKHistoryProvider.mm: Add HistoryProvider::insert.
+
+ * kwq/KWQKLocale.mm: (KLocale::language): Simplify.
+
+ * kwq/KWQListBox.h:
+ * kwq/KWQNSTextField.h:
+ Use import instead of include for Cocoa.h.
+
+ * kwq/KWQScrollView.mm: (QScrollView::contentsToViewport): Implement this.
+
+ * kwq/external.h: Add declarations so this can be included cleanly.
+
+ * kwq/khtml/khtml_pagecache.h: Put a no-op cache in here so we don't have to do so
+ many APPLE_CHANGES ifdefs.
+
+ * kwq/kparts/part.h: Put ref/deref and event/customEvent in here so they don't need
+ to be added to KHTMLPart.
+
+ * kwq/kio/scheduler.h: Add <qtimer.h> include to help us build (not sure if it's
+ really needed.
+ * kwq/kparts/partmanager.h: Add <qdatetime.h> include to help us build (not sure if it's
+ really needed.
+
=== Alexander-7 ===
2002-05-29 Richard Williamson <rjw at apple.com>
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index 1d93cd6..ddd74ab 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -2,7 +2,13 @@
.objc_class_name_WebCoreViewFactory
.objc_class_name_WebCoreImageRendererFactory
__Z27WCSetIFLoadProgressMakeFuncPFP11objc_objectvE
+__Z28WCSetIFWebDataSourceMakeFuncPFP11objc_objectPvS1_jE
__ZN11QMouseEventC1EN6QEvent4TypeERK6QPointii
+__ZN16KWQKHTMLPartImpl10setBaseURLERK4KURL
+__ZN16KWQKHTMLPartImpl13setDataSourceEP15IFWebDataSource
+__ZN16KWQKHTMLPartImpl14gotoBaseAnchorEv
+__ZN16KWQKHTMLPartImpl7setViewEP9KHTMLView
+__ZN16KWQKHTMLPartImpl8slotDataEP8NSStringPKcib
__ZN3DOM12DocumentImpl19updateStyleSelectorEv
__ZN3DOM9DOMStringD1Ev
__ZN3DOM9DomShared3refEv
@@ -12,27 +18,21 @@ __ZN4KURLD1Ev
__ZN5khtml5Cache13getStatisticsEv
__ZN5khtml5Cache16setCacheDisabledEb
__ZN5khtml5Cache8flushAllEv
-__ZN6QPointC1Eii
__ZN6QEventD2Ev
+__ZN6QPointC1Eii
+__ZN7QString12fromNSStringEP8NSString
__ZN7QStringD1Ev
__ZN7QWidget7setViewEP6NSView
__ZN8QPainterC1EP7QWidget
__ZN8QPainterD1Ev
-__ZN9KHTMLPart10setBaseURLERK4KURL
-__ZN9KHTMLPart13setDataSourceEP15IFWebDataSource
-__ZN9KHTMLPart14gotoBaseAnchorEv
-__ZN9KHTMLPart7setViewEP9KHTMLView
-__ZN9KHTMLPart8slotDataEP8NSStringPKcib
__ZN9KHTMLPartC1EP7QWidgetPKcP7QObjectS3_NS_10GUIProfileE
__ZN9KHTMLView6layoutEv
__ZN9KHTMLViewC1EP9KHTMLPartP7QWidgetPKc
+__ZN9QKeyEventC1EN6QEvent4TypeEiiiRK7QStringbt
+__ZNK16KWQKHTMLPartImpl14documentSourceEv
__ZNK3DOM8NodeImpl16recursive_toHTMLEb
__ZNK3DOM8NodeImpl8rendererEv
__ZNK3DOM9DOMString6stringEv
__ZNK7QString6latin1Ev
__ZNK7QWidget7getViewEv
__ZNK9KHTMLPart10xmlDocImplEv
-__ZNK9KHTMLPart14documentSourceEv
-__Z28WCSetIFWebDataSourceMakeFuncPFP11objc_objectPvS1_jE
-__ZN7QString12fromNSStringEP8NSString
-__ZN9QKeyEventC1EN6QEvent4TypeEiiiRK7QStringbt
diff --git a/WebCore/khtml/.cvsignore b/WebCore/khtml/.cvsignore
index 8bf79da..051d1bd 100644
--- a/WebCore/khtml/.cvsignore
+++ b/WebCore/khtml/.cvsignore
@@ -1,13 +1,3 @@
Makefile
Makefile.in
-testkhtml
-testcss
-testrender
-SunWS_cache
-ir.out
-testkhtml_static
-*.moc
.deps
-.libs
-*.lo
-*.la
diff --git a/WebCore/khtml/css/.cvsignore b/WebCore/khtml/css/.cvsignore
index 53a4f50..3c0f24c 100644
--- a/WebCore/khtml/css/.cvsignore
+++ b/WebCore/khtml/css/.cvsignore
@@ -9,6 +9,3 @@ cssproperties.strip
cssproperties.h
.deps
*-stamp
-*.lo
-*.la
-.libs
diff --git a/WebCore/khtml/dom/.cvsignore b/WebCore/khtml/dom/.cvsignore
index dc4caac..e440faf 100644
--- a/WebCore/khtml/dom/.cvsignore
+++ b/WebCore/khtml/dom/.cvsignore
@@ -1,6 +1,3 @@
Makefile.in
Makefile
.deps
-.libs
-*.lo
-*.la
diff --git a/WebCore/khtml/ecma/.cvsignore b/WebCore/khtml/ecma/.cvsignore
index 4bf0791..680bee0 100644
--- a/WebCore/khtml/ecma/.cvsignore
+++ b/WebCore/khtml/ecma/.cvsignore
@@ -1,9 +1,4 @@
Makefile.in
Makefile
-testecma
.deps
-.libs
-*.la
-*.lo
-*.moc
*.lut.h
diff --git a/WebCore/khtml/html/.cvsignore b/WebCore/khtml/html/.cvsignore
index 2290cd7..3582895 100644
--- a/WebCore/khtml/html/.cvsignore
+++ b/WebCore/khtml/html/.cvsignore
@@ -1,4 +1,3 @@
Makefile
Makefile.in
-*.moc
kentities.c
diff --git a/WebCore/khtml/java/.cvsignore b/WebCore/khtml/java/.cvsignore
index 2a6ec4d..051d1bd 100644
--- a/WebCore/khtml/java/.cvsignore
+++ b/WebCore/khtml/java/.cvsignore
@@ -1,7 +1,3 @@
Makefile
Makefile.in
.deps
-.libs
-*.lo
-*.la
-*.moc
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 8b7fb67..e16989f 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -31,6 +31,7 @@
#define DIRECT_LINKAGE_TO_ECMA
#define QT_NO_CLIPBOARD
#define QT_NO_DRAGANDDROP
+#include <KWQKHTMLPartImpl.h>
#endif
#include "khtml_pagecache.h"
@@ -133,6 +134,8 @@ FrameList::Iterator FrameList::find( const QString &name )
return it;
}
+#endif // APPLE_CHANGES
+
KHTMLPart::KHTMLPart( QWidget *parentWidget, const char *widgetname, QObject *parent, const char *name,
GUIProfile prof )
: KParts::ReadOnlyPart( parent, name )
@@ -140,9 +143,15 @@ KHTMLPart::KHTMLPart( QWidget *parentWidget, const char *widgetname, QObject *pa
d = 0;
KHTMLFactory::registerPart( this );
setInstance( KHTMLFactory::instance(), prof == BrowserViewGUI && !parentPart() );
+#ifdef APPLE_CHANGES
+ init( 0, prof );
+#else
init( new KHTMLView( this, parentWidget, widgetname ), prof );
+#endif
}
+#ifndef APPLE_CHANGES
+
KHTMLPart::KHTMLPart( KHTMLView *view, QObject *parent, const char *name, GUIProfile prof )
: KParts::ReadOnlyPart( parent, name )
{
@@ -153,7 +162,7 @@ KHTMLPart::KHTMLPart( KHTMLView *view, QObject *parent, const char *name, GUIPro
init( view, prof );
}
-#endif
+#endif // APPLE_CHANGES
void KHTMLPart::init( KHTMLView *view, GUIProfile prof )
{
@@ -244,15 +253,15 @@ void KHTMLPart::init( KHTMLView *view, GUIProfile prof )
d->m_dcopobject = new KHTMLPartIface(this);
#endif
+
+#ifdef APPLE_CHANGES
+ impl = new KWQKHTMLPartImpl(this);
+#endif
}
KHTMLPart::~KHTMLPart()
{
//kdDebug(6050) << "KHTMLPart::~KHTMLPart " << this << endl;
-#ifdef APPLE_CHANGES
- killTimer(d->m_redirectionTimer);
- d->m_redirectionTimer = 0;
-#endif
#ifndef APPLE_CHANGES
if ( d->m_findDialog )
disconnect( d->m_findDialog, SIGNAL( destroyed() ),
@@ -293,6 +302,10 @@ KHTMLPart::~KHTMLPart()
d->m_view->viewport()->hide();
d->m_view->m_part = 0;
}
+
+#ifdef APPLE_CHANGES
+ delete impl;
+#endif
delete d; d = 0;
KHTMLFactory::deregisterPart( this );
@@ -330,9 +343,9 @@ bool KHTMLPart::restoreURL( const KURL &url )
m_url = url;
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->fetchData( d->m_cacheId, this, SLOT(slotRestoreData(const QByteArray &)));
+#ifndef APPLE_CHANGES
emit started( 0L );
#endif
@@ -340,10 +353,12 @@ bool KHTMLPart::restoreURL( const KURL &url )
}
-#ifndef APPLE_CHANGES
-
bool KHTMLPart::openURL( const KURL &url )
{
+#ifdef APPLE_CHANGES
+ impl->openURL(url);
+ return true;
+#else
kdDebug( 6050 ) << "KHTMLPart(" << this << ")::openURL " << url.url() << endl;
d->m_redirectionTimer.stop();
@@ -472,17 +487,15 @@ bool KHTMLPart::openURL( const KURL &url )
emit started( 0L );
return true;
+#endif // APPLE_CHANGES
}
-#endif
bool KHTMLPart::closeURL()
{
if ( d->m_job )
{
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->cancelEntry(d->m_cacheId);
-#endif
d->m_job->kill();
d->m_job = 0;
}
@@ -502,9 +515,7 @@ bool KHTMLPart::closeURL()
d->m_bLoadEventEmitted = true; // don't want that one either
d->m_bReloading = false;
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->cancelFetch(this);
-#endif
if ( d->m_doc && d->m_doc->parsing() )
{
kdDebug( 6050 ) << " was still parsing... calling end " << endl;
@@ -523,10 +534,10 @@ bool KHTMLPart::closeURL()
d->m_workingURL = KURL();
-#ifndef APPLE_CHANGES
if ( d->m_doc && d->m_doc->docLoader() )
khtml::Cache::loader()->cancelRequests( d->m_doc->docLoader() );
+#ifndef APPLE_CHANGES
// tell all subframes to stop as well
ConstFrameIt it = d->m_frames.begin();
ConstFrameIt end = d->m_frames.end();
@@ -753,6 +764,8 @@ bool KHTMLPart::pluginsEnabled() const
return d->m_bPluginsEnabled;
}
+#ifndef APPLE_CHANGES
+
void KHTMLPart::slotShowDocument( const QString &url, const QString &target )
{
// this is mostly copied from KHTMLPart::slotChildURLRequest. The better approach
@@ -784,7 +797,6 @@ void KHTMLPart::slotShowDocument( const QString &url, const QString &target )
}
else if ( frameName != QString::fromLatin1( "_self" ) )
{
-#ifndef APPLE_CHANGES
khtml::ChildFrame *_frame = recursiveFrameRequest( url, args );
if ( !_frame )
@@ -794,7 +806,6 @@ void KHTMLPart::slotShowDocument( const QString &url, const QString &target )
}
child = _frame;
-#endif
}
}
@@ -814,6 +825,8 @@ void KHTMLPart::slotShowDocument( const QString &url, const QString &target )
}
}
+#endif // APPLE_CHANGES
+
void KHTMLPart::slotDebugDOMTree()
{
if ( d->m_doc && d->m_doc->firstChild() )
@@ -1017,9 +1030,7 @@ void KHTMLPart::slotData( KIO::Job* kio_job, const QByteArray &data )
d->m_doc->docLoader()->setReloading(d->m_bReloading);
d->m_workingURL = KURL();
-#ifndef APPLE_CHANGES
d->m_cacheId = KHTMLPageCache::self()->createCacheEntry();
-#endif
// When the first data arrives, the metadata has just been made available
d->m_bSecurityInQuestion = false;
@@ -1110,9 +1121,7 @@ void KHTMLPart::slotData( KIO::Job* kio_job, const QByteArray &data )
//kdDebug() << "KHTMLPart::slotData metadata modified: " << d->m_lastModified << endl;
}
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->addData(d->m_cacheId, data);
-#endif
write( data.data(), data.size() );
}
@@ -1265,9 +1274,7 @@ void KHTMLPart::slotFinished( KIO::Job * job )
{
if (job->error())
{
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->cancelEntry(d->m_cacheId);
-#endif
d->m_job = 0L;
#ifndef APPLE_CHANGES
emit canceled( job->errorString() );
@@ -1281,9 +1288,7 @@ void KHTMLPart::slotFinished( KIO::Job * job )
}
//kdDebug( 6050 ) << "slotFinished" << endl;
-#ifndef APPLE_CHANGES
KHTMLPageCache::self()->endData(d->m_cacheId);
-#endif
if ( d->m_doc && d->m_doc->docLoader()->expireDate() && m_url.protocol().lower().startsWith("http"))
KIO::http_update_cache(m_url, false, d->m_doc->docLoader()->expireDate());
@@ -1295,17 +1300,17 @@ void KHTMLPart::slotFinished( KIO::Job * job )
end(); //will emit completed()
}
-#ifndef APPLE_CHANGES
-
void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
{
+#ifdef APPLE_CHANGES
+ impl->begin(url, xOffset, xOffset);
+#else
clear();
d->m_bCleared = false;
d->m_cacheId = 0;
d->m_bComplete = false;
d->m_bLoadEventEmitted = false;
-#ifndef APPLE_CHANGES
if(url.isValid()) {
QString urlString = url.url();
KHTMLFactory::vLinks()->insert( urlString );
@@ -1314,7 +1319,6 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
KHTMLFactory::vLinks()->insert( urlString2 );
}
}
-#endif
// ###
//stopParser();
@@ -1328,7 +1332,6 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
m_url = url;
KURL baseurl;
-#ifndef APPLE_CHANGES
if ( !m_url.isEmpty() )
{
KURL::List lst = KURL::split( m_url );
@@ -1342,7 +1345,6 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
}
else
emit setWindowCaption( i18n( "no title", "* Unknown *" ) );
-#endif
// ### not sure if XHTML documents served as text/xml should use DocumentImpl or HTMLDocumentImpl
if (args.serviceType == "text/xml")
@@ -1357,11 +1359,8 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
// We prefer m_baseURL over m_url because m_url changes when we are
// about to load a new page.
d->m_doc->setBaseURL( baseurl.url() );
-#ifndef APPLE_CHANGES
d->m_doc->docLoader()->setShowAnimations( KHTMLFactory::defaultHTMLSettings()->showAnimations() );
-#endif
-#ifndef APPLE_CHANGES
// Inherit domain from parent
KHTMLPart* parent = parentPart();
if (d->m_doc->isHTMLDocument() && parent && parent->d->m_doc && parent->d->m_doc->isHTMLDocument()) {
@@ -1372,30 +1371,29 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
d->m_paUseStylesheet->setItems(QStringList());
d->m_paUseStylesheet->setEnabled( false );
-#endif
setAutoloadImages( KHTMLFactory::defaultHTMLSettings()->autoLoadImages() );
QString userStyleSheet = KHTMLFactory::defaultHTMLSettings()->userStyleSheet();
if ( !userStyleSheet.isEmpty() )
setUserStyleSheet( KURL( userStyleSheet ) );
-#ifndef APPLE_CHANGES
d->m_doc->setRestoreState(args.docState);
-#endif
d->m_doc->open();
// clear widget
d->m_view->resizeContents( 0, 0 );
connect(d->m_doc,SIGNAL(finishedParsing()),this,SLOT(slotFinishedParsing()));
-#ifndef APPLE_CHANGES
emit d->m_extension->enableAction( "print", true );
-#endif
d->m_doc->setParsing(true);
+#endif // APPLE_CHANGES
}
void KHTMLPart::write( const char *str, int len )
{
+#ifdef APPLE_CHANGES
+ impl->write(str, len);
+#else
if ( !d->m_decoder ) {
d->m_decoder = new khtml::Decoder();
if(d->m_encoding != QString::null)
@@ -1429,10 +1427,9 @@ void KHTMLPart::write( const char *str, int len )
Tokenizer* t = d->m_doc->tokenizer();
if(t)
t->write( decoded, true );
+#endif // APPLE_CHANGES
}
-#endif
-
void KHTMLPart::write( const QString &str )
{
if ( str.isNull() )
@@ -1450,18 +1447,19 @@ void KHTMLPart::write( const QString &str )
t->write( str, true );
}
-#ifndef APPLE_CHANGES
-
void KHTMLPart::end()
{
+#ifdef APPLE_CHANGES
+ impl->end();
+#else
// make sure nothing's left in there...
if(d->m_decoder)
write(d->m_decoder->flush());
if (d->m_doc)
d->m_doc->finishParsing();
+#endif
}
-#endif
void KHTMLPart::paint(QPainter *p, const QRect &rc, int yOff, bool *more)
{
@@ -1655,19 +1653,19 @@ void KHTMLPart::checkCompleted()
void KHTMLPart::checkEmitLoadEvent()
{
-#ifndef APPLE_CHANGES
if ( d->m_bLoadEventEmitted || !d->m_doc || d->m_doc->parsing() ) return;
+#ifndef APPLE_CHANGES
ConstFrameIt it = d->m_frames.begin();
ConstFrameIt end = d->m_frames.end();
for (; it != end; ++it )
if ( !(*it).m_bCompleted ) // still got a frame running -> too early
return;
+#endif
d->m_bLoadEventEmitted = true;
if (d->m_doc)
d->m_doc->close();
-#endif
}
const KHTMLSettings *KHTMLPart::settings() const
@@ -1701,12 +1699,13 @@ KURL KHTMLPart::completeURL( const QString &url )
return KURL( d->m_doc->completeURL( url ) );
}
-#ifndef APPLE_CHANGES
-
// ### implement lockhistory being optional (sometimes javascript wants
// to do redirection that end up in the history!)
void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool /* doLockHistory*/ )
{
+#ifdef APPLE_CHANGES
+ impl->scheduleRedirection(delay, url);
+#else
//kdDebug(6050) << "KHTMLPart::scheduleRedirection delay=" << delay << " url=" << url << endl;
if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
{
@@ -1717,10 +1716,9 @@ void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool /* doLo
d->m_redirectionTimer.start( 1000 * d->m_delayRedirect, true );
}
}
+#endif // APPLE_CHANGES
}
-#endif
-
void KHTMLPart::slotRedirect()
{
QString u = d->m_redirectURL;
@@ -1763,7 +1761,6 @@ bool KHTMLPart::setEncoding( const QString &name, bool override )
d->m_encoding = name;
d->m_haveEncoding = override;
-#ifndef APPLE_CHANGES
if( !m_url.isEmpty() ) {
// reload document
closeURL();
@@ -1771,7 +1768,6 @@ bool KHTMLPart::setEncoding( const QString &name, bool override )
m_url = 0;
openURL(url);
}
-#endif
return true;
}
@@ -2058,10 +2054,9 @@ void KHTMLPart::slotClearSelection()
emitSelectionChanged();
}
-#ifndef APPLE_CHANGES
-
void KHTMLPart::overURL( const QString &url, const QString &target, bool shiftPressed )
{
+#ifndef APPLE_CHANGES
if ( !d->m_kjsStatusBarText.isEmpty() && !shiftPressed ) {
emit onURL( url );
emit setStatusBarText( d->m_kjsStatusBarText );
@@ -2218,11 +2213,15 @@ void KHTMLPart::overURL( const QString &url, const QString &target, bool shiftPr
#endif
emit setStatusBarText(u.prettyURL() + extra);
}
+#endif // APPLE_CHANGES
}
void KHTMLPart::urlSelected( const QString &url, int button, int state, const QString &_target,
KParts::URLArgs args )
{
+#ifdef APPLE_CHANGES
+ impl->urlSelected(url, button, state, _target, args);
+#else
bool hasTarget = false;
QString target = _target;
@@ -2306,8 +2305,11 @@ void KHTMLPart::urlSelected( const QString &url, int button, int state, const QS
return;
}
emit d->m_extension->openURLRequest( cURL, args );
+#endif // APPLE_CHANGES
}
+#ifndef APPLE_CHANGES
+
void KHTMLPart::slotViewDocumentSource()
{
KURL url(m_url);
@@ -2528,9 +2530,14 @@ void KHTMLPart::updateActions()
d->m_paSaveBackground->setEnabled( !bgURL.isEmpty() );
}
+#endif
+
bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
const QStringList ¶ms, bool isIFrame )
{
+#ifdef APPLE_CHANGES
+ return impl->requestFrame(frame, url, frameName, params, isIFrame);
+#else
// kdDebug( 6050 ) << "childRequest( ..., " << url << ", " << frameName << " )" << endl;
FrameIt it = d->m_frames.find( frameName );
if ( it == d->m_frames.end() )
@@ -2556,20 +2563,20 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
return processObjectRequest(&(*it), myurl, QString("text/html") );
}
return requestObject( &(*it), completeURL( url ));
+#endif // APPLE_CHANGES
}
-#endif
-
QString KHTMLPart::requestFrameName()
{
return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
}
-#ifndef APPLE_CHANGES
-
bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
const QStringList ¶ms )
{
+#ifdef APPLE_CHANGES
+ return impl->requestObject(frame, url, serviceType, params);
+#else
if (url.isEmpty())
return false;
khtml::ChildFrame child;
@@ -2581,10 +2588,14 @@ bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, con
KParts::URLArgs args;
args.serviceType = serviceType;
return requestObject( &(*it), completeURL( url ), args );
+#endif
}
bool KHTMLPart::requestObject( khtml::ChildFrame *child, const KURL &url, const KParts::URLArgs &_args )
{
+#ifdef APPLE_CHANGES
+ return false;
+#else
if (!checkLinkSecurity(url))
return false;
if ( child->m_bPreloaded )
@@ -2628,8 +2639,11 @@ bool KHTMLPart::requestObject( khtml::ChildFrame *child, const KURL &url, const
} else {
return processObjectRequest( child, url, args.serviceType );
}
+#endif
}
+#ifndef APPLE_CHANGES
+
bool KHTMLPart::processObjectRequest( khtml::ChildFrame *child, const KURL &_url, const QString &mimetype )
{
//kdDebug( 6050 ) << "KHTMLPart::processObjectRequest trying to create part for " << mimetype << endl;
@@ -2855,10 +2869,11 @@ void KHTMLPart::submitFormAgain()
disconnect(this, SIGNAL(completed()), this, SLOT(submitFormAgain()));
}
-#ifndef APPLE_CHANGES
-
void KHTMLPart::submitForm( const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary )
{
+#ifdef APPLE_CHANGES
+ impl->submitForm(action, url, formData, _target, contentType, boundary);
+#else
kdDebug(6000) << this << ": KHTMLPart::submitForm target=" << _target << " url=" << url << endl;
KURL u = completeURL( url );
@@ -2971,10 +2986,12 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
{
emit d->m_extension->openURLRequest( u, args );
}
+#endif // APPLE_CHANGES
}
void KHTMLPart::popupMenu( const QString &linkUrl )
{
+#ifndef APPLE_CHANGES
KURL popupURL;
KURL linkKURL;
if ( linkUrl.isEmpty() ) // click on background
@@ -2992,8 +3009,11 @@ void KHTMLPart::popupMenu( const QString &linkUrl )
delete client;
emit popupMenu(linkUrl, QCursor::pos());
+#endif
}
+#ifndef APPLE_CHANGES
+
void KHTMLPart::slotParentCompleted()
{
if ( !d->m_redirectURL.isEmpty() && !d->m_redirectionTimer.isActive() )
@@ -3117,8 +3137,14 @@ khtml::ChildFrame *KHTMLPart::frame( const QObject *obj )
return 0L;
}
+#endif // APPLE_CHANGES
+
KHTMLPart *KHTMLPart::findFrame( const QString &f )
{
+#ifdef APPLE_CHANGES
+ // FIXME: Get rid of this method altogether rather than returning a bogus value?
+ return this;
+#else
#if 0
kdDebug() << "KHTMLPart::findFrame '" << f << "'" << endl;
FrameIt it2 = d->m_frames.begin();
@@ -3151,8 +3177,11 @@ KHTMLPart *KHTMLPart::findFrame( const QString &f )
return 0L;
}
}
+#endif
}
+#ifndef APPLE_CHANGES
+
KParts::ReadOnlyPart *KHTMLPart::currentFrame() const
{
KParts::ReadOnlyPart* part = (KParts::ReadOnlyPart*)(this);
@@ -3168,8 +3197,13 @@ KParts::ReadOnlyPart *KHTMLPart::currentFrame() const
return part;
}
+#endif // APPLE_CHANGES
+
bool KHTMLPart::frameExists( const QString &frameName )
{
+#ifdef APPLE_CHANGES
+ return impl->frameExists(frameName);
+#else
ConstFrameIt it = d->m_frames.find( frameName );
if ( it == d->m_frames.end() )
return false;
@@ -3178,9 +3212,8 @@ bool KHTMLPart::frameExists( const QString &frameName )
// set. Otherwise we might find our preloaded-selve.
// This happens when we restore the frameset.
return (!(*it).m_frame.isNull());
-}
-
#endif
+}
KHTMLPart *KHTMLPart::parentPart()
{
@@ -3661,8 +3694,14 @@ QStringList KHTMLPart::frameNames() const
return res;
}
+#endif
+
QPtrList<KParts::ReadOnlyPart> KHTMLPart::frames() const
{
+#ifdef APPLE_CHANGES
+ // FIXME: Get rid of this method altogether rather than returning a bogus value?
+ return QPtrList<KParts::ReadOnlyPart>();
+#else
QPtrList<KParts::ReadOnlyPart> res;
ConstFrameIt it = d->m_frames.begin();
@@ -3671,8 +3710,11 @@ QPtrList<KParts::ReadOnlyPart> KHTMLPart::frames() const
res.append( (*it).m_part );
return res;
+#endif
}
+#ifndef APPLE_CHANGES
+
bool KHTMLPart::openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs )
{
FrameIt it = d->m_frames.find( urlArgs.frameName );
@@ -3701,8 +3743,6 @@ bool KHTMLPart::dndEnabled() const
return d->m_bDnd;
}
-#ifndef APPLE_CHANGES
-
void KHTMLPart::customEvent( QCustomEvent *event )
{
if ( khtml::MousePressEvent::test( event ) )
@@ -4075,6 +4115,8 @@ void KHTMLPart::khtmlDrawContentsEvent( khtml::DrawContentsEvent * )
{
}
+#ifndef APPLE_CHANGES
+
void KHTMLPart::guiActivateEvent( KParts::GUIActivateEvent *event )
{
if ( event->activated() )
@@ -4445,6 +4487,23 @@ bool KHTMLPart::restored() const
return d->m_restored;
}
+#ifdef APPLE_CHANGES
+
+void KHTMLPart::onURL(const QString &)
+{
+}
+
+void KHTMLPart::nodeActivated(const DOM::Node &aNode)
+{
+}
+
+void KHTMLPart::setTitle(const DOMString &title)
+{
+ impl->setTitle(title);
+}
+
+#endif
+
using namespace KParts;
#include "khtml_part.moc"
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index b0dc46b..5321f3a 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -42,13 +42,7 @@ class KHTMLSettings;
class KJavaAppletContext;
#ifdef APPLE_CHANGES
-#ifdef __OBJC__
- at class IFURLHandle;
- at class IFWebDataSource;
-#else
-typedef void IFURLHandle;
-typedef void IFWebDataSource;
-#endif
+class KWQKHTMLPartImpl;
#endif
namespace DOM
@@ -359,13 +353,11 @@ public:
bool onlyLocalReferences() const;
#ifndef KDE_NO_COMPAT
-#ifndef APPLE_CHANGES
void enableJScript(bool e) { setJScriptEnabled(e); }
void enableJava(bool e) { setJavaEnabled(e); }
void enablePlugins(bool e) { setPluginsEnabled(e); }
void autoloadImages(bool e) { setAutoloadImages(e); }
void enableMetaRefresh(bool e) { setMetaRefreshEnabled(e); }
-#endif
bool setCharset( const QString &, bool ) { return true; }
KURL baseURL() const;
@@ -764,9 +756,7 @@ protected:
*/
void htmlError(int errorCode, const QString& text, const KURL& reqUrl);
-#ifndef APPLE_CHANGES
virtual void customEvent( QCustomEvent *event );
-#endif
/**
* Eventhandler of the khtml::MousePressEvent.
@@ -1097,33 +1087,10 @@ private:
#ifdef APPLE_CHANGES
public:
- void redirectJS();
- void timerEvent ( QTimerEvent * );
-
- // In the original KDE, these come from superclasses.
- void ref() { _ref++; }
- void deref() { if(_ref) _ref--; if(!_ref) delete this; }
- bool event(QEvent *event);
-
- // Additions.
-
- bool gotoBaseAnchor();
-
- void setView(KHTMLView *view);
-
- void slotData(NSString *, const char *bytes, int length, bool complete = false);
-
- void setBaseURL(const KURL &);
-
- QString documentSource() const;
-
- void setTitle(const DOM::DOMString &);
-
- void setDataSource(IFWebDataSource *);
- IFWebDataSource *getDataSource();
-
-private:
- unsigned int _ref;
+ void setTitle(const DOM::DOMString &);
+
+ KWQKHTMLPartImpl *impl;
+ friend class KWQKHTMLPartImpl;
#endif
};
diff --git a/WebCore/khtml/khtmlpart_p.h b/WebCore/khtml/khtmlpart_p.h
index 0b54b73..5e4d026 100644
--- a/WebCore/khtml/khtmlpart_p.h
+++ b/WebCore/khtml/khtmlpart_p.h
@@ -178,11 +178,6 @@ public:
m_newJSInterpreterExists = false;
m_dcopobject = 0;
m_dcop_counter = ++khtml_part_dcop_counter;
-
-#ifdef APPLE_CHANGES
- m_decodingStarted = 0;
- m_dataSource = 0;
-#endif
}
~KHTMLPartPrivate()
{
@@ -266,11 +261,7 @@ public:
KURL m_workingURL;
-#ifdef APPLE_CHANGES
- int m_redirectionTimer;
-#else
QTimer m_redirectionTimer;
-#endif
QTime m_parsetime;
int m_delayRedirect;
QString m_redirectURL;
@@ -370,13 +361,6 @@ public:
bool m_newJSInterpreterExists; // set to 1 by setOpenedByJS, for window.open
bool m_bPendingChildRedirection;
-
-#ifdef APPLE_CHANGES
- KURL m_baseURL;
- QString m_documentSource;
- bool m_decodingStarted;
- void *m_dataSource;
-#endif
};
#endif
diff --git a/WebCore/khtml/misc/.cvsignore b/WebCore/khtml/misc/.cvsignore
index 7860227..c125695 100644
--- a/WebCore/khtml/misc/.cvsignore
+++ b/WebCore/khtml/misc/.cvsignore
@@ -1,6 +1,5 @@
Makefile
Makefile.in
-khtmldata.h
htmltags.c
htmltags.h
htmltags.gperf
@@ -9,6 +8,3 @@ htmlattrs.h
htmlattrs.gperf
.deps
*-stamp
-*.lo
-*.la
-.libs
diff --git a/WebCore/khtml/misc/Makefile.am b/WebCore/khtml/misc/Makefile.am
index c8e03a7..a5c5d17 100644
--- a/WebCore/khtml/misc/Makefile.am
+++ b/WebCore/khtml/misc/Makefile.am
@@ -15,6 +15,7 @@ libkhtmlmisc_o_SOURCES = \
htmltags.h \
khtmldata.h \
khtmllayout.h \
+ loader.cpp \
loader.h \
loader_client.h \
stringit.h \
diff --git a/WebCore/kwq/KWQLoaderImpl.mm b/WebCore/khtml/misc/loader.cpp
similarity index 79%
copy from WebCore/kwq/KWQLoaderImpl.mm
copy to WebCore/khtml/misc/loader.cpp
index d83686e..3eefe2d 100644
--- a/WebCore/kwq/KWQLoaderImpl.mm
+++ b/WebCore/khtml/misc/loader.cpp
@@ -28,13 +28,7 @@
//#define CACHE_DEBUG
#include <assert.h>
-#include "misc/loader.h"
-#ifdef APPLE_CHANGES
-#include <kwqdebug.h>
-#import <WebFoundation/WebFoundation.h>
-#include <WCLoadProgress.h>
-#include <external.h>
-#endif /* APPLE_CHANGES */
+#include "loader.h"
// up to which size is a picture for sure cacheable
#define MAXCACHEABLE 40*1024
@@ -61,6 +55,10 @@
#include "css/css_stylesheetimpl.h"
#include "xml/dom_docimpl.h"
+#ifdef APPLE_CHANGES
+#include <KWQLoaderImpl.h>
+#endif
+
using namespace khtml;
using namespace DOM;
@@ -68,15 +66,6 @@ using namespace DOM;
static bool cacheDisabled;
#endif
-#ifdef APPLE_CHANGES
-WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
-
-void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
-{
- WCIFLoadProgressMake = func;
-}
-#endif /* APPLE_CHANGES */
-
void CachedObject::finish()
{
if( m_size > MAXCACHEABLE )
@@ -121,7 +110,7 @@ void CachedObject::setRequest(Request *_request)
// -------------------------------------------------------------------------------------------
CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
+#ifdef APPLE_CHANGES
: CachedObject(dl, url, CSSStyleSheet, reload, _expireDate)
#else
: CachedObject(url, CSSStyleSheet, reload, _expireDate)
@@ -139,6 +128,21 @@ CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bo
m_codec = QTextCodec::codecForMib(4); // latin-1
}
+#ifndef APPLE_CHANGES
+
+CachedCSSStyleSheet::CachedCSSStyleSheet(const DOMString &url, const QString &stylesheet_data)
+ : CachedObject(url, CSSStyleSheet, false, 0)
+{
+ m_loading = false;
+ m_status = Persistent;
+ m_codec = 0;
+ m_size = stylesheet_data.length();
+ m_sheet = DOMString(stylesheet_data);
+}
+
+#endif
+
+
CachedCSSStyleSheet::~CachedCSSStyleSheet()
{
}
@@ -194,7 +198,7 @@ void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
// -------------------------------------------------------------------------------------------
CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
+#ifdef APPLE_CHANGES
: CachedObject(dl, url, Script, reload, _expireDate)
#else
: CachedObject(url, Script, reload, _expireDate)
@@ -214,6 +218,20 @@ CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int
m_codec = QTextCodec::codecForMib(4); // latin-1
}
+#ifndef APPLE_CHANGES
+
+CachedScript::CachedScript(const DOMString &url, const QString &script_data)
+ : CachedObject(url, Script, false, 0)
+{
+ m_loading = false;
+ m_status = Persistent;
+ m_codec = 0;
+ m_size = script_data.length();
+ m_script = DOMString(script_data);
+}
+
+#endif
+
CachedScript::~CachedScript()
{
}
@@ -417,8 +435,8 @@ static QString buildAcceptHeader()
// -------------------------------------------------------------------------------------
CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _expireDate)
-#if APPLE_CHANGES
- : QObject(), CachedObject(dl, url, Image, reload, _expireDate)
+#ifdef APPLE_CHANGES
+ : CachedObject(dl, url, Image, reload, _expireDate)
#else
: QObject(), CachedObject(url, Image, reload, _expireDate)
#endif
@@ -439,6 +457,7 @@ CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _
m_size = 0;
imgSource = 0;
setAccept( acceptHeader );
+ m_showAnimations = dl->showAnimations();
}
CachedImage::~CachedImage()
@@ -664,14 +683,10 @@ void CachedImage::movieStatus(int status)
}
-#ifdef APPLE_CHANGES
- if (status == QMovie::EndOfMovie)
-#else
if((status == QMovie::EndOfMovie) ||
((status == QMovie::EndOfLoop) && (m_showAnimations == KHTMLSettings::KAnimationLoopOnce)) ||
((status == QMovie::EndOfFrame) && (m_showAnimations == KHTMLSettings::KAnimationDisabled))
)
-#endif
{
#if 0
// the movie has ended and it doesn't loop nor is it an animation,
@@ -684,9 +699,9 @@ void CachedImage::movieStatus(int status)
if(imgSource)
#endif
{
-#ifndef APPLE_CHANGES
setShowAnimations( KHTMLSettings::KAnimationDisabled );
+#ifndef APPLE_CHANGES
// monochrome alphamasked images are usually about 10000 times
// faster to draw, so this is worth the hack
if ( p && monochrome && p->depth() > 1 )
@@ -723,7 +738,6 @@ void CachedImage::movieResize(const QSize& /*s*/)
// do_notify(m->framePixmap(), QRect());
}
-#ifndef APPLE_CHANGES
void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
{
m_showAnimations = showAnimations;
@@ -738,7 +752,6 @@ void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimati
imgSource = 0;
}
}
-#endif
void CachedImage::deleteMovie()
{
@@ -764,24 +777,17 @@ void CachedImage::clear()
void CachedImage::data ( QBuffer &_buffer, bool eof )
{
-#if APPLE_CHANGES
- // FIXME!!!
- bool UseQPixmapForImageLoading = TRUE;
-#endif /* APPLE_CHANGES */
-
#ifdef CACHE_DEBUG
kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
#endif
if ( !typeChecked )
{
+#ifndef APPLE_CHANGES
formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
+#endif
typeChecked = true;
-#if APPLE_CHANGES
- if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
-#else /* APPLE_CHANGES not defined */
if ( formatType ) // movie format exists
-#endif /* APPLE_CHANGES not defined */
{
imgSource = new ImageSource( _buffer.buffer());
m = new QMovie( imgSource, 8192 );
@@ -802,12 +808,7 @@ 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 APPLE_CHANGES
- // FIXME: this is a hack put in place until the QMovie stuff works right
- if(UseQPixmapForImageLoading || (typeChecked && !formatType))
-#else /* APPLE_CHANGES not defined */
if(typeChecked && !formatType)
-#endif /* APPLE_CHANGES not defined */
{
#ifdef CACHE_DEBUG
kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
@@ -865,13 +866,11 @@ DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
m_reloading = false;
m_expireDate = 0;
m_bautoloadImages = true;
-#ifndef APPLE_CHANGES
m_showAnimations = KHTMLSettings::KAnimationEnabled;
-#endif
m_part = part;
m_doc = doc;
-#if APPLE_CHANGES
+#ifdef APPLE_CHANGES
Cache::init();
#endif
Cache::docloader->append( this );
@@ -973,7 +972,6 @@ void DocLoader::setReloading( bool enable )
m_reloading = enable;
}
-#ifndef APPLE_CHANGES
void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
{
if ( showAnimations == m_showAnimations ) return;
@@ -988,7 +986,6 @@ void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimation
img->setShowAnimations( showAnimations );
}
}
-#endif
void DocLoader::removeCachedObject( CachedObject* o ) const
{
@@ -997,242 +994,30 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
// ------------------------------------------------------------------------------------------
-#if APPLE_CHANGES
-// Class URLLoadClient ======================================================================
-
- at implementation URLLoadClient
-
--(id)initWithLoader:(Loader *)loader dataSource: dataSource
-{
- if ((self = [super init])) {
- m_loader = loader;
- m_dataSource = [dataSource retain];
- return self;
- }
-
- return nil;
-}
-
-- (void)dealloc
-{
- [m_dataSource autorelease];
- [super dealloc];
-}
-
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
-{
- id controller;
- int contentLength = [sender contentLength];
- int contentLengthReceived = [sender contentLengthReceived];
- void *userData;
-
- userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- QString urlString = job->url().url();
-
- KWQDEBUGLEVEL(KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource,
- static_cast<KIO::TransferJob *>(
- [[sender attributeForKey:IFURLHandleUserData] pointerValue])->url().url().latin1());
-
- IFLoadProgress *loadProgress = WCIFLoadProgressMake();
- loadProgress->totalToLoad = contentLength;
- loadProgress->bytesSoFar = contentLengthReceived;
-
- controller = [m_dataSource controller];
- [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
- [controller _didStartLoading:job->url().getNSURL()];
-}
-
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
-{
- id controller;
- void *userData;
-
- userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- QString urlString = job->url().url();
-
- [m_dataSource _removeURLHandle: job->handle()];
-
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, urlString.latin1());
-
- job->setError(1);
- m_loader->slotFinished(job);
-
- IFLoadProgress *loadProgress = WCIFLoadProgressMake();
- loadProgress->totalToLoad = -1;
- loadProgress->bytesSoFar = -1;
-
- controller = [m_dataSource controller];
- [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
-
- [controller _didStopLoading:job->url().getNSURL()];
-
- delete job;
-}
-
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
-{
- id controller;
- void *userData;
-
- userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- QString urlString = job->url().url();
-
- [m_dataSource _removeURLHandle: job->handle()];
-
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d\n", m_dataSource, urlString.latin1(), data, [data length]);
-
- m_loader->slotFinished(job);
-
- IFLoadProgress *loadProgress = WCIFLoadProgressMake();
- loadProgress->totalToLoad = [data length];
- loadProgress->bytesSoFar = [data length];
-
- controller = [m_dataSource controller];
- [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
-
- [controller _didStopLoading:job->url().getNSURL()];
-
- delete job;
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
-{
- void *userData;
- int contentLength = [sender contentLength];
- int contentLengthReceived = [sender contentLengthReceived];
-
- userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- QString urlString = job->url().url();
-
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d\n", m_dataSource, urlString.latin1(), data, [data length]);
-
- m_loader->slotData(job, (const char *)[data bytes], [data length]);
-
- // Don't send the last progress message, it will be sent via
- // IFURLHandleResourceDidFinishLoading
- if (contentLength == contentLengthReceived &&
- contentLength != -1){
- return;
- }
-
- id controller;
-
- IFLoadProgress *loadProgress = WCIFLoadProgressMake();
- loadProgress->totalToLoad = contentLength;
- loadProgress->bytesSoFar = contentLengthReceived;
-
- controller = [m_dataSource controller];
- [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
-{
- void *userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p, result = %s, URL = %s\n", m_dataSource, [[result errorDescription] lossyCString], job->url().url().latin1());
-
- [m_dataSource _removeURLHandle: job->handle()];
-
- id <IFLoadHandler> controller = [m_dataSource controller];
-
- IFLoadProgress *loadProgress = WCIFLoadProgressMake();
- loadProgress->totalToLoad = [sender contentLength];
- loadProgress->bytesSoFar = [sender contentLengthReceived];
-
- job->setError(1);
- m_loader->slotFinished(job);
-
- [(IFBaseWebController *)controller _receivedError: result forResource: QSTRING_TO_NSSTRING(job->url().url()) partialProgress: loadProgress fromDataSource: m_dataSource];
-
- [(IFBaseWebController *)controller _didStopLoading:job->url().getNSURL()];
-
- delete job;
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
-{
- void *userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
- KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
- NSURL *oldURL = job->url().getNSURL();
-
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", [[url absoluteString] cString]);
- [m_dataSource _part]->setBaseURL([[url absoluteString] cString]);
-
- [m_dataSource _setFinalURL: url];
-
- [(id <IFLocationChangeHandler>)[m_dataSource controller] serverRedirectTo: url forDataSource: m_dataSource];
- [(IFBaseWebController *)[m_dataSource controller] _didStopLoading:oldURL];
- [(IFBaseWebController *)[m_dataSource controller] _didStartLoading:url];
-}
-
- at end
-#endif
-
-#if APPLE_CHANGES
-namespace khtml {
-
-class LoaderPrivate
-{
-friend class Loader;
-public:
- LoaderPrivate(Loader *parent)
- {
- _parent = parent;
- //m_recv = [[URLLoadClient alloc] initWithLoader:parent dataSource: nil];
- }
-
- ~LoaderPrivate()
- {
- //[m_recv autorelease];
- }
-
-private:
- Loader *_parent;
- //URLLoadClient *m_recv;
-};
-
-} // namespace khtml
-#endif
-
Loader::Loader() : QObject()
{
m_requestsPending.setAutoDelete( true );
m_requestsLoading.setAutoDelete( true );
-#if APPLE_CHANGES
- d = new LoaderPrivate(this);
+#ifdef APPLE_CHANGES
+ d = new KWQLoaderImpl(this);
#endif
}
Loader::~Loader()
{
-#if APPLE_CHANGES
+#ifdef APPLE_CHANGES
delete d;
#endif
}
-
-void Loader::load(DocLoader* dl, CachedObject *object, bool incremental = true)
+void Loader::load(DocLoader* dl, CachedObject *object, bool incremental)
{
Request *req = new Request(dl, object, incremental);
-
-#if APPLE_CHANGES
- id client;
-
- IFWebDataSource *dataSource = ((KHTMLPart *)(((DocLoader *)(object->loader()))->part()))->getDataSource();
- client = [[[URLLoadClient alloc] initWithLoader:this dataSource: dataSource] autorelease];
- req->client = client;
+#ifdef APPLE_CHANGES
+ d->setClient(req);
#endif
-
m_requestsPending.append(req);
-
+
#ifndef APPLE_CHANGES
emit requestStarted( req->m_docLoader, req->object );
#endif
@@ -1242,69 +1027,47 @@ void Loader::load(DocLoader* dl, CachedObject *object, bool incremental = true)
void Loader::servePendingRequests()
{
- if ( m_requestsPending.count() == 0 )
+ if ( m_requestsPending.count() == 0 )
return;
-
- // get the first pending request
- Request *req = m_requestsPending.take(0);
-
- #ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
- #endif
-
- // Don't attempt to load resources if we're cancelling this document.
- if ([((URLLoadClient *)req->client)->m_dataSource _isStopping])
- {
- //NSLog (@"Attempt to start loading %@ during cancelation\n", QSTRING_TO_NSSTRING(req->object->url().string()));
- return;
- }
- KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
-
+ // get the first pending request
+ Request *req = m_requestsPending.take(0);
+
+#ifdef CACHE_DEBUG
+ kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
+#endif
+
+ KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
+
#ifdef APPLE_CHANGES
- KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n",
- req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
- //job->begin(d->m_recv, job);
-
- job->begin((URLLoadClient *)req->client, job);
- if (job->handle() == nil){
- // Must be a malformed URL.
- NSString *urlString = QSTRING_TO_NSSTRING(req->object->url().string());
- IFError *error = [IFError errorWithCode:IFURLHandleResultBadURLError inDomain:IFErrorCodeDomainWebFoundation isTerminal:YES];
-
- id <IFLoadHandler> controller = [((URLLoadClient *)req->client)->m_dataSource controller];
- [(IFBaseWebController *)controller _receivedError: error forResource: urlString partialProgress: nil fromDataSource: ((URLLoadClient *)req->client)->m_dataSource];
- }
- else {
- [((URLLoadClient *)req->client)->m_dataSource _addURLHandle: job->handle()];
+ d->serveRequest(req, job);
#else
- if (!req->object->accept().isEmpty())
+ if (!req->object->accept().isEmpty())
job->addMetaData("accept", req->object->accept());
- if ( req->m_docLoader ) {
+ if ( req->m_docLoader ) {
KURL r = req->m_docLoader->doc()->URL();
if ( r.protocol().startsWith( "http" ) && r.path().isEmpty() )
r.setPath( "/" );
-
+
job->addMetaData("referrer", r.url());
-
+
if (req->m_docLoader->part()->restored())
{
- // kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
+// kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
job->addMetaData("cache","Cache");
}
-
- }
-
- connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
- connect( job, SIGNAL( data( KIO::Job*, const QByteArray &)),
+
+ }
+
+ connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
+ connect( job, SIGNAL( data( KIO::Job*, const QByteArray &)),
SLOT( slotData( KIO::Job*, const QByteArray &)));
-
- if ( req->object->schedule() )
+
+ if ( req->object->schedule() )
KIO::Scheduler::scheduleJob( job );
-#endif
-
- m_requestsLoading.insert(job, req);
- }
+#endif // APPLE_CHANGES
+
+ m_requestsLoading.insert(job, req);
}
void Loader::slotFinished( KIO::Job* job )
@@ -1326,16 +1089,10 @@ void Loader::slotFinished( KIO::Job* job )
r->object->data(r->m_buffer, true);
emit requestDone( r->m_docLoader, r->object );
}
-
-#if APPLE_CHANGES
- NSString *urlString;
- urlString = [NSString stringWithCString:r->object->url().string().latin1()];
- if ([urlString hasSuffix:@"/"]) {
- urlString = [urlString substringToIndex:([urlString length] - 1)];
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-#endif
+#ifdef APPLE_CHANGES
+ d->objectFinished(r->object);
+#endif
r->object->finish();
#ifdef CACHE_DEBUG
@@ -1348,9 +1105,9 @@ void Loader::slotFinished( KIO::Job* job )
#ifdef APPLE_CHANGES
void Loader::slotData( KIO::Job*job, const char *data, int size )
-#else /* APPLE_CHANGES not defined */
+#else
void Loader::slotData( KIO::Job*job, const QByteArray &data )
-#endif /* APPLE_CHANGES not defined */
+#endif
{
Request *r = m_requestsLoading[job];
if(!r) {
@@ -1363,9 +1120,9 @@ void Loader::slotData( KIO::Job*job, const QByteArray &data )
#ifdef APPLE_CHANGES
r->m_buffer.writeBlock( data, size );
-#else /* APPLE_CHANGES not defined */
+#else
r->m_buffer.writeBlock( data.data(), data.size() );
-#endif /* APPLE_CHANGES not defined */
+#endif
if(r->incremental)
r->object->data( r->m_buffer, false );
@@ -1868,6 +1625,6 @@ void Cache::preloadStyleSheet(const QString &, const QString &)
{
}
-#endif
+#endif // APPLE_CHANGES
#include "loader.moc"
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index 23404bd..85a926c 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -64,13 +64,14 @@ namespace DOM
class DocumentImpl;
};
+#ifdef APPLE_CHANGES
+class KWQLoaderImpl;
+#endif
+
namespace khtml
{
class CachedObject;
class Request;
-#ifdef APPLE_CHANGES
- class LoaderPrivate;
-#endif
class DocLoader;
/**
@@ -420,7 +421,7 @@ namespace khtml
KJPEGFormatType m_jpegloader;
#endif
#ifdef APPLE_CHANGES
- LoaderPrivate *d;
+ KWQLoaderImpl *d;
#endif
};
diff --git a/WebCore/kwq/loader.moc b/WebCore/khtml/misc/loader.moc
similarity index 100%
rename from WebCore/kwq/loader.moc
rename to WebCore/khtml/misc/loader.moc
diff --git a/WebCore/khtml/rendering/.cvsignore b/WebCore/khtml/rendering/.cvsignore
index 984c9d9..051d1bd 100644
--- a/WebCore/khtml/rendering/.cvsignore
+++ b/WebCore/khtml/rendering/.cvsignore
@@ -1,7 +1,3 @@
Makefile
Makefile.in
.deps
-.libs
-*.moc
-*.lo
-*.la
diff --git a/WebCore/khtml/xml/.cvsignore b/WebCore/khtml/xml/.cvsignore
index e7837c4..051d1bd 100644
--- a/WebCore/khtml/xml/.cvsignore
+++ b/WebCore/khtml/xml/.cvsignore
@@ -1,7 +1,3 @@
Makefile
Makefile.in
-*.moc
-*.lo
-*.la
.deps
-.libs
diff --git a/WebCore/kwq/KWQKHTMLPageCache.h b/WebCore/kwq/KWQKHTMLPageCache.h
index e69de29..0c47b64 100644
--- a/WebCore/kwq/KWQKHTMLPageCache.h
+++ b/WebCore/kwq/KWQKHTMLPageCache.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KHTML_PAGECACHE_H_
+#define KHTML_PAGECACHE_H_
+
+#include <qcstring.h>
+
+class QObject;
+
+class KHTMLPageCache
+{
+public:
+ static KHTMLPageCache *self() { return 0; }
+
+ long createCacheEntry() { return 0; }
+ void addData(long, const QByteArray &) { }
+ void cancelEntry(long) { }
+ void endData(long) { }
+
+ bool isValid(long) { return false; }
+
+ void fetchData(long, QObject *, const char *) { }
+ void cancelFetch(QObject *) { }
+};
+
+#endif
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
new file mode 100644
index 0000000..89ebf10
--- /dev/null
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <khtml_part.h>
+
+#ifdef __OBJC__
+ at class IFWebDataSource;
+#else
+class IFWebDataSource;
+#endif
+
+class KWQKHTMLPartImpl : public QObject
+{
+public:
+ KWQKHTMLPartImpl(KHTMLPart *);
+ ~KWQKHTMLPartImpl();
+
+ void setView(KHTMLView *view);
+
+ void openURL(const KURL &);
+ void begin(const KURL &, int xOffset, int yOffset);
+ void write(const char *str, int len);
+ void end();
+
+ void slotData(NSString *, const char *bytes, int length, bool complete = false);
+
+ void scheduleRedirection(int delay, const QString &url);
+ void redirectJS();
+ virtual void timerEvent(QTimerEvent *);
+
+ bool gotoBaseAnchor();
+
+ void setBaseURL(const KURL &);
+
+ void setTitle(const DOM::DOMString &);
+
+ QString documentSource() const;
+
+ void setDataSource(IFWebDataSource *);
+ IFWebDataSource *getDataSource();
+
+ bool frameExists(const QString &frameName);
+
+ void urlSelected(const QString &url, int button, int state, const QString &_target, KParts::URLArgs);
+ bool requestFrame(khtml::RenderPart *frame, const QString &url, const QString &frameName, const QStringList ¶ms, bool isIFrame);
+ bool requestObject(khtml::RenderPart *frame, const QString &url, const QString &serviceType, const QStringList &args);
+
+ void submitForm(const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary);
+
+private:
+ KHTMLPart *part;
+ KHTMLPartPrivate *d;
+
+ int m_redirectionTimer;
+
+ KURL m_baseURL;
+ QString m_documentSource;
+ bool m_decodingStarted;
+ IFWebDataSource *m_dataSource;
+
+ friend class KHTMLPart;
+};
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index d257de9..d14e9d0 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
@@ -24,51 +23,22 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-#include <misc/decoder.h>
-#include <qfont.h>
-#include <qtextcodec.h>
-
-#import <Foundation/Foundation.h>
-#import <WebFoundation/WebFoundation.h>
-
-#include <job.h>
-#include <jobclasses.h>
-#include <khtml_settings.h>
-#include <khtml_factory.h>
-#include <kcharsets.h>
-#include <kglobal.h>
-#include <html/htmltokenizer.h>
-#include <html/html_imageimpl.h>
-#include <xml/dom_docimpl.h>
-#include <html/html_miscimpl.h>
-#include <html/html_documentimpl.h>
-#include <rendering/render_image.h>
-#include <misc/loader.h>
-#include <kjs/interpreter.h>
-#include <kjs/collector.h>
-#include <ecma/kjs_proxy.h>
-#include <ecma/kjs_dom.h>
-#include <dom/dom_doc.h>
-#include <qcursor.h>
-#include <kurl.h>
-#include <khtmlview.h>
-
-#include <qdatetime.h>
-#include <khtml_part.h>
-#include <khtmlpart_p.h>
-#include <khtml_events.h>
+#import <KWQKHTMLPartImpl.h>
-#import <WCPluginWidget.h>
+#import <html/htmltokenizer.h>
+#import <html/html_documentimpl.h>
+
+#import <rendering/render_frames.h>
-#include <rendering/render_frames.h>
+#import <khtmlview.h>
-#import <KWQView.h>
+#import <khtmlpart_p.h>
-#include <WCWebDataSource.h>
+#import <WCPluginWidget.h>
+#import <WCWebDataSource.h>
+#import <external.h>
-#include <external.h>
+#import <kwqdebug.h>
#undef _KWQ_TIMING
@@ -121,24 +91,30 @@ static QString splitUrlTarget(const QString &url, QString *target=0)
}
#endif
-KHTMLPart::KHTMLPart(QWidget *, const char *, QObject *, const char *, GUIProfile prof)
+KWQKHTMLPartImpl::KWQKHTMLPartImpl(KHTMLPart *p)
+ : part(p)
+ , d(part->d)
+ , m_redirectionTimer(0)
+ , m_decodingStarted(false)
+ , m_dataSource(0)
{
- _ref = 1;
- init(0, prof);
}
-bool KHTMLPart::openURL( const KURL &url )
+KWQKHTMLPartImpl::~KWQKHTMLPartImpl()
+{
+ killTimer(m_redirectionTimer);
+}
+
+void KWQKHTMLPartImpl::openURL(const KURL &url)
{
d->m_workingURL = url;
- m_url = url;
+ part->m_url = url;
- d->m_documentSource = "";
- d->m_decodingStarted = 0;
-
- return true;
+ m_documentSource = "";
+ m_decodingStarted = false;
}
-void KHTMLPart::slotData(NSString *encoding, const char *bytes, int length, bool complete)
+void KWQKHTMLPartImpl::slotData(NSString *encoding, const char *bytes, int length, bool complete)
{
// NOTE: This code emulates the interface used by the original khtml part
QString enc;
@@ -152,57 +128,55 @@ void KHTMLPart::slotData(NSString *encoding, const char *bytes, int length, bool
if (!d->m_workingURL.isEmpty()) {
//begin(d->m_workingURL, d->m_extension->urlArgs().xOffset, d->m_extension->urlArgs().yOffset);
- begin(d->m_workingURL, 0, 0);
+ part->begin(d->m_workingURL, 0, 0);
//d->m_doc->docLoader()->setReloading(d->m_bReloading);
d->m_workingURL = KURL();
}
if (encoding != NULL) {
- enc = QString::fromCFString((CFStringRef) encoding);
- setEncoding(enc, true);
+ enc = QString::fromCFString((CFStringRef) encoding);
+ part->setEncoding(enc, true);
}
// FIXME [rjw]: Remove this log eventually. Should never happen. For debugging
// purposes only.
if (d->m_doc == 0){
- fprintf (stderr, "ERROR: KHTMLPart::slotData m_doc == 0 IGNORING DATA, url = %s\n", m_url.url().latin1());
+ fprintf (stderr, "ERROR: KHTMLPart::slotData m_doc == 0 IGNORING DATA, url = %s\n", part->m_url.url().latin1());
return;
}
-
- write(bytes, length);
+ part->write(bytes, length);
}
-void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::begin( const KURL &url, int xOffset, int yOffset )
{
KParts::URLArgs args;
args.xOffset = xOffset;
args.yOffset = yOffset;
-#ifndef APPLE_CHANGES
d->m_extension->setURLArgs( args );
-#endif
// d->m_referrer = url.url();
- m_url = url;
+ part->m_url = url;
KURL baseurl;
// ### not sure if XHTML documents served as text/xml should use DocumentImpl or HTMLDocumentImpl
if (args.serviceType == "text/xml")
- d->m_doc = DOMImplementationImpl::instance()->createDocument( d->m_view );
+ d->m_doc = DOM::DOMImplementationImpl::instance()->createDocument( d->m_view );
else
- d->m_doc = DOMImplementationImpl::instance()->createHTMLDocument( d->m_view );
+ d->m_doc = DOM::DOMImplementationImpl::instance()->createHTMLDocument( d->m_view );
//DomShared::instanceToCheck = (void *)((DomShared *)d->m_doc);
d->m_doc->ref();
- if (d->m_baseURL.isEmpty()) {
- d->m_baseURL = KURL();
+ if (m_baseURL.isEmpty()) {
+ m_baseURL = KURL();
}
else {
// If we get here, this means the part has received a redirect before
// m_doc was created. Update the document with the base URL.
- d->m_doc->setBaseURL(d->m_baseURL.url());
+ d->m_doc->setBaseURL(m_baseURL.url());
}
d->m_workingURL = url;
@@ -218,10 +192,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
d->m_doc->setURL( url.url() );
// do not set base URL if it has already been set
- if (!d->m_workingURL.isEmpty() && d->m_baseURL.isEmpty())
+ if (!d->m_workingURL.isEmpty() && m_baseURL.isEmpty())
{
// We're not planning to support the KDE chained URL feature, AFAIK
-#define KDE_CHAINED_URIS 0
#if KDE_CHAINED_URIS
KURL::List lst = KURL::split( d->m_workingURL );
KURL baseurl;
@@ -252,7 +225,8 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
#endif
}
-void KHTMLPart::write( const char *str, int len )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::write( const char *str, int len )
{
/* FIXME: hook this code back when we have decoders completely working */
#ifndef APPLE_CHANGES
@@ -301,28 +275,28 @@ void KHTMLPart::write( const char *str, int len )
// FIX ME: This is very expensive. We should using the IFMutableData
// that represents the document, and only constructing the complete
// string when requested.
- d->m_documentSource += QString(str, len);
+ m_documentSource += QString(str, len);
QString decoded;
- if (d->m_decodingStarted)
+ if (m_decodingStarted)
decoded = d->m_decoder->decode( str, len );
else
- decoded = d->m_decoder->decode( d->m_documentSource, d->m_documentSource.length() );
+ decoded = d->m_decoder->decode( m_documentSource, m_documentSource.length() );
if(decoded.isEmpty()){
// Check flag to tell whether the load has completed.
// If we get here, it means that no text encoding was available.
// Try to process what we have with the default encoding.
if (d->m_bComplete) {
- decoded = d->m_documentSource;
+ decoded = m_documentSource;
}
else {
- fprintf (stderr, "WARNING: DECODER unable to decode string, length = %d, total length = %d\n", len, d->m_documentSource.length());
+ fprintf (stderr, "WARNING: DECODER unable to decode string, length = %d, total length = %d\n", len, m_documentSource.length());
return;
}
}
- d->m_decodingStarted = 1;
+ m_decodingStarted = true;
// Transition from provisional to committed data source at this point.
@@ -332,8 +306,8 @@ void KHTMLPart::write( const char *str, int len )
// end lines added in lieu of big fixme
- if (jScript())
- jScript()->appendSourceFile(m_url.url(),decoded);
+ if (part->jScript())
+ part->jScript()->appendSourceFile(part->m_url.url(),decoded);
Tokenizer* t = d->m_doc->tokenizer();
if(t)
t->write( decoded, true );
@@ -341,11 +315,12 @@ void KHTMLPart::write( const char *str, int len )
#ifdef _KWQ_TIMING
double thisTime = CFAbsoluteTimeGetCurrent() - start;
d->totalWriteTime += thisTime;
- KWQDEBUGLEVEL (0x200, "%s bytes = %d, seconds = %f, total = %f\n", m_url.url().latin1(), len, thisTime, d->totalWriteTime);
+ KWQDEBUGLEVEL (0x200, "%s bytes = %d, seconds = %f, total = %f\n", part->m_url.url().latin1(), len, thisTime, d->totalWriteTime);
#endif
}
-void KHTMLPart::end()
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::end()
{
// FIXME [rjw]: Remove this log eventually. Should never happen. For debugging
// purposes only.
@@ -359,40 +334,43 @@ void KHTMLPart::end()
d->m_doc->close();
KURL::clearCaches();
- d->m_view->complete();
+ // FIXME: If this is still needed we will have to add friend to KHTMLView,
+ // but it seems like a better thing to do is to use KHTMLPart::end() instead.
+ //d->m_view->complete();
}
-
-bool KHTMLPart::gotoBaseAnchor()
+
+bool KWQKHTMLPartImpl::gotoBaseAnchor()
{
- if ( !m_url.ref().isEmpty() )
- return gotoAnchor( m_url.ref() );
+ if ( !part->m_url.ref().isEmpty() )
+ return part->gotoAnchor( part->m_url.ref() );
return false;
}
-void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::scheduleRedirection(int delay, const QString &url)
{
- if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
- {
- if (delay < 1) {
- delay = 1;
- }
- d->m_delayRedirect = delay;
- d->m_redirectURL = url;
- killTimer(d->m_redirectionTimer);
- d->m_redirectionTimer = startTimer( 1000 * d->m_delayRedirect);
- }
+ if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
+ {
+ if (delay < 1) {
+ delay = 1;
+ }
+ d->m_delayRedirect = delay;
+ d->m_redirectURL = url;
+ killTimer(m_redirectionTimer);
+ m_redirectionTimer = startTimer(1000 * d->m_delayRedirect);
+ }
}
-void KHTMLPart::timerEvent ( QTimerEvent *e )
+void KWQKHTMLPartImpl::timerEvent(QTimerEvent *e)
{
- if (e->timerId()==d->m_redirectionTimer)
+ if (e->timerId()==m_redirectionTimer)
{
redirectJS();
return;
}
}
-void KHTMLPart::redirectJS()
+void KWQKHTMLPartImpl::redirectJS()
{
QString u = d->m_redirectURL;
d->m_delayRedirect = 0;
@@ -401,11 +379,11 @@ void KHTMLPart::redirectJS()
{
QString script = KURL::decode_string( u.right( u.length() - 11 ) );
//kdDebug( 6050 ) << "KHTMLPart::slotRedirect script=" << script << endl;
- QVariant res = executeScript( script );
+ QVariant res = part->executeScript( script );
if ( res.type() == QVariant::String ) {
- begin( url() );
- write( res.asString() );
- end();
+ part->begin( part->url() );
+ part->write( res.asString() );
+ part->end();
}
return;
}
@@ -417,21 +395,21 @@ void KHTMLPart::redirectJS()
args.setLockHistory( true );
#endif
- urlSelected( u, 0, 0, QString::null, args );
+ part->urlSelected( u, 0, 0, QString::null, args );
}
-void KHTMLPart::urlSelected( const QString &url, int button, int state, const QString &_target, KParts::URLArgs )
+void KWQKHTMLPartImpl::urlSelected( const QString &url, int button, int state, const QString &_target, KParts::URLArgs )
{
- IFWebDataSource *oldDataSource, *newDataSource;
- KURL clickedURL(completeURL( url));
- IFWebFrame *frame;
- KURL refLess(clickedURL);
+ IFWebDataSource *oldDataSource, *newDataSource;
+ KURL clickedURL(part->completeURL( url));
+ IFWebFrame *frame;
+ KURL refLess(clickedURL);
if ( url.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 )
{
- executeScript( url.right( url.length() - 11) );
+ part->executeScript( url.right( url.length() - 11) );
return;
}
@@ -441,32 +419,32 @@ void KHTMLPart::urlSelected( const QString &url, int button, int state, const QS
return;
}
- m_url.setRef ("");
- refLess.setRef ("");
- if (refLess.url() == m_url.url()){
- m_url = clickedURL;
- gotoAnchor (clickedURL.ref());
- return;
- }
-
- if (_target.isEmpty()){
- oldDataSource = getDataSource();
- frame = [oldDataSource webFrame];
- }
- else {
- frame = [[getDataSource() controller] frameNamed: QSTRING_TO_NSSTRING(_target)];
- oldDataSource = [frame dataSource];
- }
-
- newDataSource = WCIFWebDataSourceMake(clickedURL.getNSURL(), nil, 0);
- [newDataSource _setParent: [oldDataSource parent]];
-
- [frame setProvisionalDataSource: newDataSource];
- [frame startLoading];
+ part->m_url.setRef ("");
+ refLess.setRef ("");
+ if (refLess.url() == part->m_url.url()){
+ part->m_url = clickedURL;
+ part->gotoAnchor (clickedURL.ref());
+ return;
+ }
+
+ if (_target.isEmpty()){
+ oldDataSource = getDataSource();
+ frame = [oldDataSource webFrame];
+ }
+ else {
+ frame = [[getDataSource() controller] frameNamed: QSTRING_TO_NSSTRING(_target)];
+ oldDataSource = [frame dataSource];
+ }
+
+ newDataSource = WCIFWebDataSourceMake(clickedURL.getNSURL(), nil, 0);
+ [newDataSource _setParent: [oldDataSource parent]];
+
+ [frame setProvisionalDataSource: newDataSource];
+ [frame startLoading];
}
-bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
- const QStringList ¶ms, bool isIFrame )
+bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
+ const QStringList ¶ms, bool isIFrame )
{
NSString *nsframeName = QSTRING_TO_NSSTRING(frameName);
IFWebFrame *aFrame;
@@ -488,7 +466,7 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
id <IFWebController> controller;
HTMLIFrameElementImpl *o = static_cast<HTMLIFrameElementImpl *>(frame->element());
- childURL = completeURL(url).getNSURL();
+ childURL = part->completeURL(url).getNSURL();
if (childURL == nil || [childURL path] == nil) {
NSLog (@"ERROR (probably need to fix CFURL): unable to create URL with path");
return false;
@@ -496,8 +474,8 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
oldDataSource = getDataSource();
controller = [oldDataSource controller];
- newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource inScrollView: o->scrollingMode() == QScrollView::AlwaysOff ? NO : YES];
- if (newFrame == nil){
+ newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource inScrollView: o->scrollingMode() != QScrollView::AlwaysOff];
+ if (newFrame == nil) {
// Controller return NO to location change, now what?
return false;
}
@@ -536,32 +514,26 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
return true;
}
-bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
- const QStringList &args )
+bool KWQKHTMLPartImpl::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
+ const QStringList &args )
{
if (url.isEmpty()) {
return false;
}
if (!frame->widget()) {
- frame->setWidget(IFPluginWidgetCreate(completeURL(url).url(), serviceType, args, d->m_baseURL.url()));
+ frame->setWidget(IFPluginWidgetCreate(part->completeURL(url).url(), serviceType, args, m_baseURL.url()));
}
return true;
}
-bool KHTMLPart::requestObject( khtml::ChildFrame *frame, const KURL &url, const KParts::URLArgs &args )
-{
- _logNotYetImplemented();
- return false;
-}
-
-void KHTMLPart::submitForm( const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary )
+void KWQKHTMLPartImpl::submitForm( const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary )
{
QString target = _target;
//if ( target.isEmpty() )
// target = d->m_baseTarget;
- KURL u = completeURL( url );
+ KURL u = part->completeURL( url );
if ( u.isMalformed() )
{
@@ -573,7 +545,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
urlstring = KURL::decode_string(urlstring);
- executeScript( urlstring.right( urlstring.length() - 11) );
+ part->executeScript( urlstring.right( urlstring.length() - 11) );
return;
}
@@ -663,410 +635,21 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
[frame startLoading];
}
-KHTMLPart *KHTMLPart::findFrame( const QString &f )
-{
- _logNeverImplemented();
- return this;
-}
-
-bool KHTMLPart::frameExists( const QString &frameName )
+bool KWQKHTMLPartImpl::frameExists( const QString &frameName )
{
return [getDataSource() frameExists: (NSString *)frameName.getCFMutableString()];
}
-QPtrList<KParts::ReadOnlyPart> KHTMLPart::frames() const
+QString KWQKHTMLPartImpl::documentSource() const
{
- _logNeverImplemented();
- return QPtrList<KParts::ReadOnlyPart>();
+ return m_documentSource;
}
-bool KHTMLPart::event( QEvent *event )
+void KWQKHTMLPartImpl::setBaseURL(const KURL &url)
{
- if ( khtml::MousePressEvent::test( event ) )
- {
- khtmlMousePressEvent( static_cast<khtml::MousePressEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseDoubleClickEvent::test( event ) )
- {
- khtmlMouseDoubleClickEvent( static_cast<khtml::MouseDoubleClickEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseMoveEvent::test( event ) )
- {
- khtmlMouseMoveEvent( static_cast<khtml::MouseMoveEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseReleaseEvent::test( event ) )
- {
- khtmlMouseReleaseEvent( static_cast<khtml::MouseReleaseEvent *>( event ) );
- return true;
- }
-
- if ( khtml::DrawContentsEvent::test( event ) )
- {
- khtmlDrawContentsEvent( static_cast<khtml::DrawContentsEvent *>( event ) );
- return true;
- }
-
- return false;
-}
-
-void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
-{
- DOM::DOMString url = event->url();
- QMouseEvent *_mouse = event->qmouseEvent();
- DOM::Node innerNode = event->innerNode();
- d->m_mousePressNode = innerNode;
-
- d->m_dragStartPos = _mouse->pos();
-
- if ( !event->url().isNull() ){
- d->m_strSelectedURL = event->url().string();
- d->m_strSelectedURLTarget = event->target().string();
- }
- else
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
-
- if ( _mouse->button() == LeftButton ||
- _mouse->button() == MidButton )
- {
- d->m_bMousePressed = true;
-
-#ifndef KHTML_NO_SELECTION
- if ( _mouse->button() == LeftButton )
- {
- if ( !innerNode.isNull() && innerNode.handle()->renderer()) {
- int offset = 0;
- DOM::NodeImpl* node = 0;
- innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
- event->absX()-innerNode.handle()->renderer()->xPos(),
- event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
-
- d->m_selectionStart = node;
- d->m_startOffset = offset;
- // kdDebug(6005) << "KHTMLPart::khtmlMousePressEvent selectionStart=" << d->m_selectionStart.handle()->renderer()
- // << " offset=" << d->m_startOffset << endl;
- d->m_selectionEnd = d->m_selectionStart;
- d->m_endOffset = d->m_startOffset;
- d->m_doc->clearSelection();
- }
- else
- {
- d->m_selectionStart = DOM::Node();
- d->m_selectionEnd = DOM::Node();
- }
- //emitSelectionChanged();
- //startAutoScroll();
- }
-#else
- d->m_dragLastPos = _mouse->globalPos();
-#endif
- }
-
- if ( _mouse->button() == RightButton )
- {
- //popupMenu( d->m_strSelectedURL );
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
- }
-}
-
-void KHTMLPart::khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * )
-{
-}
-
-void KHTMLPart::khtmlMouseMoveEvent( khtml::MouseMoveEvent *event )
-{
-// FIXME: need working implementation of this event
-#if 0
- QMouseEvent *_mouse = event->qmouseEvent();
- DOM::DOMString url = event->url();
- DOM::Node innerNode = event->innerNode();
-
-#define QT_NO_DRAGANDDROP 1
-#ifndef QT_NO_DRAGANDDROP
- if( d->m_bMousePressed && (!d->m_strSelectedURL.isEmpty() || (!innerNode.isNull() && innerNode.elementId() == ID_IMG) ) &&
- ( d->m_dragStartPos - _mouse->pos() ).manhattanLength() > KGlobalSettings::dndEventDelay() &&
- d->m_bDnd && d->m_mousePressNode == innerNode ) {
-
- QPixmap p;
- QDragObject *drag = 0;
- if( !d->m_strSelectedURL.isEmpty() ) {
- KURL u( completeURL( splitUrlTarget(d->m_strSelectedURL)) );
- KURLDrag* urlDrag = KURLDrag::newDrag( u, d->m_view->viewport() );
- if ( !d->m_referrer.isEmpty() )
- urlDrag->metaData()["referrer"] = d->m_referrer;
- drag = urlDrag;
- p = KMimeType::pixmapForURL(u, 0, KIcon::Desktop, KIcon::SizeMedium);
- } else {
- HTMLImageElementImpl *i = static_cast<HTMLImageElementImpl *>(innerNode.handle());
- if( i ) {
- KMultipleDrag *mdrag = new KMultipleDrag( d->m_view->viewport() );
- mdrag->addDragObject( new QImageDrag( i->currentImage(), 0L ) );
- KURL u( completeURL( splitUrlTarget( khtml::parseURL(i->getAttribute(ATTR_SRC)).string() ) ) );
- KURLDrag* urlDrag = KURLDrag::newDrag( u, 0L );
- if ( !d->m_referrer.isEmpty() )
- urlDrag->metaData()["referrer"] = d->m_referrer;
- mdrag->addDragObject( urlDrag );
- drag = mdrag;
- p = KMimeType::mimeType("image/png")->pixmap(KIcon::Desktop);
- }
- }
-
- if ( !p.isNull() )
- drag->setPixmap(p);
-
- stopAutoScroll();
- if(drag)
- drag->drag();
-
- // when we finish our drag, we need to undo our mouse press
- d->m_bMousePressed = false;
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
- return;
- }
-#endif
- DOM::DOMString url = event->url();
- DOM::DOMString target = event->target();
-
- // Not clicked -> mouse over stuff
- if ( !d->m_bMousePressed )
- {
- // The mouse is over something
- if ( url.length() )
- {
- bool shiftPressed = ( _mouse->state() & ShiftButton );
-
- // Image map
- if ( !innerNode.isNull() && innerNode.elementId() == ID_IMG )
- {
- HTMLImageElementImpl *i = static_cast<HTMLImageElementImpl *>(innerNode.handle());
- if ( i && i->isServerMap() )
- {
- khtml::RenderObject *r = i->renderer();
- if(r)
- {
- int absx, absy, vx, vy;
- r->absolutePosition(absx, absy);
- view()->contentsToViewport( absx, absy, vx, vy );
-
- int x(_mouse->x() - vx), y(_mouse->y() - vy);
-
- d->m_overURL = url.string() + QString("?%1,%2").arg(x).arg(y);
- d->m_overURLTarget = target.string();
- overURL( d->m_overURL, target.string(), shiftPressed );
- return;
- }
- }
- }
-
- // normal link
- if ( d->m_overURL.isEmpty() || d->m_overURL != url || d->m_overURLTarget != target )
- {
- d->m_overURL = url.string();
- d->m_overURLTarget = target.string();
- overURL( d->m_overURL, target.string(), shiftPressed );
- }
- }
- else // Not over a link...
- {
- if( !d->m_overURL.isEmpty() ) // and we were over a link -> reset to "default statusbar text"
- {
- d->m_overURL = d->m_overURLTarget = QString::null;
- emit onURL( QString::null );
- // Default statusbar text can be set from javascript. Otherwise it's empty.
- emit setStatusBarText( d->m_kjsDefaultStatusBarText );
- }
- }
- }
- else {
-#ifndef KHTML_NO_SELECTION
- // selection stuff
- if( d->m_bMousePressed && innerNode.handle() && innerNode.handle()->renderer() &&
- ( _mouse->state() == LeftButton )) {
- int offset;
- //kdDebug(6000) << "KHTMLPart::khtmlMouseMoveEvent x=" << event->x() << " y=" << event->y()
- // << " nodeAbsX=" << event->nodeAbsX() << " nodeAbsY=" << event->nodeAbsY()
- // << endl;
- DOM::NodeImpl* node=0;
- innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
- event->absX()-innerNode.handle()->renderer()->xPos(),
- event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
- d->m_selectionEnd = node;
- d->m_endOffset = offset;
-// if (d->m_selectionEnd.handle() && d->m_selectionEnd.handle()->renderer())
-// kdDebug( 6000 ) << "setting end of selection to " << d->m_selectionEnd.handle()->renderer() << "/"
-// << d->m_endOffset << endl;
-
- // we have to get to know if end is before start or not...
- DOM::Node n = d->m_selectionStart;
- d->m_startBeforeEnd = false;
- while(!n.isNull()) {
- if(n == d->m_selectionEnd) {
- d->m_startBeforeEnd = true;
- break;
- }
- DOM::Node next = n.firstChild();
- if(next.isNull()) next = n.nextSibling();
- while( next.isNull() && !n.parentNode().isNull() ) {
- n = n.parentNode();
- next = n.nextSibling();
- }
- n = next;
- //d->m_view->viewport()->repaint(false);
- }
-
- if ( !d->m_selectionStart.isNull() && !d->m_selectionEnd.isNull() )
- {
- if (d->m_selectionEnd == d->m_selectionStart && d->m_endOffset < d->m_startOffset)
- d->m_doc
- ->setSelection(d->m_selectionStart.handle(),d->m_endOffset,
- d->m_selectionEnd.handle(),d->m_startOffset);
- else if (d->m_startBeforeEnd)
- d->m_doc
- ->setSelection(d->m_selectionStart.handle(),d->m_startOffset,
- d->m_selectionEnd.handle(),d->m_endOffset);
- else
- d->m_doc
- ->setSelection(d->m_selectionEnd.handle(),d->m_endOffset,
- d->m_selectionStart.handle(),d->m_startOffset);
- }
- }
-#else
- if ( d->m_doc && d->m_view ) {
- QPoint diff( _mouse->globalPos() - d->m_dragLastPos );
-
- if ( abs( diff.x() ) > 64 || abs( diff.y() ) > 64 ) {
- d->m_view->scrollBy( -diff.x(), -diff.y() );
- d->m_dragLastPos = _mouse->globalPos();
- }
- }
-#endif
- }
-#endif
-}
-
-void KHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event )
- {
- DOM::Node innerNode = event->innerNode();
- d->m_mousePressNode = DOM::Node();
-
- if ( d->m_bMousePressed )
- stopAutoScroll();
-
- // Used to prevent mouseMoveEvent from initiating a drag before
- // the mouse is pressed again.
- d->m_bMousePressed = false;
-
- #ifndef _KWQ_
- #define QT_NO_CLIPBOARD 1
- #ifndef QT_NO_CLIPBOARD
- QMouseEvent *_mouse = event->qmouseEvent();
- if ((_mouse->button() == MidButton) && (event->url().isNull()))
- {
- QClipboard *cb = QApplication::clipboard();
- cb->setSelectionMode( true );
- QCString plain("plain");
- QString url = cb->text(plain).stripWhiteSpace();
- KURL u(url);
- if ( u.isMalformed() ) {
- // some half-baked guesses for incomplete urls
- // (the same code is in libkonq/konq_dirpart.cc)
- if ( url.startsWith( "ftp." ) )
- {
- url.prepend( "ftp://" );
- u = url;
- }
- else
- {
- url.prepend( "http://" );
- u = url;
- }
- }
- if (u.isValid())
- {
- QString savedReferrer = d->m_referrer;
- d->m_referrer = QString::null; // Disable referrer.
- urlSelected(url, 0,0, "_top");
- d->m_referrer = savedReferrer; // Restore original referrer.
- }
- }
- #endif
-
- #ifndef KHTML_NO_SELECTION
- // delete selection in case start and end position are at the same point
- if(d->m_selectionStart == d->m_selectionEnd && d->m_startOffset == d->m_endOffset) {
- d->m_selectionStart = 0;
- d->m_selectionEnd = 0;
- d->m_startOffset = 0;
- d->m_endOffset = 0;
- //emitSelectionChanged();
- } else {
- // we have to get to know if end is before start or not...
- DOM::Node n = d->m_selectionStart;
- d->m_startBeforeEnd = false;
- if( d->m_selectionStart == d->m_selectionEnd ) {
- if( d->m_startOffset < d->m_endOffset )
- d->m_startBeforeEnd = true;
- } else {
- while(!n.isNull()) {
- if(n == d->m_selectionEnd) {
- d->m_startBeforeEnd = true;
- break;
- }
- DOM::Node next = n.firstChild();
- if(next.isNull()) next = n.nextSibling();
- while( next.isNull() && !n.parentNode().isNull() ) {
- n = n.parentNode();
- next = n.nextSibling();
- }
- n = next;
- }
- }
- if(!d->m_startBeforeEnd)
- {
- DOM::Node tmpNode = d->m_selectionStart;
- int tmpOffset = d->m_startOffset;
- d->m_selectionStart = d->m_selectionEnd;
- d->m_startOffset = d->m_endOffset;
- d->m_selectionEnd = tmpNode;
- d->m_endOffset = tmpOffset;
- d->m_startBeforeEnd = true;
- }
- // get selected text and paste to the clipboard
- #ifndef QT_NO_CLIPBOARD
- QString text = selectedText();
- text.replace(QRegExp(QChar(0xa0)), " ");
- QClipboard *cb = QApplication::clipboard();
- cb->setSelectionMode( true );
- cb->setText(text);
- cb->setSelectionMode( false );
- #endif
- //kdDebug( 6000 ) << "selectedText = " << text << endl;
- //emitSelectionChanged();
- }
- #endif
- #endif
-
- }
-
-void KHTMLPart::khtmlDrawContentsEvent( khtml::DrawContentsEvent * )
-{
-}
-
-QString KHTMLPart::documentSource() const
-{
- return d->m_documentSource;
-}
-
-void KHTMLPart::setBaseURL(const KURL &url)
-{
- d->m_baseURL = url;
- if (d->m_baseURL.protocol().startsWith( "http" ) && !d->m_baseURL.host().isEmpty() && d->m_baseURL.path().isEmpty()) {
- d->m_baseURL.setPath( "/" );
+ m_baseURL = url;
+ if (m_baseURL.protocol().startsWith( "http" ) && !m_baseURL.host().isEmpty() && m_baseURL.path().isEmpty()) {
+ m_baseURL.setPath( "/" );
// communicate the change in base URL to the document so that links and subloads work
if (d->m_doc) {
d->m_doc->setBaseURL(url.url());
@@ -1074,27 +657,22 @@ void KHTMLPart::setBaseURL(const KURL &url)
}
}
-void KHTMLPart::setView(KHTMLView *view)
+void KWQKHTMLPartImpl::setView(KHTMLView *view)
{
d->m_view = view;
}
-void KHTMLPart::nodeActivated(const DOM::Node &aNode)
-{
- KWQDEBUG ("name %s = %s\n", (const char *)aNode.nodeName().string(), (const char *)aNode.nodeValue().string());
-}
-
-void KHTMLPart::setTitle(const DOMString &title)
+void KWQKHTMLPartImpl::setTitle(const DOMString &title)
{
- [getDataSource() _setTitle:(NSString *)title.string().getCFMutableString()];
+ [getDataSource() _setTitle:title.string().getNSString()];
}
-void KHTMLPart::setDataSource(IFWebDataSource *dataSource)
+void KWQKHTMLPartImpl::setDataSource(IFWebDataSource *dataSource)
{
- d->m_dataSource = dataSource; // not retained
+ m_dataSource = dataSource; // not retained
}
-IFWebDataSource *KHTMLPart::getDataSource()
+IFWebDataSource *KWQKHTMLPartImpl::getDataSource()
{
- return (IFWebDataSource *)d->m_dataSource;
+ return m_dataSource;
}
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.h b/WebCore/kwq/KWQKHTMLPartImpl.h
new file mode 100644
index 0000000..89ebf10
--- /dev/null
+++ b/WebCore/kwq/KWQKHTMLPartImpl.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <khtml_part.h>
+
+#ifdef __OBJC__
+ at class IFWebDataSource;
+#else
+class IFWebDataSource;
+#endif
+
+class KWQKHTMLPartImpl : public QObject
+{
+public:
+ KWQKHTMLPartImpl(KHTMLPart *);
+ ~KWQKHTMLPartImpl();
+
+ void setView(KHTMLView *view);
+
+ void openURL(const KURL &);
+ void begin(const KURL &, int xOffset, int yOffset);
+ void write(const char *str, int len);
+ void end();
+
+ void slotData(NSString *, const char *bytes, int length, bool complete = false);
+
+ void scheduleRedirection(int delay, const QString &url);
+ void redirectJS();
+ virtual void timerEvent(QTimerEvent *);
+
+ bool gotoBaseAnchor();
+
+ void setBaseURL(const KURL &);
+
+ void setTitle(const DOM::DOMString &);
+
+ QString documentSource() const;
+
+ void setDataSource(IFWebDataSource *);
+ IFWebDataSource *getDataSource();
+
+ bool frameExists(const QString &frameName);
+
+ void urlSelected(const QString &url, int button, int state, const QString &_target, KParts::URLArgs);
+ bool requestFrame(khtml::RenderPart *frame, const QString &url, const QString &frameName, const QStringList ¶ms, bool isIFrame);
+ bool requestObject(khtml::RenderPart *frame, const QString &url, const QString &serviceType, const QStringList &args);
+
+ void submitForm(const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary);
+
+private:
+ KHTMLPart *part;
+ KHTMLPartPrivate *d;
+
+ int m_redirectionTimer;
+
+ KURL m_baseURL;
+ QString m_documentSource;
+ bool m_decodingStarted;
+ IFWebDataSource *m_dataSource;
+
+ friend class KHTMLPart;
+};
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index d257de9..d14e9d0 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
/*
* Copyright (C) 2001, 2002 Apple Computer, Inc. All rights reserved.
*
@@ -24,51 +23,22 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
-#include <misc/decoder.h>
-#include <qfont.h>
-#include <qtextcodec.h>
-
-#import <Foundation/Foundation.h>
-#import <WebFoundation/WebFoundation.h>
-
-#include <job.h>
-#include <jobclasses.h>
-#include <khtml_settings.h>
-#include <khtml_factory.h>
-#include <kcharsets.h>
-#include <kglobal.h>
-#include <html/htmltokenizer.h>
-#include <html/html_imageimpl.h>
-#include <xml/dom_docimpl.h>
-#include <html/html_miscimpl.h>
-#include <html/html_documentimpl.h>
-#include <rendering/render_image.h>
-#include <misc/loader.h>
-#include <kjs/interpreter.h>
-#include <kjs/collector.h>
-#include <ecma/kjs_proxy.h>
-#include <ecma/kjs_dom.h>
-#include <dom/dom_doc.h>
-#include <qcursor.h>
-#include <kurl.h>
-#include <khtmlview.h>
-
-#include <qdatetime.h>
-#include <khtml_part.h>
-#include <khtmlpart_p.h>
-#include <khtml_events.h>
+#import <KWQKHTMLPartImpl.h>
-#import <WCPluginWidget.h>
+#import <html/htmltokenizer.h>
+#import <html/html_documentimpl.h>
+
+#import <rendering/render_frames.h>
-#include <rendering/render_frames.h>
+#import <khtmlview.h>
-#import <KWQView.h>
+#import <khtmlpart_p.h>
-#include <WCWebDataSource.h>
+#import <WCPluginWidget.h>
+#import <WCWebDataSource.h>
+#import <external.h>
-#include <external.h>
+#import <kwqdebug.h>
#undef _KWQ_TIMING
@@ -121,24 +91,30 @@ static QString splitUrlTarget(const QString &url, QString *target=0)
}
#endif
-KHTMLPart::KHTMLPart(QWidget *, const char *, QObject *, const char *, GUIProfile prof)
+KWQKHTMLPartImpl::KWQKHTMLPartImpl(KHTMLPart *p)
+ : part(p)
+ , d(part->d)
+ , m_redirectionTimer(0)
+ , m_decodingStarted(false)
+ , m_dataSource(0)
{
- _ref = 1;
- init(0, prof);
}
-bool KHTMLPart::openURL( const KURL &url )
+KWQKHTMLPartImpl::~KWQKHTMLPartImpl()
+{
+ killTimer(m_redirectionTimer);
+}
+
+void KWQKHTMLPartImpl::openURL(const KURL &url)
{
d->m_workingURL = url;
- m_url = url;
+ part->m_url = url;
- d->m_documentSource = "";
- d->m_decodingStarted = 0;
-
- return true;
+ m_documentSource = "";
+ m_decodingStarted = false;
}
-void KHTMLPart::slotData(NSString *encoding, const char *bytes, int length, bool complete)
+void KWQKHTMLPartImpl::slotData(NSString *encoding, const char *bytes, int length, bool complete)
{
// NOTE: This code emulates the interface used by the original khtml part
QString enc;
@@ -152,57 +128,55 @@ void KHTMLPart::slotData(NSString *encoding, const char *bytes, int length, bool
if (!d->m_workingURL.isEmpty()) {
//begin(d->m_workingURL, d->m_extension->urlArgs().xOffset, d->m_extension->urlArgs().yOffset);
- begin(d->m_workingURL, 0, 0);
+ part->begin(d->m_workingURL, 0, 0);
//d->m_doc->docLoader()->setReloading(d->m_bReloading);
d->m_workingURL = KURL();
}
if (encoding != NULL) {
- enc = QString::fromCFString((CFStringRef) encoding);
- setEncoding(enc, true);
+ enc = QString::fromCFString((CFStringRef) encoding);
+ part->setEncoding(enc, true);
}
// FIXME [rjw]: Remove this log eventually. Should never happen. For debugging
// purposes only.
if (d->m_doc == 0){
- fprintf (stderr, "ERROR: KHTMLPart::slotData m_doc == 0 IGNORING DATA, url = %s\n", m_url.url().latin1());
+ fprintf (stderr, "ERROR: KHTMLPart::slotData m_doc == 0 IGNORING DATA, url = %s\n", part->m_url.url().latin1());
return;
}
-
- write(bytes, length);
+ part->write(bytes, length);
}
-void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::begin( const KURL &url, int xOffset, int yOffset )
{
KParts::URLArgs args;
args.xOffset = xOffset;
args.yOffset = yOffset;
-#ifndef APPLE_CHANGES
d->m_extension->setURLArgs( args );
-#endif
// d->m_referrer = url.url();
- m_url = url;
+ part->m_url = url;
KURL baseurl;
// ### not sure if XHTML documents served as text/xml should use DocumentImpl or HTMLDocumentImpl
if (args.serviceType == "text/xml")
- d->m_doc = DOMImplementationImpl::instance()->createDocument( d->m_view );
+ d->m_doc = DOM::DOMImplementationImpl::instance()->createDocument( d->m_view );
else
- d->m_doc = DOMImplementationImpl::instance()->createHTMLDocument( d->m_view );
+ d->m_doc = DOM::DOMImplementationImpl::instance()->createHTMLDocument( d->m_view );
//DomShared::instanceToCheck = (void *)((DomShared *)d->m_doc);
d->m_doc->ref();
- if (d->m_baseURL.isEmpty()) {
- d->m_baseURL = KURL();
+ if (m_baseURL.isEmpty()) {
+ m_baseURL = KURL();
}
else {
// If we get here, this means the part has received a redirect before
// m_doc was created. Update the document with the base URL.
- d->m_doc->setBaseURL(d->m_baseURL.url());
+ d->m_doc->setBaseURL(m_baseURL.url());
}
d->m_workingURL = url;
@@ -218,10 +192,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
d->m_doc->setURL( url.url() );
// do not set base URL if it has already been set
- if (!d->m_workingURL.isEmpty() && d->m_baseURL.isEmpty())
+ if (!d->m_workingURL.isEmpty() && m_baseURL.isEmpty())
{
// We're not planning to support the KDE chained URL feature, AFAIK
-#define KDE_CHAINED_URIS 0
#if KDE_CHAINED_URIS
KURL::List lst = KURL::split( d->m_workingURL );
KURL baseurl;
@@ -252,7 +225,8 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
#endif
}
-void KHTMLPart::write( const char *str, int len )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::write( const char *str, int len )
{
/* FIXME: hook this code back when we have decoders completely working */
#ifndef APPLE_CHANGES
@@ -301,28 +275,28 @@ void KHTMLPart::write( const char *str, int len )
// FIX ME: This is very expensive. We should using the IFMutableData
// that represents the document, and only constructing the complete
// string when requested.
- d->m_documentSource += QString(str, len);
+ m_documentSource += QString(str, len);
QString decoded;
- if (d->m_decodingStarted)
+ if (m_decodingStarted)
decoded = d->m_decoder->decode( str, len );
else
- decoded = d->m_decoder->decode( d->m_documentSource, d->m_documentSource.length() );
+ decoded = d->m_decoder->decode( m_documentSource, m_documentSource.length() );
if(decoded.isEmpty()){
// Check flag to tell whether the load has completed.
// If we get here, it means that no text encoding was available.
// Try to process what we have with the default encoding.
if (d->m_bComplete) {
- decoded = d->m_documentSource;
+ decoded = m_documentSource;
}
else {
- fprintf (stderr, "WARNING: DECODER unable to decode string, length = %d, total length = %d\n", len, d->m_documentSource.length());
+ fprintf (stderr, "WARNING: DECODER unable to decode string, length = %d, total length = %d\n", len, m_documentSource.length());
return;
}
}
- d->m_decodingStarted = 1;
+ m_decodingStarted = true;
// Transition from provisional to committed data source at this point.
@@ -332,8 +306,8 @@ void KHTMLPart::write( const char *str, int len )
// end lines added in lieu of big fixme
- if (jScript())
- jScript()->appendSourceFile(m_url.url(),decoded);
+ if (part->jScript())
+ part->jScript()->appendSourceFile(part->m_url.url(),decoded);
Tokenizer* t = d->m_doc->tokenizer();
if(t)
t->write( decoded, true );
@@ -341,11 +315,12 @@ void KHTMLPart::write( const char *str, int len )
#ifdef _KWQ_TIMING
double thisTime = CFAbsoluteTimeGetCurrent() - start;
d->totalWriteTime += thisTime;
- KWQDEBUGLEVEL (0x200, "%s bytes = %d, seconds = %f, total = %f\n", m_url.url().latin1(), len, thisTime, d->totalWriteTime);
+ KWQDEBUGLEVEL (0x200, "%s bytes = %d, seconds = %f, total = %f\n", part->m_url.url().latin1(), len, thisTime, d->totalWriteTime);
#endif
}
-void KHTMLPart::end()
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::end()
{
// FIXME [rjw]: Remove this log eventually. Should never happen. For debugging
// purposes only.
@@ -359,40 +334,43 @@ void KHTMLPart::end()
d->m_doc->close();
KURL::clearCaches();
- d->m_view->complete();
+ // FIXME: If this is still needed we will have to add friend to KHTMLView,
+ // but it seems like a better thing to do is to use KHTMLPart::end() instead.
+ //d->m_view->complete();
}
-
-bool KHTMLPart::gotoBaseAnchor()
+
+bool KWQKHTMLPartImpl::gotoBaseAnchor()
{
- if ( !m_url.ref().isEmpty() )
- return gotoAnchor( m_url.ref() );
+ if ( !part->m_url.ref().isEmpty() )
+ return part->gotoAnchor( part->m_url.ref() );
return false;
}
-void KHTMLPart::scheduleRedirection( int delay, const QString &url, bool )
+// FIXME: Need to remerge this with code in khtml_part.cpp?
+void KWQKHTMLPartImpl::scheduleRedirection(int delay, const QString &url)
{
- if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
- {
- if (delay < 1) {
- delay = 1;
- }
- d->m_delayRedirect = delay;
- d->m_redirectURL = url;
- killTimer(d->m_redirectionTimer);
- d->m_redirectionTimer = startTimer( 1000 * d->m_delayRedirect);
- }
+ if( d->m_redirectURL.isEmpty() || delay < d->m_delayRedirect )
+ {
+ if (delay < 1) {
+ delay = 1;
+ }
+ d->m_delayRedirect = delay;
+ d->m_redirectURL = url;
+ killTimer(m_redirectionTimer);
+ m_redirectionTimer = startTimer(1000 * d->m_delayRedirect);
+ }
}
-void KHTMLPart::timerEvent ( QTimerEvent *e )
+void KWQKHTMLPartImpl::timerEvent(QTimerEvent *e)
{
- if (e->timerId()==d->m_redirectionTimer)
+ if (e->timerId()==m_redirectionTimer)
{
redirectJS();
return;
}
}
-void KHTMLPart::redirectJS()
+void KWQKHTMLPartImpl::redirectJS()
{
QString u = d->m_redirectURL;
d->m_delayRedirect = 0;
@@ -401,11 +379,11 @@ void KHTMLPart::redirectJS()
{
QString script = KURL::decode_string( u.right( u.length() - 11 ) );
//kdDebug( 6050 ) << "KHTMLPart::slotRedirect script=" << script << endl;
- QVariant res = executeScript( script );
+ QVariant res = part->executeScript( script );
if ( res.type() == QVariant::String ) {
- begin( url() );
- write( res.asString() );
- end();
+ part->begin( part->url() );
+ part->write( res.asString() );
+ part->end();
}
return;
}
@@ -417,21 +395,21 @@ void KHTMLPart::redirectJS()
args.setLockHistory( true );
#endif
- urlSelected( u, 0, 0, QString::null, args );
+ part->urlSelected( u, 0, 0, QString::null, args );
}
-void KHTMLPart::urlSelected( const QString &url, int button, int state, const QString &_target, KParts::URLArgs )
+void KWQKHTMLPartImpl::urlSelected( const QString &url, int button, int state, const QString &_target, KParts::URLArgs )
{
- IFWebDataSource *oldDataSource, *newDataSource;
- KURL clickedURL(completeURL( url));
- IFWebFrame *frame;
- KURL refLess(clickedURL);
+ IFWebDataSource *oldDataSource, *newDataSource;
+ KURL clickedURL(part->completeURL( url));
+ IFWebFrame *frame;
+ KURL refLess(clickedURL);
if ( url.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 )
{
- executeScript( url.right( url.length() - 11) );
+ part->executeScript( url.right( url.length() - 11) );
return;
}
@@ -441,32 +419,32 @@ void KHTMLPart::urlSelected( const QString &url, int button, int state, const QS
return;
}
- m_url.setRef ("");
- refLess.setRef ("");
- if (refLess.url() == m_url.url()){
- m_url = clickedURL;
- gotoAnchor (clickedURL.ref());
- return;
- }
-
- if (_target.isEmpty()){
- oldDataSource = getDataSource();
- frame = [oldDataSource webFrame];
- }
- else {
- frame = [[getDataSource() controller] frameNamed: QSTRING_TO_NSSTRING(_target)];
- oldDataSource = [frame dataSource];
- }
-
- newDataSource = WCIFWebDataSourceMake(clickedURL.getNSURL(), nil, 0);
- [newDataSource _setParent: [oldDataSource parent]];
-
- [frame setProvisionalDataSource: newDataSource];
- [frame startLoading];
+ part->m_url.setRef ("");
+ refLess.setRef ("");
+ if (refLess.url() == part->m_url.url()){
+ part->m_url = clickedURL;
+ part->gotoAnchor (clickedURL.ref());
+ return;
+ }
+
+ if (_target.isEmpty()){
+ oldDataSource = getDataSource();
+ frame = [oldDataSource webFrame];
+ }
+ else {
+ frame = [[getDataSource() controller] frameNamed: QSTRING_TO_NSSTRING(_target)];
+ oldDataSource = [frame dataSource];
+ }
+
+ newDataSource = WCIFWebDataSourceMake(clickedURL.getNSURL(), nil, 0);
+ [newDataSource _setParent: [oldDataSource parent]];
+
+ [frame setProvisionalDataSource: newDataSource];
+ [frame startLoading];
}
-bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
- const QStringList ¶ms, bool isIFrame )
+bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &url, const QString &frameName,
+ const QStringList ¶ms, bool isIFrame )
{
NSString *nsframeName = QSTRING_TO_NSSTRING(frameName);
IFWebFrame *aFrame;
@@ -488,7 +466,7 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
id <IFWebController> controller;
HTMLIFrameElementImpl *o = static_cast<HTMLIFrameElementImpl *>(frame->element());
- childURL = completeURL(url).getNSURL();
+ childURL = part->completeURL(url).getNSURL();
if (childURL == nil || [childURL path] == nil) {
NSLog (@"ERROR (probably need to fix CFURL): unable to create URL with path");
return false;
@@ -496,8 +474,8 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
oldDataSource = getDataSource();
controller = [oldDataSource controller];
- newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource inScrollView: o->scrollingMode() == QScrollView::AlwaysOff ? NO : YES];
- if (newFrame == nil){
+ newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource inScrollView: o->scrollingMode() != QScrollView::AlwaysOff];
+ if (newFrame == nil) {
// Controller return NO to location change, now what?
return false;
}
@@ -536,32 +514,26 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
return true;
}
-bool KHTMLPart::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
- const QStringList &args )
+bool KWQKHTMLPartImpl::requestObject( khtml::RenderPart *frame, const QString &url, const QString &serviceType,
+ const QStringList &args )
{
if (url.isEmpty()) {
return false;
}
if (!frame->widget()) {
- frame->setWidget(IFPluginWidgetCreate(completeURL(url).url(), serviceType, args, d->m_baseURL.url()));
+ frame->setWidget(IFPluginWidgetCreate(part->completeURL(url).url(), serviceType, args, m_baseURL.url()));
}
return true;
}
-bool KHTMLPart::requestObject( khtml::ChildFrame *frame, const KURL &url, const KParts::URLArgs &args )
-{
- _logNotYetImplemented();
- return false;
-}
-
-void KHTMLPart::submitForm( const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary )
+void KWQKHTMLPartImpl::submitForm( const char *action, const QString &url, const QByteArray &formData, const QString &_target, const QString& contentType, const QString& boundary )
{
QString target = _target;
//if ( target.isEmpty() )
// target = d->m_baseTarget;
- KURL u = completeURL( url );
+ KURL u = part->completeURL( url );
if ( u.isMalformed() )
{
@@ -573,7 +545,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
urlstring = KURL::decode_string(urlstring);
- executeScript( urlstring.right( urlstring.length() - 11) );
+ part->executeScript( urlstring.right( urlstring.length() - 11) );
return;
}
@@ -663,410 +635,21 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
[frame startLoading];
}
-KHTMLPart *KHTMLPart::findFrame( const QString &f )
-{
- _logNeverImplemented();
- return this;
-}
-
-bool KHTMLPart::frameExists( const QString &frameName )
+bool KWQKHTMLPartImpl::frameExists( const QString &frameName )
{
return [getDataSource() frameExists: (NSString *)frameName.getCFMutableString()];
}
-QPtrList<KParts::ReadOnlyPart> KHTMLPart::frames() const
+QString KWQKHTMLPartImpl::documentSource() const
{
- _logNeverImplemented();
- return QPtrList<KParts::ReadOnlyPart>();
+ return m_documentSource;
}
-bool KHTMLPart::event( QEvent *event )
+void KWQKHTMLPartImpl::setBaseURL(const KURL &url)
{
- if ( khtml::MousePressEvent::test( event ) )
- {
- khtmlMousePressEvent( static_cast<khtml::MousePressEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseDoubleClickEvent::test( event ) )
- {
- khtmlMouseDoubleClickEvent( static_cast<khtml::MouseDoubleClickEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseMoveEvent::test( event ) )
- {
- khtmlMouseMoveEvent( static_cast<khtml::MouseMoveEvent *>( event ) );
- return true;
- }
-
- if ( khtml::MouseReleaseEvent::test( event ) )
- {
- khtmlMouseReleaseEvent( static_cast<khtml::MouseReleaseEvent *>( event ) );
- return true;
- }
-
- if ( khtml::DrawContentsEvent::test( event ) )
- {
- khtmlDrawContentsEvent( static_cast<khtml::DrawContentsEvent *>( event ) );
- return true;
- }
-
- return false;
-}
-
-void KHTMLPart::khtmlMousePressEvent( khtml::MousePressEvent *event )
-{
- DOM::DOMString url = event->url();
- QMouseEvent *_mouse = event->qmouseEvent();
- DOM::Node innerNode = event->innerNode();
- d->m_mousePressNode = innerNode;
-
- d->m_dragStartPos = _mouse->pos();
-
- if ( !event->url().isNull() ){
- d->m_strSelectedURL = event->url().string();
- d->m_strSelectedURLTarget = event->target().string();
- }
- else
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
-
- if ( _mouse->button() == LeftButton ||
- _mouse->button() == MidButton )
- {
- d->m_bMousePressed = true;
-
-#ifndef KHTML_NO_SELECTION
- if ( _mouse->button() == LeftButton )
- {
- if ( !innerNode.isNull() && innerNode.handle()->renderer()) {
- int offset = 0;
- DOM::NodeImpl* node = 0;
- innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
- event->absX()-innerNode.handle()->renderer()->xPos(),
- event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
-
- d->m_selectionStart = node;
- d->m_startOffset = offset;
- // kdDebug(6005) << "KHTMLPart::khtmlMousePressEvent selectionStart=" << d->m_selectionStart.handle()->renderer()
- // << " offset=" << d->m_startOffset << endl;
- d->m_selectionEnd = d->m_selectionStart;
- d->m_endOffset = d->m_startOffset;
- d->m_doc->clearSelection();
- }
- else
- {
- d->m_selectionStart = DOM::Node();
- d->m_selectionEnd = DOM::Node();
- }
- //emitSelectionChanged();
- //startAutoScroll();
- }
-#else
- d->m_dragLastPos = _mouse->globalPos();
-#endif
- }
-
- if ( _mouse->button() == RightButton )
- {
- //popupMenu( d->m_strSelectedURL );
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
- }
-}
-
-void KHTMLPart::khtmlMouseDoubleClickEvent( khtml::MouseDoubleClickEvent * )
-{
-}
-
-void KHTMLPart::khtmlMouseMoveEvent( khtml::MouseMoveEvent *event )
-{
-// FIXME: need working implementation of this event
-#if 0
- QMouseEvent *_mouse = event->qmouseEvent();
- DOM::DOMString url = event->url();
- DOM::Node innerNode = event->innerNode();
-
-#define QT_NO_DRAGANDDROP 1
-#ifndef QT_NO_DRAGANDDROP
- if( d->m_bMousePressed && (!d->m_strSelectedURL.isEmpty() || (!innerNode.isNull() && innerNode.elementId() == ID_IMG) ) &&
- ( d->m_dragStartPos - _mouse->pos() ).manhattanLength() > KGlobalSettings::dndEventDelay() &&
- d->m_bDnd && d->m_mousePressNode == innerNode ) {
-
- QPixmap p;
- QDragObject *drag = 0;
- if( !d->m_strSelectedURL.isEmpty() ) {
- KURL u( completeURL( splitUrlTarget(d->m_strSelectedURL)) );
- KURLDrag* urlDrag = KURLDrag::newDrag( u, d->m_view->viewport() );
- if ( !d->m_referrer.isEmpty() )
- urlDrag->metaData()["referrer"] = d->m_referrer;
- drag = urlDrag;
- p = KMimeType::pixmapForURL(u, 0, KIcon::Desktop, KIcon::SizeMedium);
- } else {
- HTMLImageElementImpl *i = static_cast<HTMLImageElementImpl *>(innerNode.handle());
- if( i ) {
- KMultipleDrag *mdrag = new KMultipleDrag( d->m_view->viewport() );
- mdrag->addDragObject( new QImageDrag( i->currentImage(), 0L ) );
- KURL u( completeURL( splitUrlTarget( khtml::parseURL(i->getAttribute(ATTR_SRC)).string() ) ) );
- KURLDrag* urlDrag = KURLDrag::newDrag( u, 0L );
- if ( !d->m_referrer.isEmpty() )
- urlDrag->metaData()["referrer"] = d->m_referrer;
- mdrag->addDragObject( urlDrag );
- drag = mdrag;
- p = KMimeType::mimeType("image/png")->pixmap(KIcon::Desktop);
- }
- }
-
- if ( !p.isNull() )
- drag->setPixmap(p);
-
- stopAutoScroll();
- if(drag)
- drag->drag();
-
- // when we finish our drag, we need to undo our mouse press
- d->m_bMousePressed = false;
- d->m_strSelectedURL = d->m_strSelectedURLTarget = QString::null;
- return;
- }
-#endif
- DOM::DOMString url = event->url();
- DOM::DOMString target = event->target();
-
- // Not clicked -> mouse over stuff
- if ( !d->m_bMousePressed )
- {
- // The mouse is over something
- if ( url.length() )
- {
- bool shiftPressed = ( _mouse->state() & ShiftButton );
-
- // Image map
- if ( !innerNode.isNull() && innerNode.elementId() == ID_IMG )
- {
- HTMLImageElementImpl *i = static_cast<HTMLImageElementImpl *>(innerNode.handle());
- if ( i && i->isServerMap() )
- {
- khtml::RenderObject *r = i->renderer();
- if(r)
- {
- int absx, absy, vx, vy;
- r->absolutePosition(absx, absy);
- view()->contentsToViewport( absx, absy, vx, vy );
-
- int x(_mouse->x() - vx), y(_mouse->y() - vy);
-
- d->m_overURL = url.string() + QString("?%1,%2").arg(x).arg(y);
- d->m_overURLTarget = target.string();
- overURL( d->m_overURL, target.string(), shiftPressed );
- return;
- }
- }
- }
-
- // normal link
- if ( d->m_overURL.isEmpty() || d->m_overURL != url || d->m_overURLTarget != target )
- {
- d->m_overURL = url.string();
- d->m_overURLTarget = target.string();
- overURL( d->m_overURL, target.string(), shiftPressed );
- }
- }
- else // Not over a link...
- {
- if( !d->m_overURL.isEmpty() ) // and we were over a link -> reset to "default statusbar text"
- {
- d->m_overURL = d->m_overURLTarget = QString::null;
- emit onURL( QString::null );
- // Default statusbar text can be set from javascript. Otherwise it's empty.
- emit setStatusBarText( d->m_kjsDefaultStatusBarText );
- }
- }
- }
- else {
-#ifndef KHTML_NO_SELECTION
- // selection stuff
- if( d->m_bMousePressed && innerNode.handle() && innerNode.handle()->renderer() &&
- ( _mouse->state() == LeftButton )) {
- int offset;
- //kdDebug(6000) << "KHTMLPart::khtmlMouseMoveEvent x=" << event->x() << " y=" << event->y()
- // << " nodeAbsX=" << event->nodeAbsX() << " nodeAbsY=" << event->nodeAbsY()
- // << endl;
- DOM::NodeImpl* node=0;
- innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
- event->absX()-innerNode.handle()->renderer()->xPos(),
- event->absY()-innerNode.handle()->renderer()->yPos(), node, offset);
- d->m_selectionEnd = node;
- d->m_endOffset = offset;
-// if (d->m_selectionEnd.handle() && d->m_selectionEnd.handle()->renderer())
-// kdDebug( 6000 ) << "setting end of selection to " << d->m_selectionEnd.handle()->renderer() << "/"
-// << d->m_endOffset << endl;
-
- // we have to get to know if end is before start or not...
- DOM::Node n = d->m_selectionStart;
- d->m_startBeforeEnd = false;
- while(!n.isNull()) {
- if(n == d->m_selectionEnd) {
- d->m_startBeforeEnd = true;
- break;
- }
- DOM::Node next = n.firstChild();
- if(next.isNull()) next = n.nextSibling();
- while( next.isNull() && !n.parentNode().isNull() ) {
- n = n.parentNode();
- next = n.nextSibling();
- }
- n = next;
- //d->m_view->viewport()->repaint(false);
- }
-
- if ( !d->m_selectionStart.isNull() && !d->m_selectionEnd.isNull() )
- {
- if (d->m_selectionEnd == d->m_selectionStart && d->m_endOffset < d->m_startOffset)
- d->m_doc
- ->setSelection(d->m_selectionStart.handle(),d->m_endOffset,
- d->m_selectionEnd.handle(),d->m_startOffset);
- else if (d->m_startBeforeEnd)
- d->m_doc
- ->setSelection(d->m_selectionStart.handle(),d->m_startOffset,
- d->m_selectionEnd.handle(),d->m_endOffset);
- else
- d->m_doc
- ->setSelection(d->m_selectionEnd.handle(),d->m_endOffset,
- d->m_selectionStart.handle(),d->m_startOffset);
- }
- }
-#else
- if ( d->m_doc && d->m_view ) {
- QPoint diff( _mouse->globalPos() - d->m_dragLastPos );
-
- if ( abs( diff.x() ) > 64 || abs( diff.y() ) > 64 ) {
- d->m_view->scrollBy( -diff.x(), -diff.y() );
- d->m_dragLastPos = _mouse->globalPos();
- }
- }
-#endif
- }
-#endif
-}
-
-void KHTMLPart::khtmlMouseReleaseEvent( khtml::MouseReleaseEvent *event )
- {
- DOM::Node innerNode = event->innerNode();
- d->m_mousePressNode = DOM::Node();
-
- if ( d->m_bMousePressed )
- stopAutoScroll();
-
- // Used to prevent mouseMoveEvent from initiating a drag before
- // the mouse is pressed again.
- d->m_bMousePressed = false;
-
- #ifndef _KWQ_
- #define QT_NO_CLIPBOARD 1
- #ifndef QT_NO_CLIPBOARD
- QMouseEvent *_mouse = event->qmouseEvent();
- if ((_mouse->button() == MidButton) && (event->url().isNull()))
- {
- QClipboard *cb = QApplication::clipboard();
- cb->setSelectionMode( true );
- QCString plain("plain");
- QString url = cb->text(plain).stripWhiteSpace();
- KURL u(url);
- if ( u.isMalformed() ) {
- // some half-baked guesses for incomplete urls
- // (the same code is in libkonq/konq_dirpart.cc)
- if ( url.startsWith( "ftp." ) )
- {
- url.prepend( "ftp://" );
- u = url;
- }
- else
- {
- url.prepend( "http://" );
- u = url;
- }
- }
- if (u.isValid())
- {
- QString savedReferrer = d->m_referrer;
- d->m_referrer = QString::null; // Disable referrer.
- urlSelected(url, 0,0, "_top");
- d->m_referrer = savedReferrer; // Restore original referrer.
- }
- }
- #endif
-
- #ifndef KHTML_NO_SELECTION
- // delete selection in case start and end position are at the same point
- if(d->m_selectionStart == d->m_selectionEnd && d->m_startOffset == d->m_endOffset) {
- d->m_selectionStart = 0;
- d->m_selectionEnd = 0;
- d->m_startOffset = 0;
- d->m_endOffset = 0;
- //emitSelectionChanged();
- } else {
- // we have to get to know if end is before start or not...
- DOM::Node n = d->m_selectionStart;
- d->m_startBeforeEnd = false;
- if( d->m_selectionStart == d->m_selectionEnd ) {
- if( d->m_startOffset < d->m_endOffset )
- d->m_startBeforeEnd = true;
- } else {
- while(!n.isNull()) {
- if(n == d->m_selectionEnd) {
- d->m_startBeforeEnd = true;
- break;
- }
- DOM::Node next = n.firstChild();
- if(next.isNull()) next = n.nextSibling();
- while( next.isNull() && !n.parentNode().isNull() ) {
- n = n.parentNode();
- next = n.nextSibling();
- }
- n = next;
- }
- }
- if(!d->m_startBeforeEnd)
- {
- DOM::Node tmpNode = d->m_selectionStart;
- int tmpOffset = d->m_startOffset;
- d->m_selectionStart = d->m_selectionEnd;
- d->m_startOffset = d->m_endOffset;
- d->m_selectionEnd = tmpNode;
- d->m_endOffset = tmpOffset;
- d->m_startBeforeEnd = true;
- }
- // get selected text and paste to the clipboard
- #ifndef QT_NO_CLIPBOARD
- QString text = selectedText();
- text.replace(QRegExp(QChar(0xa0)), " ");
- QClipboard *cb = QApplication::clipboard();
- cb->setSelectionMode( true );
- cb->setText(text);
- cb->setSelectionMode( false );
- #endif
- //kdDebug( 6000 ) << "selectedText = " << text << endl;
- //emitSelectionChanged();
- }
- #endif
- #endif
-
- }
-
-void KHTMLPart::khtmlDrawContentsEvent( khtml::DrawContentsEvent * )
-{
-}
-
-QString KHTMLPart::documentSource() const
-{
- return d->m_documentSource;
-}
-
-void KHTMLPart::setBaseURL(const KURL &url)
-{
- d->m_baseURL = url;
- if (d->m_baseURL.protocol().startsWith( "http" ) && !d->m_baseURL.host().isEmpty() && d->m_baseURL.path().isEmpty()) {
- d->m_baseURL.setPath( "/" );
+ m_baseURL = url;
+ if (m_baseURL.protocol().startsWith( "http" ) && !m_baseURL.host().isEmpty() && m_baseURL.path().isEmpty()) {
+ m_baseURL.setPath( "/" );
// communicate the change in base URL to the document so that links and subloads work
if (d->m_doc) {
d->m_doc->setBaseURL(url.url());
@@ -1074,27 +657,22 @@ void KHTMLPart::setBaseURL(const KURL &url)
}
}
-void KHTMLPart::setView(KHTMLView *view)
+void KWQKHTMLPartImpl::setView(KHTMLView *view)
{
d->m_view = view;
}
-void KHTMLPart::nodeActivated(const DOM::Node &aNode)
-{
- KWQDEBUG ("name %s = %s\n", (const char *)aNode.nodeName().string(), (const char *)aNode.nodeValue().string());
-}
-
-void KHTMLPart::setTitle(const DOMString &title)
+void KWQKHTMLPartImpl::setTitle(const DOMString &title)
{
- [getDataSource() _setTitle:(NSString *)title.string().getCFMutableString()];
+ [getDataSource() _setTitle:title.string().getNSString()];
}
-void KHTMLPart::setDataSource(IFWebDataSource *dataSource)
+void KWQKHTMLPartImpl::setDataSource(IFWebDataSource *dataSource)
{
- d->m_dataSource = dataSource; // not retained
+ m_dataSource = dataSource; // not retained
}
-IFWebDataSource *KHTMLPart::getDataSource()
+IFWebDataSource *KWQKHTMLPartImpl::getDataSource()
{
- return (IFWebDataSource *)d->m_dataSource;
+ return m_dataSource;
}
diff --git a/WebCore/kwq/KWQKHistoryProvider.mm b/WebCore/kwq/KWQKHistoryProvider.mm
index a58c38e..5f9c90b 100644
--- a/WebCore/kwq/KWQKHistoryProvider.mm
+++ b/WebCore/kwq/KWQKHistoryProvider.mm
@@ -23,41 +23,25 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <kwqdebug.h>
-
#include <historyprovider.h>
namespace KParts {
-static HistoryProvider *instance = 0;
-
HistoryProvider *HistoryProvider::self()
{
- if (instance == 0) {
- instance = new HistoryProvider();
- }
- return instance;
-}
-
-
-HistoryProvider::HistoryProvider()
-{
+ static HistoryProvider instance;
+ return &instance;
}
-
-HistoryProvider::~HistoryProvider()
+void HistoryProvider::insert(const QString &)
{
+ // FIXME: implement real history?
}
-
bool HistoryProvider::contains(const QString &s) const
{
- // FIXME: implement real history
- return FALSE;
+ // FIXME: implement real history?
+ return false;
}
-
} // namespace KParts
-
-
-
diff --git a/WebCore/kwq/KWQKLocale.mm b/WebCore/kwq/KWQKLocale.mm
index e04960b..93fbeef 100644
--- a/WebCore/kwq/KWQKLocale.mm
+++ b/WebCore/kwq/KWQKLocale.mm
@@ -26,23 +26,17 @@
#include <qstring.h>
#include <klocale.h>
-//FIX ME:
-static QString *tempQString = NULL;
-
QString i18n(const char* text)
{
NSBundle *wkBundle = [NSBundle bundleWithIdentifier:@"com.apple.webkit"];
NSString *locString = [wkBundle localizedStringForKey:[NSString stringWithCString:text] value:nil table:nil];
-
return NSSTRING_TO_QSTRING(locString);
}
QString KLocale::language() const
{
_logNotYetImplemented();
- if (tempQString == NULL) {
- tempQString = new QString("en_US");
- }
- return *tempQString;
+ static QString language("en_US");
+ return language;
}
diff --git a/WebCore/kwq/KWQKPartsHistoryProvider.h b/WebCore/kwq/KWQKPartsHistoryProvider.h
index aeaf5d9..799cd19 100644
--- a/WebCore/kwq/KWQKPartsHistoryProvider.h
+++ b/WebCore/kwq/KWQKPartsHistoryProvider.h
@@ -26,62 +26,18 @@
#ifndef HISTORYPROVIDER_H_
#define HISTORYPROVIDER_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qobject.h>
namespace KParts {
-// class HistoryProvider =======================================================
-
class HistoryProvider : public QObject {
public:
-
- // structs -----------------------------------------------------------------
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
-
- // static member functions -------------------------------------------------
-
static HistoryProvider *self();
- // constructors, copy constructors, and destructors ------------------------
-
- HistoryProvider();
- virtual ~HistoryProvider();
-
- // member functions --------------------------------------------------------
-
+ void insert(const QString &);
bool contains(const QString &) const;
+};
- // operators ---------------------------------------------------------------
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+}
-private:
-
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
- HistoryProvider(const HistoryProvider &);
-#endif
-
-// add assignment operator
-// this private declaration prevents assignment
-#ifdef _KWQ_PEDANTIC_
- HistoryProvider &operator=(const HistoryProvider &);
-#endif
-
-}; // class HistoryProvider ====================================================
-
-
-} // namespace KParts
-
#endif
-
-
-
diff --git a/WebCore/kwq/KWQKPartsPart.h b/WebCore/kwq/KWQKPartsPart.h
index 2ec0a32..6374d0d 100644
--- a/WebCore/kwq/KWQKPartsPart.h
+++ b/WebCore/kwq/KWQKPartsPart.h
@@ -44,11 +44,20 @@ namespace KParts {
class Part : public QObject {
public:
- Part() : m_widget(0) { }
+ Part() : m_widget(0), m_ref(1) { }
+
QWidget *widget() const { return m_widget; }
void setWidget(QWidget *widget) { m_widget = widget; }
+
+ void ref() { m_ref++; }
+ void deref() { if(m_ref) m_ref--; if (!m_ref) delete this; }
+
+ void event(QEvent *event) { customEvent((QCustomEvent *)event); }
+ virtual void customEvent(QCustomEvent *) { }
+
private:
QWidget *m_widget;
+ unsigned int m_ref;
};
class ReadOnlyPart : public Part {
diff --git a/WebCore/kwq/KWQKPartsPartManager.h b/WebCore/kwq/KWQKPartsPartManager.h
index 5380961..dff5a24 100644
--- a/WebCore/kwq/KWQKPartsPartManager.h
+++ b/WebCore/kwq/KWQKPartsPartManager.h
@@ -28,6 +28,7 @@
#include <qguardedptr.h>
#include <qtimer.h>
+#include <qdatetime.h>
namespace KParts {
diff --git a/WebCore/kwq/KWQKloader.mm b/WebCore/kwq/KWQKloader.mm
index d83686e..6bd63ca 100644
--- a/WebCore/kwq/KWQKloader.mm
+++ b/WebCore/kwq/KWQKloader.mm
@@ -1,1004 +1,49 @@
/*
- This file is part of the KDE libraries
-
- Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
- Copyright (C) 2001 Dirk Mueller (mueller at kde.org)
- Copyright (C) 2002 Waldo Bastian (bastian at kde.org)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-
-#undef CACHE_DEBUG
-//#define CACHE_DEBUG
-#include <assert.h>
-
-#include "misc/loader.h"
-#ifdef APPLE_CHANGES
-#include <kwqdebug.h>
-#import <WebFoundation/WebFoundation.h>
-#include <WCLoadProgress.h>
-#include <external.h>
-#endif /* APPLE_CHANGES */
-
-// up to which size is a picture for sure cacheable
-#define MAXCACHEABLE 40*1024
-// default cache size
-#define DEFCACHESIZE 512*1024
+ * Copyright (C) 2001, 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-#include <qasyncio.h>
-#include <qasyncimageio.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qmovie.h>
+#include <KWQLoaderImpl.h>
-#include <kio/job.h>
#include <kio/jobclasses.h>
-#include <kglobal.h>
-#include <kimageio.h>
-#include <kcharsets.h>
-#include <kiconloader.h>
-#include <scheduler.h>
-#include <kdebug.h>
-#include "khtml_factory.h"
-#include "khtml_part.h"
+#include <misc/loader.h>
+#include <KWQKHTMLPartImpl.h>
-#include "css/css_stylesheetimpl.h"
-#include "xml/dom_docimpl.h"
+#include <external.h>
+#include <WCLoadProgress.h>
-using namespace khtml;
-using namespace DOM;
+#include <kwqdebug.h>
-#ifdef APPLE_CHANGES
-static bool cacheDisabled;
-#endif
+using khtml::DocLoader;
+using khtml::Loader;
+using khtml::Request;
-#ifdef APPLE_CHANGES
WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
{
WCIFLoadProgressMake = func;
}
-#endif /* APPLE_CHANGES */
-
-void CachedObject::finish()
-{
- if( m_size > MAXCACHEABLE )
- {
- m_status = Uncacheable;
- //Cache::flush(true); // Force flush.
- }
- else
- m_status = Cached;
- KURL url(m_url.string());
- if (m_expireDate && url.protocol().startsWith("http"))
- {
- KIO::http_update_cache(url, false, m_expireDate);
-#ifdef CACHE_DEBUG
- kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " << m_expireDate << endl;
-#endif
- }
-#ifdef CACHE_DEBUG
- else kdDebug(6060) << " No expire date for image "<<m_url.string()<<endl;
-#endif
-}
-
-void CachedObject::setExpireDate(int _expireDate)
-{
- // assert(_expireDate);
- if ( _expireDate != m_expireDate && (m_status == Uncacheable || m_status == Cached))
- {
- finish();
- }
- m_expireDate = _expireDate;
-}
-
-void CachedObject::setRequest(Request *_request)
-{
- if ( _request && !m_request )
- m_status = Pending;
- m_request = _request;
- if (canDelete() && m_free)
- delete this;
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, CSSStyleSheet, reload, _expireDate)
-#else
- : CachedObject(url, CSSStyleSheet, reload, _expireDate)
-#endif
-{
- // It's css we want.
- setAccept( QString::fromLatin1("text/css") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedCSSStyleSheet::~CachedCSSStyleSheet()
-{
-}
-
-void CachedCSSStyleSheet::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->setStyleSheet( m_url, m_sheet );
-}
-
-void CachedCSSStyleSheet::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedCSSStyleSheet::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_sheet = DOMString(data);
- m_loading = false;
-
- checkNotify();
-}
-
-void CachedCSSStyleSheet::checkNotify()
-{
- if(m_loading) return;
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "CachedCSSStyleSheet:: finishedLoading " << m_url.string() << endl;
-#endif
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->setStyleSheet( m_url, m_sheet );
-}
-
-
-void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, Script, reload, _expireDate)
-#else
- : CachedObject(url, Script, reload, _expireDate)
-#endif
-{
- // It's javascript we want.
- // But some websites think their scripts are <some wrong mimetype here>
- // and refuse to serve them if we only accept application/x-javascript.
- setAccept( QString::fromLatin1("*/*") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedScript::~CachedScript()
-{
-}
-
-void CachedScript::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->notifyFinished(this);
-}
-
-void CachedScript::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedScript::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_script = DOMString(data);
- m_loading = false;
- checkNotify();
-}
-
-void CachedScript::checkNotify()
-{
- if(m_loading) return;
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
-}
-
-
-void CachedScript::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// ------------------------------------------------------------------------------------------
-
-namespace khtml
-{
-
- class ImageSource : public QDataSource
- {
- public:
- ImageSource(QByteArray buf);
-
- /**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
- */
- int readyToSend();
-
- /*!
- Reads and sends a block of data.
- */
- void sendTo(QDataSink*, int count);
-
- /**
- * Sets the EOF state.
- */
- void setEOF( bool state );
-
- /*!
- KHTMLImageSource's is rewindable.
- */
- bool rewindable() const;
-
- /*!
- Enables rewinding. No special action is taken.
- */
- void enableRewind(bool on);
-
- /*
- Calls reset() on the QIODevice.
- */
- void rewind();
-
- /*
- Indicates that the buffered data is no longer
- needed.
- */
- void cleanBuffer();
-
- QByteArray buffer;
- unsigned int pos;
- private:
- bool eof : 1;
- bool rew : 1;
- bool rewable : 1;
- };
-}
-
-
-/*!
- This Class defines the DataSource for incremental loading of images.
-*/
-ImageSource::ImageSource(QByteArray buf)
-{
- buffer = buf;
- rew = false;
- pos = 0;
- eof = false;
- rewable = true;
-}
-
-/**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
-*/
-int ImageSource::readyToSend()
-{
- if(eof && pos == buffer.size())
- return -1;
-
- return buffer.size() - pos;
-}
-
-/*!
- Reads and sends a block of data.
-*/
-void ImageSource::sendTo(QDataSink* sink, int n)
-{
- sink->receive((const uchar*)&buffer.at(pos), n);
-
- pos += n;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size() && !rewable)
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-/**
- * Sets the EOF state.
- */
-void ImageSource::setEOF( bool state )
-{
- eof = state;
-}
-
-// ImageSource's is rewindable.
-bool ImageSource::rewindable() const
-{
- return rewable;
-}
-
-// Enables rewinding. No special action is taken.
-void ImageSource::enableRewind(bool on)
-{
- rew = on;
-}
-
-// Calls reset() on the QIODevice.
-void ImageSource::rewind()
-{
- pos = 0;
- if (!rew) {
- QDataSource::rewind();
- } else
- ready();
-}
-
-
-void ImageSource::cleanBuffer()
-{
- // if we need to be able to rewind, buffer is needed
- if(rew)
- return;
-
- rewable = false;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size())
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-static QString buildAcceptHeader()
-{
- QString result = KImageIO::mimeTypes( KImageIO::Reading ).join(", ");
- if (result.right(2) == ", ")
- result = result.left(result.length()-2);
- return result;
-}
-
-// -------------------------------------------------------------------------------------
-
-CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _expireDate)
-#if APPLE_CHANGES
- : QObject(), CachedObject(dl, url, Image, reload, _expireDate)
-#else
- : QObject(), CachedObject(url, Image, reload, _expireDate)
-#endif
-{
- static const QString &acceptHeader = KGlobal::staticQString( buildAcceptHeader() );
-
- m = 0;
- p = 0;
- pixPart = 0;
- bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xFF );
- typeChecked = false;
- isFullyTransparent = false;
- errorOccured = false;
- monochrome = false;
- formatType = 0;
- m_status = Unknown;
- m_size = 0;
- imgSource = 0;
- setAccept( acceptHeader );
-}
-
-CachedImage::~CachedImage()
-{
- clear();
-}
-
-void CachedImage::ref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::ref(" << c << ") " << endl;
-#endif
-
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if( m ) {
- m->unpause();
- if( m->finished() )
- m->restart();
- }
-
- // for mouseovers, dynamic changes
- if ( m_status >= Persistent && !valid_rect().isNull() )
- c->setPixmap( pixmap(), valid_rect(), this);
-}
-
-void CachedImage::deref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::deref(" << c << ") " << endl;
-#endif
- m_clients.remove( c );
- if(m && m_clients.isEmpty() && m->running())
- m->pause();
-
- if ( canDelete() && m_free )
- delete this;
-}
-
-#define BGMINWIDTH 32
-#define BGMINHEIGHT 32
-
-const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
-{
- static QRgb bgTransparant = qRgba( 0, 0, 0, 0xFF );
- if ( (bgColor != bgTransparant) && (bgColor != newc.rgb()) ) {
- delete bg; bg = 0;
- }
-
- if (bg)
- return *bg;
-
- const QPixmap &r = pixmap();
-
- if (r.isNull()) return r;
-
- // no error indication for background images
- if(errorOccured) return *Cache::nullPixmap;
-
- bool isvalid = newc.isValid();
- QSize s(pixmap_size());
- int w = r.width();
- int h = r.height();
- if ( w*h < 8192 )
- {
- if ( r.width() < BGMINWIDTH )
- w = ((BGMINWIDTH / s.width())+1) * s.width();
- if ( r.height() < BGMINHEIGHT )
- h = ((BGMINHEIGHT / s.height())+1) * s.height();
- }
- if ( (w != r.width()) || (h != r.height()) )
- {
- QPixmap pix = r;
- if ( w != r.width() )
- {
- bg = new QPixmap(w, r.height());
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
- p.drawTiledPixmap(0, 0, w, r.height(), pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, r.height());
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, r.height(), *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- pix = *bg;
- }
- if ( h != r.height() )
- {
- delete bg;
- bg = new QPixmap(w, h);
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, h, newc);
- p.drawTiledPixmap(0, 0, w, h, pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, h);
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, h, *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- }
- return *bg;
- }
-
- return r;
-}
-
-const QPixmap &CachedImage::pixmap( ) const
-{
- if(errorOccured)
- return *Cache::brokenPixmap;
-
- if(m)
- {
- if(m->framePixmap().size() != m->getValidRect().size() && m->getValidRect().size().isValid())
- {
- // pixmap is not yet completely loaded, so we
- // return a clipped version. asserting here
- // that the valid rect is always from 0/0 to fullwidth/ someheight
- if(!pixPart) pixPart = new QPixmap(m->getValidRect().size());
-
- (*pixPart) = m->framePixmap();
- pixPart->resize(m->getValidRect().size());
- return *pixPart;
- }
- else
- return m->framePixmap();
- }
- else if(p)
- return *p;
-
- return *Cache::nullPixmap;
-}
-
-
-QSize CachedImage::pixmap_size() const
-{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
-}
-
-
-QRect CachedImage::valid_rect() const
-{
- return m ? m->getValidRect() : ( p ? p->rect() : QRect());
-}
-
-
-void CachedImage::do_notify(const QPixmap& p, const QRect& r)
-{
- CachedObjectClient *c;
-
- for ( c = m_clients.first(); c != 0; c = m_clients.next() ) {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "found a client to update: " << c << endl;
-#endif
- c->setPixmap( p, r, this);
- }
-}
-
-
-void CachedImage::movieUpdated( const QRect& r )
-{
-#ifdef CACHE_DEBUG
- qDebug("movie updated %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
- m->framePixmap().size().width(), m->framePixmap().size().height());
-#endif
-
- do_notify(m->framePixmap(), r);
-}
-
-void CachedImage::movieStatus(int status)
-{
-#ifdef CACHE_DEBUG
- qDebug("movieStatus(%d)", status);
-#endif
-
- // ### the html image objects are supposed to send the load event after every frame (according to
- // netscape). We have a problem though where an image is present, and js code creates a new Image object,
- // which uses the same CachedImage, the one in the document is not supposed to be notified
-
- // just another Qt 2.2.0 bug. we cannot call
- // QMovie::frameImage if we're after QMovie::EndOfMovie
- if(status == QMovie::EndOfFrame)
- {
- const QImage& im = m->frameImage();
-#ifndef APPLE_CHANGES
- monochrome = ( ( im.depth() <= 8 ) && ( im.numColors() - int( im.hasAlphaBuffer() ) <= 2 ) );
-#endif
- if(im.width() < 5 && im.height() < 5 && im.hasAlphaBuffer()) // only evaluate for small images
- {
- QImage am = im.createAlphaMask();
- if(am.depth() == 1)
- {
- bool solid = false;
- for(int y = 0; y < am.height(); y++)
- for(int x = 0; x < am.width(); x++)
- if(am.pixelIndex(x, y)) {
- solid = true;
- break;
- }
- isFullyTransparent = (!solid);
- }
- }
-
- // we have to delete our tiled bg variant here
- // because the frame has changed (in order to keep it in sync)
- delete bg;
- bg = 0;
- }
-
-
-#ifdef APPLE_CHANGES
- if (status == QMovie::EndOfMovie)
-#else
- if((status == QMovie::EndOfMovie) ||
- ((status == QMovie::EndOfLoop) && (m_showAnimations == KHTMLSettings::KAnimationLoopOnce)) ||
- ((status == QMovie::EndOfFrame) && (m_showAnimations == KHTMLSettings::KAnimationDisabled))
- )
-#endif
- {
-#if 0
- // the movie has ended and it doesn't loop nor is it an animation,
- // so there is no need to keep the buffer in memory
- if(imgSource && (m->frameNumber() == 1))
-#else
- // WABA: Throw away the movie when it gets to the end.
- // We might want to do a pause instead in some cases if there is
- // a chance that we want to play the movie again.
- if(imgSource)
-#endif
- {
-#ifndef APPLE_CHANGES
- setShowAnimations( KHTMLSettings::KAnimationDisabled );
-
- // monochrome alphamasked images are usually about 10000 times
- // faster to draw, so this is worth the hack
- if ( p && monochrome && p->depth() > 1 )
- {
- QPixmap* pix = new QPixmap;
- pix->convertFromImage( p->convertToImage().convertDepth( 1 ), MonoOnly|AvoidDither );
- if ( p->mask() )
- pix->setMask( *p->mask() );
- delete p;
- p = pix;
- monochrome = false;
- }
-#endif
- }
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
- }
-
- if((status == QMovie::EndOfFrame) || (status == QMovie::EndOfMovie))
- {
-#ifdef CACHE_DEBUG
-// QRect r(valid_rect());
-// qDebug("movie Status frame update %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
-// pixmap().size().width(), pixmap().size().height());
-#endif
- do_notify(pixmap(), valid_rect());
- }
-}
-
-void CachedImage::movieResize(const QSize& /*s*/)
-{
-// do_notify(m->framePixmap(), QRect());
-}
-
-#ifndef APPLE_CHANGES
-void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- m_showAnimations = showAnimations;
- if ( (m_showAnimations == KHTMLSettings::KAnimationDisabled) && imgSource ) {
- imgSource->cleanBuffer();
- delete p;
- p = new QPixmap(m->framePixmap());
- m->disconnectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->disconnectStatus( this, SLOT( movieStatus( int ) ));
- m->disconnectResize( this, SLOT( movieResize( const QSize& ) ) );
- QTimer::singleShot(0, this, SLOT( deleteMovie()));
- imgSource = 0;
- }
-}
-#endif
-
-void CachedImage::deleteMovie()
-{
- delete m; m = 0;
-}
-
-void CachedImage::clear()
-{
- delete m; m = 0;
- delete p; p = 0;
- delete bg; bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xff );
- delete pixPart; pixPart = 0;
-
- formatType = 0;
-
- typeChecked = false;
- m_size = 0;
-
- // No need to delete imageSource - QMovie does it for us
- imgSource = 0;
-}
-
-void CachedImage::data ( QBuffer &_buffer, bool eof )
-{
-#if APPLE_CHANGES
- // FIXME!!!
- bool UseQPixmapForImageLoading = TRUE;
-#endif /* APPLE_CHANGES */
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
-#endif
- if ( !typeChecked )
- {
- formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
- typeChecked = true;
-
-#if APPLE_CHANGES
- if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
-#else /* APPLE_CHANGES not defined */
- if ( formatType ) // movie format exists
-#endif /* APPLE_CHANGES not defined */
- {
- imgSource = new ImageSource( _buffer.buffer());
- m = new QMovie( imgSource, 8192 );
- m->connectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->connectStatus( this, SLOT( movieStatus(int)));
- m->connectResize( this, SLOT( movieResize( const QSize& ) ) );
- }
- }
-
- if ( imgSource )
- {
- imgSource->setEOF(eof);
- imgSource->maybeReady();
- }
-
- if(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 APPLE_CHANGES
- // FIXME: this is a hack put in place until the QMovie stuff works right
- if(UseQPixmapForImageLoading || (typeChecked && !formatType))
-#else /* APPLE_CHANGES not defined */
- if(typeChecked && !formatType)
-#endif /* APPLE_CHANGES not defined */
- {
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
-#endif
- p = new QPixmap( _buffer.buffer() );
- // set size of image.
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): image is null: " << p->isNull() << endl;
-#endif
- if(p->isNull())
- {
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16)); // load "broken image" icon
- }
- else
- do_notify(*p, p->rect());
- }
-
- QSize s = pixmap_size();
- m_size = s.width() * s.height() * 2;
- }
-}
-
-void CachedImage::error( int /*err*/, const char */*text*/ )
-{
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CahcedImage::error" << endl;
-#endif
-
- clear();
- typeChecked = true;
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16));
-}
-
-// ------------------------------------------------------------------------------------------
-
-Request::Request(DocLoader* dl, CachedObject *_object, bool _incremental)
-{
- object = _object;
- object->setRequest(this);
- incremental = _incremental;
- m_docLoader = dl;
-}
-
-Request::~Request()
-{
- object->setRequest(0);
-}
-
-// ------------------------------------------------------------------------------------------
-
-DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
-{
- m_reloading = false;
- m_expireDate = 0;
- m_bautoloadImages = true;
-#ifndef APPLE_CHANGES
- m_showAnimations = KHTMLSettings::KAnimationEnabled;
-#endif
- m_part = part;
- m_doc = doc;
-
-#if APPLE_CHANGES
- Cache::init();
-#endif
- Cache::docloader->append( this );
-}
-
-DocLoader::~DocLoader()
-{
- Cache::docloader->remove( this );
-}
-
-void DocLoader::setExpireDate(int _expireDate)
-{
- m_expireDate = _expireDate;
-}
-
-CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestImage(this, url, true, m_expireDate);
- }
- }
-
- CachedImage* ci = Cache::requestImage(this, url, false, m_expireDate);
-
- return ci;
-}
-
-CachedCSSStyleSheet *DocLoader::requestStyleSheet( const DOM::DOMString &url, const QString& charset)
-{
-// KURL fullURL = url.string();
- KURL fullURL = m_doc->completeURL( url.string() );
-
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestStyleSheet(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestStyleSheet(this, url, false,m_expireDate, charset);
-}
-
-CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString& charset)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
-// KURL fullURL = url.string();
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestScript(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestScript(this, url, false,m_expireDate, charset);
-}
-
-void DocLoader::setAutoloadImages( bool enable )
-{
- if ( enable == m_bautoloadImages )
- return;
-
- m_bautoloadImages = enable;
-
- if ( !m_bautoloadImages ) return;
-
- for ( const CachedObject* co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- CachedObject::Status status = img->status();
- if ( status != CachedObject::Unknown )
- continue;
-
- Cache::loader()->load(this, img, true);
- }
-}
-
-void DocLoader::setReloading( bool enable )
-{
- m_reloading = enable;
-}
-
-#ifndef APPLE_CHANGES
-void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- if ( showAnimations == m_showAnimations ) return;
- m_showAnimations = showAnimations;
-
- const CachedObject* co;
- for ( co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- img->setShowAnimations( showAnimations );
- }
-}
-#endif
-
-void DocLoader::removeCachedObject( CachedObject* o ) const
-{
- m_docObjects.removeRef( o );
-}
-
-// ------------------------------------------------------------------------------------------
-
-#if APPLE_CHANGES
-// Class URLLoadClient ======================================================================
@implementation URLLoadClient
@@ -1104,8 +149,8 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
void *userData;
- int contentLength = [sender contentLength];
- int contentLengthReceived = [sender contentLengthReceived];
+ int contentLength = [sender contentLength];
+ int contentLengthReceived = [sender contentLengthReceived];
userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
@@ -1164,7 +209,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSURL *oldURL = job->url().getNSURL();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", [[url absoluteString] cString]);
- [m_dataSource _part]->setBaseURL([[url absoluteString] cString]);
+ [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
@@ -1174,94 +219,24 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
}
@end
-#endif
-#if APPLE_CHANGES
-namespace khtml {
-
-class LoaderPrivate
+KWQLoaderImpl::KWQLoaderImpl(Loader *l)
+ : loader(l)
{
-friend class Loader;
-public:
- LoaderPrivate(Loader *parent)
- {
- _parent = parent;
- //m_recv = [[URLLoadClient alloc] initWithLoader:parent dataSource: nil];
- }
-
- ~LoaderPrivate()
- {
- //[m_recv autorelease];
- }
-
-private:
- Loader *_parent;
- //URLLoadClient *m_recv;
-};
-
-} // namespace khtml
-#endif
-
-Loader::Loader() : QObject()
-{
- m_requestsPending.setAutoDelete( true );
- m_requestsLoading.setAutoDelete( true );
-#if APPLE_CHANGES
- d = new LoaderPrivate(this);
-#endif
}
-Loader::~Loader()
+KWQLoaderImpl::~KWQLoaderImpl()
{
-#if APPLE_CHANGES
- delete d;
-#endif
}
-
-void Loader::load(DocLoader* dl, CachedObject *object, bool incremental = true)
+void KWQLoaderImpl::setClient(Request *req)
{
- Request *req = new Request(dl, object, incremental);
-
-#if APPLE_CHANGES
- id client;
-
- IFWebDataSource *dataSource = ((KHTMLPart *)(((DocLoader *)(object->loader()))->part()))->getDataSource();
- client = [[[URLLoadClient alloc] initWithLoader:this dataSource: dataSource] autorelease];
- req->client = client;
-#endif
-
- m_requestsPending.append(req);
-
-#ifndef APPLE_CHANGES
- emit requestStarted( req->m_docLoader, req->object );
-#endif
-
- servePendingRequests();
+ IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
+ req->client = [[[URLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
}
-void Loader::servePendingRequests()
+void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
{
- if ( m_requestsPending.count() == 0 )
- return;
-
- // get the first pending request
- Request *req = m_requestsPending.take(0);
-
- #ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
- #endif
-
- // Don't attempt to load resources if we're cancelling this document.
- if ([((URLLoadClient *)req->client)->m_dataSource _isStopping])
- {
- //NSLog (@"Attempt to start loading %@ during cancelation\n", QSTRING_TO_NSSTRING(req->object->url().string()));
- return;
- }
-
- KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
-
-#ifdef APPLE_CHANGES
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n",
req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
//job->begin(d->m_recv, job);
@@ -1277,597 +252,16 @@ void Loader::servePendingRequests()
}
else {
[((URLLoadClient *)req->client)->m_dataSource _addURLHandle: job->handle()];
-#else
- if (!req->object->accept().isEmpty())
- job->addMetaData("accept", req->object->accept());
- if ( req->m_docLoader ) {
- KURL r = req->m_docLoader->doc()->URL();
- if ( r.protocol().startsWith( "http" ) && r.path().isEmpty() )
- r.setPath( "/" );
-
- job->addMetaData("referrer", r.url());
-
- if (req->m_docLoader->part()->restored())
- {
- // kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
- job->addMetaData("cache","Cache");
- }
-
- }
-
- connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
- connect( job, SIGNAL( data( KIO::Job*, const QByteArray &)),
- SLOT( slotData( KIO::Job*, const QByteArray &)));
-
- if ( req->object->schedule() )
- KIO::Scheduler::scheduleJob( job );
-#endif
-
- m_requestsLoading.insert(job, req);
}
}
-void Loader::slotFinished( KIO::Job* job )
+void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
{
- Request *r = m_requestsLoading.take( job );
- KIO::TransferJob* j = static_cast<KIO::TransferJob*>(job);
-
- if ( !r )
- return;
-
- if (j->error() || j->isErrorPage())
- {
- kdDebug(6060) << "Loader::slotFinished, with error. job->error()= " << j->error() << " job->isErrorPage()=" << j->isErrorPage() << endl;
- r->object->error( job->error(), job->errorText().ascii() );
- emit requestFailed( r->m_docLoader, r->object );
- }
- else
- {
- r->object->data(r->m_buffer, true);
- emit requestDone( r->m_docLoader, r->object );
- }
-
-#if APPLE_CHANGES
NSString *urlString;
- urlString = [NSString stringWithCString:r->object->url().string().latin1()];
+
+ urlString = [NSString stringWithCString:object->url().string().latin1()];
if ([urlString hasSuffix:@"/"]) {
urlString = [urlString substringToIndex:([urlString length] - 1)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-#endif
-
- r->object->finish();
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Loader:: JOB FINISHED " << r->object << ": " << r->object->url().string() << endl;
-#endif
-
- delete r;
- servePendingRequests();
-}
-
-#ifdef APPLE_CHANGES
-void Loader::slotData( KIO::Job*job, const char *data, int size )
-#else /* APPLE_CHANGES not defined */
-void Loader::slotData( KIO::Job*job, const QByteArray &data )
-#endif /* APPLE_CHANGES not defined */
-{
- 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 );
-
-#ifdef APPLE_CHANGES
- r->m_buffer.writeBlock( data, size );
-#else /* APPLE_CHANGES not defined */
- r->m_buffer.writeBlock( data.data(), data.size() );
-#endif /* APPLE_CHANGES not defined */
-
- if(r->incremental)
- r->object->data( r->m_buffer, false );
-}
-
-int Loader::numRequests( DocLoader* dl ) const
-{
- int res = 0;
-
- QPtrListIterator<Request> pIt( m_requestsPending );
- for (; pIt.current(); ++pIt )
- if ( pIt.current()->m_docLoader == dl )
- res++;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- for (; lIt.current(); ++lIt )
- if ( lIt.current()->m_docLoader == dl )
- res++;
-
- return res;
}
-
-void Loader::cancelRequests( DocLoader* dl )
-{
- //kdDebug( 6060 ) << "void Loader::cancelRequests()" << endl;
- //kdDebug( 6060 ) << "got " << m_requestsPending.count() << " pending requests" << endl;
- QPtrListIterator<Request> pIt( m_requestsPending );
- while ( pIt.current() )
- {
- if ( pIt.current()->m_docLoader == dl )
- {
- kdDebug( 6060 ) << "cancelling pending request for " << pIt.current()->object->url().string() << endl;
- //emit requestFailed( dl, pIt.current()->object );
- Cache::removeCacheEntry( pIt.current()->object );
- m_requestsPending.remove( pIt );
- }
- else
- ++pIt;
- }
-
- //kdDebug( 6060 ) << "got " << m_requestsLoading.count() << "loading requests" << endl;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- while ( lIt.current() )
- {
- if ( lIt.current()->m_docLoader == dl )
- {
- //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();
- //emit requestFailed( dl, pIt.current()->object );
- }
- else
- ++lIt;
- }
-}
-
-KIO::Job *Loader::jobForRequest( const DOM::DOMString &url ) const
-{
- QPtrDictIterator<Request> it( m_requestsLoading );
-
- for (; it.current(); ++it )
- {
- CachedObject *obj = it.current()->object;
-
- if ( obj && obj->url() == url )
- return static_cast<KIO::Job *>( it.currentKey() );
- }
-
- return 0;
-}
-
-// ----------------------------------------------------------------------------
-
-
-QDict<CachedObject> *Cache::cache = 0;
-QPtrList<DocLoader>* Cache::docloader = 0;
-Cache::LRUList *Cache::lru = 0;
-Loader *Cache::m_loader = 0;
-
-int Cache::maxSize = DEFCACHESIZE;
-int Cache::flushCount = 0;
-int Cache::cacheSize = 0;
-
-QPixmap *Cache::nullPixmap = 0;
-QPixmap *Cache::brokenPixmap = 0;
-
-void Cache::init()
-{
- if ( !cache )
- cache = new QDict<CachedObject>(401, true);
-
- if ( !lru )
- lru = new LRUList;
-
- if ( !docloader )
- docloader = new QPtrList<DocLoader>;
-
- if ( !nullPixmap )
- nullPixmap = new QPixmap;
-
- if ( !brokenPixmap )
-#ifdef APPLE_CHANGES
- brokenPixmap = new QPixmap;
-#else
-// brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::FileSystem, 16, KIcon::DisabledState));
- brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::Desktop, 16, KIcon::DisabledState));
-#endif
-
- if ( !m_loader )
- m_loader = new Loader();
-}
-
-void Cache::clear()
-{
- if ( !cache ) return;
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: CLEAR!" << endl;
- statistics();
-#endif
- cache->setAutoDelete( true );
- delete cache; cache = 0;
- delete lru; lru = 0;
- delete nullPixmap; nullPixmap = 0;
- delete brokenPixmap; brokenPixmap = 0;
- delete m_loader; m_loader = 0;
- delete docloader; docloader = 0;
-}
-
-CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool reload, int _expireDate )
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = 0;
- if (!reload)
- o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedImage *im = new CachedImage(dl, kurl.url(), reload, _expireDate);
- if ( dl && dl->autoloadImages() ) Cache::loader()->load(dl, im, true);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- im->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), im );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = im;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::Image)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestImage url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << ", status " << o->status() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedImage *>(o);
-}
-
-CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString & url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedCSSStyleSheet *sheet = new CachedCSSStyleSheet(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- sheet->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), sheet );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = sheet;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::CSSStyleSheet)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestStyleSheet url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedCSSStyleSheet *>(o);
-}
-
-CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedScript *script = new CachedScript(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- script->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), script );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = script;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!(o->type() == CachedObject::Script))
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestScript url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedScript *>(o);
-}
-
-void Cache::flush(bool force)
-{
- if (force)
- flushCount = 0;
- // Don't flush for every image.
- if (!lru || (lru->count() < (uint) flushCount))
- return;
-
- init();
-
-#ifdef CACHE_DEBUG
- //statistics();
- kdDebug( 6060 ) << "Cache: flush()" << endl;
-#endif
-
- int _cacheSize = 0;
-
- for ( QStringList::Iterator it = lru->fromLast(); it != lru->end(); )
- {
- QString url = *it;
- --it; // Update iterator, we might delete the current entry later on.
- CachedObject *o = cache->find( url );
-
-#if APPLE_CHANGES
- if( !o ) {
- continue;
- }
-#endif
-
- if( !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.
- }
-
- if( o->status() != CachedObject::Uncacheable )
- {
- _cacheSize += o->size();
-
- if( _cacheSize < maxSize )
- continue;
- }
- removeCacheEntry( o );
- }
- Cache::cacheSize = _cacheSize;
-
- flushCount = lru->count()+10; // Flush again when the cache has grown.
-#ifdef CACHE_DEBUG
- //statistics();
-#endif
-}
-
-void Cache::setSize( int bytes )
-{
- maxSize = bytes;
- // may be we need to clear parts of the cache
- flushCount = 0;
- flush(true);
-}
-
-void Cache::statistics()
-{
- CachedObject *o;
- // this function is for debugging purposes only
- init();
-
- int size = 0;
- int msize = 0;
- int movie = 0;
- int stylesheets = 0;
- QDictIterator<CachedObject> it(*cache);
- for(it.toFirst(); it.current(); ++it)
- {
- o = it.current();
- if(o->type() == CachedObject::Image)
- {
- CachedImage *im = static_cast<CachedImage *>(o);
- if(im->m != 0)
- {
- movie++;
- msize += im->size();
- }
- }
- else
- {
- if(o->type() == CachedObject::CSSStyleSheet)
- stylesheets++;
-
- }
- size += o->size();
- }
- size /= 1024;
-
- kdDebug( 6060 ) << "------------------------- image cache statistics -------------------" << endl;
- kdDebug( 6060 ) << "Number of items in cache: " << cache->count() << endl;
- kdDebug( 6060 ) << "Number of items in lru : " << lru->count() << endl;
- kdDebug( 6060 ) << "Number of cached images: " << cache->count()-movie << endl;
- kdDebug( 6060 ) << "Number of cached movies: " << movie << endl;
- kdDebug( 6060 ) << "Number of cached stylesheets: " << stylesheets << endl;
- kdDebug( 6060 ) << "pixmaps: allocated space approx. " << size << " kB" << endl;
- kdDebug( 6060 ) << "movies : allocated space approx. " << msize/1024 << " kB" << endl;
- kdDebug( 6060 ) << "--------------------------------------------------------------------" << endl;
-}
-
-void Cache::removeCacheEntry( CachedObject *object )
-{
- QString key = object->url().string();
-
- // this indicates the deref() method of CachedObject to delete itself when the reference counter
- // drops down to zero
- object->setFree( true );
-
- cache->remove( key );
- lru->remove( key );
-
- const DocLoader* dl;
- for ( dl=docloader->first(); dl; dl=docloader->next() )
- dl->removeCachedObject( object );
-
- if ( object->canDelete() )
- delete object;
-}
-
-#ifdef APPLE_CHANGES
-
-Cache::Statistics Cache::getStatistics()
-{
- Statistics stats;
-
- if (!cache)
- return stats;
-
- QDictIterator<CachedObject> i(*cache);
- for (i.toFirst(); i.current(); ++i) {
- CachedObject *o = i.current();
- switch (o->type()) {
- case CachedObject::Image:
- if (static_cast<CachedImage *>(o)->m) {
- stats.movies.count++;
- stats.movies.size += o->size();
- } else {
- stats.images.count++;
- stats.images.size += o->size();
- }
- break;
-
- case CachedObject::CSSStyleSheet:
- stats.styleSheets.count++;
- stats.styleSheets.size += o->size();
- break;
-
- case CachedObject::Script:
- stats.scripts.count++;
- stats.scripts.size += o->size();
- break;
-
- default:
- stats.other.count++;
- stats.other.size += o->size();
- }
- }
-
- return stats;
-}
-
-void Cache::flushAll()
-{
- if (!cache)
- return;
-
- for (;;) {
- QDictIterator<CachedObject> i(*cache);
- CachedObject *o = i.toFirst();
- if (!o)
- break;
- removeCacheEntry(o);
- }
- cacheSize = 0;
-}
-
-void Cache::setCacheDisabled(bool disabled)
-{
- cacheDisabled = disabled;
- if (disabled)
- flushAll();
-}
-
-void Cache::preloadScript(const QString &, const QString &)
-{
-}
-
-void Cache::preloadStyleSheet(const QString &, const QString &)
-{
-}
-
-#endif
-
-#include "loader.moc"
diff --git a/WebCore/kwq/KWQListBox.h b/WebCore/kwq/KWQListBox.h
index 6d8904a..530c82a 100644
--- a/WebCore/kwq/KWQListBox.h
+++ b/WebCore/kwq/KWQListBox.h
@@ -34,7 +34,7 @@
#include <qstring.h>
#if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
-#include <Cocoa/Cocoa.h>
+#import <Cocoa/Cocoa.h>
#endif
class QListBoxItem;
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.m b/WebCore/kwq/KWQLoader.h
similarity index 74%
copy from WebCore/kwq/WebCoreTextRendererFactory.m
copy to WebCore/kwq/KWQLoader.h
index f7ba9e4..a1e4de3 100644
--- a/WebCore/kwq/WebCoreTextRendererFactory.m
+++ b/WebCore/kwq/KWQLoader.h
@@ -23,31 +23,29 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "WebCoreTextRendererFactory.h"
-#import <kwqdebug.h>
-
- at implementation WebCoreTextRendererFactory
-
-static WebCoreTextRendererFactory *sharedFactory;
-
-+ (WebCoreTextRendererFactory *)sharedFactory
-{
- return sharedFactory;
+namespace khtml {
+ class CachedObject;
+ class Loader;
+ class Request;
}
-- init
-{
- [super init];
-
- KWQ_ASSERT(!sharedFactory);
- sharedFactory = [self retain];
-
- return self;
+namespace KIO {
+ class TransferJob;
}
-- (id <WebCoreTextRenderer>)rendererWithFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size
+class KWQLoaderImpl
{
- return nil;
-}
+public:
+ KWQLoaderImpl(khtml::Loader *);
+ ~KWQLoaderImpl();
+
+ void setClient(khtml::Request *);
+ void serveRequest(khtml::Request *, KIO::TransferJob *);
+ void objectFinished(khtml::CachedObject *);
- at end
+private:
+ KWQLoaderImpl(const KWQLoaderImpl&);
+ KWQLoaderImpl& operator=(const KWQLoaderImpl&);
+
+ khtml::Loader *loader;
+};
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index d83686e..6bd63ca 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -1,1004 +1,49 @@
/*
- This file is part of the KDE libraries
-
- Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
- Copyright (C) 2001 Dirk Mueller (mueller at kde.org)
- Copyright (C) 2002 Waldo Bastian (bastian at kde.org)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-
-#undef CACHE_DEBUG
-//#define CACHE_DEBUG
-#include <assert.h>
-
-#include "misc/loader.h"
-#ifdef APPLE_CHANGES
-#include <kwqdebug.h>
-#import <WebFoundation/WebFoundation.h>
-#include <WCLoadProgress.h>
-#include <external.h>
-#endif /* APPLE_CHANGES */
-
-// up to which size is a picture for sure cacheable
-#define MAXCACHEABLE 40*1024
-// default cache size
-#define DEFCACHESIZE 512*1024
+ * Copyright (C) 2001, 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-#include <qasyncio.h>
-#include <qasyncimageio.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qmovie.h>
+#include <KWQLoaderImpl.h>
-#include <kio/job.h>
#include <kio/jobclasses.h>
-#include <kglobal.h>
-#include <kimageio.h>
-#include <kcharsets.h>
-#include <kiconloader.h>
-#include <scheduler.h>
-#include <kdebug.h>
-#include "khtml_factory.h"
-#include "khtml_part.h"
+#include <misc/loader.h>
+#include <KWQKHTMLPartImpl.h>
-#include "css/css_stylesheetimpl.h"
-#include "xml/dom_docimpl.h"
+#include <external.h>
+#include <WCLoadProgress.h>
-using namespace khtml;
-using namespace DOM;
+#include <kwqdebug.h>
-#ifdef APPLE_CHANGES
-static bool cacheDisabled;
-#endif
+using khtml::DocLoader;
+using khtml::Loader;
+using khtml::Request;
-#ifdef APPLE_CHANGES
WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
{
WCIFLoadProgressMake = func;
}
-#endif /* APPLE_CHANGES */
-
-void CachedObject::finish()
-{
- if( m_size > MAXCACHEABLE )
- {
- m_status = Uncacheable;
- //Cache::flush(true); // Force flush.
- }
- else
- m_status = Cached;
- KURL url(m_url.string());
- if (m_expireDate && url.protocol().startsWith("http"))
- {
- KIO::http_update_cache(url, false, m_expireDate);
-#ifdef CACHE_DEBUG
- kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " << m_expireDate << endl;
-#endif
- }
-#ifdef CACHE_DEBUG
- else kdDebug(6060) << " No expire date for image "<<m_url.string()<<endl;
-#endif
-}
-
-void CachedObject::setExpireDate(int _expireDate)
-{
- // assert(_expireDate);
- if ( _expireDate != m_expireDate && (m_status == Uncacheable || m_status == Cached))
- {
- finish();
- }
- m_expireDate = _expireDate;
-}
-
-void CachedObject::setRequest(Request *_request)
-{
- if ( _request && !m_request )
- m_status = Pending;
- m_request = _request;
- if (canDelete() && m_free)
- delete this;
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, CSSStyleSheet, reload, _expireDate)
-#else
- : CachedObject(url, CSSStyleSheet, reload, _expireDate)
-#endif
-{
- // It's css we want.
- setAccept( QString::fromLatin1("text/css") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedCSSStyleSheet::~CachedCSSStyleSheet()
-{
-}
-
-void CachedCSSStyleSheet::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->setStyleSheet( m_url, m_sheet );
-}
-
-void CachedCSSStyleSheet::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedCSSStyleSheet::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_sheet = DOMString(data);
- m_loading = false;
-
- checkNotify();
-}
-
-void CachedCSSStyleSheet::checkNotify()
-{
- if(m_loading) return;
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "CachedCSSStyleSheet:: finishedLoading " << m_url.string() << endl;
-#endif
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->setStyleSheet( m_url, m_sheet );
-}
-
-
-void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, Script, reload, _expireDate)
-#else
- : CachedObject(url, Script, reload, _expireDate)
-#endif
-{
- // It's javascript we want.
- // But some websites think their scripts are <some wrong mimetype here>
- // and refuse to serve them if we only accept application/x-javascript.
- setAccept( QString::fromLatin1("*/*") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedScript::~CachedScript()
-{
-}
-
-void CachedScript::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->notifyFinished(this);
-}
-
-void CachedScript::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedScript::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_script = DOMString(data);
- m_loading = false;
- checkNotify();
-}
-
-void CachedScript::checkNotify()
-{
- if(m_loading) return;
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
-}
-
-
-void CachedScript::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// ------------------------------------------------------------------------------------------
-
-namespace khtml
-{
-
- class ImageSource : public QDataSource
- {
- public:
- ImageSource(QByteArray buf);
-
- /**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
- */
- int readyToSend();
-
- /*!
- Reads and sends a block of data.
- */
- void sendTo(QDataSink*, int count);
-
- /**
- * Sets the EOF state.
- */
- void setEOF( bool state );
-
- /*!
- KHTMLImageSource's is rewindable.
- */
- bool rewindable() const;
-
- /*!
- Enables rewinding. No special action is taken.
- */
- void enableRewind(bool on);
-
- /*
- Calls reset() on the QIODevice.
- */
- void rewind();
-
- /*
- Indicates that the buffered data is no longer
- needed.
- */
- void cleanBuffer();
-
- QByteArray buffer;
- unsigned int pos;
- private:
- bool eof : 1;
- bool rew : 1;
- bool rewable : 1;
- };
-}
-
-
-/*!
- This Class defines the DataSource for incremental loading of images.
-*/
-ImageSource::ImageSource(QByteArray buf)
-{
- buffer = buf;
- rew = false;
- pos = 0;
- eof = false;
- rewable = true;
-}
-
-/**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
-*/
-int ImageSource::readyToSend()
-{
- if(eof && pos == buffer.size())
- return -1;
-
- return buffer.size() - pos;
-}
-
-/*!
- Reads and sends a block of data.
-*/
-void ImageSource::sendTo(QDataSink* sink, int n)
-{
- sink->receive((const uchar*)&buffer.at(pos), n);
-
- pos += n;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size() && !rewable)
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-/**
- * Sets the EOF state.
- */
-void ImageSource::setEOF( bool state )
-{
- eof = state;
-}
-
-// ImageSource's is rewindable.
-bool ImageSource::rewindable() const
-{
- return rewable;
-}
-
-// Enables rewinding. No special action is taken.
-void ImageSource::enableRewind(bool on)
-{
- rew = on;
-}
-
-// Calls reset() on the QIODevice.
-void ImageSource::rewind()
-{
- pos = 0;
- if (!rew) {
- QDataSource::rewind();
- } else
- ready();
-}
-
-
-void ImageSource::cleanBuffer()
-{
- // if we need to be able to rewind, buffer is needed
- if(rew)
- return;
-
- rewable = false;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size())
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-static QString buildAcceptHeader()
-{
- QString result = KImageIO::mimeTypes( KImageIO::Reading ).join(", ");
- if (result.right(2) == ", ")
- result = result.left(result.length()-2);
- return result;
-}
-
-// -------------------------------------------------------------------------------------
-
-CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _expireDate)
-#if APPLE_CHANGES
- : QObject(), CachedObject(dl, url, Image, reload, _expireDate)
-#else
- : QObject(), CachedObject(url, Image, reload, _expireDate)
-#endif
-{
- static const QString &acceptHeader = KGlobal::staticQString( buildAcceptHeader() );
-
- m = 0;
- p = 0;
- pixPart = 0;
- bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xFF );
- typeChecked = false;
- isFullyTransparent = false;
- errorOccured = false;
- monochrome = false;
- formatType = 0;
- m_status = Unknown;
- m_size = 0;
- imgSource = 0;
- setAccept( acceptHeader );
-}
-
-CachedImage::~CachedImage()
-{
- clear();
-}
-
-void CachedImage::ref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::ref(" << c << ") " << endl;
-#endif
-
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if( m ) {
- m->unpause();
- if( m->finished() )
- m->restart();
- }
-
- // for mouseovers, dynamic changes
- if ( m_status >= Persistent && !valid_rect().isNull() )
- c->setPixmap( pixmap(), valid_rect(), this);
-}
-
-void CachedImage::deref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::deref(" << c << ") " << endl;
-#endif
- m_clients.remove( c );
- if(m && m_clients.isEmpty() && m->running())
- m->pause();
-
- if ( canDelete() && m_free )
- delete this;
-}
-
-#define BGMINWIDTH 32
-#define BGMINHEIGHT 32
-
-const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
-{
- static QRgb bgTransparant = qRgba( 0, 0, 0, 0xFF );
- if ( (bgColor != bgTransparant) && (bgColor != newc.rgb()) ) {
- delete bg; bg = 0;
- }
-
- if (bg)
- return *bg;
-
- const QPixmap &r = pixmap();
-
- if (r.isNull()) return r;
-
- // no error indication for background images
- if(errorOccured) return *Cache::nullPixmap;
-
- bool isvalid = newc.isValid();
- QSize s(pixmap_size());
- int w = r.width();
- int h = r.height();
- if ( w*h < 8192 )
- {
- if ( r.width() < BGMINWIDTH )
- w = ((BGMINWIDTH / s.width())+1) * s.width();
- if ( r.height() < BGMINHEIGHT )
- h = ((BGMINHEIGHT / s.height())+1) * s.height();
- }
- if ( (w != r.width()) || (h != r.height()) )
- {
- QPixmap pix = r;
- if ( w != r.width() )
- {
- bg = new QPixmap(w, r.height());
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
- p.drawTiledPixmap(0, 0, w, r.height(), pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, r.height());
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, r.height(), *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- pix = *bg;
- }
- if ( h != r.height() )
- {
- delete bg;
- bg = new QPixmap(w, h);
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, h, newc);
- p.drawTiledPixmap(0, 0, w, h, pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, h);
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, h, *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- }
- return *bg;
- }
-
- return r;
-}
-
-const QPixmap &CachedImage::pixmap( ) const
-{
- if(errorOccured)
- return *Cache::brokenPixmap;
-
- if(m)
- {
- if(m->framePixmap().size() != m->getValidRect().size() && m->getValidRect().size().isValid())
- {
- // pixmap is not yet completely loaded, so we
- // return a clipped version. asserting here
- // that the valid rect is always from 0/0 to fullwidth/ someheight
- if(!pixPart) pixPart = new QPixmap(m->getValidRect().size());
-
- (*pixPart) = m->framePixmap();
- pixPart->resize(m->getValidRect().size());
- return *pixPart;
- }
- else
- return m->framePixmap();
- }
- else if(p)
- return *p;
-
- return *Cache::nullPixmap;
-}
-
-
-QSize CachedImage::pixmap_size() const
-{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
-}
-
-
-QRect CachedImage::valid_rect() const
-{
- return m ? m->getValidRect() : ( p ? p->rect() : QRect());
-}
-
-
-void CachedImage::do_notify(const QPixmap& p, const QRect& r)
-{
- CachedObjectClient *c;
-
- for ( c = m_clients.first(); c != 0; c = m_clients.next() ) {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "found a client to update: " << c << endl;
-#endif
- c->setPixmap( p, r, this);
- }
-}
-
-
-void CachedImage::movieUpdated( const QRect& r )
-{
-#ifdef CACHE_DEBUG
- qDebug("movie updated %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
- m->framePixmap().size().width(), m->framePixmap().size().height());
-#endif
-
- do_notify(m->framePixmap(), r);
-}
-
-void CachedImage::movieStatus(int status)
-{
-#ifdef CACHE_DEBUG
- qDebug("movieStatus(%d)", status);
-#endif
-
- // ### the html image objects are supposed to send the load event after every frame (according to
- // netscape). We have a problem though where an image is present, and js code creates a new Image object,
- // which uses the same CachedImage, the one in the document is not supposed to be notified
-
- // just another Qt 2.2.0 bug. we cannot call
- // QMovie::frameImage if we're after QMovie::EndOfMovie
- if(status == QMovie::EndOfFrame)
- {
- const QImage& im = m->frameImage();
-#ifndef APPLE_CHANGES
- monochrome = ( ( im.depth() <= 8 ) && ( im.numColors() - int( im.hasAlphaBuffer() ) <= 2 ) );
-#endif
- if(im.width() < 5 && im.height() < 5 && im.hasAlphaBuffer()) // only evaluate for small images
- {
- QImage am = im.createAlphaMask();
- if(am.depth() == 1)
- {
- bool solid = false;
- for(int y = 0; y < am.height(); y++)
- for(int x = 0; x < am.width(); x++)
- if(am.pixelIndex(x, y)) {
- solid = true;
- break;
- }
- isFullyTransparent = (!solid);
- }
- }
-
- // we have to delete our tiled bg variant here
- // because the frame has changed (in order to keep it in sync)
- delete bg;
- bg = 0;
- }
-
-
-#ifdef APPLE_CHANGES
- if (status == QMovie::EndOfMovie)
-#else
- if((status == QMovie::EndOfMovie) ||
- ((status == QMovie::EndOfLoop) && (m_showAnimations == KHTMLSettings::KAnimationLoopOnce)) ||
- ((status == QMovie::EndOfFrame) && (m_showAnimations == KHTMLSettings::KAnimationDisabled))
- )
-#endif
- {
-#if 0
- // the movie has ended and it doesn't loop nor is it an animation,
- // so there is no need to keep the buffer in memory
- if(imgSource && (m->frameNumber() == 1))
-#else
- // WABA: Throw away the movie when it gets to the end.
- // We might want to do a pause instead in some cases if there is
- // a chance that we want to play the movie again.
- if(imgSource)
-#endif
- {
-#ifndef APPLE_CHANGES
- setShowAnimations( KHTMLSettings::KAnimationDisabled );
-
- // monochrome alphamasked images are usually about 10000 times
- // faster to draw, so this is worth the hack
- if ( p && monochrome && p->depth() > 1 )
- {
- QPixmap* pix = new QPixmap;
- pix->convertFromImage( p->convertToImage().convertDepth( 1 ), MonoOnly|AvoidDither );
- if ( p->mask() )
- pix->setMask( *p->mask() );
- delete p;
- p = pix;
- monochrome = false;
- }
-#endif
- }
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
- }
-
- if((status == QMovie::EndOfFrame) || (status == QMovie::EndOfMovie))
- {
-#ifdef CACHE_DEBUG
-// QRect r(valid_rect());
-// qDebug("movie Status frame update %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
-// pixmap().size().width(), pixmap().size().height());
-#endif
- do_notify(pixmap(), valid_rect());
- }
-}
-
-void CachedImage::movieResize(const QSize& /*s*/)
-{
-// do_notify(m->framePixmap(), QRect());
-}
-
-#ifndef APPLE_CHANGES
-void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- m_showAnimations = showAnimations;
- if ( (m_showAnimations == KHTMLSettings::KAnimationDisabled) && imgSource ) {
- imgSource->cleanBuffer();
- delete p;
- p = new QPixmap(m->framePixmap());
- m->disconnectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->disconnectStatus( this, SLOT( movieStatus( int ) ));
- m->disconnectResize( this, SLOT( movieResize( const QSize& ) ) );
- QTimer::singleShot(0, this, SLOT( deleteMovie()));
- imgSource = 0;
- }
-}
-#endif
-
-void CachedImage::deleteMovie()
-{
- delete m; m = 0;
-}
-
-void CachedImage::clear()
-{
- delete m; m = 0;
- delete p; p = 0;
- delete bg; bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xff );
- delete pixPart; pixPart = 0;
-
- formatType = 0;
-
- typeChecked = false;
- m_size = 0;
-
- // No need to delete imageSource - QMovie does it for us
- imgSource = 0;
-}
-
-void CachedImage::data ( QBuffer &_buffer, bool eof )
-{
-#if APPLE_CHANGES
- // FIXME!!!
- bool UseQPixmapForImageLoading = TRUE;
-#endif /* APPLE_CHANGES */
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
-#endif
- if ( !typeChecked )
- {
- formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
- typeChecked = true;
-
-#if APPLE_CHANGES
- if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
-#else /* APPLE_CHANGES not defined */
- if ( formatType ) // movie format exists
-#endif /* APPLE_CHANGES not defined */
- {
- imgSource = new ImageSource( _buffer.buffer());
- m = new QMovie( imgSource, 8192 );
- m->connectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->connectStatus( this, SLOT( movieStatus(int)));
- m->connectResize( this, SLOT( movieResize( const QSize& ) ) );
- }
- }
-
- if ( imgSource )
- {
- imgSource->setEOF(eof);
- imgSource->maybeReady();
- }
-
- if(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 APPLE_CHANGES
- // FIXME: this is a hack put in place until the QMovie stuff works right
- if(UseQPixmapForImageLoading || (typeChecked && !formatType))
-#else /* APPLE_CHANGES not defined */
- if(typeChecked && !formatType)
-#endif /* APPLE_CHANGES not defined */
- {
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
-#endif
- p = new QPixmap( _buffer.buffer() );
- // set size of image.
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): image is null: " << p->isNull() << endl;
-#endif
- if(p->isNull())
- {
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16)); // load "broken image" icon
- }
- else
- do_notify(*p, p->rect());
- }
-
- QSize s = pixmap_size();
- m_size = s.width() * s.height() * 2;
- }
-}
-
-void CachedImage::error( int /*err*/, const char */*text*/ )
-{
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CahcedImage::error" << endl;
-#endif
-
- clear();
- typeChecked = true;
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16));
-}
-
-// ------------------------------------------------------------------------------------------
-
-Request::Request(DocLoader* dl, CachedObject *_object, bool _incremental)
-{
- object = _object;
- object->setRequest(this);
- incremental = _incremental;
- m_docLoader = dl;
-}
-
-Request::~Request()
-{
- object->setRequest(0);
-}
-
-// ------------------------------------------------------------------------------------------
-
-DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
-{
- m_reloading = false;
- m_expireDate = 0;
- m_bautoloadImages = true;
-#ifndef APPLE_CHANGES
- m_showAnimations = KHTMLSettings::KAnimationEnabled;
-#endif
- m_part = part;
- m_doc = doc;
-
-#if APPLE_CHANGES
- Cache::init();
-#endif
- Cache::docloader->append( this );
-}
-
-DocLoader::~DocLoader()
-{
- Cache::docloader->remove( this );
-}
-
-void DocLoader::setExpireDate(int _expireDate)
-{
- m_expireDate = _expireDate;
-}
-
-CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestImage(this, url, true, m_expireDate);
- }
- }
-
- CachedImage* ci = Cache::requestImage(this, url, false, m_expireDate);
-
- return ci;
-}
-
-CachedCSSStyleSheet *DocLoader::requestStyleSheet( const DOM::DOMString &url, const QString& charset)
-{
-// KURL fullURL = url.string();
- KURL fullURL = m_doc->completeURL( url.string() );
-
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestStyleSheet(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestStyleSheet(this, url, false,m_expireDate, charset);
-}
-
-CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString& charset)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
-// KURL fullURL = url.string();
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestScript(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestScript(this, url, false,m_expireDate, charset);
-}
-
-void DocLoader::setAutoloadImages( bool enable )
-{
- if ( enable == m_bautoloadImages )
- return;
-
- m_bautoloadImages = enable;
-
- if ( !m_bautoloadImages ) return;
-
- for ( const CachedObject* co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- CachedObject::Status status = img->status();
- if ( status != CachedObject::Unknown )
- continue;
-
- Cache::loader()->load(this, img, true);
- }
-}
-
-void DocLoader::setReloading( bool enable )
-{
- m_reloading = enable;
-}
-
-#ifndef APPLE_CHANGES
-void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- if ( showAnimations == m_showAnimations ) return;
- m_showAnimations = showAnimations;
-
- const CachedObject* co;
- for ( co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- img->setShowAnimations( showAnimations );
- }
-}
-#endif
-
-void DocLoader::removeCachedObject( CachedObject* o ) const
-{
- m_docObjects.removeRef( o );
-}
-
-// ------------------------------------------------------------------------------------------
-
-#if APPLE_CHANGES
-// Class URLLoadClient ======================================================================
@implementation URLLoadClient
@@ -1104,8 +149,8 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
void *userData;
- int contentLength = [sender contentLength];
- int contentLengthReceived = [sender contentLengthReceived];
+ int contentLength = [sender contentLength];
+ int contentLengthReceived = [sender contentLengthReceived];
userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
@@ -1164,7 +209,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSURL *oldURL = job->url().getNSURL();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", [[url absoluteString] cString]);
- [m_dataSource _part]->setBaseURL([[url absoluteString] cString]);
+ [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
@@ -1174,94 +219,24 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
}
@end
-#endif
-#if APPLE_CHANGES
-namespace khtml {
-
-class LoaderPrivate
+KWQLoaderImpl::KWQLoaderImpl(Loader *l)
+ : loader(l)
{
-friend class Loader;
-public:
- LoaderPrivate(Loader *parent)
- {
- _parent = parent;
- //m_recv = [[URLLoadClient alloc] initWithLoader:parent dataSource: nil];
- }
-
- ~LoaderPrivate()
- {
- //[m_recv autorelease];
- }
-
-private:
- Loader *_parent;
- //URLLoadClient *m_recv;
-};
-
-} // namespace khtml
-#endif
-
-Loader::Loader() : QObject()
-{
- m_requestsPending.setAutoDelete( true );
- m_requestsLoading.setAutoDelete( true );
-#if APPLE_CHANGES
- d = new LoaderPrivate(this);
-#endif
}
-Loader::~Loader()
+KWQLoaderImpl::~KWQLoaderImpl()
{
-#if APPLE_CHANGES
- delete d;
-#endif
}
-
-void Loader::load(DocLoader* dl, CachedObject *object, bool incremental = true)
+void KWQLoaderImpl::setClient(Request *req)
{
- Request *req = new Request(dl, object, incremental);
-
-#if APPLE_CHANGES
- id client;
-
- IFWebDataSource *dataSource = ((KHTMLPart *)(((DocLoader *)(object->loader()))->part()))->getDataSource();
- client = [[[URLLoadClient alloc] initWithLoader:this dataSource: dataSource] autorelease];
- req->client = client;
-#endif
-
- m_requestsPending.append(req);
-
-#ifndef APPLE_CHANGES
- emit requestStarted( req->m_docLoader, req->object );
-#endif
-
- servePendingRequests();
+ IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
+ req->client = [[[URLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
}
-void Loader::servePendingRequests()
+void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
{
- if ( m_requestsPending.count() == 0 )
- return;
-
- // get the first pending request
- Request *req = m_requestsPending.take(0);
-
- #ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
- #endif
-
- // Don't attempt to load resources if we're cancelling this document.
- if ([((URLLoadClient *)req->client)->m_dataSource _isStopping])
- {
- //NSLog (@"Attempt to start loading %@ during cancelation\n", QSTRING_TO_NSSTRING(req->object->url().string()));
- return;
- }
-
- KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
-
-#ifdef APPLE_CHANGES
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n",
req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
//job->begin(d->m_recv, job);
@@ -1277,597 +252,16 @@ void Loader::servePendingRequests()
}
else {
[((URLLoadClient *)req->client)->m_dataSource _addURLHandle: job->handle()];
-#else
- if (!req->object->accept().isEmpty())
- job->addMetaData("accept", req->object->accept());
- if ( req->m_docLoader ) {
- KURL r = req->m_docLoader->doc()->URL();
- if ( r.protocol().startsWith( "http" ) && r.path().isEmpty() )
- r.setPath( "/" );
-
- job->addMetaData("referrer", r.url());
-
- if (req->m_docLoader->part()->restored())
- {
- // kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
- job->addMetaData("cache","Cache");
- }
-
- }
-
- connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
- connect( job, SIGNAL( data( KIO::Job*, const QByteArray &)),
- SLOT( slotData( KIO::Job*, const QByteArray &)));
-
- if ( req->object->schedule() )
- KIO::Scheduler::scheduleJob( job );
-#endif
-
- m_requestsLoading.insert(job, req);
}
}
-void Loader::slotFinished( KIO::Job* job )
+void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
{
- Request *r = m_requestsLoading.take( job );
- KIO::TransferJob* j = static_cast<KIO::TransferJob*>(job);
-
- if ( !r )
- return;
-
- if (j->error() || j->isErrorPage())
- {
- kdDebug(6060) << "Loader::slotFinished, with error. job->error()= " << j->error() << " job->isErrorPage()=" << j->isErrorPage() << endl;
- r->object->error( job->error(), job->errorText().ascii() );
- emit requestFailed( r->m_docLoader, r->object );
- }
- else
- {
- r->object->data(r->m_buffer, true);
- emit requestDone( r->m_docLoader, r->object );
- }
-
-#if APPLE_CHANGES
NSString *urlString;
- urlString = [NSString stringWithCString:r->object->url().string().latin1()];
+
+ urlString = [NSString stringWithCString:object->url().string().latin1()];
if ([urlString hasSuffix:@"/"]) {
urlString = [urlString substringToIndex:([urlString length] - 1)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-#endif
-
- r->object->finish();
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Loader:: JOB FINISHED " << r->object << ": " << r->object->url().string() << endl;
-#endif
-
- delete r;
- servePendingRequests();
-}
-
-#ifdef APPLE_CHANGES
-void Loader::slotData( KIO::Job*job, const char *data, int size )
-#else /* APPLE_CHANGES not defined */
-void Loader::slotData( KIO::Job*job, const QByteArray &data )
-#endif /* APPLE_CHANGES not defined */
-{
- 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 );
-
-#ifdef APPLE_CHANGES
- r->m_buffer.writeBlock( data, size );
-#else /* APPLE_CHANGES not defined */
- r->m_buffer.writeBlock( data.data(), data.size() );
-#endif /* APPLE_CHANGES not defined */
-
- if(r->incremental)
- r->object->data( r->m_buffer, false );
-}
-
-int Loader::numRequests( DocLoader* dl ) const
-{
- int res = 0;
-
- QPtrListIterator<Request> pIt( m_requestsPending );
- for (; pIt.current(); ++pIt )
- if ( pIt.current()->m_docLoader == dl )
- res++;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- for (; lIt.current(); ++lIt )
- if ( lIt.current()->m_docLoader == dl )
- res++;
-
- return res;
}
-
-void Loader::cancelRequests( DocLoader* dl )
-{
- //kdDebug( 6060 ) << "void Loader::cancelRequests()" << endl;
- //kdDebug( 6060 ) << "got " << m_requestsPending.count() << " pending requests" << endl;
- QPtrListIterator<Request> pIt( m_requestsPending );
- while ( pIt.current() )
- {
- if ( pIt.current()->m_docLoader == dl )
- {
- kdDebug( 6060 ) << "cancelling pending request for " << pIt.current()->object->url().string() << endl;
- //emit requestFailed( dl, pIt.current()->object );
- Cache::removeCacheEntry( pIt.current()->object );
- m_requestsPending.remove( pIt );
- }
- else
- ++pIt;
- }
-
- //kdDebug( 6060 ) << "got " << m_requestsLoading.count() << "loading requests" << endl;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- while ( lIt.current() )
- {
- if ( lIt.current()->m_docLoader == dl )
- {
- //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();
- //emit requestFailed( dl, pIt.current()->object );
- }
- else
- ++lIt;
- }
-}
-
-KIO::Job *Loader::jobForRequest( const DOM::DOMString &url ) const
-{
- QPtrDictIterator<Request> it( m_requestsLoading );
-
- for (; it.current(); ++it )
- {
- CachedObject *obj = it.current()->object;
-
- if ( obj && obj->url() == url )
- return static_cast<KIO::Job *>( it.currentKey() );
- }
-
- return 0;
-}
-
-// ----------------------------------------------------------------------------
-
-
-QDict<CachedObject> *Cache::cache = 0;
-QPtrList<DocLoader>* Cache::docloader = 0;
-Cache::LRUList *Cache::lru = 0;
-Loader *Cache::m_loader = 0;
-
-int Cache::maxSize = DEFCACHESIZE;
-int Cache::flushCount = 0;
-int Cache::cacheSize = 0;
-
-QPixmap *Cache::nullPixmap = 0;
-QPixmap *Cache::brokenPixmap = 0;
-
-void Cache::init()
-{
- if ( !cache )
- cache = new QDict<CachedObject>(401, true);
-
- if ( !lru )
- lru = new LRUList;
-
- if ( !docloader )
- docloader = new QPtrList<DocLoader>;
-
- if ( !nullPixmap )
- nullPixmap = new QPixmap;
-
- if ( !brokenPixmap )
-#ifdef APPLE_CHANGES
- brokenPixmap = new QPixmap;
-#else
-// brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::FileSystem, 16, KIcon::DisabledState));
- brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::Desktop, 16, KIcon::DisabledState));
-#endif
-
- if ( !m_loader )
- m_loader = new Loader();
-}
-
-void Cache::clear()
-{
- if ( !cache ) return;
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: CLEAR!" << endl;
- statistics();
-#endif
- cache->setAutoDelete( true );
- delete cache; cache = 0;
- delete lru; lru = 0;
- delete nullPixmap; nullPixmap = 0;
- delete brokenPixmap; brokenPixmap = 0;
- delete m_loader; m_loader = 0;
- delete docloader; docloader = 0;
-}
-
-CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool reload, int _expireDate )
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = 0;
- if (!reload)
- o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedImage *im = new CachedImage(dl, kurl.url(), reload, _expireDate);
- if ( dl && dl->autoloadImages() ) Cache::loader()->load(dl, im, true);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- im->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), im );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = im;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::Image)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestImage url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << ", status " << o->status() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedImage *>(o);
-}
-
-CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString & url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedCSSStyleSheet *sheet = new CachedCSSStyleSheet(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- sheet->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), sheet );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = sheet;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::CSSStyleSheet)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestStyleSheet url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedCSSStyleSheet *>(o);
-}
-
-CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedScript *script = new CachedScript(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- script->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), script );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = script;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!(o->type() == CachedObject::Script))
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestScript url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedScript *>(o);
-}
-
-void Cache::flush(bool force)
-{
- if (force)
- flushCount = 0;
- // Don't flush for every image.
- if (!lru || (lru->count() < (uint) flushCount))
- return;
-
- init();
-
-#ifdef CACHE_DEBUG
- //statistics();
- kdDebug( 6060 ) << "Cache: flush()" << endl;
-#endif
-
- int _cacheSize = 0;
-
- for ( QStringList::Iterator it = lru->fromLast(); it != lru->end(); )
- {
- QString url = *it;
- --it; // Update iterator, we might delete the current entry later on.
- CachedObject *o = cache->find( url );
-
-#if APPLE_CHANGES
- if( !o ) {
- continue;
- }
-#endif
-
- if( !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.
- }
-
- if( o->status() != CachedObject::Uncacheable )
- {
- _cacheSize += o->size();
-
- if( _cacheSize < maxSize )
- continue;
- }
- removeCacheEntry( o );
- }
- Cache::cacheSize = _cacheSize;
-
- flushCount = lru->count()+10; // Flush again when the cache has grown.
-#ifdef CACHE_DEBUG
- //statistics();
-#endif
-}
-
-void Cache::setSize( int bytes )
-{
- maxSize = bytes;
- // may be we need to clear parts of the cache
- flushCount = 0;
- flush(true);
-}
-
-void Cache::statistics()
-{
- CachedObject *o;
- // this function is for debugging purposes only
- init();
-
- int size = 0;
- int msize = 0;
- int movie = 0;
- int stylesheets = 0;
- QDictIterator<CachedObject> it(*cache);
- for(it.toFirst(); it.current(); ++it)
- {
- o = it.current();
- if(o->type() == CachedObject::Image)
- {
- CachedImage *im = static_cast<CachedImage *>(o);
- if(im->m != 0)
- {
- movie++;
- msize += im->size();
- }
- }
- else
- {
- if(o->type() == CachedObject::CSSStyleSheet)
- stylesheets++;
-
- }
- size += o->size();
- }
- size /= 1024;
-
- kdDebug( 6060 ) << "------------------------- image cache statistics -------------------" << endl;
- kdDebug( 6060 ) << "Number of items in cache: " << cache->count() << endl;
- kdDebug( 6060 ) << "Number of items in lru : " << lru->count() << endl;
- kdDebug( 6060 ) << "Number of cached images: " << cache->count()-movie << endl;
- kdDebug( 6060 ) << "Number of cached movies: " << movie << endl;
- kdDebug( 6060 ) << "Number of cached stylesheets: " << stylesheets << endl;
- kdDebug( 6060 ) << "pixmaps: allocated space approx. " << size << " kB" << endl;
- kdDebug( 6060 ) << "movies : allocated space approx. " << msize/1024 << " kB" << endl;
- kdDebug( 6060 ) << "--------------------------------------------------------------------" << endl;
-}
-
-void Cache::removeCacheEntry( CachedObject *object )
-{
- QString key = object->url().string();
-
- // this indicates the deref() method of CachedObject to delete itself when the reference counter
- // drops down to zero
- object->setFree( true );
-
- cache->remove( key );
- lru->remove( key );
-
- const DocLoader* dl;
- for ( dl=docloader->first(); dl; dl=docloader->next() )
- dl->removeCachedObject( object );
-
- if ( object->canDelete() )
- delete object;
-}
-
-#ifdef APPLE_CHANGES
-
-Cache::Statistics Cache::getStatistics()
-{
- Statistics stats;
-
- if (!cache)
- return stats;
-
- QDictIterator<CachedObject> i(*cache);
- for (i.toFirst(); i.current(); ++i) {
- CachedObject *o = i.current();
- switch (o->type()) {
- case CachedObject::Image:
- if (static_cast<CachedImage *>(o)->m) {
- stats.movies.count++;
- stats.movies.size += o->size();
- } else {
- stats.images.count++;
- stats.images.size += o->size();
- }
- break;
-
- case CachedObject::CSSStyleSheet:
- stats.styleSheets.count++;
- stats.styleSheets.size += o->size();
- break;
-
- case CachedObject::Script:
- stats.scripts.count++;
- stats.scripts.size += o->size();
- break;
-
- default:
- stats.other.count++;
- stats.other.size += o->size();
- }
- }
-
- return stats;
-}
-
-void Cache::flushAll()
-{
- if (!cache)
- return;
-
- for (;;) {
- QDictIterator<CachedObject> i(*cache);
- CachedObject *o = i.toFirst();
- if (!o)
- break;
- removeCacheEntry(o);
- }
- cacheSize = 0;
-}
-
-void Cache::setCacheDisabled(bool disabled)
-{
- cacheDisabled = disabled;
- if (disabled)
- flushAll();
-}
-
-void Cache::preloadScript(const QString &, const QString &)
-{
-}
-
-void Cache::preloadStyleSheet(const QString &, const QString &)
-{
-}
-
-#endif
-
-#include "loader.moc"
diff --git a/WebCore/kwq/WebCoreTextRendererFactory.m b/WebCore/kwq/KWQLoaderImpl.h
similarity index 74%
copy from WebCore/kwq/WebCoreTextRendererFactory.m
copy to WebCore/kwq/KWQLoaderImpl.h
index f7ba9e4..a1e4de3 100644
--- a/WebCore/kwq/WebCoreTextRendererFactory.m
+++ b/WebCore/kwq/KWQLoaderImpl.h
@@ -23,31 +23,29 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "WebCoreTextRendererFactory.h"
-#import <kwqdebug.h>
-
- at implementation WebCoreTextRendererFactory
-
-static WebCoreTextRendererFactory *sharedFactory;
-
-+ (WebCoreTextRendererFactory *)sharedFactory
-{
- return sharedFactory;
+namespace khtml {
+ class CachedObject;
+ class Loader;
+ class Request;
}
-- init
-{
- [super init];
-
- KWQ_ASSERT(!sharedFactory);
- sharedFactory = [self retain];
-
- return self;
+namespace KIO {
+ class TransferJob;
}
-- (id <WebCoreTextRenderer>)rendererWithFamily:(NSString *)family traits:(NSFontTraitMask)traits size:(float)size
+class KWQLoaderImpl
{
- return nil;
-}
+public:
+ KWQLoaderImpl(khtml::Loader *);
+ ~KWQLoaderImpl();
+
+ void setClient(khtml::Request *);
+ void serveRequest(khtml::Request *, KIO::TransferJob *);
+ void objectFinished(khtml::CachedObject *);
- at end
+private:
+ KWQLoaderImpl(const KWQLoaderImpl&);
+ KWQLoaderImpl& operator=(const KWQLoaderImpl&);
+
+ khtml::Loader *loader;
+};
diff --git a/WebCore/kwq/KWQLoaderImpl.mm b/WebCore/kwq/KWQLoaderImpl.mm
index d83686e..6bd63ca 100644
--- a/WebCore/kwq/KWQLoaderImpl.mm
+++ b/WebCore/kwq/KWQLoaderImpl.mm
@@ -1,1004 +1,49 @@
/*
- This file is part of the KDE libraries
-
- Copyright (C) 1998 Lars Knoll (knoll at mpi-hd.mpg.de)
- Copyright (C) 2001 Dirk Mueller (mueller at kde.org)
- Copyright (C) 2002 Waldo Bastian (bastian at kde.org)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-
-#undef CACHE_DEBUG
-//#define CACHE_DEBUG
-#include <assert.h>
-
-#include "misc/loader.h"
-#ifdef APPLE_CHANGES
-#include <kwqdebug.h>
-#import <WebFoundation/WebFoundation.h>
-#include <WCLoadProgress.h>
-#include <external.h>
-#endif /* APPLE_CHANGES */
-
-// up to which size is a picture for sure cacheable
-#define MAXCACHEABLE 40*1024
-// default cache size
-#define DEFCACHESIZE 512*1024
+ * Copyright (C) 2001, 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
-#include <qasyncio.h>
-#include <qasyncimageio.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qmovie.h>
+#include <KWQLoaderImpl.h>
-#include <kio/job.h>
#include <kio/jobclasses.h>
-#include <kglobal.h>
-#include <kimageio.h>
-#include <kcharsets.h>
-#include <kiconloader.h>
-#include <scheduler.h>
-#include <kdebug.h>
-#include "khtml_factory.h"
-#include "khtml_part.h"
+#include <misc/loader.h>
+#include <KWQKHTMLPartImpl.h>
-#include "css/css_stylesheetimpl.h"
-#include "xml/dom_docimpl.h"
+#include <external.h>
+#include <WCLoadProgress.h>
-using namespace khtml;
-using namespace DOM;
+#include <kwqdebug.h>
-#ifdef APPLE_CHANGES
-static bool cacheDisabled;
-#endif
+using khtml::DocLoader;
+using khtml::Loader;
+using khtml::Request;
-#ifdef APPLE_CHANGES
WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
{
WCIFLoadProgressMake = func;
}
-#endif /* APPLE_CHANGES */
-
-void CachedObject::finish()
-{
- if( m_size > MAXCACHEABLE )
- {
- m_status = Uncacheable;
- //Cache::flush(true); // Force flush.
- }
- else
- m_status = Cached;
- KURL url(m_url.string());
- if (m_expireDate && url.protocol().startsWith("http"))
- {
- KIO::http_update_cache(url, false, m_expireDate);
-#ifdef CACHE_DEBUG
- kdDebug(6060) << " Setting expire date for image "<<m_url.string()<<" to " << m_expireDate << endl;
-#endif
- }
-#ifdef CACHE_DEBUG
- else kdDebug(6060) << " No expire date for image "<<m_url.string()<<endl;
-#endif
-}
-
-void CachedObject::setExpireDate(int _expireDate)
-{
- // assert(_expireDate);
- if ( _expireDate != m_expireDate && (m_status == Uncacheable || m_status == Cached))
- {
- finish();
- }
- m_expireDate = _expireDate;
-}
-
-void CachedObject::setRequest(Request *_request)
-{
- if ( _request && !m_request )
- m_status = Pending;
- m_request = _request;
- if (canDelete() && m_free)
- delete this;
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, CSSStyleSheet, reload, _expireDate)
-#else
- : CachedObject(url, CSSStyleSheet, reload, _expireDate)
-#endif
-{
- // It's css we want.
- setAccept( QString::fromLatin1("text/css") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedCSSStyleSheet::~CachedCSSStyleSheet()
-{
-}
-
-void CachedCSSStyleSheet::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->setStyleSheet( m_url, m_sheet );
-}
-
-void CachedCSSStyleSheet::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedCSSStyleSheet::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_sheet = DOMString(data);
- m_loading = false;
-
- checkNotify();
-}
-
-void CachedCSSStyleSheet::checkNotify()
-{
- if(m_loading) return;
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "CachedCSSStyleSheet:: finishedLoading " << m_url.string() << endl;
-#endif
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->setStyleSheet( m_url, m_sheet );
-}
-
-
-void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// -------------------------------------------------------------------------------------------
-
-CachedScript::CachedScript(DocLoader* dl, const DOMString &url, bool reload, int _expireDate, const QString& charset)
-#if APPLE_CHANGES
- : CachedObject(dl, url, Script, reload, _expireDate)
-#else
- : CachedObject(url, Script, reload, _expireDate)
-#endif
-{
- // It's javascript we want.
- // But some websites think their scripts are <some wrong mimetype here>
- // and refuse to serve them if we only accept application/x-javascript.
- setAccept( QString::fromLatin1("*/*") );
- // load the file
- Cache::loader()->load(dl, this, false);
- m_loading = true;
- bool b;
- if(!charset.isEmpty())
- m_codec = KGlobal::charsets()->codecForName(charset, b);
- else
- m_codec = QTextCodec::codecForMib(4); // latin-1
-}
-
-CachedScript::~CachedScript()
-{
-}
-
-void CachedScript::ref(CachedObjectClient *c)
-{
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if(!m_loading) c->notifyFinished(this);
-}
-
-void CachedScript::deref(CachedObjectClient *c)
-{
- m_clients.remove(c);
- if ( canDelete() && m_free )
- delete this;
-}
-
-void CachedScript::data( QBuffer &buffer, bool eof )
-{
- if(!eof) return;
- buffer.close();
- m_size = buffer.buffer().size();
- QString data = m_codec->toUnicode( buffer.buffer().data(), m_size );
- m_script = DOMString(data);
- m_loading = false;
- checkNotify();
-}
-
-void CachedScript::checkNotify()
-{
- if(m_loading) return;
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
-}
-
-
-void CachedScript::error( int /*err*/, const char */*text*/ )
-{
- m_loading = false;
- checkNotify();
-}
-
-// ------------------------------------------------------------------------------------------
-
-namespace khtml
-{
-
- class ImageSource : public QDataSource
- {
- public:
- ImageSource(QByteArray buf);
-
- /**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
- */
- int readyToSend();
-
- /*!
- Reads and sends a block of data.
- */
- void sendTo(QDataSink*, int count);
-
- /**
- * Sets the EOF state.
- */
- void setEOF( bool state );
-
- /*!
- KHTMLImageSource's is rewindable.
- */
- bool rewindable() const;
-
- /*!
- Enables rewinding. No special action is taken.
- */
- void enableRewind(bool on);
-
- /*
- Calls reset() on the QIODevice.
- */
- void rewind();
-
- /*
- Indicates that the buffered data is no longer
- needed.
- */
- void cleanBuffer();
-
- QByteArray buffer;
- unsigned int pos;
- private:
- bool eof : 1;
- bool rew : 1;
- bool rewable : 1;
- };
-}
-
-
-/*!
- This Class defines the DataSource for incremental loading of images.
-*/
-ImageSource::ImageSource(QByteArray buf)
-{
- buffer = buf;
- rew = false;
- pos = 0;
- eof = false;
- rewable = true;
-}
-
-/**
- * Overload QDataSource::readyToSend() and returns the number
- * of bytes ready to send if not eof instead of returning -1.
-*/
-int ImageSource::readyToSend()
-{
- if(eof && pos == buffer.size())
- return -1;
-
- return buffer.size() - pos;
-}
-
-/*!
- Reads and sends a block of data.
-*/
-void ImageSource::sendTo(QDataSink* sink, int n)
-{
- sink->receive((const uchar*)&buffer.at(pos), n);
-
- pos += n;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size() && !rewable)
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-/**
- * Sets the EOF state.
- */
-void ImageSource::setEOF( bool state )
-{
- eof = state;
-}
-
-// ImageSource's is rewindable.
-bool ImageSource::rewindable() const
-{
- return rewable;
-}
-
-// Enables rewinding. No special action is taken.
-void ImageSource::enableRewind(bool on)
-{
- rew = on;
-}
-
-// Calls reset() on the QIODevice.
-void ImageSource::rewind()
-{
- pos = 0;
- if (!rew) {
- QDataSource::rewind();
- } else
- ready();
-}
-
-
-void ImageSource::cleanBuffer()
-{
- // if we need to be able to rewind, buffer is needed
- if(rew)
- return;
-
- rewable = false;
-
- // buffer is no longer needed
- if(eof && pos == buffer.size())
- {
- buffer.resize(0);
- pos = 0;
- }
-}
-
-static QString buildAcceptHeader()
-{
- QString result = KImageIO::mimeTypes( KImageIO::Reading ).join(", ");
- if (result.right(2) == ", ")
- result = result.left(result.length()-2);
- return result;
-}
-
-// -------------------------------------------------------------------------------------
-
-CachedImage::CachedImage(DocLoader* dl, const DOMString &url, bool reload, int _expireDate)
-#if APPLE_CHANGES
- : QObject(), CachedObject(dl, url, Image, reload, _expireDate)
-#else
- : QObject(), CachedObject(url, Image, reload, _expireDate)
-#endif
-{
- static const QString &acceptHeader = KGlobal::staticQString( buildAcceptHeader() );
-
- m = 0;
- p = 0;
- pixPart = 0;
- bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xFF );
- typeChecked = false;
- isFullyTransparent = false;
- errorOccured = false;
- monochrome = false;
- formatType = 0;
- m_status = Unknown;
- m_size = 0;
- imgSource = 0;
- setAccept( acceptHeader );
-}
-
-CachedImage::~CachedImage()
-{
- clear();
-}
-
-void CachedImage::ref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::ref(" << c << ") " << endl;
-#endif
-
- // make sure we don't get it twice...
- m_clients.remove(c);
- m_clients.append(c);
-
- if( m ) {
- m->unpause();
- if( m->finished() )
- m->restart();
- }
-
- // for mouseovers, dynamic changes
- if ( m_status >= Persistent && !valid_rect().isNull() )
- c->setPixmap( pixmap(), valid_rect(), this);
-}
-
-void CachedImage::deref( CachedObjectClient *c )
-{
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << " CachedImage::deref(" << c << ") " << endl;
-#endif
- m_clients.remove( c );
- if(m && m_clients.isEmpty() && m->running())
- m->pause();
-
- if ( canDelete() && m_free )
- delete this;
-}
-
-#define BGMINWIDTH 32
-#define BGMINHEIGHT 32
-
-const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
-{
- static QRgb bgTransparant = qRgba( 0, 0, 0, 0xFF );
- if ( (bgColor != bgTransparant) && (bgColor != newc.rgb()) ) {
- delete bg; bg = 0;
- }
-
- if (bg)
- return *bg;
-
- const QPixmap &r = pixmap();
-
- if (r.isNull()) return r;
-
- // no error indication for background images
- if(errorOccured) return *Cache::nullPixmap;
-
- bool isvalid = newc.isValid();
- QSize s(pixmap_size());
- int w = r.width();
- int h = r.height();
- if ( w*h < 8192 )
- {
- if ( r.width() < BGMINWIDTH )
- w = ((BGMINWIDTH / s.width())+1) * s.width();
- if ( r.height() < BGMINHEIGHT )
- h = ((BGMINHEIGHT / s.height())+1) * s.height();
- }
- if ( (w != r.width()) || (h != r.height()) )
- {
- QPixmap pix = r;
- if ( w != r.width() )
- {
- bg = new QPixmap(w, r.height());
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
- p.drawTiledPixmap(0, 0, w, r.height(), pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, r.height());
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, r.height(), *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- pix = *bg;
- }
- if ( h != r.height() )
- {
- delete bg;
- bg = new QPixmap(w, h);
- QPainter p(bg);
- if(isvalid) p.fillRect(0, 0, w, h, newc);
- p.drawTiledPixmap(0, 0, w, h, pix);
- if(!isvalid && pix.mask())
- {
- // unfortunately our anti-transparency trick doesn't work here
- // we need to create a mask.
- QBitmap newmask(w, h);
- QPainter pm(&newmask);
- pm.drawTiledPixmap(0, 0, w, h, *pix.mask());
- bg->setMask(newmask);
- bgColor = bgTransparant;
- }
- else
- bgColor= newc.rgb();
- }
- return *bg;
- }
-
- return r;
-}
-
-const QPixmap &CachedImage::pixmap( ) const
-{
- if(errorOccured)
- return *Cache::brokenPixmap;
-
- if(m)
- {
- if(m->framePixmap().size() != m->getValidRect().size() && m->getValidRect().size().isValid())
- {
- // pixmap is not yet completely loaded, so we
- // return a clipped version. asserting here
- // that the valid rect is always from 0/0 to fullwidth/ someheight
- if(!pixPart) pixPart = new QPixmap(m->getValidRect().size());
-
- (*pixPart) = m->framePixmap();
- pixPart->resize(m->getValidRect().size());
- return *pixPart;
- }
- else
- return m->framePixmap();
- }
- else if(p)
- return *p;
-
- return *Cache::nullPixmap;
-}
-
-
-QSize CachedImage::pixmap_size() const
-{
- return (m ? m->framePixmap().size() : ( p ? p->size() : QSize()));
-}
-
-
-QRect CachedImage::valid_rect() const
-{
- return m ? m->getValidRect() : ( p ? p->rect() : QRect());
-}
-
-
-void CachedImage::do_notify(const QPixmap& p, const QRect& r)
-{
- CachedObjectClient *c;
-
- for ( c = m_clients.first(); c != 0; c = m_clients.next() ) {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "found a client to update: " << c << endl;
-#endif
- c->setPixmap( p, r, this);
- }
-}
-
-
-void CachedImage::movieUpdated( const QRect& r )
-{
-#ifdef CACHE_DEBUG
- qDebug("movie updated %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
- m->framePixmap().size().width(), m->framePixmap().size().height());
-#endif
-
- do_notify(m->framePixmap(), r);
-}
-
-void CachedImage::movieStatus(int status)
-{
-#ifdef CACHE_DEBUG
- qDebug("movieStatus(%d)", status);
-#endif
-
- // ### the html image objects are supposed to send the load event after every frame (according to
- // netscape). We have a problem though where an image is present, and js code creates a new Image object,
- // which uses the same CachedImage, the one in the document is not supposed to be notified
-
- // just another Qt 2.2.0 bug. we cannot call
- // QMovie::frameImage if we're after QMovie::EndOfMovie
- if(status == QMovie::EndOfFrame)
- {
- const QImage& im = m->frameImage();
-#ifndef APPLE_CHANGES
- monochrome = ( ( im.depth() <= 8 ) && ( im.numColors() - int( im.hasAlphaBuffer() ) <= 2 ) );
-#endif
- if(im.width() < 5 && im.height() < 5 && im.hasAlphaBuffer()) // only evaluate for small images
- {
- QImage am = im.createAlphaMask();
- if(am.depth() == 1)
- {
- bool solid = false;
- for(int y = 0; y < am.height(); y++)
- for(int x = 0; x < am.width(); x++)
- if(am.pixelIndex(x, y)) {
- solid = true;
- break;
- }
- isFullyTransparent = (!solid);
- }
- }
-
- // we have to delete our tiled bg variant here
- // because the frame has changed (in order to keep it in sync)
- delete bg;
- bg = 0;
- }
-
-
-#ifdef APPLE_CHANGES
- if (status == QMovie::EndOfMovie)
-#else
- if((status == QMovie::EndOfMovie) ||
- ((status == QMovie::EndOfLoop) && (m_showAnimations == KHTMLSettings::KAnimationLoopOnce)) ||
- ((status == QMovie::EndOfFrame) && (m_showAnimations == KHTMLSettings::KAnimationDisabled))
- )
-#endif
- {
-#if 0
- // the movie has ended and it doesn't loop nor is it an animation,
- // so there is no need to keep the buffer in memory
- if(imgSource && (m->frameNumber() == 1))
-#else
- // WABA: Throw away the movie when it gets to the end.
- // We might want to do a pause instead in some cases if there is
- // a chance that we want to play the movie again.
- if(imgSource)
-#endif
- {
-#ifndef APPLE_CHANGES
- setShowAnimations( KHTMLSettings::KAnimationDisabled );
-
- // monochrome alphamasked images are usually about 10000 times
- // faster to draw, so this is worth the hack
- if ( p && monochrome && p->depth() > 1 )
- {
- QPixmap* pix = new QPixmap;
- pix->convertFromImage( p->convertToImage().convertDepth( 1 ), MonoOnly|AvoidDither );
- if ( p->mask() )
- pix->setMask( *p->mask() );
- delete p;
- p = pix;
- monochrome = false;
- }
-#endif
- }
-
- CachedObjectClient *c;
- for ( c = m_clients.first(); c != 0; c = m_clients.next() )
- c->notifyFinished(this);
- }
-
- if((status == QMovie::EndOfFrame) || (status == QMovie::EndOfMovie))
- {
-#ifdef CACHE_DEBUG
-// QRect r(valid_rect());
-// qDebug("movie Status frame update %d/%d/%d/%d, pixmap size %d/%d", r.x(), r.y(), r.right(), r.bottom(),
-// pixmap().size().width(), pixmap().size().height());
-#endif
- do_notify(pixmap(), valid_rect());
- }
-}
-
-void CachedImage::movieResize(const QSize& /*s*/)
-{
-// do_notify(m->framePixmap(), QRect());
-}
-
-#ifndef APPLE_CHANGES
-void CachedImage::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- m_showAnimations = showAnimations;
- if ( (m_showAnimations == KHTMLSettings::KAnimationDisabled) && imgSource ) {
- imgSource->cleanBuffer();
- delete p;
- p = new QPixmap(m->framePixmap());
- m->disconnectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->disconnectStatus( this, SLOT( movieStatus( int ) ));
- m->disconnectResize( this, SLOT( movieResize( const QSize& ) ) );
- QTimer::singleShot(0, this, SLOT( deleteMovie()));
- imgSource = 0;
- }
-}
-#endif
-
-void CachedImage::deleteMovie()
-{
- delete m; m = 0;
-}
-
-void CachedImage::clear()
-{
- delete m; m = 0;
- delete p; p = 0;
- delete bg; bg = 0;
- bgColor = qRgba( 0, 0, 0, 0xff );
- delete pixPart; pixPart = 0;
-
- formatType = 0;
-
- typeChecked = false;
- m_size = 0;
-
- // No need to delete imageSource - QMovie does it for us
- imgSource = 0;
-}
-
-void CachedImage::data ( QBuffer &_buffer, bool eof )
-{
-#if APPLE_CHANGES
- // FIXME!!!
- bool UseQPixmapForImageLoading = TRUE;
-#endif /* APPLE_CHANGES */
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << this << "in CachedImage::data(buffersize " << _buffer.buffer().size() <<", eof=" << eof << endl;
-#endif
- if ( !typeChecked )
- {
- formatType = QImageDecoder::formatName( (const uchar*)_buffer.buffer().data(), _buffer.size());
- typeChecked = true;
-
-#if APPLE_CHANGES
- if ( !UseQPixmapForImageLoading && formatType ) // movie format exists
-#else /* APPLE_CHANGES not defined */
- if ( formatType ) // movie format exists
-#endif /* APPLE_CHANGES not defined */
- {
- imgSource = new ImageSource( _buffer.buffer());
- m = new QMovie( imgSource, 8192 );
- m->connectUpdate( this, SLOT( movieUpdated( const QRect &) ));
- m->connectStatus( this, SLOT( movieStatus(int)));
- m->connectResize( this, SLOT( movieResize( const QSize& ) ) );
- }
- }
-
- if ( imgSource )
- {
- imgSource->setEOF(eof);
- imgSource->maybeReady();
- }
-
- if(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 APPLE_CHANGES
- // FIXME: this is a hack put in place until the QMovie stuff works right
- if(UseQPixmapForImageLoading || (typeChecked && !formatType))
-#else /* APPLE_CHANGES not defined */
- if(typeChecked && !formatType)
-#endif /* APPLE_CHANGES not defined */
- {
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): reloading as pixmap:" << endl;
-#endif
- p = new QPixmap( _buffer.buffer() );
- // set size of image.
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CachedImage::data(): image is null: " << p->isNull() << endl;
-#endif
- if(p->isNull())
- {
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16)); // load "broken image" icon
- }
- else
- do_notify(*p, p->rect());
- }
-
- QSize s = pixmap_size();
- m_size = s.width() * s.height() * 2;
- }
-}
-
-void CachedImage::error( int /*err*/, const char */*text*/ )
-{
-#ifdef CACHE_DEBUG
- kdDebug(6060) << "CahcedImage::error" << endl;
-#endif
-
- clear();
- typeChecked = true;
- errorOccured = true;
- do_notify(pixmap(), QRect(0, 0, 16, 16));
-}
-
-// ------------------------------------------------------------------------------------------
-
-Request::Request(DocLoader* dl, CachedObject *_object, bool _incremental)
-{
- object = _object;
- object->setRequest(this);
- incremental = _incremental;
- m_docLoader = dl;
-}
-
-Request::~Request()
-{
- object->setRequest(0);
-}
-
-// ------------------------------------------------------------------------------------------
-
-DocLoader::DocLoader(KHTMLPart* part, DocumentImpl* doc)
-{
- m_reloading = false;
- m_expireDate = 0;
- m_bautoloadImages = true;
-#ifndef APPLE_CHANGES
- m_showAnimations = KHTMLSettings::KAnimationEnabled;
-#endif
- m_part = part;
- m_doc = doc;
-
-#if APPLE_CHANGES
- Cache::init();
-#endif
- Cache::docloader->append( this );
-}
-
-DocLoader::~DocLoader()
-{
- Cache::docloader->remove( this );
-}
-
-void DocLoader::setExpireDate(int _expireDate)
-{
- m_expireDate = _expireDate;
-}
-
-CachedImage *DocLoader::requestImage( const DOM::DOMString &url)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestImage(this, url, true, m_expireDate);
- }
- }
-
- CachedImage* ci = Cache::requestImage(this, url, false, m_expireDate);
-
- return ci;
-}
-
-CachedCSSStyleSheet *DocLoader::requestStyleSheet( const DOM::DOMString &url, const QString& charset)
-{
-// KURL fullURL = url.string();
- KURL fullURL = m_doc->completeURL( url.string() );
-
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestStyleSheet(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestStyleSheet(this, url, false,m_expireDate, charset);
-}
-
-CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString& charset)
-{
- KURL fullURL = m_doc->completeURL( url.string() );
-// KURL fullURL = url.string();
- if ( m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
-
- if (m_reloading) {
- if (!m_reloadedURLs.contains(fullURL.url())) {
- CachedObject *existing = Cache::cache->find(fullURL.url());
- if (existing)
- Cache::removeCacheEntry(existing);
- m_reloadedURLs.append(fullURL.url());
- return Cache::requestScript(this, url, true,m_expireDate, charset);
- }
- }
-
- return Cache::requestScript(this, url, false,m_expireDate, charset);
-}
-
-void DocLoader::setAutoloadImages( bool enable )
-{
- if ( enable == m_bautoloadImages )
- return;
-
- m_bautoloadImages = enable;
-
- if ( !m_bautoloadImages ) return;
-
- for ( const CachedObject* co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- CachedObject::Status status = img->status();
- if ( status != CachedObject::Unknown )
- continue;
-
- Cache::loader()->load(this, img, true);
- }
-}
-
-void DocLoader::setReloading( bool enable )
-{
- m_reloading = enable;
-}
-
-#ifndef APPLE_CHANGES
-void DocLoader::setShowAnimations( KHTMLSettings::KAnimationAdvice showAnimations )
-{
- if ( showAnimations == m_showAnimations ) return;
- m_showAnimations = showAnimations;
-
- const CachedObject* co;
- for ( co=m_docObjects.first(); co; co=m_docObjects.next() )
- if ( co->type() == CachedObject::Image )
- {
- CachedImage *img = const_cast<CachedImage*>( static_cast<const CachedImage *>( co ) );
-
- img->setShowAnimations( showAnimations );
- }
-}
-#endif
-
-void DocLoader::removeCachedObject( CachedObject* o ) const
-{
- m_docObjects.removeRef( o );
-}
-
-// ------------------------------------------------------------------------------------------
-
-#if APPLE_CHANGES
-// Class URLLoadClient ======================================================================
@implementation URLLoadClient
@@ -1104,8 +149,8 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
{
void *userData;
- int contentLength = [sender contentLength];
- int contentLengthReceived = [sender contentLengthReceived];
+ int contentLength = [sender contentLength];
+ int contentLengthReceived = [sender contentLengthReceived];
userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
@@ -1164,7 +209,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
NSURL *oldURL = job->url().getNSURL();
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", [[url absoluteString] cString]);
- [m_dataSource _part]->setBaseURL([[url absoluteString] cString]);
+ [m_dataSource _part]->impl->setBaseURL([[url absoluteString] cString]);
[m_dataSource _setFinalURL: url];
@@ -1174,94 +219,24 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
}
@end
-#endif
-#if APPLE_CHANGES
-namespace khtml {
-
-class LoaderPrivate
+KWQLoaderImpl::KWQLoaderImpl(Loader *l)
+ : loader(l)
{
-friend class Loader;
-public:
- LoaderPrivate(Loader *parent)
- {
- _parent = parent;
- //m_recv = [[URLLoadClient alloc] initWithLoader:parent dataSource: nil];
- }
-
- ~LoaderPrivate()
- {
- //[m_recv autorelease];
- }
-
-private:
- Loader *_parent;
- //URLLoadClient *m_recv;
-};
-
-} // namespace khtml
-#endif
-
-Loader::Loader() : QObject()
-{
- m_requestsPending.setAutoDelete( true );
- m_requestsLoading.setAutoDelete( true );
-#if APPLE_CHANGES
- d = new LoaderPrivate(this);
-#endif
}
-Loader::~Loader()
+KWQLoaderImpl::~KWQLoaderImpl()
{
-#if APPLE_CHANGES
- delete d;
-#endif
}
-
-void Loader::load(DocLoader* dl, CachedObject *object, bool incremental = true)
+void KWQLoaderImpl::setClient(Request *req)
{
- Request *req = new Request(dl, object, incremental);
-
-#if APPLE_CHANGES
- id client;
-
- IFWebDataSource *dataSource = ((KHTMLPart *)(((DocLoader *)(object->loader()))->part()))->getDataSource();
- client = [[[URLLoadClient alloc] initWithLoader:this dataSource: dataSource] autorelease];
- req->client = client;
-#endif
-
- m_requestsPending.append(req);
-
-#ifndef APPLE_CHANGES
- emit requestStarted( req->m_docLoader, req->object );
-#endif
-
- servePendingRequests();
+ IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
+ req->client = [[[URLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
}
-void Loader::servePendingRequests()
+void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
{
- if ( m_requestsPending.count() == 0 )
- return;
-
- // get the first pending request
- Request *req = m_requestsPending.take(0);
-
- #ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "starting Loader url=" << req->object->url().string() << endl;
- #endif
-
- // Don't attempt to load resources if we're cancelling this document.
- if ([((URLLoadClient *)req->client)->m_dataSource _isStopping])
- {
- //NSLog (@"Attempt to start loading %@ during cancelation\n", QSTRING_TO_NSSTRING(req->object->url().string()));
- return;
- }
-
- KIO::TransferJob* job = KIO::get( req->object->url().string(), req->object->reload(), false /*no GUI*/);
-
-#ifdef APPLE_CHANGES
KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n",
req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
//job->begin(d->m_recv, job);
@@ -1277,597 +252,16 @@ void Loader::servePendingRequests()
}
else {
[((URLLoadClient *)req->client)->m_dataSource _addURLHandle: job->handle()];
-#else
- if (!req->object->accept().isEmpty())
- job->addMetaData("accept", req->object->accept());
- if ( req->m_docLoader ) {
- KURL r = req->m_docLoader->doc()->URL();
- if ( r.protocol().startsWith( "http" ) && r.path().isEmpty() )
- r.setPath( "/" );
-
- job->addMetaData("referrer", r.url());
-
- if (req->m_docLoader->part()->restored())
- {
- // kdDebug() << "USING NON-VALIDATING CACHE!"<< endl;
- job->addMetaData("cache","Cache");
- }
-
- }
-
- connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotFinished( KIO::Job * ) ) );
- connect( job, SIGNAL( data( KIO::Job*, const QByteArray &)),
- SLOT( slotData( KIO::Job*, const QByteArray &)));
-
- if ( req->object->schedule() )
- KIO::Scheduler::scheduleJob( job );
-#endif
-
- m_requestsLoading.insert(job, req);
}
}
-void Loader::slotFinished( KIO::Job* job )
+void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
{
- Request *r = m_requestsLoading.take( job );
- KIO::TransferJob* j = static_cast<KIO::TransferJob*>(job);
-
- if ( !r )
- return;
-
- if (j->error() || j->isErrorPage())
- {
- kdDebug(6060) << "Loader::slotFinished, with error. job->error()= " << j->error() << " job->isErrorPage()=" << j->isErrorPage() << endl;
- r->object->error( job->error(), job->errorText().ascii() );
- emit requestFailed( r->m_docLoader, r->object );
- }
- else
- {
- r->object->data(r->m_buffer, true);
- emit requestDone( r->m_docLoader, r->object );
- }
-
-#if APPLE_CHANGES
NSString *urlString;
- urlString = [NSString stringWithCString:r->object->url().string().latin1()];
+
+ urlString = [NSString stringWithCString:object->url().string().latin1()];
if ([urlString hasSuffix:@"/"]) {
urlString = [urlString substringToIndex:([urlString length] - 1)];
}
[[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-#endif
-
- r->object->finish();
-
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Loader:: JOB FINISHED " << r->object << ": " << r->object->url().string() << endl;
-#endif
-
- delete r;
- servePendingRequests();
-}
-
-#ifdef APPLE_CHANGES
-void Loader::slotData( KIO::Job*job, const char *data, int size )
-#else /* APPLE_CHANGES not defined */
-void Loader::slotData( KIO::Job*job, const QByteArray &data )
-#endif /* APPLE_CHANGES not defined */
-{
- 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 );
-
-#ifdef APPLE_CHANGES
- r->m_buffer.writeBlock( data, size );
-#else /* APPLE_CHANGES not defined */
- r->m_buffer.writeBlock( data.data(), data.size() );
-#endif /* APPLE_CHANGES not defined */
-
- if(r->incremental)
- r->object->data( r->m_buffer, false );
-}
-
-int Loader::numRequests( DocLoader* dl ) const
-{
- int res = 0;
-
- QPtrListIterator<Request> pIt( m_requestsPending );
- for (; pIt.current(); ++pIt )
- if ( pIt.current()->m_docLoader == dl )
- res++;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- for (; lIt.current(); ++lIt )
- if ( lIt.current()->m_docLoader == dl )
- res++;
-
- return res;
}
-
-void Loader::cancelRequests( DocLoader* dl )
-{
- //kdDebug( 6060 ) << "void Loader::cancelRequests()" << endl;
- //kdDebug( 6060 ) << "got " << m_requestsPending.count() << " pending requests" << endl;
- QPtrListIterator<Request> pIt( m_requestsPending );
- while ( pIt.current() )
- {
- if ( pIt.current()->m_docLoader == dl )
- {
- kdDebug( 6060 ) << "cancelling pending request for " << pIt.current()->object->url().string() << endl;
- //emit requestFailed( dl, pIt.current()->object );
- Cache::removeCacheEntry( pIt.current()->object );
- m_requestsPending.remove( pIt );
- }
- else
- ++pIt;
- }
-
- //kdDebug( 6060 ) << "got " << m_requestsLoading.count() << "loading requests" << endl;
-
- QPtrDictIterator<Request> lIt( m_requestsLoading );
- while ( lIt.current() )
- {
- if ( lIt.current()->m_docLoader == dl )
- {
- //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();
- //emit requestFailed( dl, pIt.current()->object );
- }
- else
- ++lIt;
- }
-}
-
-KIO::Job *Loader::jobForRequest( const DOM::DOMString &url ) const
-{
- QPtrDictIterator<Request> it( m_requestsLoading );
-
- for (; it.current(); ++it )
- {
- CachedObject *obj = it.current()->object;
-
- if ( obj && obj->url() == url )
- return static_cast<KIO::Job *>( it.currentKey() );
- }
-
- return 0;
-}
-
-// ----------------------------------------------------------------------------
-
-
-QDict<CachedObject> *Cache::cache = 0;
-QPtrList<DocLoader>* Cache::docloader = 0;
-Cache::LRUList *Cache::lru = 0;
-Loader *Cache::m_loader = 0;
-
-int Cache::maxSize = DEFCACHESIZE;
-int Cache::flushCount = 0;
-int Cache::cacheSize = 0;
-
-QPixmap *Cache::nullPixmap = 0;
-QPixmap *Cache::brokenPixmap = 0;
-
-void Cache::init()
-{
- if ( !cache )
- cache = new QDict<CachedObject>(401, true);
-
- if ( !lru )
- lru = new LRUList;
-
- if ( !docloader )
- docloader = new QPtrList<DocLoader>;
-
- if ( !nullPixmap )
- nullPixmap = new QPixmap;
-
- if ( !brokenPixmap )
-#ifdef APPLE_CHANGES
- brokenPixmap = new QPixmap;
-#else
-// brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::FileSystem, 16, KIcon::DisabledState));
- brokenPixmap = new QPixmap(KHTMLFactory::instance()->iconLoader()->loadIcon("file_broken", KIcon::Desktop, 16, KIcon::DisabledState));
-#endif
-
- if ( !m_loader )
- m_loader = new Loader();
-}
-
-void Cache::clear()
-{
- if ( !cache ) return;
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: CLEAR!" << endl;
- statistics();
-#endif
- cache->setAutoDelete( true );
- delete cache; cache = 0;
- delete lru; lru = 0;
- delete nullPixmap; nullPixmap = 0;
- delete brokenPixmap; brokenPixmap = 0;
- delete m_loader; m_loader = 0;
- delete docloader; docloader = 0;
-}
-
-CachedImage *Cache::requestImage( DocLoader* dl, const DOMString & url, bool reload, int _expireDate )
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = 0;
- if (!reload)
- o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedImage *im = new CachedImage(dl, kurl.url(), reload, _expireDate);
- if ( dl && dl->autoloadImages() ) Cache::loader()->load(dl, im, true);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- im->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), im );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = im;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::Image)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestImage url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << ", status " << o->status() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedImage *>(o);
-}
-
-CachedCSSStyleSheet *Cache::requestStyleSheet( DocLoader* dl, const DOMString & url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedCSSStyleSheet *sheet = new CachedCSSStyleSheet(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- sheet->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), sheet );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = sheet;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!o->type() == CachedObject::CSSStyleSheet)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestStyleSheet url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedCSSStyleSheet *>(o);
-}
-
-CachedScript *Cache::requestScript( DocLoader* dl, const DOM::DOMString &url, bool reload, int _expireDate, const QString& charset)
-{
- // this brings the _url to a standard form...
- KURL kurl;
- if ( dl )
- kurl = dl->m_doc->completeURL( url.string() );
- else
- kurl = url.string();
-
- CachedObject *o = cache->find(kurl.url());
- if(!o)
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
-#endif
- CachedScript *script = new CachedScript(dl, kurl.url(), reload, _expireDate, charset);
-#ifdef APPLE_CHANGES
- if (cacheDisabled)
- script->setFree(true);
- else {
-#endif
- cache->insert( kurl.url(), script );
- lru->prepend( kurl.url() );
- flush();
-#ifdef APPLE_CHANGES
- }
-#endif
- o = script;
- }
-
- o->setExpireDate(_expireDate);
-
- if(!(o->type() == CachedObject::Script))
- {
-#ifdef CACHE_DEBUG
- kdDebug( 6060 ) << "Cache::Internal Error in requestScript url=" << kurl.url() << "!" << endl;
-#endif
- return 0;
- }
-
-#ifdef CACHE_DEBUG
- if( o->status() == CachedObject::Pending )
- kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
- else
- kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
-#endif
-
- lru->touch( kurl.url() );
- if ( dl ) {
- dl->m_docObjects.remove( o );
-#ifdef APPLE_CHANGES
- if (!cacheDisabled)
-#endif
- dl->m_docObjects.append( o );
- }
- return static_cast<CachedScript *>(o);
-}
-
-void Cache::flush(bool force)
-{
- if (force)
- flushCount = 0;
- // Don't flush for every image.
- if (!lru || (lru->count() < (uint) flushCount))
- return;
-
- init();
-
-#ifdef CACHE_DEBUG
- //statistics();
- kdDebug( 6060 ) << "Cache: flush()" << endl;
-#endif
-
- int _cacheSize = 0;
-
- for ( QStringList::Iterator it = lru->fromLast(); it != lru->end(); )
- {
- QString url = *it;
- --it; // Update iterator, we might delete the current entry later on.
- CachedObject *o = cache->find( url );
-
-#if APPLE_CHANGES
- if( !o ) {
- continue;
- }
-#endif
-
- if( !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.
- }
-
- if( o->status() != CachedObject::Uncacheable )
- {
- _cacheSize += o->size();
-
- if( _cacheSize < maxSize )
- continue;
- }
- removeCacheEntry( o );
- }
- Cache::cacheSize = _cacheSize;
-
- flushCount = lru->count()+10; // Flush again when the cache has grown.
-#ifdef CACHE_DEBUG
- //statistics();
-#endif
-}
-
-void Cache::setSize( int bytes )
-{
- maxSize = bytes;
- // may be we need to clear parts of the cache
- flushCount = 0;
- flush(true);
-}
-
-void Cache::statistics()
-{
- CachedObject *o;
- // this function is for debugging purposes only
- init();
-
- int size = 0;
- int msize = 0;
- int movie = 0;
- int stylesheets = 0;
- QDictIterator<CachedObject> it(*cache);
- for(it.toFirst(); it.current(); ++it)
- {
- o = it.current();
- if(o->type() == CachedObject::Image)
- {
- CachedImage *im = static_cast<CachedImage *>(o);
- if(im->m != 0)
- {
- movie++;
- msize += im->size();
- }
- }
- else
- {
- if(o->type() == CachedObject::CSSStyleSheet)
- stylesheets++;
-
- }
- size += o->size();
- }
- size /= 1024;
-
- kdDebug( 6060 ) << "------------------------- image cache statistics -------------------" << endl;
- kdDebug( 6060 ) << "Number of items in cache: " << cache->count() << endl;
- kdDebug( 6060 ) << "Number of items in lru : " << lru->count() << endl;
- kdDebug( 6060 ) << "Number of cached images: " << cache->count()-movie << endl;
- kdDebug( 6060 ) << "Number of cached movies: " << movie << endl;
- kdDebug( 6060 ) << "Number of cached stylesheets: " << stylesheets << endl;
- kdDebug( 6060 ) << "pixmaps: allocated space approx. " << size << " kB" << endl;
- kdDebug( 6060 ) << "movies : allocated space approx. " << msize/1024 << " kB" << endl;
- kdDebug( 6060 ) << "--------------------------------------------------------------------" << endl;
-}
-
-void Cache::removeCacheEntry( CachedObject *object )
-{
- QString key = object->url().string();
-
- // this indicates the deref() method of CachedObject to delete itself when the reference counter
- // drops down to zero
- object->setFree( true );
-
- cache->remove( key );
- lru->remove( key );
-
- const DocLoader* dl;
- for ( dl=docloader->first(); dl; dl=docloader->next() )
- dl->removeCachedObject( object );
-
- if ( object->canDelete() )
- delete object;
-}
-
-#ifdef APPLE_CHANGES
-
-Cache::Statistics Cache::getStatistics()
-{
- Statistics stats;
-
- if (!cache)
- return stats;
-
- QDictIterator<CachedObject> i(*cache);
- for (i.toFirst(); i.current(); ++i) {
- CachedObject *o = i.current();
- switch (o->type()) {
- case CachedObject::Image:
- if (static_cast<CachedImage *>(o)->m) {
- stats.movies.count++;
- stats.movies.size += o->size();
- } else {
- stats.images.count++;
- stats.images.size += o->size();
- }
- break;
-
- case CachedObject::CSSStyleSheet:
- stats.styleSheets.count++;
- stats.styleSheets.size += o->size();
- break;
-
- case CachedObject::Script:
- stats.scripts.count++;
- stats.scripts.size += o->size();
- break;
-
- default:
- stats.other.count++;
- stats.other.size += o->size();
- }
- }
-
- return stats;
-}
-
-void Cache::flushAll()
-{
- if (!cache)
- return;
-
- for (;;) {
- QDictIterator<CachedObject> i(*cache);
- CachedObject *o = i.toFirst();
- if (!o)
- break;
- removeCacheEntry(o);
- }
- cacheSize = 0;
-}
-
-void Cache::setCacheDisabled(bool disabled)
-{
- cacheDisabled = disabled;
- if (disabled)
- flushAll();
-}
-
-void Cache::preloadScript(const QString &, const QString &)
-{
-}
-
-void Cache::preloadStyleSheet(const QString &, const QString &)
-{
-}
-
-#endif
-
-#include "loader.moc"
diff --git a/WebCore/kwq/KWQNSTextField.h b/WebCore/kwq/KWQNSTextField.h
index 148b883..17b1c43 100644
--- a/WebCore/kwq/KWQNSTextField.h
+++ b/WebCore/kwq/KWQNSTextField.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <Cocoa/Cocoa.h>
+#import <Cocoa/Cocoa.h>
class QWidget;
diff --git a/WebCore/kwq/KWQScrollView.mm b/WebCore/kwq/KWQScrollView.mm
index fd3efc4..6d2c6cf 100644
--- a/WebCore/kwq/KWQScrollView.mm
+++ b/WebCore/kwq/KWQScrollView.mm
@@ -234,10 +234,26 @@ void QScrollView::repaintContents(int x, int y, int w, int h, bool erase=TRUE)
KWQDEBUGLEVEL (KWQ_LOG_FRAMES, "%p %s at (%d,%d) w %d h %d\n", getView(), [[[getView() class] className] cString], x, y, w, h);
}
-QPoint QScrollView::contentsToViewport(const QPoint &)
+QPoint QScrollView::contentsToViewport(const QPoint &p)
{
- _logNeverImplemented();
- return QPoint();
+ int vx, vy;
+ contentsToViewport(p.x(), p.y(), vx, vy);
+ return QPoint(vx, vy);
+}
+
+
+void QScrollView::contentsToViewport(int x, int y, int& vx, int& vy)
+{
+ NSView *view = getView();
+ if ([view isKindOfClass: [NSScrollView class]]) {
+ NSScrollView *scrollView = (NSScrollView *)view;
+ view = [scrollView documentView];
+ }
+
+ NSPoint np = [view convertPoint: NSMakePoint (x, y) toView: nil];
+
+ vx = (int)np.x;
+ vy = (int)np.y;
}
@@ -250,7 +266,6 @@ void QScrollView::viewportToContents(int vx, int vy, int& x, int& y)
}
NSPoint np = [view convertPoint: NSMakePoint (vx, vy) fromView: nil];
-
x = (int)np.x;
y = (int)np.y;
diff --git a/WebCore/kwq/KWQTextField.h b/WebCore/kwq/KWQTextField.h
index 148b883..17b1c43 100644
--- a/WebCore/kwq/KWQTextField.h
+++ b/WebCore/kwq/KWQTextField.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <Cocoa/Cocoa.h>
+#import <Cocoa/Cocoa.h>
class QWidget;
diff --git a/WebCore/kwq/external.h b/WebCore/kwq/external.h
index b49de87..39be02c 100644
--- a/WebCore/kwq/external.h
+++ b/WebCore/kwq/external.h
@@ -28,6 +28,12 @@
#import <WebFoundation/WebFoundation.h>
+class KHTMLPart;
+class QWidget;
+
+namespace khtml {
+ class Loader;
+}
@class IFWebDataSource;
@class IFWebView;
diff --git a/WebCore/kwq/khtml/khtml_pagecache.h b/WebCore/kwq/khtml/khtml_pagecache.h
index e69de29..0c47b64 100644
--- a/WebCore/kwq/khtml/khtml_pagecache.h
+++ b/WebCore/kwq/khtml/khtml_pagecache.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2002 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KHTML_PAGECACHE_H_
+#define KHTML_PAGECACHE_H_
+
+#include <qcstring.h>
+
+class QObject;
+
+class KHTMLPageCache
+{
+public:
+ static KHTMLPageCache *self() { return 0; }
+
+ long createCacheEntry() { return 0; }
+ void addData(long, const QByteArray &) { }
+ void cancelEntry(long) { }
+ void endData(long) { }
+
+ bool isValid(long) { return false; }
+
+ void fetchData(long, QObject *, const char *) { }
+ void cancelFetch(QObject *) { }
+};
+
+#endif
diff --git a/WebCore/kwq/kio/scheduler.h b/WebCore/kwq/kio/scheduler.h
index 113be16..ef05fbb 100644
--- a/WebCore/kwq/kio/scheduler.h
+++ b/WebCore/kwq/kio/scheduler.h
@@ -31,6 +31,7 @@
#endif
#include <qobject.h>
+#include <qtimer.h>
#include "job.h"
#include "jobclasses.h"
diff --git a/WebCore/kwq/kparts/historyprovider.h b/WebCore/kwq/kparts/historyprovider.h
index aeaf5d9..799cd19 100644
--- a/WebCore/kwq/kparts/historyprovider.h
+++ b/WebCore/kwq/kparts/historyprovider.h
@@ -26,62 +26,18 @@
#ifndef HISTORYPROVIDER_H_
#define HISTORYPROVIDER_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include <qobject.h>
namespace KParts {
-// class HistoryProvider =======================================================
-
class HistoryProvider : public QObject {
public:
-
- // structs -----------------------------------------------------------------
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
-
- // static member functions -------------------------------------------------
-
static HistoryProvider *self();
- // constructors, copy constructors, and destructors ------------------------
-
- HistoryProvider();
- virtual ~HistoryProvider();
-
- // member functions --------------------------------------------------------
-
+ void insert(const QString &);
bool contains(const QString &) const;
+};
- // operators ---------------------------------------------------------------
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+}
-private:
-
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
- HistoryProvider(const HistoryProvider &);
-#endif
-
-// add assignment operator
-// this private declaration prevents assignment
-#ifdef _KWQ_PEDANTIC_
- HistoryProvider &operator=(const HistoryProvider &);
-#endif
-
-}; // class HistoryProvider ====================================================
-
-
-} // namespace KParts
-
#endif
-
-
-
diff --git a/WebCore/kwq/kparts/part.h b/WebCore/kwq/kparts/part.h
index 2ec0a32..6374d0d 100644
--- a/WebCore/kwq/kparts/part.h
+++ b/WebCore/kwq/kparts/part.h
@@ -44,11 +44,20 @@ namespace KParts {
class Part : public QObject {
public:
- Part() : m_widget(0) { }
+ Part() : m_widget(0), m_ref(1) { }
+
QWidget *widget() const { return m_widget; }
void setWidget(QWidget *widget) { m_widget = widget; }
+
+ void ref() { m_ref++; }
+ void deref() { if(m_ref) m_ref--; if (!m_ref) delete this; }
+
+ void event(QEvent *event) { customEvent((QCustomEvent *)event); }
+ virtual void customEvent(QCustomEvent *) { }
+
private:
QWidget *m_widget;
+ unsigned int m_ref;
};
class ReadOnlyPart : public Part {
diff --git a/WebCore/kwq/kparts/partmanager.h b/WebCore/kwq/kparts/partmanager.h
index 5380961..dff5a24 100644
--- a/WebCore/kwq/kparts/partmanager.h
+++ b/WebCore/kwq/kparts/partmanager.h
@@ -28,6 +28,7 @@
#include <qguardedptr.h>
#include <qtimer.h>
+#include <qdatetime.h>
namespace KParts {
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 137d709..9056623 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-30 Darin Adler <darin at apple.com>
+
+ Use methods in KWQKHTMLPartImpl that were moved there from KHTMLPart.
+
+ * WebView.subproj/IFMainURLHandleClient.mm:
+ (-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
+ (-[IFMainURLHandleClient processData:isComplete:allDataReceived:]):
+ * WebView.subproj/IFWebDataSource.mm:
+ (-[IFWebDataSource documentText]):
+ * WebView.subproj/IFWebDataSourcePrivate.mm:
+ (-[IFWebDataSource _setController:]):
+ * WebView.subproj/IFWebFramePrivate.mm:
+ (-[IFWebFrame _isLoadComplete]):
+ * WebView.subproj/IFWebView.mm:
+ (-[IFWebView provisionalDataSourceChanged:]):
+
2002-05-30 Chris Blumenberg <cblu at apple.com>
Use NSWorkspace methods instead of Launch Services and Finder functions.
@@ -7,8 +23,6 @@
* WebView.subproj/IFWebFrame.mm:
(-[IFWebFrame setProvisionalDataSource:]):
-
-=======
2002-05-30 Richard Williamson <rjw at apple.com>
Added 'canDraw' check to ensure that we can render
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 137d709..9056623 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,19 @@
+2002-05-30 Darin Adler <darin at apple.com>
+
+ Use methods in KWQKHTMLPartImpl that were moved there from KHTMLPart.
+
+ * WebView.subproj/IFMainURLHandleClient.mm:
+ (-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
+ (-[IFMainURLHandleClient processData:isComplete:allDataReceived:]):
+ * WebView.subproj/IFWebDataSource.mm:
+ (-[IFWebDataSource documentText]):
+ * WebView.subproj/IFWebDataSourcePrivate.mm:
+ (-[IFWebDataSource _setController:]):
+ * WebView.subproj/IFWebFramePrivate.mm:
+ (-[IFWebFrame _isLoadComplete]):
+ * WebView.subproj/IFWebView.mm:
+ (-[IFWebView provisionalDataSourceChanged:]):
+
2002-05-30 Chris Blumenberg <cblu at apple.com>
Use NSWorkspace methods instead of Launch Services and Finder functions.
@@ -7,8 +23,6 @@
* WebView.subproj/IFWebFrame.mm:
(-[IFWebFrame setProvisionalDataSource:]):
-
-=======
2002-05-30 Richard Williamson <rjw at apple.com>
Added 'canDraw' check to ensure that we can render
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index bb87f3d..11d1a3c 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -23,7 +23,7 @@
#import <WebFoundation/IFError.h>
#import <khtmlview.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFMainURLHandleClient
@@ -186,7 +186,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)URL
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_REDIRECT, "url = %s\n", [[URL absoluteString] cString]);
- part->setBaseURL([[URL absoluteString] cString]);
+ part->impl->setBaseURL([[URL absoluteString] cString]);
[dataSource _setFinalURL: URL];
@@ -209,7 +209,7 @@
if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
// If data is html, send it to the part.
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
@@ -221,14 +221,14 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
fakeHTMLDocument = [contentHandler HTMLDocument];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
[contentHandler release];
sentFakeDocForNonHTMLContentType = YES;
}
// For text documents, the incoming data is part of the main page.
if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
}
}
@@ -263,7 +263,7 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
[contentHandler release];
}
}
diff --git a/WebKit/WebView.subproj/IFWebDataSource.mm b/WebKit/WebView.subproj/IFWebDataSource.mm
index dd03c87..5109e1e 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.mm
+++ b/WebKit/WebView.subproj/IFWebDataSource.mm
@@ -12,7 +12,7 @@
#import <WebFoundation/WebFoundation.h>
#import <xml/dom_docimpl.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
#import <WCWebDataSource.h>
@@ -240,7 +240,7 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
{
KHTMLPart *part = [self _part];
- return QSTRING_TO_NSSTRING(part->documentSource());
+ return QSTRING_TO_NSSTRING(part->impl->documentSource());
}
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index 7c63f43..a329596 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -15,7 +15,7 @@
#import <WebFoundation/IFError.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebKit/IFLocationChangeHandler.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
#import "IFWebController.h"
@implementation IFWebDataSourcePrivate
@@ -102,7 +102,7 @@
[_private->controller release];
}
_private->controller = controller;
- _private->part->setDataSource(self);
+ _private->part->impl->setDataSource(self);
}
- (KHTMLPart *)_part
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index 0f22af1..9d40bfc 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -19,6 +19,8 @@
#import <khtmlview.h>
#import <rendering/render_frames.h>
+#import <KWQKHTMLPartImpl.h>
+
static const char * const stateNames[6] = {
"zero state",
"IFWEBFRAMESTATE_UNINITIALIZED",
@@ -348,7 +350,7 @@ static const char * const stateNames[6] = {
}
// Jump to anchor point, if necessary.
- [ds _part]->gotoBaseAnchor();
+ [ds _part]->impl->gotoBaseAnchor();
[[ds _locationChangeHandler] locationChangeDone: [ds mainDocumentError]];
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFWebView.mm
index d2c3b38..7312664 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFWebView.mm
@@ -27,6 +27,7 @@
#import <qevent.h>
#import <html/html_documentimpl.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFWebView
@@ -103,7 +104,7 @@
KHTMLPart *part = [dataSource _part];
_private->provisionalWidget = new KHTMLView (part, 0);
- part->setView (_private->provisionalWidget);
+ part->impl->setView (_private->provisionalWidget);
// Create a temporary provisional view. It will be replaced with
// the actual view once the datasource has been committed.
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index dd03c87..5109e1e 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -12,7 +12,7 @@
#import <WebFoundation/WebFoundation.h>
#import <xml/dom_docimpl.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
#import <WCWebDataSource.h>
@@ -240,7 +240,7 @@ static id IFWebDataSourceMake(void *url, void *attributes, unsigned flags)
{
KHTMLPart *part = [self _part];
- return QSTRING_TO_NSSTRING(part->documentSource());
+ return QSTRING_TO_NSSTRING(part->impl->documentSource());
}
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 7c63f43..a329596 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -15,7 +15,7 @@
#import <WebFoundation/IFError.h>
#import <WebFoundation/IFNSStringExtensions.h>
#import <WebKit/IFLocationChangeHandler.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
#import "IFWebController.h"
@implementation IFWebDataSourcePrivate
@@ -102,7 +102,7 @@
[_private->controller release];
}
_private->controller = controller;
- _private->part->setDataSource(self);
+ _private->part->impl->setDataSource(self);
}
- (KHTMLPart *)_part
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 0f22af1..9d40bfc 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -19,6 +19,8 @@
#import <khtmlview.h>
#import <rendering/render_frames.h>
+#import <KWQKHTMLPartImpl.h>
+
static const char * const stateNames[6] = {
"zero state",
"IFWEBFRAMESTATE_UNINITIALIZED",
@@ -348,7 +350,7 @@ static const char * const stateNames[6] = {
}
// Jump to anchor point, if necessary.
- [ds _part]->gotoBaseAnchor();
+ [ds _part]->impl->gotoBaseAnchor();
[[ds _locationChangeHandler] locationChangeDone: [ds mainDocumentError]];
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index d2c3b38..7312664 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -27,6 +27,7 @@
#import <qevent.h>
#import <html/html_documentimpl.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFWebView
@@ -103,7 +104,7 @@
KHTMLPart *part = [dataSource _part];
_private->provisionalWidget = new KHTMLView (part, 0);
- part->setView (_private->provisionalWidget);
+ part->impl->setView (_private->provisionalWidget);
// Create a temporary provisional view. It will be replaced with
// the actual view once the datasource has been committed.
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index bb87f3d..11d1a3c 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -23,7 +23,7 @@
#import <WebFoundation/IFError.h>
#import <khtmlview.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFMainURLHandleClient
@@ -186,7 +186,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)URL
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_REDIRECT, "url = %s\n", [[URL absoluteString] cString]);
- part->setBaseURL([[URL absoluteString] cString]);
+ part->impl->setBaseURL([[URL absoluteString] cString]);
[dataSource _setFinalURL: URL];
@@ -209,7 +209,7 @@
if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
// If data is html, send it to the part.
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
@@ -221,14 +221,14 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
fakeHTMLDocument = [contentHandler HTMLDocument];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
[contentHandler release];
sentFakeDocForNonHTMLContentType = YES;
}
// For text documents, the incoming data is part of the main page.
if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
}
}
@@ -263,7 +263,7 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
[contentHandler release];
}
}
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index bb87f3d..11d1a3c 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -23,7 +23,7 @@
#import <WebFoundation/IFError.h>
#import <khtmlview.h>
-#import <khtml_part.h>
+#import <KWQKHTMLPartImpl.h>
@implementation IFMainURLHandleClient
@@ -186,7 +186,7 @@
- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)URL
{
WEBKITDEBUGLEVEL (WEBKIT_LOG_REDIRECT, "url = %s\n", [[URL absoluteString] cString]);
- part->setBaseURL([[URL absoluteString] cString]);
+ part->impl->setBaseURL([[URL absoluteString] cString]);
[dataSource _setFinalURL: URL];
@@ -209,7 +209,7 @@
if(handlerType == IFMIMEHANDLERTYPE_NIL || handlerType == IFMIMEHANDLERTYPE_HTML) {
// If data is html, send it to the part.
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
else if(handlerType == IFMIMEHANDLERTYPE_IMAGE ||
@@ -221,14 +221,14 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:handlerType];
fakeHTMLDocument = [contentHandler HTMLDocument];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), allDataReceived);
[contentHandler release];
sentFakeDocForNonHTMLContentType = YES;
}
// For text documents, the incoming data is part of the main page.
if(handlerType == IFMIMEHANDLERTYPE_TEXT){
- part->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
+ part->impl->slotData(encoding, (const char *)[data bytes], [data length], allDataReceived);
}
}
}
@@ -263,7 +263,7 @@
contentHandler = [[IFContentHandler alloc] initWithURL:url MIMEType:MIMEType MIMEHandlerType:IFMIMEHANDLERTYPE_TEXT];
fakeHTMLDocument = [contentHandler textHTMLDocumentBottom];
fakeHTMLDocumentBytes = [fakeHTMLDocument cString];
- part->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
+ part->impl->slotData(encoding, (const char *)fakeHTMLDocumentBytes, strlen(fakeHTMLDocumentBytes), YES);
[contentHandler release];
}
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list