[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:19:35 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 1adfcc050558b6220c52de19d2856c8f795e7159
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jun 15 21:02:28 2002 +0000

    WebCore:
    
    	- fixed 2942808 -- remove all calls to WebKit from WebCore
    
    	More work on the bridge. Now we don't call anything in WebKit explicitly,
    	although there are still implicit connections that need to be fixed.
    
    	* WebCore.exp: Remove exports that are no longer needed, now that
    	WebKit is using the bridge to get at more things.
    
    	* khtml/misc/loader.h:
    	* khtml/misc/loader.cpp:
    	(CachedCSSStyleSheet::CachedCSSStyleSheet):
    	(CachedScript::CachedScript):
    	(CachedImage::CachedImage):
    	Remove the extra parameter to the CachedObject constructor. We don't
    	need it any more, so we can remove all these APPLE_CHANGES.
    
    	* kwq/KWQKHTMLPart.mm: Remove getDataSource.
    
    	* kwq/KWQLoaderImpl.h: Remove destructor.
    	* kwq/KWQKloader.mm:
    	(-[KWQURLLoadClient initWithLoader:bridge:]): Keep the bridge around instead
    	of the data source.
    	(-[KWQURLLoadClient dealloc]): Release the bridge instead of the data source.
    	Also put another workaround for 2954901 here, like in WebKit.
    	(-[KWQURLLoadClient IFURLHandleResourceDidBeginLoading:]):
    	(-[KWQURLLoadClient IFURLHandle:resourceDataDidBecomeAvailable:]):
    	(-[KWQURLLoadClient doneWithHandle:error:]):
    	(-[KWQURLLoadClient IFURLHandleResourceDidCancelLoading:]):
    	(-[KWQURLLoadClient IFURLHandleResourceDidFinishLoading:data:]):
    	(-[KWQURLLoadClient IFURLHandle:resourceDidFailLoadingWithResult:]):
    	(-[KWQURLLoadClient IFURLHandle:didRedirectToURL:]):
    	(KWQLoaderImpl::setClient):
    	(KWQLoaderImpl::serveRequest):
    	Use the bridge to do all the heavy lifting, and put lots of common code into
    	a doneWithHandle:error: method. Also store the URL so the redirect code works
    	properly for multiple redirects and add asserts like the ones in IFMainURLHandleClient.
    	(KWQLoaderImpl::objectFinished): Add a comment.
    
    	* kwq/WebCoreBridge.h: Make header so it can be included from plain Objective C,
    	not just Objective C++. Add a bunch of methods for bridging in to WebCore as opposed
    	to out of WebCore. Add new methods for bridging out from WebCore too for all the
    	progress hooks. Put all the subclass responsibility methods into a protocol
    	in such a way that we don't need to implement them in the base class, and subclasses
    	can set things up so they get errors if they forget to implement anything.
    
    	* kwq/WebCoreBridge.mm:
    	(-[WebCoreBridge openURL:]): Added.
    	(-[WebCoreBridge addData:withEncoding:]): Added.
    	(-[WebCoreBridge closeURL]): Added.
    	(-[WebCoreBridge end]): Added.
    	(-[WebCoreBridge setURL:]): Added.
    	(-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]): Added.
    	(-[WebCoreBridge documentTextFromDOM]): Added.
    	(-[WebCoreBridge scrollToBaseAnchor]): Added.
    
    	* kwq/external.h: Removed.
    
    WebKit:
    
    	- fixed 2942808 -- remove all calls to WebKit from WebCore
    
    	Update to use the WebCore bridge for more things, reducing
    	dependencies in both directions. Besides using the bridge for all the
    	remaining WebCore to WebKit calls, almost no WebKit code deals with
    	KHTMLPart directly any more, instead the other side of the bridge handles it.
    
    	* Plugins.subproj/IFPluginStream.mm:
    	(-[IFPluginStream IFURLHandleResourceDidBeginLoading:]): Remove unneeded casts.
    	(-[IFPluginStream IFURLHandle:resourceDataDidBecomeAvailable:]):
    	(-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
    	(-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
    	(-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
    	(-[IFPluginStream IFURLHandle:didRedirectToURL:]):
    	Use the new IFProgress methods to simplify code.
    
    	* WebCoreSupport.subproj/IFWebCoreBridge.h: Use the new WebCoreBridge protocol
    	so we get a compiler error if we forget to implement anything. Add a method for
    	IFWebDataSource that gets the WebCoreBridge if it has an IFHTMLRepresentation,
    	and nil otherwise.
    	* WebCoreSupport.subproj/IFWebCoreBridge.mm:
    	(-[IFWebDataSource _bridge]): Add; does checking so that it returns
    	nil if the representation is not an IFHTMLRepresentation. This is now used
    	almost everywhere so we don't have to do so much type casting.
    	(-[IFWebCoreBridge loadURL:attributes:flags:inFrame:withParent:]): Remove a
    	stray use of [IFWebCoreBridge dataSource] so we can remove it.
    	(-[IFWebCoreBridge receivedData:withDataSource:]): Use the
    	new [WebCoreBridge openURL:] and [WebCoreBridge addData:] methods from the
    	other side of the bridge so we don't have to deal with the KHTMLPart directly.
    	(-[IFWebCoreBridge addHandle:]): Added.
    	(-[IFWebCoreBridge removeHandle:]): Added.
    	(-[IFWebCoreBridge didStartLoadingWithHandle:]): Added.
    	(-[IFWebCoreBridge receivedProgressWithHandle:]): Added.
    	(-[IFWebCoreBridge didFinishLoadingWithHandle:]): Added.
    	(-[IFWebCoreBridge didCancelLoadingWithHandle:]): Added.
    	(-[IFWebCoreBridge didFailBeforeLoadingWithError:]): Added.
    	(-[IFWebCoreBridge didFailToLoadWithHandle:error:]): Added.
    	(-[IFWebCoreBridge didRedirectWithHandle:fromURL:]): Added.
    
    	* WebView.subproj/IFHTMLRepresentation.h: Remove unneeded declarations.
    	* WebView.subproj/IFHTMLRepresentation.mm: Remove [IFHTMLRepresentation part].
    	* WebView.subproj/IFHTMLRepresentationPrivate.h: Remove [IFHTMLRepresentation part].
    
    	* WebView.subproj/IFHTMLView.mm: (-[IFHTMLView provisionalDataSourceChanged:]): Use the bridge.
    
    	* WebView.subproj/IFHTMLViewPrivate.mm: Remove a bunch of unused stuff that was
    	there for the render and document tree viewers. I had removed it once before but
    	it got re-added as a side effect of the reorganization process.
    
    	* WebView.subproj/IFLoadProgress.h: Remove the unused IFLoadType -- we can add
    	it back if we find that it's needed. It didn't do much good to have it here
    	and only partly implemented, and I don't think it's needed. Added some convenient
    	interfaces for creating IFLoadProgress objects.
    
    	* WebView.subproj/IFLoadProgress.mm: Get rid of WCSetIFLoadProgressMakeFunc stuff.
    	(-[IFLoadProgress init]): Added.
    	(-[IFLoadProgress initWithBytesSoFar:totalToLoad:]): Remove type part.
    	(-[IFLoadProgress initWithURLHandle:]): Added.
    	(+[IFLoadProgress progress]): Added.
    	(+[IFLoadProgress progressWithBytesSoFar:totalToLoad:]): Added.
    	(+[IFLoadProgress progressWithURLHandle:]): Added.
    
    	* WebView.subproj/IFMainURLHandleClient.mm:
    	(-[IFMainURLHandleClient dealloc]): Add more workaround for 2954901.
    	(-[IFMainURLHandleClient IFURLHandleResourceDidBeginLoading:]):
    	(-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
    	(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
    	(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
    	(-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
    	(-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
    	Remove unneeded type casts and simplify by using new IFLoadProgress methods.
    	Also simplify access to _bridge by using [IFWebDataSource _bridge].
    
    	* WebView.subproj/IFWebControllerPrivate.mm:
    	* WebView.subproj/IFWebFrame.mm:
    	Remove unneeded include of KHTMLPart header.
    
    	* WebView.subproj/IFWebDataSource.mm: (-[IFWebDataSource documentTextFromDOM]):
    	* WebView.subproj/IFWebDataSourcePrivate.mm: (-[IFWebDataSource _stopLoading]):
    	* WebView.subproj/IFWebFramePrivate.mm: (-[IFWebFrame _isLoadComplete]):
    	Use bridge.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1373 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 8c58ec1..17af3a2 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,62 @@
+2002-06-15  Darin Adler  <darin at apple.com>
+
+	- fixed 2942808 -- remove all calls to WebKit from WebCore
+
+	More work on the bridge. Now we don't call anything in WebKit explicitly,
+	although there are still implicit connections that need to be fixed.
+
+	* WebCore.exp: Remove exports that are no longer needed, now that
+	WebKit is using the bridge to get at more things.
+
+	* khtml/misc/loader.h:
+	* khtml/misc/loader.cpp:
+	(CachedCSSStyleSheet::CachedCSSStyleSheet):
+	(CachedScript::CachedScript):
+	(CachedImage::CachedImage):
+	Remove the extra parameter to the CachedObject constructor. We don't
+	need it any more, so we can remove all these APPLE_CHANGES.
+
+	* kwq/KWQKHTMLPart.mm: Remove getDataSource.
+
+	* kwq/KWQLoaderImpl.h: Remove destructor.
+	* kwq/KWQKloader.mm:
+	(-[KWQURLLoadClient initWithLoader:bridge:]): Keep the bridge around instead
+	of the data source.
+	(-[KWQURLLoadClient dealloc]): Release the bridge instead of the data source.
+	Also put another workaround for 2954901 here, like in WebKit.
+	(-[KWQURLLoadClient IFURLHandleResourceDidBeginLoading:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[KWQURLLoadClient doneWithHandle:error:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidCancelLoading:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[KWQURLLoadClient IFURLHandle:didRedirectToURL:]):
+	(KWQLoaderImpl::setClient):
+	(KWQLoaderImpl::serveRequest):
+	Use the bridge to do all the heavy lifting, and put lots of common code into
+	a doneWithHandle:error: method. Also store the URL so the redirect code works
+	properly for multiple redirects and add asserts like the ones in IFMainURLHandleClient.
+	(KWQLoaderImpl::objectFinished): Add a comment.
+
+	* kwq/WebCoreBridge.h: Make header so it can be included from plain Objective C,
+	not just Objective C++. Add a bunch of methods for bridging in to WebCore as opposed
+	to out of WebCore. Add new methods for bridging out from WebCore too for all the
+	progress hooks. Put all the subclass responsibility methods into a protocol
+	in such a way that we don't need to implement them in the base class, and subclasses
+	can set things up so they get errors if they forget to implement anything.
+
+	* kwq/WebCoreBridge.mm:
+	(-[WebCoreBridge openURL:]): Added.
+	(-[WebCoreBridge addData:withEncoding:]): Added.
+	(-[WebCoreBridge closeURL]): Added.
+	(-[WebCoreBridge end]): Added.
+	(-[WebCoreBridge setURL:]): Added.
+	(-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]): Added.
+	(-[WebCoreBridge documentTextFromDOM]): Added.
+	(-[WebCoreBridge scrollToBaseAnchor]): Added.
+
+	* kwq/external.h: Removed.
+
 2002-06-15  Maciej Stachowiak  <mjs at apple.com>
 
 	Get current bits per pixel from CoreGraphics, thereby fixing
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 8c58ec1..17af3a2 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,62 @@
+2002-06-15  Darin Adler  <darin at apple.com>
+
+	- fixed 2942808 -- remove all calls to WebKit from WebCore
+
+	More work on the bridge. Now we don't call anything in WebKit explicitly,
+	although there are still implicit connections that need to be fixed.
+
+	* WebCore.exp: Remove exports that are no longer needed, now that
+	WebKit is using the bridge to get at more things.
+
+	* khtml/misc/loader.h:
+	* khtml/misc/loader.cpp:
+	(CachedCSSStyleSheet::CachedCSSStyleSheet):
+	(CachedScript::CachedScript):
+	(CachedImage::CachedImage):
+	Remove the extra parameter to the CachedObject constructor. We don't
+	need it any more, so we can remove all these APPLE_CHANGES.
+
+	* kwq/KWQKHTMLPart.mm: Remove getDataSource.
+
+	* kwq/KWQLoaderImpl.h: Remove destructor.
+	* kwq/KWQKloader.mm:
+	(-[KWQURLLoadClient initWithLoader:bridge:]): Keep the bridge around instead
+	of the data source.
+	(-[KWQURLLoadClient dealloc]): Release the bridge instead of the data source.
+	Also put another workaround for 2954901 here, like in WebKit.
+	(-[KWQURLLoadClient IFURLHandleResourceDidBeginLoading:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[KWQURLLoadClient doneWithHandle:error:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidCancelLoading:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[KWQURLLoadClient IFURLHandle:didRedirectToURL:]):
+	(KWQLoaderImpl::setClient):
+	(KWQLoaderImpl::serveRequest):
+	Use the bridge to do all the heavy lifting, and put lots of common code into
+	a doneWithHandle:error: method. Also store the URL so the redirect code works
+	properly for multiple redirects and add asserts like the ones in IFMainURLHandleClient.
+	(KWQLoaderImpl::objectFinished): Add a comment.
+
+	* kwq/WebCoreBridge.h: Make header so it can be included from plain Objective C,
+	not just Objective C++. Add a bunch of methods for bridging in to WebCore as opposed
+	to out of WebCore. Add new methods for bridging out from WebCore too for all the
+	progress hooks. Put all the subclass responsibility methods into a protocol
+	in such a way that we don't need to implement them in the base class, and subclasses
+	can set things up so they get errors if they forget to implement anything.
+
+	* kwq/WebCoreBridge.mm:
+	(-[WebCoreBridge openURL:]): Added.
+	(-[WebCoreBridge addData:withEncoding:]): Added.
+	(-[WebCoreBridge closeURL]): Added.
+	(-[WebCoreBridge end]): Added.
+	(-[WebCoreBridge setURL:]): Added.
+	(-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]): Added.
+	(-[WebCoreBridge documentTextFromDOM]): Added.
+	(-[WebCoreBridge scrollToBaseAnchor]): Added.
+
+	* kwq/external.h: Removed.
+
 2002-06-15  Maciej Stachowiak  <mjs at apple.com>
 
 	Get current bits per pixel from CoreGraphics, thereby fixing
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 8c58ec1..17af3a2 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,62 @@
+2002-06-15  Darin Adler  <darin at apple.com>
+
+	- fixed 2942808 -- remove all calls to WebKit from WebCore
+
+	More work on the bridge. Now we don't call anything in WebKit explicitly,
+	although there are still implicit connections that need to be fixed.
+
+	* WebCore.exp: Remove exports that are no longer needed, now that
+	WebKit is using the bridge to get at more things.
+
+	* khtml/misc/loader.h:
+	* khtml/misc/loader.cpp:
+	(CachedCSSStyleSheet::CachedCSSStyleSheet):
+	(CachedScript::CachedScript):
+	(CachedImage::CachedImage):
+	Remove the extra parameter to the CachedObject constructor. We don't
+	need it any more, so we can remove all these APPLE_CHANGES.
+
+	* kwq/KWQKHTMLPart.mm: Remove getDataSource.
+
+	* kwq/KWQLoaderImpl.h: Remove destructor.
+	* kwq/KWQKloader.mm:
+	(-[KWQURLLoadClient initWithLoader:bridge:]): Keep the bridge around instead
+	of the data source.
+	(-[KWQURLLoadClient dealloc]): Release the bridge instead of the data source.
+	Also put another workaround for 2954901 here, like in WebKit.
+	(-[KWQURLLoadClient IFURLHandleResourceDidBeginLoading:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[KWQURLLoadClient doneWithHandle:error:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidCancelLoading:]):
+	(-[KWQURLLoadClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[KWQURLLoadClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[KWQURLLoadClient IFURLHandle:didRedirectToURL:]):
+	(KWQLoaderImpl::setClient):
+	(KWQLoaderImpl::serveRequest):
+	Use the bridge to do all the heavy lifting, and put lots of common code into
+	a doneWithHandle:error: method. Also store the URL so the redirect code works
+	properly for multiple redirects and add asserts like the ones in IFMainURLHandleClient.
+	(KWQLoaderImpl::objectFinished): Add a comment.
+
+	* kwq/WebCoreBridge.h: Make header so it can be included from plain Objective C,
+	not just Objective C++. Add a bunch of methods for bridging in to WebCore as opposed
+	to out of WebCore. Add new methods for bridging out from WebCore too for all the
+	progress hooks. Put all the subclass responsibility methods into a protocol
+	in such a way that we don't need to implement them in the base class, and subclasses
+	can set things up so they get errors if they forget to implement anything.
+
+	* kwq/WebCoreBridge.mm:
+	(-[WebCoreBridge openURL:]): Added.
+	(-[WebCoreBridge addData:withEncoding:]): Added.
+	(-[WebCoreBridge closeURL]): Added.
+	(-[WebCoreBridge end]): Added.
+	(-[WebCoreBridge setURL:]): Added.
+	(-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]): Added.
+	(-[WebCoreBridge documentTextFromDOM]): Added.
+	(-[WebCoreBridge scrollToBaseAnchor]): Added.
+
+	* kwq/external.h: Removed.
+
 2002-06-15  Maciej Stachowiak  <mjs at apple.com>
 
 	Get current bits per pixel from CoreGraphics, thereby fixing
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index 640c156..251decc 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -2,12 +2,7 @@
 .objc_class_name_WebCoreImageRendererFactory
 .objc_class_name_WebCoreTextRendererFactory
 .objc_class_name_WebCoreViewFactory
-__Z27WCSetIFLoadProgressMakeFuncPFP11objc_objectvE
 __ZN11QMouseEventC1EN6QEvent4TypeERK6QPointii
-__ZN16KWQKHTMLPartImpl10setBaseURLERK4KURL
-__ZN16KWQKHTMLPartImpl14gotoBaseAnchorEv
-__ZN16KWQKHTMLPartImpl7setViewEP9KHTMLView
-__ZN16KWQKHTMLPartImpl8slotDataEP8NSStringPKcib
 __ZN3DOM12DocumentImpl19updateStyleSelectorEv
 __ZN3DOM9DOMStringD1Ev
 __ZN4KURLC1EPKci
@@ -22,16 +17,10 @@ __ZN7QStringD1Ev
 __ZN7QWidget7setViewEP6NSView
 __ZN8QPainterC1EP7QWidget
 __ZN8QPainterD1Ev
-__ZN9KHTMLPartC1EP7QWidgetPKcP7QObjectS3_NS_10GUIProfileE
 __ZN9KHTMLView6layoutEv
-__ZN9KHTMLViewC1EP9KHTMLPartP7QWidgetPKc
 __ZN9QKeyEventC1EN6QEvent4TypeEiiiRK7QStringbt
-__ZNK16KWQKHTMLPartImpl14documentSourceEv
 __ZNK3DOM8NodeImpl16recursive_toHTMLEb
 __ZNK3DOM8NodeImpl8rendererEv
 __ZNK3DOM9DOMString6stringEv
-__ZNK7QString6latin1Ev
 __ZNK7QWidget7getViewEv
 __ZNK9KHTMLPart10xmlDocImplEv
-__ZN9KHTMLView14setMarginWidthEi
-__ZN9KHTMLView15setMarginHeightEi
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 882b143..575625c 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -120,11 +120,7 @@ void CachedObject::setRequest(Request *_request)
 // -------------------------------------------------------------------------------------------
 
 CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
-#ifdef APPLE_CHANGES
-    : CachedObject(dl, url, CSSStyleSheet, _cachePolicy, _expireDate)
-#else
     : CachedObject(url, CSSStyleSheet, _cachePolicy, _expireDate)
-#endif
 {
     // It's css we want.
     setAccept( QString::fromLatin1("text/css") );
@@ -139,11 +135,7 @@ CachedCSSStyleSheet::CachedCSSStyleSheet(DocLoader* dl, const DOMString &url, KI
 }
 
 CachedCSSStyleSheet::CachedCSSStyleSheet(const DOMString &url, const QString &stylesheet_data)
-#ifdef APPLE_CHANGES
-    : CachedObject(0, url, CSSStyleSheet, KIO::CC_Verify, 0)
-#else
     : CachedObject(url, CSSStyleSheet, KIO::CC_Verify, 0)
-#endif
 {
     m_loading = false;
     m_status = Persistent;
@@ -208,11 +200,7 @@ void CachedCSSStyleSheet::error( int /*err*/, const char */*text*/ )
 // -------------------------------------------------------------------------------------------
 
 CachedScript::CachedScript(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate, const QString& charset)
-#ifdef APPLE_CHANGES
-    : CachedObject(dl, url, Script, _cachePolicy, _expireDate)
-#else
     : CachedObject(url, Script, _cachePolicy, _expireDate)
-#endif
 {
     // It's javascript we want.
     // But some websites think their scripts are <some wrong mimetype here>
@@ -229,11 +217,7 @@ CachedScript::CachedScript(DocLoader* dl, const DOMString &url, KIO::CacheContro
 }
 
 CachedScript::CachedScript(const DOMString &url, const QString &script_data)
-#ifdef APPLE_CHANGES
-    : CachedObject(0, url, Script, KIO::CC_Verify, 0)
-#else
     : CachedObject(url, Script, KIO::CC_Verify, 0)
-#endif
 {
     m_loading = false;
     m_status = Persistent;
@@ -460,11 +444,7 @@ static bool crossDomain(const QString &a, const QString &b)
 // -------------------------------------------------------------------------------------
 
 CachedImage::CachedImage(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate)
-#ifdef APPLE_CHANGES
-    : CachedObject(dl, url, Image, _cachePolicy, _expireDate)
-#else
     : QObject(), CachedObject(url, Image, _cachePolicy, _expireDate)
-#endif
 {
 #ifndef APPLE_CHANGES
     static const QString &acceptHeader = KGlobal::staticQString( buildAcceptHeader() );
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index b900a23..64b8cd1 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -108,15 +108,8 @@ namespace khtml
 	    Uncacheable   // to big to be cached,
 	};  	          // will be destroyed as soon as possible
 
-#ifdef APPLE_CHANGES
-	CachedObject(const DocLoader *loader, const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate)
-#else
 	CachedObject(const DOM::DOMString &url, Type type, KIO::CacheControl _cachePolicy, time_t _expireDate)
-#endif
 	{
-#ifdef APPLE_CHANGES
-	    m_loader = loader;
-#endif
 	    m_url = url;
 	    m_type = type;
 	    m_status = Pending;
@@ -181,14 +174,8 @@ namespace khtml
         // e.g. "text/*"
         QString accept() const { return m_accept; }
         void setAccept(const QString &_accept) { m_accept = _accept; }
-#ifdef APPLE_CHANGES
-	const DocLoader *loader() { return m_loader; }
-#endif
 
     protected:
-#ifdef APPLE_CHANGES
-        const DocLoader *m_loader;
-#endif
         QPtrList<CachedObjectClient> m_clients;
 
 	DOM::DOMString m_url;
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index a4bad96..bf08df3 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -635,11 +635,6 @@ void KWQKHTMLPartImpl::setTitle(const DOMString &title)
     [bridge setTitle:title.string().getNSString()];
 }
 
-IFWebDataSource *KWQKHTMLPartImpl::getDataSource()
-{
-    return [bridge dataSource];
-}
-
 KHTMLPart *KWQKHTMLPartImpl::parentPart()
 {
     return [[bridge parent] part];
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index a4bad96..bf08df3 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -635,11 +635,6 @@ void KWQKHTMLPartImpl::setTitle(const DOMString &title)
     [bridge setTitle:title.string().getNSString()];
 }
 
-IFWebDataSource *KWQKHTMLPartImpl::getDataSource()
-{
-    return [bridge dataSource];
-}
-
 KHTMLPart *KWQKHTMLPartImpl::parentPart()
 {
     return [[bridge parent] part];
diff --git a/WebCore/kwq/KWQKloader.mm b/WebCore/kwq/KWQKloader.mm
index 1882535..98823d6 100644
--- a/WebCore/kwq/KWQKloader.mm
+++ b/WebCore/kwq/KWQKloader.mm
@@ -25,95 +25,34 @@
 
 #include <KWQLoaderImpl.h>
 
-#include <kio/jobclasses.h>
-#include <misc/loader.h>
-#include <KWQKHTMLPartImpl.h>
-
-#include <WCLoadProgress.h>
-
-#include <kwqdebug.h>
-
-// ==== start of temporary section, formerly from external.h, to be killed ====
-
- at class IFWebDataSource;
- at class IFLoadProgress;
-
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML   = 4
-} IF_LOAD_TYPE;
-
- at interface IFLoadProgress : NSObject
-{
-    int bytesSoFar;	// 0 if this is the start of load
-    int totalToLoad;	// -1 if this is not known.
-                        // bytesSoFar == totalLoaded when complete
-    IF_LOAD_TYPE type;	// load types, either image, css, or jscript
-}
-- init;
- at end
-
- at protocol IFLocationChangeHandler
-- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)dataSource;
- at end
-
- at interface IFWebController <IFLocationChangeHandler>
-- (void)_receivedProgress: (IFLoadProgress *)progress forResourceHandle: (IFURLHandle *)handle fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_receivedError: (IFError *)error forResourceHandle: (IFURLHandle *)handle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_didStartLoading: (NSURL *)url;
-- (void)_didStopLoading: (NSURL *)url;
- at end
-
- at interface IFWebDataSource : NSObject
-- (IFWebController *)controller;
-- (void)_addURLHandle: (IFURLHandle *)handle;
-- (void)_removeURLHandle: (IFURLHandle *)handle;
-- (void)_setFinalURL: (NSURL *)url;
-- representation;
-- (id <IFLocationChangeHandler>)_locationChangeHandler;
- at end
-
- at interface IFHTMLRepresentation : NSObject
-- (KHTMLPart *)part;
- at end
-
- at protocol IFLoadHandler
-- (void)receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-- (void)receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- at end
-
-// ==== end of temporary section, formerly from external.h, to be killed ====
+#import <kio/jobclasses.h>
+#import <misc/loader.h>
+#import <KWQKHTMLPartImpl.h>
+#import <WebCoreBridge.h>
+#import <kwqdebug.h>
 
 using khtml::DocLoader;
 using khtml::Loader;
 using khtml::Request;
 
-WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
-
-void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
-{
-    WCIFLoadProgressMake = func;
-}
-
 @interface KWQURLLoadClient : NSObject <IFURLHandleClient>
 {
     khtml::Loader *m_loader;
-    IFWebDataSource *m_dataSource;
+    WebCoreBridge *m_bridge;
+    NSURL *m_currentURL;
 }
 
--(id)initWithLoader:(khtml::Loader *)loader dataSource:(IFWebDataSource *)dataSource;
+-(id)initWithLoader:(khtml::Loader *)loader bridge:(WebCoreBridge *)bridge;
 
 @end
 
 @implementation KWQURLLoadClient
 
--(id)initWithLoader:(Loader *)loader dataSource:(IFWebDataSource *)dataSource
+-(id)initWithLoader:(Loader *)loader bridge:(WebCoreBridge *)bridge
 {
     if ((self = [super init])) {
         m_loader = loader;
-        m_dataSource = [dataSource retain];
+        m_bridge = [m_bridge retain];
         return self;
     }
     
@@ -122,156 +61,100 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
 
 - (void)dealloc
 {
-    [m_dataSource autorelease];
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT(m_currentURL == nil);
+#else
+    [m_currentURL release];
+#endif    
+    [m_bridge release];
     [super dealloc];
 }
 
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)handle
 {
-    id controller;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    void *userData;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-
-    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT(m_currentURL == nil);
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-    [controller _didStartLoading:job->url()];
+    m_currentURL = [[handle url] retain];
+    [m_bridge didStartLoadingWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDataDidBecomeAvailable:(NSData *)data
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length], [handle contentLength], [handle contentLengthReceived]);
 
-    [m_dataSource _removeURLHandle: job->handle()];
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
 
-    job->setError(1);
-    m_loader->slotFinished(job);
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    m_loader->slotData(job, (const char *)[data bytes], [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
-    delete job;
+    [m_bridge receivedProgressWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+- (void)doneWithHandle:(IFURLHandle *)handle error:(BOOL)error
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    // FIXME Radar 2954901: Replaced the assertion below with a more lenient one,
+    // since cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#else
+    KWQ_ASSERT(m_currentURL == nil || [m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#endif    
 
-    [m_dataSource _removeURLHandle: job->handle()];
+    [m_bridge removeHandle:handle];
     
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length]);
-
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    if (error) {
+        job->setError(1);
+    }
     m_loader->slotFinished(job);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
     delete job;
+    
+    [m_currentURL release];
+    m_currentURL = nil;
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)handle
 {
-    void *userData;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length], contentLength, contentLengthReceived);
-
-    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;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
+    [m_bridge didCancelLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)handle data:(NSData *)data
 {
-    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, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT(job->url()));
-
-    [m_dataSource _removeURLHandle: job->handle()];
-
-    id <IFLoadHandler> controller = [m_dataSource controller];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    job->setError(1);
-    m_loader->slotFinished(job);
+    KWQ_ASSERT([handle statusCode] == IFURLHandleStatusLoadComplete);
+    KWQ_ASSERT((int)[data length] == [handle contentLengthReceived]);
 
-    [(IFWebController *)controller _receivedError: result forResourceHandle: sender partialProgress: loadProgress fromDataSource: m_dataSource];
+    [m_bridge didFinishLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:NO];
+}
 
-    [(IFWebController *)controller _didStopLoading:job->url()];
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDidFailLoadingWithResult:(IFError *)result
+{
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p, result = %s, URL = %s", m_bridge, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT([handle url]));
 
-    delete job;
+    [m_bridge didFailToLoadWithHandle:handle error:result];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+- (void)IFURLHandle:(IFURLHandle *)handle didRedirectToURL:(NSURL *)URL
 {
-    void *userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    NSURL *oldURL = job->url();
-
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
-    [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
-    
-    [m_dataSource _setFinalURL: url];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "url = %s", DEBUG_OBJECT(URL));
     
-    [[m_dataSource _locationChangeHandler] serverRedirectTo: url forDataSource: m_dataSource];
-    [(IFWebController *)[m_dataSource controller] _didStopLoading:oldURL];
-    [(IFWebController *)[m_dataSource controller] _didStartLoading:url];
+    KWQ_ASSERT(m_currentURL != nil);
+
+    [m_bridge didRedirectWithHandle:handle fromURL:m_currentURL];
+    [URL retain];
+    [m_currentURL release];
+    m_currentURL = URL;
 }
 
 @end
@@ -281,33 +164,24 @@ KWQLoaderImpl::KWQLoaderImpl(Loader *l)
 {
 }
 
-KWQLoaderImpl::~KWQLoaderImpl()
-{
-}
-
 void KWQLoaderImpl::setClient(Request *req)
 {
-    IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
-    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
+    WebCoreBridge *bridge = ((KHTMLPart *)req->m_docLoader->part())->impl->getBridge();
+    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader bridge:bridge] autorelease];
 }
 
 void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
 {
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n", 
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s", 
           req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
-    //job->begin(d->m_recv, job);
     
     job->begin(req->client, job);
     if (job->handle() == nil) {
-        // Must be a malformed URL.
-        //NSString *urlString = QSTRING_TO_NSSTRING(req->object->url().string());
+        // The only error that prevents us from making a handle is a malformed URL.
         IFError *error = [IFError errorWithCode:IFURLHandleResultBadURLError inDomain:IFErrorCodeDomainWebFoundation isTerminal:YES];
-
-        id <IFLoadHandler> controller = [(req->client)->m_dataSource controller];
-        [(IFWebController *)controller _receivedError: error forResourceHandle: nil partialProgress: nil fromDataSource: req->client->m_dataSource];
-    }
-    else {
-        [req->client->m_dataSource _addURLHandle: job->handle()];
+        [req->client->m_bridge didFailBeforeLoadingWithError:error];
+    } else {
+        [req->client->m_bridge addHandle:job->handle()];
     }
 }
 
@@ -319,5 +193,9 @@ void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
     if ([urlString hasSuffix:@"/"]) {
         urlString = [urlString substringToIndex:([urlString length] - 1)];
     }
+    
+    // FIXME: Are we sure that we can globally notify with the URL as the notification
+    // name without conflicting with other frameworks? No "IF" prefix needed?
+    // Maybe the notification should have a distinctive name, and the URL should be the object.
     [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
 }
diff --git a/WebCore/kwq/KWQLoader.h b/WebCore/kwq/KWQLoader.h
index a1e4de3..91d7379 100644
--- a/WebCore/kwq/KWQLoader.h
+++ b/WebCore/kwq/KWQLoader.h
@@ -37,7 +37,6 @@ class KWQLoaderImpl
 {
 public:
     KWQLoaderImpl(khtml::Loader *);
-    ~KWQLoaderImpl();
     
     void setClient(khtml::Request *);
     void serveRequest(khtml::Request *, KIO::TransferJob *);
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index 1882535..98823d6 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -25,95 +25,34 @@
 
 #include <KWQLoaderImpl.h>
 
-#include <kio/jobclasses.h>
-#include <misc/loader.h>
-#include <KWQKHTMLPartImpl.h>
-
-#include <WCLoadProgress.h>
-
-#include <kwqdebug.h>
-
-// ==== start of temporary section, formerly from external.h, to be killed ====
-
- at class IFWebDataSource;
- at class IFLoadProgress;
-
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML   = 4
-} IF_LOAD_TYPE;
-
- at interface IFLoadProgress : NSObject
-{
-    int bytesSoFar;	// 0 if this is the start of load
-    int totalToLoad;	// -1 if this is not known.
-                        // bytesSoFar == totalLoaded when complete
-    IF_LOAD_TYPE type;	// load types, either image, css, or jscript
-}
-- init;
- at end
-
- at protocol IFLocationChangeHandler
-- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)dataSource;
- at end
-
- at interface IFWebController <IFLocationChangeHandler>
-- (void)_receivedProgress: (IFLoadProgress *)progress forResourceHandle: (IFURLHandle *)handle fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_receivedError: (IFError *)error forResourceHandle: (IFURLHandle *)handle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_didStartLoading: (NSURL *)url;
-- (void)_didStopLoading: (NSURL *)url;
- at end
-
- at interface IFWebDataSource : NSObject
-- (IFWebController *)controller;
-- (void)_addURLHandle: (IFURLHandle *)handle;
-- (void)_removeURLHandle: (IFURLHandle *)handle;
-- (void)_setFinalURL: (NSURL *)url;
-- representation;
-- (id <IFLocationChangeHandler>)_locationChangeHandler;
- at end
-
- at interface IFHTMLRepresentation : NSObject
-- (KHTMLPart *)part;
- at end
-
- at protocol IFLoadHandler
-- (void)receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-- (void)receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- at end
-
-// ==== end of temporary section, formerly from external.h, to be killed ====
+#import <kio/jobclasses.h>
+#import <misc/loader.h>
+#import <KWQKHTMLPartImpl.h>
+#import <WebCoreBridge.h>
+#import <kwqdebug.h>
 
 using khtml::DocLoader;
 using khtml::Loader;
 using khtml::Request;
 
-WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
-
-void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
-{
-    WCIFLoadProgressMake = func;
-}
-
 @interface KWQURLLoadClient : NSObject <IFURLHandleClient>
 {
     khtml::Loader *m_loader;
-    IFWebDataSource *m_dataSource;
+    WebCoreBridge *m_bridge;
+    NSURL *m_currentURL;
 }
 
--(id)initWithLoader:(khtml::Loader *)loader dataSource:(IFWebDataSource *)dataSource;
+-(id)initWithLoader:(khtml::Loader *)loader bridge:(WebCoreBridge *)bridge;
 
 @end
 
 @implementation KWQURLLoadClient
 
--(id)initWithLoader:(Loader *)loader dataSource:(IFWebDataSource *)dataSource
+-(id)initWithLoader:(Loader *)loader bridge:(WebCoreBridge *)bridge
 {
     if ((self = [super init])) {
         m_loader = loader;
-        m_dataSource = [dataSource retain];
+        m_bridge = [m_bridge retain];
         return self;
     }
     
@@ -122,156 +61,100 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
 
 - (void)dealloc
 {
-    [m_dataSource autorelease];
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT(m_currentURL == nil);
+#else
+    [m_currentURL release];
+#endif    
+    [m_bridge release];
     [super dealloc];
 }
 
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)handle
 {
-    id controller;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    void *userData;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-
-    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT(m_currentURL == nil);
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-    [controller _didStartLoading:job->url()];
+    m_currentURL = [[handle url] retain];
+    [m_bridge didStartLoadingWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDataDidBecomeAvailable:(NSData *)data
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length], [handle contentLength], [handle contentLengthReceived]);
 
-    [m_dataSource _removeURLHandle: job->handle()];
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
 
-    job->setError(1);
-    m_loader->slotFinished(job);
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    m_loader->slotData(job, (const char *)[data bytes], [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
-    delete job;
+    [m_bridge receivedProgressWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+- (void)doneWithHandle:(IFURLHandle *)handle error:(BOOL)error
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    // FIXME Radar 2954901: Replaced the assertion below with a more lenient one,
+    // since cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#else
+    KWQ_ASSERT(m_currentURL == nil || [m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#endif    
 
-    [m_dataSource _removeURLHandle: job->handle()];
+    [m_bridge removeHandle:handle];
     
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length]);
-
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    if (error) {
+        job->setError(1);
+    }
     m_loader->slotFinished(job);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
     delete job;
+    
+    [m_currentURL release];
+    m_currentURL = nil;
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)handle
 {
-    void *userData;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length], contentLength, contentLengthReceived);
-
-    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;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
+    [m_bridge didCancelLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)handle data:(NSData *)data
 {
-    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, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT(job->url()));
-
-    [m_dataSource _removeURLHandle: job->handle()];
-
-    id <IFLoadHandler> controller = [m_dataSource controller];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    job->setError(1);
-    m_loader->slotFinished(job);
+    KWQ_ASSERT([handle statusCode] == IFURLHandleStatusLoadComplete);
+    KWQ_ASSERT((int)[data length] == [handle contentLengthReceived]);
 
-    [(IFWebController *)controller _receivedError: result forResourceHandle: sender partialProgress: loadProgress fromDataSource: m_dataSource];
+    [m_bridge didFinishLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:NO];
+}
 
-    [(IFWebController *)controller _didStopLoading:job->url()];
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDidFailLoadingWithResult:(IFError *)result
+{
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p, result = %s, URL = %s", m_bridge, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT([handle url]));
 
-    delete job;
+    [m_bridge didFailToLoadWithHandle:handle error:result];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+- (void)IFURLHandle:(IFURLHandle *)handle didRedirectToURL:(NSURL *)URL
 {
-    void *userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    NSURL *oldURL = job->url();
-
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
-    [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
-    
-    [m_dataSource _setFinalURL: url];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "url = %s", DEBUG_OBJECT(URL));
     
-    [[m_dataSource _locationChangeHandler] serverRedirectTo: url forDataSource: m_dataSource];
-    [(IFWebController *)[m_dataSource controller] _didStopLoading:oldURL];
-    [(IFWebController *)[m_dataSource controller] _didStartLoading:url];
+    KWQ_ASSERT(m_currentURL != nil);
+
+    [m_bridge didRedirectWithHandle:handle fromURL:m_currentURL];
+    [URL retain];
+    [m_currentURL release];
+    m_currentURL = URL;
 }
 
 @end
@@ -281,33 +164,24 @@ KWQLoaderImpl::KWQLoaderImpl(Loader *l)
 {
 }
 
-KWQLoaderImpl::~KWQLoaderImpl()
-{
-}
-
 void KWQLoaderImpl::setClient(Request *req)
 {
-    IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
-    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
+    WebCoreBridge *bridge = ((KHTMLPart *)req->m_docLoader->part())->impl->getBridge();
+    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader bridge:bridge] autorelease];
 }
 
 void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
 {
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n", 
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s", 
           req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
-    //job->begin(d->m_recv, job);
     
     job->begin(req->client, job);
     if (job->handle() == nil) {
-        // Must be a malformed URL.
-        //NSString *urlString = QSTRING_TO_NSSTRING(req->object->url().string());
+        // The only error that prevents us from making a handle is a malformed URL.
         IFError *error = [IFError errorWithCode:IFURLHandleResultBadURLError inDomain:IFErrorCodeDomainWebFoundation isTerminal:YES];
-
-        id <IFLoadHandler> controller = [(req->client)->m_dataSource controller];
-        [(IFWebController *)controller _receivedError: error forResourceHandle: nil partialProgress: nil fromDataSource: req->client->m_dataSource];
-    }
-    else {
-        [req->client->m_dataSource _addURLHandle: job->handle()];
+        [req->client->m_bridge didFailBeforeLoadingWithError:error];
+    } else {
+        [req->client->m_bridge addHandle:job->handle()];
     }
 }
 
@@ -319,5 +193,9 @@ void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
     if ([urlString hasSuffix:@"/"]) {
         urlString = [urlString substringToIndex:([urlString length] - 1)];
     }
+    
+    // FIXME: Are we sure that we can globally notify with the URL as the notification
+    // name without conflicting with other frameworks? No "IF" prefix needed?
+    // Maybe the notification should have a distinctive name, and the URL should be the object.
     [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
 }
diff --git a/WebCore/kwq/KWQLoaderImpl.h b/WebCore/kwq/KWQLoaderImpl.h
index a1e4de3..91d7379 100644
--- a/WebCore/kwq/KWQLoaderImpl.h
+++ b/WebCore/kwq/KWQLoaderImpl.h
@@ -37,7 +37,6 @@ class KWQLoaderImpl
 {
 public:
     KWQLoaderImpl(khtml::Loader *);
-    ~KWQLoaderImpl();
     
     void setClient(khtml::Request *);
     void serveRequest(khtml::Request *, KIO::TransferJob *);
diff --git a/WebCore/kwq/KWQLoaderImpl.mm b/WebCore/kwq/KWQLoaderImpl.mm
index 1882535..98823d6 100644
--- a/WebCore/kwq/KWQLoaderImpl.mm
+++ b/WebCore/kwq/KWQLoaderImpl.mm
@@ -25,95 +25,34 @@
 
 #include <KWQLoaderImpl.h>
 
-#include <kio/jobclasses.h>
-#include <misc/loader.h>
-#include <KWQKHTMLPartImpl.h>
-
-#include <WCLoadProgress.h>
-
-#include <kwqdebug.h>
-
-// ==== start of temporary section, formerly from external.h, to be killed ====
-
- at class IFWebDataSource;
- at class IFLoadProgress;
-
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML   = 4
-} IF_LOAD_TYPE;
-
- at interface IFLoadProgress : NSObject
-{
-    int bytesSoFar;	// 0 if this is the start of load
-    int totalToLoad;	// -1 if this is not known.
-                        // bytesSoFar == totalLoaded when complete
-    IF_LOAD_TYPE type;	// load types, either image, css, or jscript
-}
-- init;
- at end
-
- at protocol IFLocationChangeHandler
-- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)dataSource;
- at end
-
- at interface IFWebController <IFLocationChangeHandler>
-- (void)_receivedProgress: (IFLoadProgress *)progress forResourceHandle: (IFURLHandle *)handle fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_receivedError: (IFError *)error forResourceHandle: (IFURLHandle *)handle partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_didStartLoading: (NSURL *)url;
-- (void)_didStopLoading: (NSURL *)url;
- at end
-
- at interface IFWebDataSource : NSObject
-- (IFWebController *)controller;
-- (void)_addURLHandle: (IFURLHandle *)handle;
-- (void)_removeURLHandle: (IFURLHandle *)handle;
-- (void)_setFinalURL: (NSURL *)url;
-- representation;
-- (id <IFLocationChangeHandler>)_locationChangeHandler;
- at end
-
- at interface IFHTMLRepresentation : NSObject
-- (KHTMLPart *)part;
- at end
-
- at protocol IFLoadHandler
-- (void)receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-- (void)receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
- at end
-
-// ==== end of temporary section, formerly from external.h, to be killed ====
+#import <kio/jobclasses.h>
+#import <misc/loader.h>
+#import <KWQKHTMLPartImpl.h>
+#import <WebCoreBridge.h>
+#import <kwqdebug.h>
 
 using khtml::DocLoader;
 using khtml::Loader;
 using khtml::Request;
 
-WCIFLoadProgressMakeFunc WCIFLoadProgressMake;
-
-void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
-{
-    WCIFLoadProgressMake = func;
-}
-
 @interface KWQURLLoadClient : NSObject <IFURLHandleClient>
 {
     khtml::Loader *m_loader;
-    IFWebDataSource *m_dataSource;
+    WebCoreBridge *m_bridge;
+    NSURL *m_currentURL;
 }
 
--(id)initWithLoader:(khtml::Loader *)loader dataSource:(IFWebDataSource *)dataSource;
+-(id)initWithLoader:(khtml::Loader *)loader bridge:(WebCoreBridge *)bridge;
 
 @end
 
 @implementation KWQURLLoadClient
 
--(id)initWithLoader:(Loader *)loader dataSource:(IFWebDataSource *)dataSource
+-(id)initWithLoader:(Loader *)loader bridge:(WebCoreBridge *)bridge
 {
     if ((self = [super init])) {
         m_loader = loader;
-        m_dataSource = [dataSource retain];
+        m_bridge = [m_bridge retain];
         return self;
     }
     
@@ -122,156 +61,100 @@ void WCSetIFLoadProgressMakeFunc(WCIFLoadProgressMakeFunc func)
 
 - (void)dealloc
 {
-    [m_dataSource autorelease];
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT(m_currentURL == nil);
+#else
+    [m_currentURL release];
+#endif    
+    [m_bridge release];
     [super dealloc];
 }
 
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)handle
 {
-    id controller;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    void *userData;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-
-    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT(m_currentURL == nil);
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-    [controller _didStartLoading:job->url()];
+    m_currentURL = [[handle url] retain];
+    [m_bridge didStartLoadingWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDataDidBecomeAvailable:(NSData *)data
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length], [handle contentLength], [handle contentLengthReceived]);
 
-    [m_dataSource _removeURLHandle: job->handle()];
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s\n", m_dataSource, DEBUG_OBJECT(job->url()));
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
 
-    job->setError(1);
-    m_loader->slotFinished(job);
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    m_loader->slotData(job, (const char *)[data bytes], [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
-    delete job;
+    [m_bridge receivedProgressWithHandle:handle];
 }
 
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+- (void)doneWithHandle:(IFURLHandle *)handle error:(BOOL)error
 {
-    id controller;
-    void *userData;
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    // FIXME Radar 2954901: Replaced the assertion below with a more lenient one,
+    // since cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
+    KWQ_ASSERT([m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#else
+    KWQ_ASSERT(m_currentURL == nil || [m_currentURL isEqual:[handle redirectedURL] ? [handle redirectedURL] : [handle url]]);
+#endif    
 
-    [m_dataSource _removeURLHandle: job->handle()];
+    [m_bridge removeHandle:handle];
     
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length]);
-
+    void *userData = [[handle attributeForKey:IFURLHandleUserData] pointerValue];
+    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
+    if (error) {
+        job->setError(1);
+    }
     m_loader->slotFinished(job);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
-
-    [controller _didStopLoading:job->url()];
-
     delete job;
+    
+    [m_currentURL release];
+    m_currentURL = nil;
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)handle
 {
-    void *userData;
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
-    
-    userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "dataSource = %p for URL %s data at %p, length %d, contentLength %d, contentLengthReceived %d\n", m_dataSource, DEBUG_OBJECT(job->url()), data, [data length], contentLength, contentLengthReceived);
-
-    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;
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s", m_bridge, DEBUG_OBJECT([handle url]));
 
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    
-    controller = [m_dataSource controller];
-    [controller _receivedProgress: loadProgress forResourceHandle: sender fromDataSource: m_dataSource];
+    [m_bridge didCancelLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)handle data:(NSData *)data
 {
-    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, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT(job->url()));
-
-    [m_dataSource _removeURLHandle: job->handle()];
-
-    id <IFLoadHandler> controller = [m_dataSource controller];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "bridge = %p for URL %s data at %p, length %d", m_bridge, DEBUG_OBJECT([handle url]), data, [data length]);
     
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    job->setError(1);
-    m_loader->slotFinished(job);
+    KWQ_ASSERT([handle statusCode] == IFURLHandleStatusLoadComplete);
+    KWQ_ASSERT((int)[data length] == [handle contentLengthReceived]);
 
-    [(IFWebController *)controller _receivedError: result forResourceHandle: sender partialProgress: loadProgress fromDataSource: m_dataSource];
+    [m_bridge didFinishLoadingWithHandle:handle];
+    [self doneWithHandle:handle error:NO];
+}
 
-    [(IFWebController *)controller _didStopLoading:job->url()];
+- (void)IFURLHandle:(IFURLHandle *)handle resourceDidFailLoadingWithResult:(IFError *)result
+{
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "bridge = %p, result = %s, URL = %s", m_bridge, DEBUG_OBJECT([result errorDescription]), DEBUG_OBJECT([handle url]));
 
-    delete job;
+    [m_bridge didFailToLoadWithHandle:handle error:result];
+    [self doneWithHandle:handle error:YES];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+- (void)IFURLHandle:(IFURLHandle *)handle didRedirectToURL:(NSURL *)URL
 {
-    void *userData = [[sender attributeForKey:IFURLHandleUserData] pointerValue];
-    KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    NSURL *oldURL = job->url();
-
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "url = %s\n", DEBUG_OBJECT(url));
-    [[m_dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
-    
-    [m_dataSource _setFinalURL: url];
+    KWQDEBUGLEVEL(KWQ_LOG_LOADING, "url = %s", DEBUG_OBJECT(URL));
     
-    [[m_dataSource _locationChangeHandler] serverRedirectTo: url forDataSource: m_dataSource];
-    [(IFWebController *)[m_dataSource controller] _didStopLoading:oldURL];
-    [(IFWebController *)[m_dataSource controller] _didStartLoading:url];
+    KWQ_ASSERT(m_currentURL != nil);
+
+    [m_bridge didRedirectWithHandle:handle fromURL:m_currentURL];
+    [URL retain];
+    [m_currentURL release];
+    m_currentURL = URL;
 }
 
 @end
@@ -281,33 +164,24 @@ KWQLoaderImpl::KWQLoaderImpl(Loader *l)
 {
 }
 
-KWQLoaderImpl::~KWQLoaderImpl()
-{
-}
-
 void KWQLoaderImpl::setClient(Request *req)
 {
-    IFWebDataSource *dataSource = ((KHTMLPart *)((DocLoader *)req->object->loader())->part())->impl->getDataSource();
-    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader dataSource: dataSource] autorelease];
+    WebCoreBridge *bridge = ((KHTMLPart *)req->m_docLoader->part())->impl->getBridge();
+    req->client = [[[KWQURLLoadClient alloc] initWithLoader:loader bridge:bridge] autorelease];
 }
 
 void KWQLoaderImpl::serveRequest(Request *req, KIO::TransferJob *job)
 {
-    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s\n", 
+    KWQDEBUGLEVEL (KWQ_LOG_LOADING, "Serving request for base %s, url %s", 
           req->m_docLoader->part()->baseURL().url().latin1(), req->object->url().string().latin1());
-    //job->begin(d->m_recv, job);
     
     job->begin(req->client, job);
     if (job->handle() == nil) {
-        // Must be a malformed URL.
-        //NSString *urlString = QSTRING_TO_NSSTRING(req->object->url().string());
+        // The only error that prevents us from making a handle is a malformed URL.
         IFError *error = [IFError errorWithCode:IFURLHandleResultBadURLError inDomain:IFErrorCodeDomainWebFoundation isTerminal:YES];
-
-        id <IFLoadHandler> controller = [(req->client)->m_dataSource controller];
-        [(IFWebController *)controller _receivedError: error forResourceHandle: nil partialProgress: nil fromDataSource: req->client->m_dataSource];
-    }
-    else {
-        [req->client->m_dataSource _addURLHandle: job->handle()];
+        [req->client->m_bridge didFailBeforeLoadingWithError:error];
+    } else {
+        [req->client->m_bridge addHandle:job->handle()];
     }
 }
 
@@ -319,5 +193,9 @@ void KWQLoaderImpl::objectFinished(khtml::CachedObject *object)
     if ([urlString hasSuffix:@"/"]) {
         urlString = [urlString substringToIndex:([urlString length] - 1)];
     }
+    
+    // FIXME: Are we sure that we can globally notify with the URL as the notification
+    // name without conflicting with other frameworks? No "IF" prefix needed?
+    // Maybe the notification should have a distinctive name, and the URL should be the object.
     [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
 }
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 982dc73..69440e3 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -25,6 +25,8 @@
 
 #import <Foundation/Foundation.h>
 
+#ifdef __cplusplus
+
 class KHTMLPart;
 class KHTMLView;
 
@@ -32,7 +34,22 @@ namespace khtml {
     class RenderPart;
 }
 
- at class IFWebDataSource; // temporary -- here only until I finish KWQKloader.mm
+typedef khtml::RenderPart KHTMLRenderPart;
+
+#else
+
+typedef struct KHTMLPart KHTMLPart;
+typedef struct KHTMLView KHTMLView;
+typedef struct KHTMLRenderPart KHTMLRenderPart;
+
+#endif
+
+ at class IFError;
+ at class IFURLHandle;
+
+ at class WebCoreBridge;
+
+// The WebCoreBridge class contains methods for use by the non-WebCore side of the bridge.
 
 @interface WebCoreBridge : NSObject
 {
@@ -41,6 +58,27 @@ namespace khtml {
 
 - (KHTMLPart *)part;
 
+- (void)openURL:(NSURL *)URL;
+- (void)addData:(NSData *)data withEncoding:(NSString *)encoding;
+- (void)closeURL;
+- (void)end;
+
+- (void)setURL:(NSURL *)URL;
+
+- (void)scrollToBaseAnchor;
+
+- (NSString *)documentTextFromDOM;
+
+- (KHTMLView *)createKHTMLViewWithNSView:(NSView *)view
+    width:(int)width height:(int)height
+    marginWidth:(int)mw marginHeight:(int)mh;
+
+ at end
+
+// The WebCoreBridge protocol contains methods for use by the WebCore side of the bridge.
+
+ at protocol WebCoreBridge
+
 - (WebCoreBridge *)parent;
 - (NSArray *)children; // WebCoreBridge objects
 
@@ -60,6 +98,19 @@ namespace khtml {
 
 - (KHTMLView *)widget;
 
-- (IFWebDataSource *)dataSource; // temporary -- here only until I finish KWQKloader.mm
+- (void)addHandle:(IFURLHandle *)handle;
+- (void)removeHandle:(IFURLHandle *)handle;
+
+- (void)didStartLoadingWithHandle:(IFURLHandle *)handle;
+- (void)receivedProgressWithHandle:(IFURLHandle *)handle;
+- (void)didFinishLoadingWithHandle:(IFURLHandle *)handle;
+
+- (void)didCancelLoadingWithHandle:(IFURLHandle *)handle;
+- (void)didFailToLoadWithHandle:(IFURLHandle *)handle error:(IFError *)error;
+- (void)didRedirectWithHandle:(IFURLHandle *)handle fromURL:(NSURL *)fromURL;
+- (void)didFailBeforeLoadingWithError:(IFError *)error;
+
+ at end
 
+ at interface WebCoreBridge (SubclassResponsibility) <WebCoreBridge>
 @end
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index b54afcf..d448609 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -26,6 +26,8 @@
 #import <WebCoreBridge.h>
 
 #import <KWQKHTMLPartImpl.h>
+#import <khtmlview.h>
+#import <xml/dom_docimpl.h>
 
 @implementation WebCoreBridge
 
@@ -51,57 +53,65 @@
     return part;
 }
 
-- (WebCoreBridge *)parent
+- (void)openURL:(NSURL *)URL
 {
-    return nil;
+    part->openURL([[URL absoluteString] cString]);
 }
 
-- (NSArray *)children
+- (void)addData:(NSData *)data withEncoding:(NSString *)encoding
 {
-    return nil;
+    part->impl->slotData(encoding, (const char *)[data bytes], [data length], NO);
 }
 
-- (void)loadURL:(NSURL *)URL
+- (void)closeURL
 {
+    part->closeURL();
 }
 
-- (void)postWithURL:(NSURL *)URL data:(NSData *)data
+- (void)end
 {
+    part->end();
 }
 
-- (BOOL)createNewFrameNamed:(NSString *)frameName
-    withURL:(NSURL *)URL renderPart:(khtml::RenderPart *)renderPart
-    allowsScrolling:(BOOL)allowsScrolling marginWidth:(int)width marginHeight:(int)height
+- (void)setURL:(NSURL *)URL
 {
-    return NO;
+    part->impl->setBaseURL([[URL absoluteString] cString]);
 }
 
-- (void)openNewWindowWithURL:(NSURL *)URL
+- (KHTMLView *)createKHTMLViewWithNSView:(NSView *)view
+    width:(int)width height:(int)height
+    marginWidth:(int)mw marginHeight:(int)mh
 {
+    // Nasty! Set up the cross references between the KHTMLView and the KHTMLPart.
+    KHTMLView *kview = new KHTMLView(part, 0);
+    part->impl->setView(kview);
+
+    kview->setView(view);
+    kview->setMarginWidth(mw);
+    kview->setMarginHeight(mh);
+    kview->resize(width, height);
+    
+    return kview;
 }
 
-- (void)setTitle:(NSString *)title
-{
-}
-
-- (WebCoreBridge *)mainFrame
-{
-    return nil;
-}
-
-- (WebCoreBridge *)frameNamed:(NSString *)name
-{
-    return nil;
-}
-
-- (KHTMLView *)widget
+- (NSString *)documentTextFromDOM
 {
-    return 0;
+    NSString *string = nil;
+    if (part) {
+        DOM::DocumentImpl *doc = part->xmlDocImpl();
+        if (doc) {
+            string = [doc->recursive_toHTML(1).getNSString() copy];
+        }
+    }
+    if (string == nil) {
+        string = @"";
+    }
+    return string;
 }
 
-- (IFWebDataSource *)dataSource
+- (void)scrollToBaseAnchor
 {
-    return nil;
+    part->impl->gotoBaseAnchor();
 }
 
 @end
diff --git a/WebCore/kwq/external.h b/WebCore/kwq/external.h
deleted file mode 100644
index bd046fa..0000000
--- a/WebCore/kwq/external.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2001 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 EXTERNAL_H
-#define EXTERNAL_H_
-
-#import <WebFoundation/WebFoundation.h>
-#import <misc/loader.h>
-
-class KHTMLPart;
-class QWidget;
-
-namespace khtml {
-    class Loader;
-}
-
- at class IFWebDataSource;
- at class IFWebView;
- at class IFWebFrame;
- at class IFError;
- at class IFURLHandle;
- at class IFLoadProgress;
- at protocol IFLocationChangeHandler;
-
- at interface IFWebController <IFLocationChangeHandler>
-- (IFWebFrame *)createFrameNamed: (NSString *)name for: (IFWebDataSource *)dataSource inParent: (IFWebDataSource *)dataSource allowsScrolling: (BOOL)allowsScrolling;
-- (IFWebFrame *)frameNamed: (NSString *)name;
-- (IFWebFrame *)mainFrame;
-- (IFWebController *)openNewWindowWithURL: (NSURL *)url;
-
-- (void)_receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_mainReceivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_mainReceivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-- (void)_didStartLoading: (NSURL *)url;
-- (void)_didStopLoading: (NSURL *)url;
- at end
-
- at protocol IFLocationChangeHandler
-- (void)serverRedirectTo: (NSURL *)url forDataSource: (IFWebDataSource *)dataSource;
- at end
-
- at interface IFWebDataSource : NSObject
-- initWithURL: (NSURL *)url;
-- (IFWebFrame *)webFrame;
-- (IFWebController *)controller;
-- frameNamed: (NSString *)f;
-- (BOOL)frameExists: (NSString *)f;
-- (void)_setParent: (IFWebDataSource *)p;
-- (IFWebDataSource *)parent;
-- (void)_addURLHandle: (IFURLHandle *)handle;
-- (void)_removeURLHandle: (IFURLHandle *)handle;
-- controller;
-- (void)_setTitle: (NSString *)title;
-- (void)_setFinalURL: (NSURL *)url;
-- (id <IFLocationChangeHandler>)_locationChangeHandler;
-- (BOOL)_isStopping;
-- (NSArray *)children;
-- representation;
- at end
-
- at interface IFHTMLRepresentation : NSObject
-- (KHTMLPart *)part;
- at end
-
- at interface IFDynamicScrollBarsView
-- (void)setCursor:(NSCursor *)cur;
- at end
-
- at interface IFWebView: NSObject
-- (QWidget *)_widget;
-- (QWidget *)_provisionalWidget;
-- (void)setFrameSize: (NSSize)r;
-- (void)_setMarginWidth: (int)w;
-- (int)_marginWidth;
-- (void)_setMarginHeight: (int)h;
-- (int)_marginHeight;
-- (id)documentView;
- at end
-
- at interface IFWebFrame: NSObject
-- (IFWebView *)webView;
-- (IFWebDataSource *)dataSource;
-- (IFWebDataSource *)provisionalDataSource;
-- (void)setProvisionalDataSource: (IFWebDataSource *)ds;
-- (void)_setRenderFramePart: (void *)p;
-- (void *)_renderFramePart;
-- (void)startLoading;
-- (IFWebFrame *)frameNamed: (NSString *)name;
- at end
-
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML   = 4
-} IF_LOAD_TYPE;
-
-
- at interface IFLoadProgress : NSObject
-{
-    int bytesSoFar;	// 0 if this is the start of load
-    int totalToLoad;	// -1 if this is not known.
-                        // bytesSoFar == totalLoaded when complete
-    IF_LOAD_TYPE type;	// load types, either image, css, or jscript
-}
-- init;
- at end
-
- at protocol  IFLoadHandler
-- (void)receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
-
-- (void)receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
-
- at end
-
-
- at interface URLLoadClient : NSObject <IFURLHandleClient>
-{
-    @public
-    khtml::Loader *m_loader;
-    id m_dataSource;
-}
-
--(id)initWithLoader:(khtml::Loader *)loader dataSource: dataSource;
-
- at end
-
- at interface WCURLHandle
--(int)contentLength;
- at end
-
-#endif
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index ab94104..12b00da 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,87 @@
+2002-06-15  Darin Adler  <darin at apple.com>
+
+	- fixed 2942808 -- remove all calls to WebKit from WebCore
+
+	Update to use the WebCore bridge for more things, reducing
+	dependencies in both directions. Besides using the bridge for all the
+	remaining WebCore to WebKit calls, almost no WebKit code deals with
+	KHTMLPart directly any more, instead the other side of the bridge handles it.
+
+	* Plugins.subproj/IFPluginStream.mm:
+	(-[IFPluginStream IFURLHandleResourceDidBeginLoading:]): Remove unneeded casts.
+	(-[IFPluginStream IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
+	(-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[IFPluginStream IFURLHandle:didRedirectToURL:]):
+	Use the new IFProgress methods to simplify code.
+
+	* WebCoreSupport.subproj/IFWebCoreBridge.h: Use the new WebCoreBridge protocol
+	so we get a compiler error if we forget to implement anything. Add a method for
+	IFWebDataSource that gets the WebCoreBridge if it has an IFHTMLRepresentation,
+	and nil otherwise.
+	* WebCoreSupport.subproj/IFWebCoreBridge.mm:
+	(-[IFWebDataSource _bridge]): Add; does checking so that it returns
+	nil if the representation is not an IFHTMLRepresentation. This is now used
+	almost everywhere so we don't have to do so much type casting.
+	(-[IFWebCoreBridge loadURL:attributes:flags:inFrame:withParent:]): Remove a
+	stray use of [IFWebCoreBridge dataSource] so we can remove it.
+	(-[IFWebCoreBridge receivedData:withDataSource:]): Use the
+	new [WebCoreBridge openURL:] and [WebCoreBridge addData:] methods from the
+	other side of the bridge so we don't have to deal with the KHTMLPart directly.
+	(-[IFWebCoreBridge addHandle:]): Added.
+	(-[IFWebCoreBridge removeHandle:]): Added.
+	(-[IFWebCoreBridge didStartLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge receivedProgressWithHandle:]): Added.
+	(-[IFWebCoreBridge didFinishLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge didCancelLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge didFailBeforeLoadingWithError:]): Added.
+	(-[IFWebCoreBridge didFailToLoadWithHandle:error:]): Added.
+	(-[IFWebCoreBridge didRedirectWithHandle:fromURL:]): Added.
+
+	* WebView.subproj/IFHTMLRepresentation.h: Remove unneeded declarations.
+	* WebView.subproj/IFHTMLRepresentation.mm: Remove [IFHTMLRepresentation part].
+	* WebView.subproj/IFHTMLRepresentationPrivate.h: Remove [IFHTMLRepresentation part].
+
+	* WebView.subproj/IFHTMLView.mm: (-[IFHTMLView provisionalDataSourceChanged:]): Use the bridge.
+
+	* WebView.subproj/IFHTMLViewPrivate.mm: Remove a bunch of unused stuff that was
+	there for the render and document tree viewers. I had removed it once before but
+	it got re-added as a side effect of the reorganization process.
+
+	* WebView.subproj/IFLoadProgress.h: Remove the unused IFLoadType -- we can add
+	it back if we find that it's needed. It didn't do much good to have it here
+	and only partly implemented, and I don't think it's needed. Added some convenient
+	interfaces for creating IFLoadProgress objects.
+
+	* WebView.subproj/IFLoadProgress.mm: Get rid of WCSetIFLoadProgressMakeFunc stuff.
+	(-[IFLoadProgress init]): Added.
+	(-[IFLoadProgress initWithBytesSoFar:totalToLoad:]): Remove type part.
+	(-[IFLoadProgress initWithURLHandle:]): Added.
+	(+[IFLoadProgress progress]): Added.
+	(+[IFLoadProgress progressWithBytesSoFar:totalToLoad:]): Added.
+	(+[IFLoadProgress progressWithURLHandle:]): Added.
+
+	* WebView.subproj/IFMainURLHandleClient.mm:
+	(-[IFMainURLHandleClient dealloc]): Add more workaround for 2954901.
+	(-[IFMainURLHandleClient IFURLHandleResourceDidBeginLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
+	Remove unneeded type casts and simplify by using new IFLoadProgress methods.
+	Also simplify access to _bridge by using [IFWebDataSource _bridge].
+
+	* WebView.subproj/IFWebControllerPrivate.mm:
+	* WebView.subproj/IFWebFrame.mm:
+	Remove unneeded include of KHTMLPart header.
+
+	* WebView.subproj/IFWebDataSource.mm: (-[IFWebDataSource documentTextFromDOM]):
+	* WebView.subproj/IFWebDataSourcePrivate.mm: (-[IFWebDataSource _stopLoading]):
+	* WebView.subproj/IFWebFramePrivate.mm: (-[IFWebFrame _isLoadComplete]):
+	Use bridge.
+
 2002-06-15  Maciej Stachowiak  <mjs at apple.com>
 
         Made Development build mode mean what Unoptimized used to mean. Removed Unoptimized build mode. 
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index ab94104..12b00da 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,87 @@
+2002-06-15  Darin Adler  <darin at apple.com>
+
+	- fixed 2942808 -- remove all calls to WebKit from WebCore
+
+	Update to use the WebCore bridge for more things, reducing
+	dependencies in both directions. Besides using the bridge for all the
+	remaining WebCore to WebKit calls, almost no WebKit code deals with
+	KHTMLPart directly any more, instead the other side of the bridge handles it.
+
+	* Plugins.subproj/IFPluginStream.mm:
+	(-[IFPluginStream IFURLHandleResourceDidBeginLoading:]): Remove unneeded casts.
+	(-[IFPluginStream IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFPluginStream IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFPluginStream IFURLHandleResourceDidCancelLoading:]):
+	(-[IFPluginStream IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[IFPluginStream IFURLHandle:didRedirectToURL:]):
+	Use the new IFProgress methods to simplify code.
+
+	* WebCoreSupport.subproj/IFWebCoreBridge.h: Use the new WebCoreBridge protocol
+	so we get a compiler error if we forget to implement anything. Add a method for
+	IFWebDataSource that gets the WebCoreBridge if it has an IFHTMLRepresentation,
+	and nil otherwise.
+	* WebCoreSupport.subproj/IFWebCoreBridge.mm:
+	(-[IFWebDataSource _bridge]): Add; does checking so that it returns
+	nil if the representation is not an IFHTMLRepresentation. This is now used
+	almost everywhere so we don't have to do so much type casting.
+	(-[IFWebCoreBridge loadURL:attributes:flags:inFrame:withParent:]): Remove a
+	stray use of [IFWebCoreBridge dataSource] so we can remove it.
+	(-[IFWebCoreBridge receivedData:withDataSource:]): Use the
+	new [WebCoreBridge openURL:] and [WebCoreBridge addData:] methods from the
+	other side of the bridge so we don't have to deal with the KHTMLPart directly.
+	(-[IFWebCoreBridge addHandle:]): Added.
+	(-[IFWebCoreBridge removeHandle:]): Added.
+	(-[IFWebCoreBridge didStartLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge receivedProgressWithHandle:]): Added.
+	(-[IFWebCoreBridge didFinishLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge didCancelLoadingWithHandle:]): Added.
+	(-[IFWebCoreBridge didFailBeforeLoadingWithError:]): Added.
+	(-[IFWebCoreBridge didFailToLoadWithHandle:error:]): Added.
+	(-[IFWebCoreBridge didRedirectWithHandle:fromURL:]): Added.
+
+	* WebView.subproj/IFHTMLRepresentation.h: Remove unneeded declarations.
+	* WebView.subproj/IFHTMLRepresentation.mm: Remove [IFHTMLRepresentation part].
+	* WebView.subproj/IFHTMLRepresentationPrivate.h: Remove [IFHTMLRepresentation part].
+
+	* WebView.subproj/IFHTMLView.mm: (-[IFHTMLView provisionalDataSourceChanged:]): Use the bridge.
+
+	* WebView.subproj/IFHTMLViewPrivate.mm: Remove a bunch of unused stuff that was
+	there for the render and document tree viewers. I had removed it once before but
+	it got re-added as a side effect of the reorganization process.
+
+	* WebView.subproj/IFLoadProgress.h: Remove the unused IFLoadType -- we can add
+	it back if we find that it's needed. It didn't do much good to have it here
+	and only partly implemented, and I don't think it's needed. Added some convenient
+	interfaces for creating IFLoadProgress objects.
+
+	* WebView.subproj/IFLoadProgress.mm: Get rid of WCSetIFLoadProgressMakeFunc stuff.
+	(-[IFLoadProgress init]): Added.
+	(-[IFLoadProgress initWithBytesSoFar:totalToLoad:]): Remove type part.
+	(-[IFLoadProgress initWithURLHandle:]): Added.
+	(+[IFLoadProgress progress]): Added.
+	(+[IFLoadProgress progressWithBytesSoFar:totalToLoad:]): Added.
+	(+[IFLoadProgress progressWithURLHandle:]): Added.
+
+	* WebView.subproj/IFMainURLHandleClient.mm:
+	(-[IFMainURLHandleClient dealloc]): Add more workaround for 2954901.
+	(-[IFMainURLHandleClient IFURLHandleResourceDidBeginLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidCancelLoading:]):
+	(-[IFMainURLHandleClient IFURLHandleResourceDidFinishLoading:data:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDataDidBecomeAvailable:]):
+	(-[IFMainURLHandleClient IFURLHandle:resourceDidFailLoadingWithResult:]):
+	(-[IFMainURLHandleClient IFURLHandle:didRedirectToURL:]):
+	Remove unneeded type casts and simplify by using new IFLoadProgress methods.
+	Also simplify access to _bridge by using [IFWebDataSource _bridge].
+
+	* WebView.subproj/IFWebControllerPrivate.mm:
+	* WebView.subproj/IFWebFrame.mm:
+	Remove unneeded include of KHTMLPart header.
+
+	* WebView.subproj/IFWebDataSource.mm: (-[IFWebDataSource documentTextFromDOM]):
+	* WebView.subproj/IFWebDataSourcePrivate.mm: (-[IFWebDataSource _stopLoading]):
+	* WebView.subproj/IFWebFramePrivate.mm: (-[IFWebFrame _isLoadComplete]):
+	Use bridge.
+
 2002-06-15  Maciej Stachowiak  <mjs at apple.com>
 
         Made Development build mode mean what Unoptimized used to mean. Removed Unoptimized build mode. 
diff --git a/WebKit/Plugins.subproj/IFPluginStream.mm b/WebKit/Plugins.subproj/IFPluginStream.mm
index f0bf1a0..f46e1bb 100644
--- a/WebKit/Plugins.subproj/IFPluginStream.mm
+++ b/WebKit/Plugins.subproj/IFPluginStream.mm
@@ -90,7 +90,7 @@ static NSString *getCarbonPath(NSString *posixPath);
 
 - (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
 {
-    [(IFWebController *)[view webController] _didStartLoading:URL];
+    [[view webController] _didStartLoading:URL];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
@@ -134,13 +134,8 @@ static NSString *getCarbonPath(NSString *posixPath);
         offset += [data length];
     }
      
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progressWithURLHandle:sender]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
@@ -170,30 +165,20 @@ static NSString *getCarbonPath(NSString *posixPath);
         WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_URLNotify\n");
     }
     
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress 
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progressWithURLHandle:sender]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress 
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progress]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
@@ -201,21 +186,20 @@ static NSString *getCarbonPath(NSString *posixPath);
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
     
     [[[view webController] resourceProgressHandler] receivedError: result forResourceHandle: sender 
         partialProgress: loadProgress fromDataSource: [view webDataSource]];
     [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)toURL
 {
-    [(IFWebController *)[view webController] _didStopLoading:URL];
-    // FIXME: This next line is not going to work. We don't remember the new URL.
-    [(IFWebController *)[view webController] _didStartLoading:url];
+    [[view webController] _didStopLoading:URL];
+    // FIXME: This next line is not sufficient. We don't do anything to remember the new URL.
+    [[view webController] _didStartLoading:toURL];
 }
 
 
diff --git a/WebKit/Plugins.subproj/WebPluginStream.m b/WebKit/Plugins.subproj/WebPluginStream.m
index f0bf1a0..f46e1bb 100644
--- a/WebKit/Plugins.subproj/WebPluginStream.m
+++ b/WebKit/Plugins.subproj/WebPluginStream.m
@@ -90,7 +90,7 @@ static NSString *getCarbonPath(NSString *posixPath);
 
 - (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
 {
-    [(IFWebController *)[view webController] _didStartLoading:URL];
+    [[view webController] _didStartLoading:URL];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
@@ -134,13 +134,8 @@ static NSString *getCarbonPath(NSString *posixPath);
         offset += [data length];
     }
      
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progressWithURLHandle:sender]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
@@ -170,30 +165,20 @@ static NSString *getCarbonPath(NSString *posixPath);
         WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_URLNotify\n");
     }
     
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress 
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progressWithURLHandle:sender]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
-    [[[view webController] resourceProgressHandler] receivedProgress: (IFLoadProgress *)loadProgress 
+    [[[view webController] resourceProgressHandler] receivedProgress:[IFLoadProgress progress]
         forResourceHandle: sender fromDataSource: [view webDataSource]];
-    [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(IFError *)result
@@ -201,21 +186,20 @@ static NSString *getCarbonPath(NSString *posixPath);
     IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [sender contentLengthReceived];
-    loadProgress->type = IF_LOAD_TYPE_PLUGIN;
     
     [[[view webController] resourceProgressHandler] receivedError: result forResourceHandle: sender 
         partialProgress: loadProgress fromDataSource: [view webDataSource]];
     [loadProgress release];
     
     [self stop];
-    [(IFWebController *)[view webController] _didStopLoading:URL];
+    [[view webController] _didStopLoading:URL];
 }
 
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)toURL
 {
-    [(IFWebController *)[view webController] _didStopLoading:URL];
-    // FIXME: This next line is not going to work. We don't remember the new URL.
-    [(IFWebController *)[view webController] _didStartLoading:url];
+    [[view webController] _didStopLoading:URL];
+    // FIXME: This next line is not sufficient. We don't do anything to remember the new URL.
+    [[view webController] _didStartLoading:toURL];
 }
 
 
diff --git a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
index 983412e..c392abc 100644
--- a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
+++ b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
@@ -8,9 +8,9 @@
 
 #import <WebCoreBridge.h>
 
- at class IFWebDataSource;
+#import <WebKit/IFWebDataSource.h>
 
- at interface IFWebCoreBridge : WebCoreBridge
+ at interface IFWebCoreBridge : WebCoreBridge <WebCoreBridge>
 {
     IFWebDataSource *dataSource;
 }
@@ -18,3 +18,10 @@
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource;
 
 @end
+
+// Convenience interface for getting here from an IFWebDataSource.
+// This returns nil if the representation is not an IFHTMLRepresentation.
+
+ at interface IFWebDataSource (IFWebCoreBridge)
+- (IFWebCoreBridge *)_bridge;
+ at end
diff --git a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.mm b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.mm
index 9203360..fbd4e4e 100644
--- a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.mm
+++ b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.mm
@@ -6,24 +6,21 @@
 //  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 //
 
-#import <WebKit/IFHTMLRepresentation.h>
-#import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFWebController.h>
 #import <WebKit/IFWebCoreBridge.h>
+
+#import <WebKit/IFWebControllerPrivate.h>
+#import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebViewPrivate.h>
-
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFHTMLViewPrivate.h>
+#import <WebKit/IFLoadProgress.h>
 #import <WebFoundation/IFURLCacheLoaderConstants.h>
-
-#import <KWQKHTMLPartImpl.h>
+#import <WebFoundation/IFURLHandle.h>
 
 #import <WebKit/WebKitDebug.h>
 
- at interface IFWebDataSource (IFWebCoreBridge)
-- (IFWebCoreBridge *)_bridge;
- at end
-
 @interface IFWebFrame (IFWebCoreBridge)
 - (IFWebCoreBridge *)_bridge;
 @end
@@ -32,7 +29,8 @@
 
 - (IFWebCoreBridge *)_bridge
 {
-    return [(IFHTMLRepresentation *)[self representation] _bridge];
+    id representation = [self representation];
+    return [representation respondsToSelector:@selector(_bridge)] ? [representation _bridge] : nil;
 }
 
 @end
@@ -89,7 +87,7 @@
 {
     IFWebDataSource *newDataSource = [[IFWebDataSource alloc] initWithURL:URL attributes:attributes flags:flags];
     IFWebCoreBridge *parentPrivate = (IFWebCoreBridge *)parent;
-    [newDataSource _setParent:[parentPrivate dataSource]];
+    [newDataSource _setParent:parentPrivate->dataSource];
     [frame setProvisionalDataSource:newDataSource];
     [newDataSource release];
     [frame startLoading];
@@ -166,17 +164,74 @@
 {
     if (dataSource == nil) {
         dataSource = withDataSource;
-        [self part]->openURL([[[dataSource inputURL] absoluteString] cString]);
+        [self openURL:[dataSource inputURL]];
     } else {
         WEBKIT_ASSERT(dataSource == withDataSource);
     }
     
-    [self part]->impl->slotData([dataSource encoding], (const char *)[data bytes], [data length], NO);
+    [self addData:data withEncoding:[dataSource encoding]];
+}
+
+- (void)addHandle:(IFURLHandle *)handle
+{
+    [dataSource _addURLHandle:handle];
+}
+
+- (void)removeHandle:(IFURLHandle *)handle
+{
+    [dataSource _removeURLHandle:handle];
+}
+
+- (void)didStartLoadingWithHandle:(IFURLHandle *)handle
+{
+    [[self controller] _didStartLoading:[handle url]];
+    [self receivedProgressWithHandle:handle];
 }
 
-- (IFWebDataSource *)dataSource
+- (void)receivedProgressWithHandle:(IFURLHandle *)handle
 {
-    return dataSource;
+    [[self controller] _receivedProgress:[IFLoadProgress progressWithURLHandle:handle]
+        forResourceHandle:handle fromDataSource:dataSource];
+}
+
+- (void)didFinishLoadingWithHandle:(IFURLHandle *)handle
+{
+    [self receivedProgressWithHandle:handle];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didCancelLoadingWithHandle:(IFURLHandle *)handle
+{
+    [[self controller] _receivedProgress:[IFLoadProgress progress]
+        forResourceHandle:handle fromDataSource:dataSource];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didFailBeforeLoadingWithError:(IFError *)error
+{
+    [[self controller] _receivedError:error forResourceHandle:nil
+        partialProgress:nil fromDataSource:dataSource];
+}
+
+- (void)didFailToLoadWithHandle:(IFURLHandle *)handle error:(IFError *)error
+{
+    [[self controller] _receivedError:error forResourceHandle:handle
+        partialProgress:[IFLoadProgress progressWithURLHandle:handle] fromDataSource:dataSource];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didRedirectWithHandle:(IFURLHandle *)handle fromURL:(NSURL *)fromURL
+{
+    NSURL *toURL = [handle redirectedURL];
+    
+    [[self controller] _didStopLoading:fromURL];
+
+    [dataSource _setFinalURL:toURL];
+    [self setURL:toURL];
+
+    [[dataSource _locationChangeHandler] serverRedirectTo:toURL forDataSource:dataSource];
+    
+    [[self controller] _didStartLoading:toURL];
 }
 
 @end
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.h b/WebKit/WebCoreSupport.subproj/WebBridge.h
index 983412e..c392abc 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.h
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.h
@@ -8,9 +8,9 @@
 
 #import <WebCoreBridge.h>
 
- at class IFWebDataSource;
+#import <WebKit/IFWebDataSource.h>
 
- at interface IFWebCoreBridge : WebCoreBridge
+ at interface IFWebCoreBridge : WebCoreBridge <WebCoreBridge>
 {
     IFWebDataSource *dataSource;
 }
@@ -18,3 +18,10 @@
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource;
 
 @end
+
+// Convenience interface for getting here from an IFWebDataSource.
+// This returns nil if the representation is not an IFHTMLRepresentation.
+
+ at interface IFWebDataSource (IFWebCoreBridge)
+- (IFWebCoreBridge *)_bridge;
+ at end
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 9203360..fbd4e4e 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -6,24 +6,21 @@
 //  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 //
 
-#import <WebKit/IFHTMLRepresentation.h>
-#import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFWebController.h>
 #import <WebKit/IFWebCoreBridge.h>
+
+#import <WebKit/IFWebControllerPrivate.h>
+#import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebViewPrivate.h>
-
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFHTMLViewPrivate.h>
+#import <WebKit/IFLoadProgress.h>
 #import <WebFoundation/IFURLCacheLoaderConstants.h>
-
-#import <KWQKHTMLPartImpl.h>
+#import <WebFoundation/IFURLHandle.h>
 
 #import <WebKit/WebKitDebug.h>
 
- at interface IFWebDataSource (IFWebCoreBridge)
-- (IFWebCoreBridge *)_bridge;
- at end
-
 @interface IFWebFrame (IFWebCoreBridge)
 - (IFWebCoreBridge *)_bridge;
 @end
@@ -32,7 +29,8 @@
 
 - (IFWebCoreBridge *)_bridge
 {
-    return [(IFHTMLRepresentation *)[self representation] _bridge];
+    id representation = [self representation];
+    return [representation respondsToSelector:@selector(_bridge)] ? [representation _bridge] : nil;
 }
 
 @end
@@ -89,7 +87,7 @@
 {
     IFWebDataSource *newDataSource = [[IFWebDataSource alloc] initWithURL:URL attributes:attributes flags:flags];
     IFWebCoreBridge *parentPrivate = (IFWebCoreBridge *)parent;
-    [newDataSource _setParent:[parentPrivate dataSource]];
+    [newDataSource _setParent:parentPrivate->dataSource];
     [frame setProvisionalDataSource:newDataSource];
     [newDataSource release];
     [frame startLoading];
@@ -166,17 +164,74 @@
 {
     if (dataSource == nil) {
         dataSource = withDataSource;
-        [self part]->openURL([[[dataSource inputURL] absoluteString] cString]);
+        [self openURL:[dataSource inputURL]];
     } else {
         WEBKIT_ASSERT(dataSource == withDataSource);
     }
     
-    [self part]->impl->slotData([dataSource encoding], (const char *)[data bytes], [data length], NO);
+    [self addData:data withEncoding:[dataSource encoding]];
+}
+
+- (void)addHandle:(IFURLHandle *)handle
+{
+    [dataSource _addURLHandle:handle];
+}
+
+- (void)removeHandle:(IFURLHandle *)handle
+{
+    [dataSource _removeURLHandle:handle];
+}
+
+- (void)didStartLoadingWithHandle:(IFURLHandle *)handle
+{
+    [[self controller] _didStartLoading:[handle url]];
+    [self receivedProgressWithHandle:handle];
 }
 
-- (IFWebDataSource *)dataSource
+- (void)receivedProgressWithHandle:(IFURLHandle *)handle
 {
-    return dataSource;
+    [[self controller] _receivedProgress:[IFLoadProgress progressWithURLHandle:handle]
+        forResourceHandle:handle fromDataSource:dataSource];
+}
+
+- (void)didFinishLoadingWithHandle:(IFURLHandle *)handle
+{
+    [self receivedProgressWithHandle:handle];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didCancelLoadingWithHandle:(IFURLHandle *)handle
+{
+    [[self controller] _receivedProgress:[IFLoadProgress progress]
+        forResourceHandle:handle fromDataSource:dataSource];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didFailBeforeLoadingWithError:(IFError *)error
+{
+    [[self controller] _receivedError:error forResourceHandle:nil
+        partialProgress:nil fromDataSource:dataSource];
+}
+
+- (void)didFailToLoadWithHandle:(IFURLHandle *)handle error:(IFError *)error
+{
+    [[self controller] _receivedError:error forResourceHandle:handle
+        partialProgress:[IFLoadProgress progressWithURLHandle:handle] fromDataSource:dataSource];
+    [[self controller] _didStopLoading:[handle url]];
+}
+
+- (void)didRedirectWithHandle:(IFURLHandle *)handle fromURL:(NSURL *)fromURL
+{
+    NSURL *toURL = [handle redirectedURL];
+    
+    [[self controller] _didStopLoading:fromURL];
+
+    [dataSource _setFinalURL:toURL];
+    [self setURL:toURL];
+
+    [[dataSource _locationChangeHandler] serverRedirectTo:toURL forDataSource:dataSource];
+    
+    [[self controller] _didStartLoading:toURL];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/IFHTMLRepresentation.h b/WebKit/WebView.subproj/IFHTMLRepresentation.h
index a40beba..fe40df8 100644
--- a/WebKit/WebView.subproj/IFHTMLRepresentation.h
+++ b/WebKit/WebView.subproj/IFHTMLRepresentation.h
@@ -5,12 +5,8 @@
 
 #import <Foundation/Foundation.h>
 
-
 @class IFError;
 @class IFWebDataSource;
- at class IFWebCoreBridge;
-
-class KHTMLPart;
 
 @protocol IFDocumentRepresentation;
 
diff --git a/WebKit/WebView.subproj/IFHTMLRepresentation.mm b/WebKit/WebView.subproj/IFHTMLRepresentation.mm
index b65caa3..055d85f 100644
--- a/WebKit/WebView.subproj/IFHTMLRepresentation.mm
+++ b/WebKit/WebView.subproj/IFHTMLRepresentation.mm
@@ -6,7 +6,6 @@
 #import <WebKit/IFHTMLRepresentation.h>
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebCoreBridge.h>
-#import <KWQKHTMLPartImpl.h>
 
 @interface IFHTMLRepresentationPrivate : NSObject
 {
@@ -42,11 +41,6 @@
     return _private->bridge;
 }
 
-- (KHTMLPart *)part
-{
-    return [_private->bridge part];
-}
-
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource
 {
     [_private->bridge receivedData:data withDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/IFHTMLRepresentationPrivate.h b/WebKit/WebView.subproj/IFHTMLRepresentationPrivate.h
index 7205f73..ff9d874 100644
--- a/WebKit/WebView.subproj/IFHTMLRepresentationPrivate.h
+++ b/WebKit/WebView.subproj/IFHTMLRepresentationPrivate.h
@@ -5,7 +5,8 @@
 
 #import <WebKit/IFHTMLRepresentation.h>
 
+ at class IFWebCoreBridge;
+
 @interface IFHTMLRepresentation (IFPrivate)
 - (IFWebCoreBridge *)_bridge;
-- (KHTMLPart *)part;
 @end
diff --git a/WebKit/WebView.subproj/IFHTMLView.mm b/WebKit/WebView.subproj/IFHTMLView.mm
index c5ad0c8..f9c17a2 100644
--- a/WebKit/WebView.subproj/IFHTMLView.mm
+++ b/WebKit/WebView.subproj/IFHTMLView.mm
@@ -5,9 +5,9 @@
 #import <WebKit/IFDynamicScrollBarsView.h>
 #import <WebKit/IFException.h>
 #import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFNSViewExtras.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFrame.h>
 #import <WebKit/IFWebViewPrivate.h>
@@ -18,7 +18,6 @@
 
 // KDE related includes
 #import <khtmlview.h>
-#import <qwidget.h>
 #import <qpainter.h>
 #import <qevent.h>
 #import <html/html_documentimpl.h>
@@ -92,35 +91,28 @@
 
 // This method is typically called by the view's controller when
 // the data source is changed.
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource 
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource 
 {
-    NSRect r = [self frame];
-    IFHTMLView *provisionalView;
-    
-    // Nasty!  Setup the cross references between the KHTMLView and
-    // the KHTMLPart.
-    KHTMLPart *part = [(IFHTMLRepresentation *)[dataSource representation] part];
-
-    _private->provisionalWidget = new KHTMLView (part, 0);
-    part->impl->setView (_private->provisionalWidget);
+    IFWebCoreBridge *bridge = [dataSource _bridge];
 
     // Create a temporary provisional view.  It will be replaced with
     // the actual view once the datasource has been committed.
-    provisionalView = [[IFHTMLView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
-        
-    _private->provisionalWidget->setView (provisionalView);
+    IFHTMLView *provisionalView = [[IFHTMLView alloc] initWithFrame:NSMakeRect(0,0,0,0)];
+    
+    NSRect r = [self frame];
     
-    [provisionalView release];
-
     int mw = [[[dataSource webFrame] webView] _marginWidth];
-    if (mw >= 0)
-        _private->provisionalWidget->setMarginWidth (mw);
+    if (mw < 0)
+        mw = 0;
     int mh = [[[dataSource webFrame] webView] _marginHeight];
-    if (mh >= 0)
-        _private->provisionalWidget->setMarginHeight (mh);
-        
-    _private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
+    if (mh < 0)
+        mh = 0;
+
+    _private->provisionalWidget = [bridge createKHTMLViewWithNSView:provisionalView
+        width:(int)r.size.width height:(int)r.size.height
+        marginWidth:mw marginHeight:mh];
     
+    [provisionalView release];
 }
 
 - (void)provisionalDataSourceCommitted: (IFWebDataSource *)dataSource 
diff --git a/WebKit/WebView.subproj/IFHTMLViewPrivate.mm b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
index 82f7c46..354dfaa 100644
--- a/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
+++ b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
@@ -12,7 +12,6 @@
 
 // Includes from KDE
 #import <khtmlview.h>
-#import <khtml_part.h>
 #import <html/html_documentimpl.h>
 #import "IFWebController.h"
 
@@ -69,45 +68,6 @@
     return _private->widget;    
 }
 
-- (DOM::DocumentImpl *)_document
-{
-    KHTMLPart *part = _private->widget->part();
-    if (part) {
-        return part->xmlDocImpl();
-    }
-    return 0;
-}
-
-+ (NSString *)_nodeName: (DOM::NodeImpl *)node
-{
-    // FIXME: good for debugging only since it's Latin 1 only
-    return [NSString stringWithCString:node->nodeName().string().latin1()];
-}
-
-+ (NSString *)_nodeValue: (DOM::NodeImpl *)node
-{
-    // FIXME: good for debugging only since it's Latin 1 only
-    return [NSString stringWithCString:node->nodeValue().string().latin1()];
-}
-
-+ (NSString *)_nodeHTML: (DOM::NodeImpl *)node
-{
-    NSString *string =  QSTRING_TO_NSSTRING(node->recursive_toHTML(1));
-    return string;
-}
-
-- (khtml::RenderObject *)_renderRoot
-{
-    KHTMLPart *part = _private->widget->part();
-    DOM::DocumentImpl *doc;
-    if (part) {
-        doc = part->xmlDocImpl();
-        if (doc)
-            return doc->renderer();
-    }
-    return 0;
-}
-
 - (KHTMLView *)_provisionalWidget
 {
     return _private->provisionalWidget;    
diff --git a/WebKit/WebView.subproj/IFLoadProgress.h b/WebKit/WebView.subproj/IFLoadProgress.h
index 8a17f1e..af6596e 100644
--- a/WebKit/WebView.subproj/IFLoadProgress.h
+++ b/WebKit/WebView.subproj/IFLoadProgress.h
@@ -1,35 +1,30 @@
 /*
         IFLoadProgress.h
-	Copyright 2001, Apple, Inc. All rights reserved.
+	Copyright 2001, 2002, Apple, Inc. All rights reserved.
 
         Public header file.
 */
 
 #import <Foundation/Foundation.h>
 
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML = 4,
-    IF_LOAD_TYPE_PLUGIN = 5
-} IFLoadType;
-
+ at class IFURLHandle;
 
 @interface IFLoadProgress : NSObject
 {
     int bytesSoFar;	// 0 if this is the start of load
     int totalToLoad;	// -1 if this is not known.
                         // bytesSoFar == totalLoaded when complete
-    IFLoadType type;
 }
 
-- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total type:(IFLoadType)loadType;
+- (id)init; // both -1
+- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total;
+- (id)initWithURLHandle:(IFURLHandle *)handle;
+
++ (IFLoadProgress *)progress; // both -1
++ (IFLoadProgress *)progressWithBytesSoFar:(int)bytes totalToLoad:(int)total;
++ (IFLoadProgress *)progressWithURLHandle:(IFURLHandle *)handle;
 
 - (int)bytesSoFar;
 - (int)totalToLoad;
-- (IFLoadType)type;
 
 @end
-
-
diff --git a/WebKit/WebView.subproj/IFLoadProgress.mm b/WebKit/WebView.subproj/IFLoadProgress.mm
index 31ebb9d..7649ec8 100644
--- a/WebKit/WebView.subproj/IFLoadProgress.mm
+++ b/WebKit/WebView.subproj/IFLoadProgress.mm
@@ -1,25 +1,20 @@
 /*	IFLoadProgress.mm
 
-        Copyright 2001, Apple, Inc. All rights reserved.
+        Copyright 2001, 2002, Apple, Inc. All rights reserved.
 */
 
-#import "IFLoadProgress.h"
+#import <WebKit/IFLoadProgress.h>
 
-#import <WCLoadProgress.h>
+#import <WebFoundation/IFURLHandle.h>
 
 @implementation IFLoadProgress
 
-static id IFLoadProgressMake(void)
+- (id)init
 {
-    return [[[IFLoadProgress alloc] init] autorelease];
+    return [self initWithBytesSoFar:-1 totalToLoad:-1];
 }
 
-+(void) load
-{
-    WCSetIFLoadProgressMakeFunc(IFLoadProgressMake);
-}
-
-- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total type:(IFLoadType)loadType
+- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total
 {
     if (![super init]) {
         return nil;
@@ -27,11 +22,32 @@ static id IFLoadProgressMake(void)
 
     bytesSoFar = bytes;
     totalToLoad = total;
-    type = loadType;
 
     return self;
 }
 
+- (id)initWithURLHandle:(IFURLHandle *)handle
+{
+    int b = [handle contentLengthReceived];
+    int t = [handle statusCode] == IFURLHandleStatusLoadComplete ? b : [handle contentLength];
+    return [self initWithBytesSoFar:b totalToLoad:t];
+}
+
++ (IFLoadProgress *)progress
+{
+    return [[[IFLoadProgress alloc] init] autorelease];
+}
+
++ (IFLoadProgress *)progressWithBytesSoFar:(int)bytes totalToLoad:(int)total
+{
+    return [[[IFLoadProgress alloc] initWithBytesSoFar:bytes totalToLoad:total] autorelease];
+}
+
++ (IFLoadProgress *)progressWithURLHandle:(IFURLHandle *)handle
+{
+    return [[[IFLoadProgress alloc] initWithURLHandle:handle] autorelease];
+}
+
 - (int)bytesSoFar
 {
     return bytesSoFar;
@@ -42,9 +58,4 @@ static id IFLoadProgressMake(void)
     return totalToLoad;
 }
 
-- (IFLoadType)type
-{
-    return type;
-}
-
- at end
\ No newline at end of file
+ at end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
index 7e44365..f6a6f34 100644
--- a/WebKit/WebView.subproj/IFMainURLHandleClient.mm
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -6,7 +6,6 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFDownloadHandler.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -17,13 +16,14 @@
 #import <WebKit/IFWebFrame.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/WebKitDebug.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 #import <WebFoundation/IFError.h>
 #import <WebFoundation/IFFileTypeMappings.h>
 
+// FIXME: This is almost completely redundant with the KWQURLLoadClient in WebCore.
+// We shouldn't have two almost-identical classes that don't share code.
 
 @implementation IFMainURLHandleClient
 
@@ -41,8 +41,12 @@
 
 - (void)dealloc
 {
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT(url == nil);
-
+#else
+    [url release];
+#endif    
     [dataSource release];
     [super dealloc];
 }
@@ -54,7 +58,7 @@
     WEBKIT_ASSERT(url == nil);
     
     url = [[sender url] retain];
-    [(IFWebController *)[dataSource controller] _didStartLoading:url];
+    [[dataSource controller] _didStartLoading:url];
 }
 
 
@@ -64,19 +68,15 @@
 
     // FIXME Radar 2954901: I replaced the assertion below with a more lenient one,
     // since cancel messages are sometimes sent before begin.
-#if wEBFOUNDATION_LOAD_MESSAGES_FIXED    
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #else
     WEBKIT_ASSERT(url == nil || [url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #endif    
     
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-    [(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
-    [(IFWebController *)[dataSource controller] _didStopLoading:url];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progress]
+        forResourceHandle:sender fromDataSource: dataSource];
+    [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
@@ -102,19 +102,15 @@
         [[dataSource representation] finishedLoadingWithDataSource:dataSource];
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
     IFError *nonTerminalError = [sender error];
     if (nonTerminalError){
-        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     }
     
     [downloadHandler finishedLoading];
@@ -125,8 +121,6 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
 {
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
     NSString *contentType = [sender contentType];
     IFWebFrame *frame = [dataSource webFrame];
     IFWebView *view = [frame webView];
@@ -184,22 +178,11 @@
         return;
     }
     
-    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
-    
-    // Don't send the last progress message, it will be sent via
-    // IFURLHandleResourceDidFinishLoading
-    if (contentLength == contentLengthReceived &&
-    	contentLength != -1){
-    	return;
-    }
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", [sender contentLengthReceived], [sender contentLength]);
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     
     isFirstChunk = NO;
 }
@@ -211,11 +194,7 @@
 
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
@@ -238,8 +217,7 @@
     url = newURL;
     [[dataSource controller] _didStartLoading:url];
 
-    if([dataSource isDocumentHTML]) 
-        [(IFHTMLRepresentation *)[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
+    [[dataSource _bridge] setURL:url];
     [dataSource _setFinalURL:url];
     
     [[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.mm b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
index 686ccac..50f059a 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
@@ -1,6 +1,6 @@
 /*	
-    IFWebController.mm
-	Copyright 2001, Apple, Inc. All rights reserved.
+    IFWebControllerPrivate.mm
+	Copyright 2001, 2002, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFPreferencesPrivate.h>
@@ -16,7 +16,6 @@
 #import <WebFoundation/IFURLCacheLoaderConstants.h>
 #import <WebFoundation/IFURLHandle.h>
 
-#import <khtml_part.h>
 #import <rendering/render_frames.h>
 
 
diff --git a/WebKit/WebView.subproj/IFWebDataSource.mm b/WebKit/WebView.subproj/IFWebDataSource.mm
index 02e782a..1ae87d6 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.mm
+++ b/WebKit/WebView.subproj/IFWebDataSource.mm
@@ -5,7 +5,8 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFException.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebController.h>
 #import <WebKit/IFWebFramePrivate.h>
@@ -15,9 +16,6 @@
 
 #import <xml/dom_docimpl.h>
 
-#import <WCWebDataSource.h>
-#import <KWQKHTMLPartImpl.h>
-
 @implementation IFWebDataSource
 
 - (void)_commonInitialization
@@ -254,25 +252,7 @@
 // FIXME: Move to representation
 - (NSString *)documentTextFromDOM
 {
-    if([self isDocumentHTML]){
-        DOM::DocumentImpl *doc;
-        NSString *string = nil;
-        KHTMLPart *part = [(IFHTMLRepresentation *)[self representation] part];
-        
-        if (part != 0){
-            doc = part->xmlDocImpl();
-            if (doc != 0){
-                QString str = doc->recursive_toHTML(1);
-                string = QSTRING_TO_NSSTRING(str);
-            }
-        }
-        if (string == nil) {
-            string = @"";
-        }
-        return string;
-    }else{
-        return nil;
-    }
+    return [[self _bridge] documentTextFromDOM];
 }
 
 
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index 84e740e..9db25cb 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -8,12 +8,13 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFException.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
+#import <WebKit/IFHTMLRepresentation.h>
 #import <WebKit/IFImageRepresentation.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFMainURLHandleClient.h>
 #import <WebKit/IFTextRepresentation.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/WebKitDebug.h>
@@ -22,8 +23,6 @@
 #import <WebFoundation/IFNSStringExtensions.h>
 #import <WebFoundation/IFURLHandle.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 #import <kurl.h>
 
 static NSMutableDictionary *_repTypes=nil;
@@ -211,8 +210,7 @@ static NSMutableDictionary *_repTypes=nil;
         [[_private->urlHandles objectAtIndex: i] cancelLoadInBackground];
     }
 
-    if ([self isDocumentHTML])
-        [(IFHTMLRepresentation *)[self representation] part]->closeURL();        
+    [[self _bridge] closeURL];        
 }
 
 - (void)_recursiveStopLoading
diff --git a/WebKit/WebView.subproj/IFWebFrame.mm b/WebKit/WebView.subproj/IFWebFrame.mm
index db6abc5..2b19730 100644
--- a/WebKit/WebView.subproj/IFWebFrame.mm
+++ b/WebKit/WebView.subproj/IFWebFrame.mm
@@ -19,7 +19,6 @@
 
 #import <WebKit/WebKitDebug.h>
 
-#import <khtml_part.h>
 #import <rendering/render_frames.h>
 
 @implementation IFWebFrame
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index 8700027..a1b2d4f 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -4,12 +4,12 @@
     Copyright 2001, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFHTMLView.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFPreferencesPrivate.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
@@ -22,8 +22,6 @@
 #import <khtmlview.h>
 #import <rendering/render_frames.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 static const char * const stateNames[6] = {
     "zero state",
     "IFWEBFRAMESTATE_UNINITIALIZED",
@@ -348,8 +346,7 @@ static const char * const stateNames[6] = {
 
                 [self _setState: IFWEBFRAMESTATE_COMPLETE];
                 
-                if([ds isDocumentHTML])
-                    [(IFHTMLRepresentation *)[ds representation] part]->end();
+                [[ds _bridge] end];
                 
                 // We have to layout the main document as
                 // it may change the size of frames.
@@ -366,8 +363,7 @@ static const char * const stateNames[6] = {
                 [[thisView documentView] layout];
 
                 // Jump to anchor point, if necessary.
-                if ([ds isDocumentHTML])
-                    [(IFHTMLRepresentation *)[ds representation] part]->impl->gotoBaseAnchor();
+                [[ds _bridge] scrollToBaseAnchor];
                                    
                 // FIXME:  We have to draw the whole document hierarchy.  We should be 
                 // able to just draw the document associated with this
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index 686ccac..50f059a 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -1,6 +1,6 @@
 /*	
-    IFWebController.mm
-	Copyright 2001, Apple, Inc. All rights reserved.
+    IFWebControllerPrivate.mm
+	Copyright 2001, 2002, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFPreferencesPrivate.h>
@@ -16,7 +16,6 @@
 #import <WebFoundation/IFURLCacheLoaderConstants.h>
 #import <WebFoundation/IFURLHandle.h>
 
-#import <khtml_part.h>
 #import <rendering/render_frames.h>
 
 
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 02e782a..1ae87d6 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -5,7 +5,8 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFException.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
+#import <WebKit/IFHTMLRepresentation.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebController.h>
 #import <WebKit/IFWebFramePrivate.h>
@@ -15,9 +16,6 @@
 
 #import <xml/dom_docimpl.h>
 
-#import <WCWebDataSource.h>
-#import <KWQKHTMLPartImpl.h>
-
 @implementation IFWebDataSource
 
 - (void)_commonInitialization
@@ -254,25 +252,7 @@
 // FIXME: Move to representation
 - (NSString *)documentTextFromDOM
 {
-    if([self isDocumentHTML]){
-        DOM::DocumentImpl *doc;
-        NSString *string = nil;
-        KHTMLPart *part = [(IFHTMLRepresentation *)[self representation] part];
-        
-        if (part != 0){
-            doc = part->xmlDocImpl();
-            if (doc != 0){
-                QString str = doc->recursive_toHTML(1);
-                string = QSTRING_TO_NSSTRING(str);
-            }
-        }
-        if (string == nil) {
-            string = @"";
-        }
-        return string;
-    }else{
-        return nil;
-    }
+    return [[self _bridge] documentTextFromDOM];
 }
 
 
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 84e740e..9db25cb 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -8,12 +8,13 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFException.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
+#import <WebKit/IFHTMLRepresentation.h>
 #import <WebKit/IFImageRepresentation.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFMainURLHandleClient.h>
 #import <WebKit/IFTextRepresentation.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/WebKitDebug.h>
@@ -22,8 +23,6 @@
 #import <WebFoundation/IFNSStringExtensions.h>
 #import <WebFoundation/IFURLHandle.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 #import <kurl.h>
 
 static NSMutableDictionary *_repTypes=nil;
@@ -211,8 +210,7 @@ static NSMutableDictionary *_repTypes=nil;
         [[_private->urlHandles objectAtIndex: i] cancelLoadInBackground];
     }
 
-    if ([self isDocumentHTML])
-        [(IFHTMLRepresentation *)[self representation] part]->closeURL();        
+    [[self _bridge] closeURL];        
 }
 
 - (void)_recursiveStopLoading
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index db6abc5..2b19730 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -19,7 +19,6 @@
 
 #import <WebKit/WebKitDebug.h>
 
-#import <khtml_part.h>
 #import <rendering/render_frames.h>
 
 @implementation IFWebFrame
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 8700027..a1b2d4f 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -4,12 +4,12 @@
     Copyright 2001, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFDynamicScrollBarsView.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFHTMLView.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFPreferencesPrivate.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFramePrivate.h>
@@ -22,8 +22,6 @@
 #import <khtmlview.h>
 #import <rendering/render_frames.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 static const char * const stateNames[6] = {
     "zero state",
     "IFWEBFRAMESTATE_UNINITIALIZED",
@@ -348,8 +346,7 @@ static const char * const stateNames[6] = {
 
                 [self _setState: IFWEBFRAMESTATE_COMPLETE];
                 
-                if([ds isDocumentHTML])
-                    [(IFHTMLRepresentation *)[ds representation] part]->end();
+                [[ds _bridge] end];
                 
                 // We have to layout the main document as
                 // it may change the size of frames.
@@ -366,8 +363,7 @@ static const char * const stateNames[6] = {
                 [[thisView documentView] layout];
 
                 // Jump to anchor point, if necessary.
-                if ([ds isDocumentHTML])
-                    [(IFHTMLRepresentation *)[ds representation] part]->impl->gotoBaseAnchor();
+                [[ds _bridge] scrollToBaseAnchor];
                                    
                 // FIXME:  We have to draw the whole document hierarchy.  We should be 
                 // able to just draw the document associated with this
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.h b/WebKit/WebView.subproj/WebHTMLRepresentation.h
index a40beba..fe40df8 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.h
@@ -5,12 +5,8 @@
 
 #import <Foundation/Foundation.h>
 
-
 @class IFError;
 @class IFWebDataSource;
- at class IFWebCoreBridge;
-
-class KHTMLPart;
 
 @protocol IFDocumentRepresentation;
 
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentation.m b/WebKit/WebView.subproj/WebHTMLRepresentation.m
index b65caa3..055d85f 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentation.m
+++ b/WebKit/WebView.subproj/WebHTMLRepresentation.m
@@ -6,7 +6,6 @@
 #import <WebKit/IFHTMLRepresentation.h>
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebCoreBridge.h>
-#import <KWQKHTMLPartImpl.h>
 
 @interface IFHTMLRepresentationPrivate : NSObject
 {
@@ -42,11 +41,6 @@
     return _private->bridge;
 }
 
-- (KHTMLPart *)part
-{
-    return [_private->bridge part];
-}
-
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource
 {
     [_private->bridge receivedData:data withDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
index 7205f73..ff9d874 100644
--- a/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLRepresentationPrivate.h
@@ -5,7 +5,8 @@
 
 #import <WebKit/IFHTMLRepresentation.h>
 
+ at class IFWebCoreBridge;
+
 @interface IFHTMLRepresentation (IFPrivate)
 - (IFWebCoreBridge *)_bridge;
-- (KHTMLPart *)part;
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index c5ad0c8..f9c17a2 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -5,9 +5,9 @@
 #import <WebKit/IFDynamicScrollBarsView.h>
 #import <WebKit/IFException.h>
 #import <WebKit/IFHTMLViewPrivate.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFNSViewExtras.h>
 #import <WebKit/IFWebController.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
 #import <WebKit/IFWebFrame.h>
 #import <WebKit/IFWebViewPrivate.h>
@@ -18,7 +18,6 @@
 
 // KDE related includes
 #import <khtmlview.h>
-#import <qwidget.h>
 #import <qpainter.h>
 #import <qevent.h>
 #import <html/html_documentimpl.h>
@@ -92,35 +91,28 @@
 
 // This method is typically called by the view's controller when
 // the data source is changed.
-- (void)provisionalDataSourceChanged: (IFWebDataSource *)dataSource 
+- (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource 
 {
-    NSRect r = [self frame];
-    IFHTMLView *provisionalView;
-    
-    // Nasty!  Setup the cross references between the KHTMLView and
-    // the KHTMLPart.
-    KHTMLPart *part = [(IFHTMLRepresentation *)[dataSource representation] part];
-
-    _private->provisionalWidget = new KHTMLView (part, 0);
-    part->impl->setView (_private->provisionalWidget);
+    IFWebCoreBridge *bridge = [dataSource _bridge];
 
     // Create a temporary provisional view.  It will be replaced with
     // the actual view once the datasource has been committed.
-    provisionalView = [[IFHTMLView alloc] initWithFrame: NSMakeRect (0,0,0,0)];
-        
-    _private->provisionalWidget->setView (provisionalView);
+    IFHTMLView *provisionalView = [[IFHTMLView alloc] initWithFrame:NSMakeRect(0,0,0,0)];
+    
+    NSRect r = [self frame];
     
-    [provisionalView release];
-
     int mw = [[[dataSource webFrame] webView] _marginWidth];
-    if (mw >= 0)
-        _private->provisionalWidget->setMarginWidth (mw);
+    if (mw < 0)
+        mw = 0;
     int mh = [[[dataSource webFrame] webView] _marginHeight];
-    if (mh >= 0)
-        _private->provisionalWidget->setMarginHeight (mh);
-        
-    _private->provisionalWidget->resize ((int)r.size.width, (int)r.size.height);
+    if (mh < 0)
+        mh = 0;
+
+    _private->provisionalWidget = [bridge createKHTMLViewWithNSView:provisionalView
+        width:(int)r.size.width height:(int)r.size.height
+        marginWidth:mw marginHeight:mh];
     
+    [provisionalView release];
 }
 
 - (void)provisionalDataSourceCommitted: (IFWebDataSource *)dataSource 
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index 82f7c46..354dfaa 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -12,7 +12,6 @@
 
 // Includes from KDE
 #import <khtmlview.h>
-#import <khtml_part.h>
 #import <html/html_documentimpl.h>
 #import "IFWebController.h"
 
@@ -69,45 +68,6 @@
     return _private->widget;    
 }
 
-- (DOM::DocumentImpl *)_document
-{
-    KHTMLPart *part = _private->widget->part();
-    if (part) {
-        return part->xmlDocImpl();
-    }
-    return 0;
-}
-
-+ (NSString *)_nodeName: (DOM::NodeImpl *)node
-{
-    // FIXME: good for debugging only since it's Latin 1 only
-    return [NSString stringWithCString:node->nodeName().string().latin1()];
-}
-
-+ (NSString *)_nodeValue: (DOM::NodeImpl *)node
-{
-    // FIXME: good for debugging only since it's Latin 1 only
-    return [NSString stringWithCString:node->nodeValue().string().latin1()];
-}
-
-+ (NSString *)_nodeHTML: (DOM::NodeImpl *)node
-{
-    NSString *string =  QSTRING_TO_NSSTRING(node->recursive_toHTML(1));
-    return string;
-}
-
-- (khtml::RenderObject *)_renderRoot
-{
-    KHTMLPart *part = _private->widget->part();
-    DOM::DocumentImpl *doc;
-    if (part) {
-        doc = part->xmlDocImpl();
-        if (doc)
-            return doc->renderer();
-    }
-    return 0;
-}
-
 - (KHTMLView *)_provisionalWidget
 {
     return _private->provisionalWidget;    
diff --git a/WebKit/WebView.subproj/WebLoadProgress.h b/WebKit/WebView.subproj/WebLoadProgress.h
index 8a17f1e..af6596e 100644
--- a/WebKit/WebView.subproj/WebLoadProgress.h
+++ b/WebKit/WebView.subproj/WebLoadProgress.h
@@ -1,35 +1,30 @@
 /*
         IFLoadProgress.h
-	Copyright 2001, Apple, Inc. All rights reserved.
+	Copyright 2001, 2002, Apple, Inc. All rights reserved.
 
         Public header file.
 */
 
 #import <Foundation/Foundation.h>
 
-typedef enum {
-    IF_LOAD_TYPE_CSS    = 1,
-    IF_LOAD_TYPE_IMAGE  = 2,
-    IF_LOAD_TYPE_SCRIPT = 3,
-    IF_LOAD_TYPE_HTML = 4,
-    IF_LOAD_TYPE_PLUGIN = 5
-} IFLoadType;
-
+ at class IFURLHandle;
 
 @interface IFLoadProgress : NSObject
 {
     int bytesSoFar;	// 0 if this is the start of load
     int totalToLoad;	// -1 if this is not known.
                         // bytesSoFar == totalLoaded when complete
-    IFLoadType type;
 }
 
-- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total type:(IFLoadType)loadType;
+- (id)init; // both -1
+- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total;
+- (id)initWithURLHandle:(IFURLHandle *)handle;
+
++ (IFLoadProgress *)progress; // both -1
++ (IFLoadProgress *)progressWithBytesSoFar:(int)bytes totalToLoad:(int)total;
++ (IFLoadProgress *)progressWithURLHandle:(IFURLHandle *)handle;
 
 - (int)bytesSoFar;
 - (int)totalToLoad;
-- (IFLoadType)type;
 
 @end
-
-
diff --git a/WebKit/WebView.subproj/WebLoadProgress.m b/WebKit/WebView.subproj/WebLoadProgress.m
index 31ebb9d..7649ec8 100644
--- a/WebKit/WebView.subproj/WebLoadProgress.m
+++ b/WebKit/WebView.subproj/WebLoadProgress.m
@@ -1,25 +1,20 @@
 /*	IFLoadProgress.mm
 
-        Copyright 2001, Apple, Inc. All rights reserved.
+        Copyright 2001, 2002, Apple, Inc. All rights reserved.
 */
 
-#import "IFLoadProgress.h"
+#import <WebKit/IFLoadProgress.h>
 
-#import <WCLoadProgress.h>
+#import <WebFoundation/IFURLHandle.h>
 
 @implementation IFLoadProgress
 
-static id IFLoadProgressMake(void)
+- (id)init
 {
-    return [[[IFLoadProgress alloc] init] autorelease];
+    return [self initWithBytesSoFar:-1 totalToLoad:-1];
 }
 
-+(void) load
-{
-    WCSetIFLoadProgressMakeFunc(IFLoadProgressMake);
-}
-
-- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total type:(IFLoadType)loadType
+- (id)initWithBytesSoFar:(int)bytes totalToLoad:(int)total
 {
     if (![super init]) {
         return nil;
@@ -27,11 +22,32 @@ static id IFLoadProgressMake(void)
 
     bytesSoFar = bytes;
     totalToLoad = total;
-    type = loadType;
 
     return self;
 }
 
+- (id)initWithURLHandle:(IFURLHandle *)handle
+{
+    int b = [handle contentLengthReceived];
+    int t = [handle statusCode] == IFURLHandleStatusLoadComplete ? b : [handle contentLength];
+    return [self initWithBytesSoFar:b totalToLoad:t];
+}
+
++ (IFLoadProgress *)progress
+{
+    return [[[IFLoadProgress alloc] init] autorelease];
+}
+
++ (IFLoadProgress *)progressWithBytesSoFar:(int)bytes totalToLoad:(int)total
+{
+    return [[[IFLoadProgress alloc] initWithBytesSoFar:bytes totalToLoad:total] autorelease];
+}
+
++ (IFLoadProgress *)progressWithURLHandle:(IFURLHandle *)handle
+{
+    return [[[IFLoadProgress alloc] initWithURLHandle:handle] autorelease];
+}
+
 - (int)bytesSoFar
 {
     return bytesSoFar;
@@ -42,9 +58,4 @@ static id IFLoadProgressMake(void)
     return totalToLoad;
 }
 
-- (IFLoadType)type
-{
-    return type;
-}
-
- at end
\ No newline at end of file
+ at end
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
index 7e44365..f6a6f34 100644
--- a/WebKit/WebView.subproj/WebMainResourceClient.m
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -6,7 +6,6 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFDownloadHandler.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -17,13 +16,14 @@
 #import <WebKit/IFWebFrame.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/WebKitDebug.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 #import <WebFoundation/IFError.h>
 #import <WebFoundation/IFFileTypeMappings.h>
 
+// FIXME: This is almost completely redundant with the KWQURLLoadClient in WebCore.
+// We shouldn't have two almost-identical classes that don't share code.
 
 @implementation IFMainURLHandleClient
 
@@ -41,8 +41,12 @@
 
 - (void)dealloc
 {
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT(url == nil);
-
+#else
+    [url release];
+#endif    
     [dataSource release];
     [super dealloc];
 }
@@ -54,7 +58,7 @@
     WEBKIT_ASSERT(url == nil);
     
     url = [[sender url] retain];
-    [(IFWebController *)[dataSource controller] _didStartLoading:url];
+    [[dataSource controller] _didStartLoading:url];
 }
 
 
@@ -64,19 +68,15 @@
 
     // FIXME Radar 2954901: I replaced the assertion below with a more lenient one,
     // since cancel messages are sometimes sent before begin.
-#if wEBFOUNDATION_LOAD_MESSAGES_FIXED    
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #else
     WEBKIT_ASSERT(url == nil || [url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #endif    
     
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-    [(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
-    [(IFWebController *)[dataSource controller] _didStopLoading:url];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progress]
+        forResourceHandle:sender fromDataSource: dataSource];
+    [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
@@ -102,19 +102,15 @@
         [[dataSource representation] finishedLoadingWithDataSource:dataSource];
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
     IFError *nonTerminalError = [sender error];
     if (nonTerminalError){
-        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     }
     
     [downloadHandler finishedLoading];
@@ -125,8 +121,6 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
 {
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
     NSString *contentType = [sender contentType];
     IFWebFrame *frame = [dataSource webFrame];
     IFWebView *view = [frame webView];
@@ -184,22 +178,11 @@
         return;
     }
     
-    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
-    
-    // Don't send the last progress message, it will be sent via
-    // IFURLHandleResourceDidFinishLoading
-    if (contentLength == contentLengthReceived &&
-    	contentLength != -1){
-    	return;
-    }
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", [sender contentLengthReceived], [sender contentLength]);
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     
     isFirstChunk = NO;
 }
@@ -211,11 +194,7 @@
 
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
@@ -238,8 +217,7 @@
     url = newURL;
     [[dataSource controller] _didStartLoading:url];
 
-    if([dataSource isDocumentHTML]) 
-        [(IFHTMLRepresentation *)[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
+    [[dataSource _bridge] setURL:url];
     [dataSource _setFinalURL:url];
     
     [[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
index 7e44365..f6a6f34 100644
--- a/WebKit/WebView.subproj/WebMainResourceLoader.m
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -6,7 +6,6 @@
 
 #import <WebKit/IFDocument.h>
 #import <WebKit/IFDownloadHandler.h>
-#import <WebKit/IFHTMLRepresentationPrivate.h>
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFLocationChangeHandler.h>
 #import <WebKit/IFMainURLHandleClient.h>
@@ -17,13 +16,14 @@
 #import <WebKit/IFWebFrame.h>
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/WebKitDebug.h>
 
-#import <KWQKHTMLPartImpl.h>
-
 #import <WebFoundation/IFError.h>
 #import <WebFoundation/IFFileTypeMappings.h>
 
+// FIXME: This is almost completely redundant with the KWQURLLoadClient in WebCore.
+// We shouldn't have two almost-identical classes that don't share code.
 
 @implementation IFMainURLHandleClient
 
@@ -41,8 +41,12 @@
 
 - (void)dealloc
 {
+    // FIXME Radar 2954901: Changed this not to leak because cancel messages are sometimes sent before begin.
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT(url == nil);
-
+#else
+    [url release];
+#endif    
     [dataSource release];
     [super dealloc];
 }
@@ -54,7 +58,7 @@
     WEBKIT_ASSERT(url == nil);
     
     url = [[sender url] retain];
-    [(IFWebController *)[dataSource controller] _didStartLoading:url];
+    [[dataSource controller] _didStartLoading:url];
 }
 
 
@@ -64,19 +68,15 @@
 
     // FIXME Radar 2954901: I replaced the assertion below with a more lenient one,
     // since cancel messages are sometimes sent before begin.
-#if wEBFOUNDATION_LOAD_MESSAGES_FIXED    
+#ifdef WEBFOUNDATION_LOAD_MESSAGES_FIXED    
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #else
     WEBKIT_ASSERT(url == nil || [url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 #endif    
     
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = -1;
-    loadProgress->bytesSoFar = -1;
-    [(IFWebController *)[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
-    [(IFWebController *)[dataSource controller] _didStopLoading:url];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progress]
+        forResourceHandle:sender fromDataSource: dataSource];
+    [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
@@ -102,19 +102,15 @@
         [[dataSource representation] finishedLoadingWithDataSource:dataSource];
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
     
     IFError *nonTerminalError = [sender error];
     if (nonTerminalError){
-        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+        [[dataSource controller] _mainReceivedError:nonTerminalError forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     }
     
     [downloadHandler finishedLoading];
@@ -125,8 +121,6 @@
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)incomingData
 {
-    int contentLength = [sender contentLength];
-    int contentLengthReceived = [sender contentLengthReceived];
     NSString *contentType = [sender contentType];
     IFWebFrame *frame = [dataSource webFrame];
     IFWebView *view = [frame webView];
@@ -184,22 +178,11 @@
         return;
     }
     
-    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", contentLengthReceived, contentLength);
-    
-    // Don't send the last progress message, it will be sent via
-    // IFURLHandleResourceDidFinishLoading
-    if (contentLength == contentLengthReceived &&
-    	contentLength != -1){
-    	return;
-    }
+    WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "%d of %d", [sender contentLengthReceived], [sender contentLength]);
     
     // update progress
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = contentLength;
-    loadProgress->bytesSoFar = contentLengthReceived;
-    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress 
-        forResourceHandle: sender fromDataSource: dataSource];
-    [loadProgress release];
+    [[dataSource controller] _mainReceivedProgress:[IFLoadProgress progressWithURLHandle:sender]
+        forResourceHandle:sender fromDataSource:dataSource];
     
     isFirstChunk = NO;
 }
@@ -211,11 +194,7 @@
 
     WEBKIT_ASSERT([url isEqual:[sender redirectedURL] ? [sender redirectedURL] : [sender url]]);
 
-    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [sender contentLengthReceived];
-
-    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:loadProgress fromDataSource:dataSource];
+    [[dataSource controller] _mainReceivedError:result forResourceHandle:sender partialProgress:[IFLoadProgress progressWithURLHandle:sender] fromDataSource:dataSource];
     [[dataSource controller] _didStopLoading:url];
     [url release];
     url = nil;
@@ -238,8 +217,7 @@
     url = newURL;
     [[dataSource controller] _didStartLoading:url];
 
-    if([dataSource isDocumentHTML]) 
-        [(IFHTMLRepresentation *)[dataSource representation] part]->impl->setBaseURL([[url absoluteString] cString]);
+    [[dataSource _bridge] setURL:url];
     [dataSource _setFinalURL:url];
     
     [[dataSource _locationChangeHandler] serverRedirectTo:url forDataSource:dataSource];
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index 686ccac..50f059a 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -1,6 +1,6 @@
 /*	
-    IFWebController.mm
-	Copyright 2001, Apple, Inc. All rights reserved.
+    IFWebControllerPrivate.mm
+	Copyright 2001, 2002, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFLoadProgress.h>
 #import <WebKit/IFPreferencesPrivate.h>
@@ -16,7 +16,6 @@
 #import <WebFoundation/IFURLCacheLoaderConstants.h>
 #import <WebFoundation/IFURLHandle.h>
 
-#import <khtml_part.h>
 #import <rendering/render_frames.h>
 
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list