[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:57:40 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 20c863f5738a5f23b28d22d58fb8d31e45083ece
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Mar 17 02:08:29 2002 +0000

    iFixed error handling.  Removed ObjC code for url handle client from KHTMLPart.
    Need to sanitize KHTMLPart further.
    
    Changed stop to use stopLoading on frame instead of datasource.
    
    Fixed error handling.  Fixed most frame loading problems.
    Cleaned up frame state machine.
    Moved IFMainURLHandleClient from WebCore.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index c74744d..508308d 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,16 @@
+2002-03-16  Richard Williamson  <rjw at apple.com>
+
+        Fixed error handling.  Removed ObjC code for url handle client from KHTMLPart.
+        Need to sanitize KHTMLPart further.
+        
+	* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::closeURL),
+	(KHTMLPart::requestFrameName), (KHTMLPart::requestFrame), (KHTMLPart::overURL):
+	* src/kwq/KWQKloader.mm: (-[URLLoadClient IFURLHandleResourceDidCancelLoading:]),
+	(-[URLLoadClient IFURLHandleResourceDidFinishLoading:data:]), (-[URLLoadClient
+	IFURLHandle:resourceDataDidBecomeAvailable:]), (-[URLLoadClient
+	IFURLHandle:resourceDidFailLoadingWithResult:]):
+	* src/kwq/external.h:
+
 2002-03-15  Richard Williamson  <rjw at apple.com>
 
         Fixed crasher initializing items in popup button.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c74744d..508308d 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,16 @@
+2002-03-16  Richard Williamson  <rjw at apple.com>
+
+        Fixed error handling.  Removed ObjC code for url handle client from KHTMLPart.
+        Need to sanitize KHTMLPart further.
+        
+	* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::closeURL),
+	(KHTMLPart::requestFrameName), (KHTMLPart::requestFrame), (KHTMLPart::overURL):
+	* src/kwq/KWQKloader.mm: (-[URLLoadClient IFURLHandleResourceDidCancelLoading:]),
+	(-[URLLoadClient IFURLHandleResourceDidFinishLoading:data:]), (-[URLLoadClient
+	IFURLHandle:resourceDataDidBecomeAvailable:]), (-[URLLoadClient
+	IFURLHandle:resourceDidFailLoadingWithResult:]):
+	* src/kwq/external.h:
+
 2002-03-15  Richard Williamson  <rjw at apple.com>
 
         Fixed crasher initializing items in popup button.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c74744d..508308d 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,16 @@
+2002-03-16  Richard Williamson  <rjw at apple.com>
+
+        Fixed error handling.  Removed ObjC code for url handle client from KHTMLPart.
+        Need to sanitize KHTMLPart further.
+        
+	* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::openURL), (KHTMLPart::closeURL),
+	(KHTMLPart::requestFrameName), (KHTMLPart::requestFrame), (KHTMLPart::overURL):
+	* src/kwq/KWQKloader.mm: (-[URLLoadClient IFURLHandleResourceDidCancelLoading:]),
+	(-[URLLoadClient IFURLHandleResourceDidFinishLoading:data:]), (-[URLLoadClient
+	IFURLHandle:resourceDataDidBecomeAvailable:]), (-[URLLoadClient
+	IFURLHandle:resourceDidFailLoadingWithResult:]):
+	* src/kwq/external.h:
+
 2002-03-15  Richard Williamson  <rjw at apple.com>
 
         Fixed crasher initializing items in popup button.
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index e37a5af..0bb10d2 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -57,9 +57,8 @@
 
 #import <KWQView.h>
 
-#include <WCLoadProgress.h>
-#include <WCWebDataSource.h>
 #include <WCError.h>
+#include <WCWebDataSource.h>
 
 #include <loader.h>
 
@@ -97,109 +96,6 @@ static void recursive(const DOM::Node &pNode, const DOM::Node &node)
     }
 }
 
-// Class KHTMLPartLoadClient ==============================================================
-
- at interface KHTMLPartLoadClient : NSObject <IFURLHandleClient>
-{
-    @public
-    KHTMLPart *m_part;
-    NSData *m_data;
-    id dataSource;
-}
- at end
-
- at implementation KHTMLPartLoadClient
-
--(id)init
-{
-    if ((self = [super init])) {
-        m_data = nil;
-    
-        return self;
-    }
-
-    return nil;
-}
-
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-}
-
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    [sender autorelease];
-}
-
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    m_part->closeURL();
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
-{
-    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-    if (!m_data) {
-        m_data = [data retain];
-    }
-    m_part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
-{
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [[sender availableResourceData] length];
-
-    IFError *error = WCIFErrorMake(result);
-    [[dataSource controller] receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
-{
-}
-
-// Non-retained
-- (void)setDataSource: d
-{
-    dataSource = d;
-}
-
-
-/*
--(void)checkCompleted:(NSNotification *)notification
-{
-    m_part->checkCompleted();
-}
-*/
-
--(void)dealloc
-{
-    [m_data release];
-    
-    [super dealloc];
-}
-
- at end
-
 
 // Class KHTMLPartPrivate ================================================================================
 
@@ -220,7 +116,6 @@ public:
     KURL m_baseURL;
     
     KHTMLPart *m_part;
-    KHTMLPartLoadClient *m_recv;
     id m_handle;
 
     bool m_bFirstData:1;
@@ -251,8 +146,6 @@ public:
     QPoint m_dragLastPos;
 #endif
 
-    int m_frameNameId;
-
 #ifdef _KWQ_TIMING        
     double totalWriteTime;
 #endif
@@ -274,15 +167,11 @@ public:
         //m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
         m_settings = new KHTMLSettings();
         m_haveEncoding = false;
-        m_recv = [[KHTMLPartLoadClient alloc] init];
-        m_recv->m_part = part;
         m_handle = nil;
         
         m_jscript = 0L;
         m_runningScripts = 0;
         m_onlyLocalReferences = 0;
-
-        m_frameNameId = 1;
         
         m_documentSource = "";
         m_decodingStarted = 0;
@@ -291,8 +180,6 @@ public:
     ~KHTMLPartPrivate()
     {
         delete m_settings;
-
-        [m_recv autorelease];   
     }
 
 };
@@ -382,87 +269,17 @@ bool KHTMLPart::openURL( const KURL &url )
 {
     KWQDEBUG2 ("0x%08x openURL(): for url %s\n", (unsigned int)this, url.url().latin1());
 
-    // Close the previous URL.
-    closeURL();
-    
-    //if ( args.doPost() && (url.protocol().startsWith("http")) )
-    //{
-    //    d->m_job = KIO::http_post( url, args.postData, false );
-    //    d->m_job->addMetaData("content-type", args.contentType() );
-    //}
-    //else
-    //    d->m_job = KIO::get( url, args.reload, false );
-        
-    //connect( d->m_job, SIGNAL( result( KIO::Job * ) ),
-    //        SLOT( slotFinished( KIO::Job * ) ) );
-    //connect( d->m_job, SIGNAL( data( KIO::Job*, const QByteArray &)),
-    //        SLOT( slotData( KIO::Job*, const QByteArray &)));
-    //connect( d->m_job, SIGNAL(redirection(KIO::Job*, const KURL&) ),
-    //        SLOT( slotRedirection(KIO::Job*,const KURL&) ) );
-    
-    // Initiate request for URL data.
-    //d->m_job = KIO::get( url, false, false );
-    //d->m_job = KIO::get( url, false, false );
-    
-    // Keep a reference to the current working URL.
     d->m_workingURL = url;
     d->m_url = url;
 
     d->m_documentSource = "";
     d->m_decodingStarted = 0;
     
-    NSString *urlString;
-    NSURL *theURL;
-    
-    urlString = [NSString stringWithCString:d->m_workingURL.url().latin1()];
-    // FIXME: temporary hack to make file: URLs work right
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    theURL = [NSURL URLWithString:urlString];
-
-    [d->m_recv setDataSource: getDataSource()];
-    
-    d->m_handle = [[IFURLHandle alloc] initWithURL:theURL];
-    [d->m_handle addClient:d->m_recv];
-    [d->m_handle loadInBackground];
-
-/*    
-    [[NSNotificationCenter defaultCenter] addObserver:d->m_recv
-        selector:@selector(checkCompleted:) name:urlString object:nil];
-    
-    // tell anyone who's interested that we've started to load a uri
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-start" object:urlString];
-*/
-    
     return true;
 }
 
 bool KHTMLPart::closeURL()
 {
-    //if (d && d->m_doc) {
-    //    recursive(0, d->m_doc);
-    //}
-
-    // Cancel any pending loads.
-    NSString *urlString;
-    
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-
-/*
-    [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-*/    
     // Reset the the current working URL to the default URL.
     d->m_workingURL = KURL();
 
@@ -1551,10 +1368,11 @@ DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code )
     return 0L;
 }
 
+static int frameNameId = 1;
 
 QString KHTMLPart::requestFrameName()
 {
-    return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
+    return QString::fromLatin1("<!--frame %1-->").arg(frameNameId++);
 }
 
 
@@ -1708,7 +1526,7 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
         oldDataSource = getDataSource();
         controller = [oldDataSource controller];
 
-        //fprintf (stdout, "0x%08x requestFrame():  part = 0x%08x, oldDataSource = 0x%08x, [oldDataSource frame] = 0x%08x\n", (unsigned int)this, (unsigned int)frame, (unsigned int)oldDataSource, (unsigned int)[oldDataSource frame]);    
+        KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "requestFrame():  frame %s, URL = %s\n", frameName.latin1(), [[childURL absoluteString] cString]);    
 
         newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource];
         if (newFrame == nil){
@@ -1806,45 +1624,3 @@ void KHTMLPart::overURL( const QString &url, const QString &target )
 {
     _logNeverImplemented();
 }
-
-/*
-void KHTMLPart::checkCompleted()
-{
-    int requests;
-    
-    NSString *urlString;
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-    
-    if ([urlString hasSuffix:@"/"]) {
-	    urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    
-    // Still waiting for images/scripts from the loader ?
-    requests = khtml::Cache::loader()->numRequests([urlString cString]);
-    if (requests == 0) {
-        // FIXME: check for same URL with slash appended
-        // We should not have to do this
-        QString qurlString = [urlString cString];
-        qurlString += '/';
-        requests = khtml::Cache::loader()->numRequests(qurlString);
-    }
-    if (requests == 0) {
-        // remove us from the notification center that checks for the end of a load
-        [[NSNotificationCenter defaultCenter] removeObserver:d->m_recv name:urlString object:nil];
-        // tell anyone who's interested that we're done
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-done" object:urlString];
-
-        IFWebDataSource *dataSource;
-        id <IFWebController> controller;
-        
-        dataSource = getDataSource();
-        controller = [dataSource controller];
-        [controller locationChangeDone: nil forFrame: [dataSource frame]];
-        
-        end();
-    }
-}
-*/
\ No newline at end of file
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index e37a5af..0bb10d2 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -57,9 +57,8 @@
 
 #import <KWQView.h>
 
-#include <WCLoadProgress.h>
-#include <WCWebDataSource.h>
 #include <WCError.h>
+#include <WCWebDataSource.h>
 
 #include <loader.h>
 
@@ -97,109 +96,6 @@ static void recursive(const DOM::Node &pNode, const DOM::Node &node)
     }
 }
 
-// Class KHTMLPartLoadClient ==============================================================
-
- at interface KHTMLPartLoadClient : NSObject <IFURLHandleClient>
-{
-    @public
-    KHTMLPart *m_part;
-    NSData *m_data;
-    id dataSource;
-}
- at end
-
- at implementation KHTMLPartLoadClient
-
--(id)init
-{
-    if ((self = [super init])) {
-        m_data = nil;
-    
-        return self;
-    }
-
-    return nil;
-}
-
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-}
-
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    [sender autorelease];
-}
-
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    m_part->closeURL();
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
-{
-    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-    if (!m_data) {
-        m_data = [data retain];
-    }
-    m_part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
-{
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [[sender availableResourceData] length];
-
-    IFError *error = WCIFErrorMake(result);
-    [[dataSource controller] receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
-{
-}
-
-// Non-retained
-- (void)setDataSource: d
-{
-    dataSource = d;
-}
-
-
-/*
--(void)checkCompleted:(NSNotification *)notification
-{
-    m_part->checkCompleted();
-}
-*/
-
--(void)dealloc
-{
-    [m_data release];
-    
-    [super dealloc];
-}
-
- at end
-
 
 // Class KHTMLPartPrivate ================================================================================
 
@@ -220,7 +116,6 @@ public:
     KURL m_baseURL;
     
     KHTMLPart *m_part;
-    KHTMLPartLoadClient *m_recv;
     id m_handle;
 
     bool m_bFirstData:1;
@@ -251,8 +146,6 @@ public:
     QPoint m_dragLastPos;
 #endif
 
-    int m_frameNameId;
-
 #ifdef _KWQ_TIMING        
     double totalWriteTime;
 #endif
@@ -274,15 +167,11 @@ public:
         //m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
         m_settings = new KHTMLSettings();
         m_haveEncoding = false;
-        m_recv = [[KHTMLPartLoadClient alloc] init];
-        m_recv->m_part = part;
         m_handle = nil;
         
         m_jscript = 0L;
         m_runningScripts = 0;
         m_onlyLocalReferences = 0;
-
-        m_frameNameId = 1;
         
         m_documentSource = "";
         m_decodingStarted = 0;
@@ -291,8 +180,6 @@ public:
     ~KHTMLPartPrivate()
     {
         delete m_settings;
-
-        [m_recv autorelease];   
     }
 
 };
@@ -382,87 +269,17 @@ bool KHTMLPart::openURL( const KURL &url )
 {
     KWQDEBUG2 ("0x%08x openURL(): for url %s\n", (unsigned int)this, url.url().latin1());
 
-    // Close the previous URL.
-    closeURL();
-    
-    //if ( args.doPost() && (url.protocol().startsWith("http")) )
-    //{
-    //    d->m_job = KIO::http_post( url, args.postData, false );
-    //    d->m_job->addMetaData("content-type", args.contentType() );
-    //}
-    //else
-    //    d->m_job = KIO::get( url, args.reload, false );
-        
-    //connect( d->m_job, SIGNAL( result( KIO::Job * ) ),
-    //        SLOT( slotFinished( KIO::Job * ) ) );
-    //connect( d->m_job, SIGNAL( data( KIO::Job*, const QByteArray &)),
-    //        SLOT( slotData( KIO::Job*, const QByteArray &)));
-    //connect( d->m_job, SIGNAL(redirection(KIO::Job*, const KURL&) ),
-    //        SLOT( slotRedirection(KIO::Job*,const KURL&) ) );
-    
-    // Initiate request for URL data.
-    //d->m_job = KIO::get( url, false, false );
-    //d->m_job = KIO::get( url, false, false );
-    
-    // Keep a reference to the current working URL.
     d->m_workingURL = url;
     d->m_url = url;
 
     d->m_documentSource = "";
     d->m_decodingStarted = 0;
     
-    NSString *urlString;
-    NSURL *theURL;
-    
-    urlString = [NSString stringWithCString:d->m_workingURL.url().latin1()];
-    // FIXME: temporary hack to make file: URLs work right
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    theURL = [NSURL URLWithString:urlString];
-
-    [d->m_recv setDataSource: getDataSource()];
-    
-    d->m_handle = [[IFURLHandle alloc] initWithURL:theURL];
-    [d->m_handle addClient:d->m_recv];
-    [d->m_handle loadInBackground];
-
-/*    
-    [[NSNotificationCenter defaultCenter] addObserver:d->m_recv
-        selector:@selector(checkCompleted:) name:urlString object:nil];
-    
-    // tell anyone who's interested that we've started to load a uri
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-start" object:urlString];
-*/
-    
     return true;
 }
 
 bool KHTMLPart::closeURL()
 {
-    //if (d && d->m_doc) {
-    //    recursive(0, d->m_doc);
-    //}
-
-    // Cancel any pending loads.
-    NSString *urlString;
-    
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-
-/*
-    [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-*/    
     // Reset the the current working URL to the default URL.
     d->m_workingURL = KURL();
 
@@ -1551,10 +1368,11 @@ DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code )
     return 0L;
 }
 
+static int frameNameId = 1;
 
 QString KHTMLPart::requestFrameName()
 {
-    return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
+    return QString::fromLatin1("<!--frame %1-->").arg(frameNameId++);
 }
 
 
@@ -1708,7 +1526,7 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
         oldDataSource = getDataSource();
         controller = [oldDataSource controller];
 
-        //fprintf (stdout, "0x%08x requestFrame():  part = 0x%08x, oldDataSource = 0x%08x, [oldDataSource frame] = 0x%08x\n", (unsigned int)this, (unsigned int)frame, (unsigned int)oldDataSource, (unsigned int)[oldDataSource frame]);    
+        KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "requestFrame():  frame %s, URL = %s\n", frameName.latin1(), [[childURL absoluteString] cString]);    
 
         newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource];
         if (newFrame == nil){
@@ -1806,45 +1624,3 @@ void KHTMLPart::overURL( const QString &url, const QString &target )
 {
     _logNeverImplemented();
 }
-
-/*
-void KHTMLPart::checkCompleted()
-{
-    int requests;
-    
-    NSString *urlString;
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-    
-    if ([urlString hasSuffix:@"/"]) {
-	    urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    
-    // Still waiting for images/scripts from the loader ?
-    requests = khtml::Cache::loader()->numRequests([urlString cString]);
-    if (requests == 0) {
-        // FIXME: check for same URL with slash appended
-        // We should not have to do this
-        QString qurlString = [urlString cString];
-        qurlString += '/';
-        requests = khtml::Cache::loader()->numRequests(qurlString);
-    }
-    if (requests == 0) {
-        // remove us from the notification center that checks for the end of a load
-        [[NSNotificationCenter defaultCenter] removeObserver:d->m_recv name:urlString object:nil];
-        // tell anyone who's interested that we're done
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-done" object:urlString];
-
-        IFWebDataSource *dataSource;
-        id <IFWebController> controller;
-        
-        dataSource = getDataSource();
-        controller = [dataSource controller];
-        [controller locationChangeDone: nil forFrame: [dataSource frame]];
-        
-        end();
-    }
-}
-*/
\ No newline at end of file
diff --git a/WebCore/kwq/KWQKloader.mm b/WebCore/kwq/KWQKloader.mm
index 43de06b..1ef9441 100644
--- a/WebCore/kwq/KWQKloader.mm
+++ b/WebCore/kwq/KWQKloader.mm
@@ -940,20 +940,33 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    QString urlString = job->url().url();
 
     [m_dataSource _removeURLHandle: job->handle()];
+    
+    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, urlString.latin1());
+
+    m_loader->slotFinished(job);
+    
+    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+
+    controller = [m_dataSource controller];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+
     [sender autorelease];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
 {
-    id <IFLoadHandler> controller;
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
@@ -972,7 +985,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
 
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
@@ -990,7 +1003,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
     m_loader->slotData(job, (const char *)[data bytes], [data length]);    
 
-    id <IFLoadHandler> controller;
+    id controller;
     
 
     IFLoadProgress *loadProgress = WCIFLoadProgressMake();
@@ -998,7 +1011,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
     
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -1008,7 +1021,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "dataSource = 0x%08x, result = %d, URL = %s\n", m_dataSource, result, job->url().url().latin1());
 
     [m_dataSource _removeURLHandle: job->handle()];
 
@@ -1020,7 +1033,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [[sender availableResourceData] length];
 
-    [controller receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: m_dataSource];
+    [controller _receivedError: error forResource: QSTRING_TO_NSSTRING(job->url().url()) partialProgress: loadProgress fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
diff --git a/WebCore/kwq/KWQLoader.mm b/WebCore/kwq/KWQLoader.mm
index 43de06b..1ef9441 100644
--- a/WebCore/kwq/KWQLoader.mm
+++ b/WebCore/kwq/KWQLoader.mm
@@ -940,20 +940,33 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    QString urlString = job->url().url();
 
     [m_dataSource _removeURLHandle: job->handle()];
+    
+    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, urlString.latin1());
+
+    m_loader->slotFinished(job);
+    
+    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+
+    controller = [m_dataSource controller];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+
     [sender autorelease];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
 {
-    id <IFLoadHandler> controller;
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
@@ -972,7 +985,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
 
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
@@ -990,7 +1003,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
     m_loader->slotData(job, (const char *)[data bytes], [data length]);    
 
-    id <IFLoadHandler> controller;
+    id controller;
     
 
     IFLoadProgress *loadProgress = WCIFLoadProgressMake();
@@ -998,7 +1011,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
     
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -1008,7 +1021,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "dataSource = 0x%08x, result = %d, URL = %s\n", m_dataSource, result, job->url().url().latin1());
 
     [m_dataSource _removeURLHandle: job->handle()];
 
@@ -1020,7 +1033,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [[sender availableResourceData] length];
 
-    [controller receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: m_dataSource];
+    [controller _receivedError: error forResource: QSTRING_TO_NSSTRING(job->url().url()) partialProgress: loadProgress fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
diff --git a/WebCore/kwq/KWQLoaderImpl.mm b/WebCore/kwq/KWQLoaderImpl.mm
index 43de06b..1ef9441 100644
--- a/WebCore/kwq/KWQLoaderImpl.mm
+++ b/WebCore/kwq/KWQLoaderImpl.mm
@@ -940,20 +940,33 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    QString urlString = job->url().url();
 
     [m_dataSource _removeURLHandle: job->handle()];
+    
+    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, urlString.latin1());
+
+    m_loader->slotFinished(job);
+    
+    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+
+    controller = [m_dataSource controller];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+
     [sender autorelease];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
 {
-    id <IFLoadHandler> controller;
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
@@ -972,7 +985,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
 
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
@@ -990,7 +1003,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
     m_loader->slotData(job, (const char *)[data bytes], [data length]);    
 
-    id <IFLoadHandler> controller;
+    id controller;
     
 
     IFLoadProgress *loadProgress = WCIFLoadProgressMake();
@@ -998,7 +1011,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
     
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -1008,7 +1021,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "dataSource = 0x%08x, result = %d, URL = %s\n", m_dataSource, result, job->url().url().latin1());
 
     [m_dataSource _removeURLHandle: job->handle()];
 
@@ -1020,7 +1033,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [[sender availableResourceData] length];
 
-    [controller receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: m_dataSource];
+    [controller _receivedError: error forResource: QSTRING_TO_NSSTRING(job->url().url()) partialProgress: loadProgress fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
diff --git a/WebCore/kwq/external.h b/WebCore/kwq/external.h
index 7bb118d..b873542 100644
--- a/WebCore/kwq/external.h
+++ b/WebCore/kwq/external.h
@@ -34,13 +34,12 @@
 @class IFWebFrame;
 @class IFError;
 @class IFURLHandle;
-
+ at class IFLoadProgress;
 
 @protocol IFWebController
 - (IFWebFrame *)createFrameNamed: (NSString *)name for: (IFWebDataSource *)dataSource inParent: (IFWebDataSource *)dataSource;
-- (BOOL)locationWillChangeTo: (NSURL *)url forFrame: (IFWebFrame *)frame;
-- (void)locationChangeStartedForFrame: (IFWebFrame *)frame;
-- (void)locationChangeDone: (IFError *)error forFrame: (IFWebFrame *)frame;
+- (void)_receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
+- (void)_receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
 @end
 
 @protocol IFLocationChangeHandler
diff --git a/WebCore/src/kwq/KWQKHTMLPart.mm b/WebCore/src/kwq/KWQKHTMLPart.mm
index e37a5af..0bb10d2 100644
--- a/WebCore/src/kwq/KWQKHTMLPart.mm
+++ b/WebCore/src/kwq/KWQKHTMLPart.mm
@@ -57,9 +57,8 @@
 
 #import <KWQView.h>
 
-#include <WCLoadProgress.h>
-#include <WCWebDataSource.h>
 #include <WCError.h>
+#include <WCWebDataSource.h>
 
 #include <loader.h>
 
@@ -97,109 +96,6 @@ static void recursive(const DOM::Node &pNode, const DOM::Node &node)
     }
 }
 
-// Class KHTMLPartLoadClient ==============================================================
-
- at interface KHTMLPartLoadClient : NSObject <IFURLHandleClient>
-{
-    @public
-    KHTMLPart *m_part;
-    NSData *m_data;
-    id dataSource;
-}
- at end
-
- at implementation KHTMLPartLoadClient
-
--(id)init
-{
-    if ((self = [super init])) {
-        m_data = nil;
-    
-        return self;
-    }
-
-    return nil;
-}
-
-- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-}
-
-- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    [sender autorelease];
-}
-
-- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
-{
-    KWQDEBUGLEVEL1 (KWQ_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
-    m_part->closeURL();
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [data length];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
-{
-    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
-    if (!m_data) {
-        m_data = [data retain];
-    }
-    m_part->slotData(sender, (const char *)[data bytes], [data length]);
-    
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [data length];
-    [[dataSource controller] receivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
-{
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
-
-    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
-    loadProgress->totalToLoad = [sender contentLength];
-    loadProgress->bytesSoFar = [[sender availableResourceData] length];
-
-    IFError *error = WCIFErrorMake(result);
-    [[dataSource controller] receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
-
-    [sender autorelease];
-}
-
-- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
-{
-}
-
-// Non-retained
-- (void)setDataSource: d
-{
-    dataSource = d;
-}
-
-
-/*
--(void)checkCompleted:(NSNotification *)notification
-{
-    m_part->checkCompleted();
-}
-*/
-
--(void)dealloc
-{
-    [m_data release];
-    
-    [super dealloc];
-}
-
- at end
-
 
 // Class KHTMLPartPrivate ================================================================================
 
@@ -220,7 +116,6 @@ public:
     KURL m_baseURL;
     
     KHTMLPart *m_part;
-    KHTMLPartLoadClient *m_recv;
     id m_handle;
 
     bool m_bFirstData:1;
@@ -251,8 +146,6 @@ public:
     QPoint m_dragLastPos;
 #endif
 
-    int m_frameNameId;
-
 #ifdef _KWQ_TIMING        
     double totalWriteTime;
 #endif
@@ -274,15 +167,11 @@ public:
         //m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
         m_settings = new KHTMLSettings();
         m_haveEncoding = false;
-        m_recv = [[KHTMLPartLoadClient alloc] init];
-        m_recv->m_part = part;
         m_handle = nil;
         
         m_jscript = 0L;
         m_runningScripts = 0;
         m_onlyLocalReferences = 0;
-
-        m_frameNameId = 1;
         
         m_documentSource = "";
         m_decodingStarted = 0;
@@ -291,8 +180,6 @@ public:
     ~KHTMLPartPrivate()
     {
         delete m_settings;
-
-        [m_recv autorelease];   
     }
 
 };
@@ -382,87 +269,17 @@ bool KHTMLPart::openURL( const KURL &url )
 {
     KWQDEBUG2 ("0x%08x openURL(): for url %s\n", (unsigned int)this, url.url().latin1());
 
-    // Close the previous URL.
-    closeURL();
-    
-    //if ( args.doPost() && (url.protocol().startsWith("http")) )
-    //{
-    //    d->m_job = KIO::http_post( url, args.postData, false );
-    //    d->m_job->addMetaData("content-type", args.contentType() );
-    //}
-    //else
-    //    d->m_job = KIO::get( url, args.reload, false );
-        
-    //connect( d->m_job, SIGNAL( result( KIO::Job * ) ),
-    //        SLOT( slotFinished( KIO::Job * ) ) );
-    //connect( d->m_job, SIGNAL( data( KIO::Job*, const QByteArray &)),
-    //        SLOT( slotData( KIO::Job*, const QByteArray &)));
-    //connect( d->m_job, SIGNAL(redirection(KIO::Job*, const KURL&) ),
-    //        SLOT( slotRedirection(KIO::Job*,const KURL&) ) );
-    
-    // Initiate request for URL data.
-    //d->m_job = KIO::get( url, false, false );
-    //d->m_job = KIO::get( url, false, false );
-    
-    // Keep a reference to the current working URL.
     d->m_workingURL = url;
     d->m_url = url;
 
     d->m_documentSource = "";
     d->m_decodingStarted = 0;
     
-    NSString *urlString;
-    NSURL *theURL;
-    
-    urlString = [NSString stringWithCString:d->m_workingURL.url().latin1()];
-    // FIXME: temporary hack to make file: URLs work right
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    theURL = [NSURL URLWithString:urlString];
-
-    [d->m_recv setDataSource: getDataSource()];
-    
-    d->m_handle = [[IFURLHandle alloc] initWithURL:theURL];
-    [d->m_handle addClient:d->m_recv];
-    [d->m_handle loadInBackground];
-
-/*    
-    [[NSNotificationCenter defaultCenter] addObserver:d->m_recv
-        selector:@selector(checkCompleted:) name:urlString object:nil];
-    
-    // tell anyone who's interested that we've started to load a uri
-    [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-start" object:urlString];
-*/
-    
     return true;
 }
 
 bool KHTMLPart::closeURL()
 {
-    //if (d && d->m_doc) {
-    //    recursive(0, d->m_doc);
-    //}
-
-    // Cancel any pending loads.
-    NSString *urlString;
-    
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-
-    if ([urlString hasSuffix:@"/"]) {
-        urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-
-/*
-    [[NSNotificationCenter defaultCenter] postNotificationName:urlString object:nil];
-*/    
     // Reset the the current working URL to the default URL.
     d->m_workingURL = KURL();
 
@@ -1551,10 +1368,11 @@ DOM::EventListener *KHTMLPart::createHTMLEventListener( QString code )
     return 0L;
 }
 
+static int frameNameId = 1;
 
 QString KHTMLPart::requestFrameName()
 {
-    return QString::fromLatin1("<!--frame %1-->").arg(d->m_frameNameId++);
+    return QString::fromLatin1("<!--frame %1-->").arg(frameNameId++);
 }
 
 
@@ -1708,7 +1526,7 @@ bool KHTMLPart::requestFrame( khtml::RenderPart *frame, const QString &url, cons
         oldDataSource = getDataSource();
         controller = [oldDataSource controller];
 
-        //fprintf (stdout, "0x%08x requestFrame():  part = 0x%08x, oldDataSource = 0x%08x, [oldDataSource frame] = 0x%08x\n", (unsigned int)this, (unsigned int)frame, (unsigned int)oldDataSource, (unsigned int)[oldDataSource frame]);    
+        KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "requestFrame():  frame %s, URL = %s\n", frameName.latin1(), [[childURL absoluteString] cString]);    
 
         newFrame = [controller createFrameNamed: nsframeName for: nil inParent: oldDataSource];
         if (newFrame == nil){
@@ -1806,45 +1624,3 @@ void KHTMLPart::overURL( const QString &url, const QString &target )
 {
     _logNeverImplemented();
 }
-
-/*
-void KHTMLPart::checkCompleted()
-{
-    int requests;
-    
-    NSString *urlString;
-    urlString = [NSString stringWithCString:d->m_url.url().latin1()];
-    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
-	    urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
-    }
-    
-    if ([urlString hasSuffix:@"/"]) {
-	    urlString = [urlString substringToIndex:([urlString length] - 1)];
-    }
-    
-    // Still waiting for images/scripts from the loader ?
-    requests = khtml::Cache::loader()->numRequests([urlString cString]);
-    if (requests == 0) {
-        // FIXME: check for same URL with slash appended
-        // We should not have to do this
-        QString qurlString = [urlString cString];
-        qurlString += '/';
-        requests = khtml::Cache::loader()->numRequests(qurlString);
-    }
-    if (requests == 0) {
-        // remove us from the notification center that checks for the end of a load
-        [[NSNotificationCenter defaultCenter] removeObserver:d->m_recv name:urlString object:nil];
-        // tell anyone who's interested that we're done
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"uri-done" object:urlString];
-
-        IFWebDataSource *dataSource;
-        id <IFWebController> controller;
-        
-        dataSource = getDataSource();
-        controller = [dataSource controller];
-        [controller locationChangeDone: nil forFrame: [dataSource frame]];
-        
-        end();
-    }
-}
-*/
\ No newline at end of file
diff --git a/WebCore/src/kwq/KWQKloader.mm b/WebCore/src/kwq/KWQKloader.mm
index 43de06b..1ef9441 100644
--- a/WebCore/src/kwq/KWQKloader.mm
+++ b/WebCore/src/kwq/KWQKloader.mm
@@ -940,20 +940,33 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
 - (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
 {
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    QString urlString = job->url().url();
 
     [m_dataSource _removeURLHandle: job->handle()];
+    
+    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, urlString.latin1());
+
+    m_loader->slotFinished(job);
+    
+    IFLoadProgress *loadProgress = WCIFLoadProgressMake();
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+
+    controller = [m_dataSource controller];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+
     [sender autorelease];
 }
 
 - (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
 {
-    id <IFLoadHandler> controller;
+    id controller;
     void *userData;
     
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
@@ -972,7 +985,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
 
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
@@ -990,7 +1003,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
 
     m_loader->slotData(job, (const char *)[data bytes], [data length]);    
 
-    id <IFLoadHandler> controller;
+    id controller;
     
 
     IFLoadProgress *loadProgress = WCIFLoadProgressMake();
@@ -998,7 +1011,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->bytesSoFar = [data length];
     
     controller = [m_dataSource controller];
-    [controller receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
+    [controller _receivedProgress: (IFLoadProgress *)loadProgress forResource: QSTRING_TO_NSSTRING(urlString) fromDataSource: m_dataSource];
 }
 
 - (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
@@ -1008,7 +1021,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     userData = [[[sender attributes] objectForKey:IFURLHandleUserData] pointerValue];
     
     KIO::TransferJob *job = static_cast<KIO::TransferJob *>(userData);
-    KWQDEBUGLEVEL2 (KWQ_LOG_LOADING, "dataSource = 0x%08x for URL %s\n", m_dataSource, job->url().url().latin1());
+    KWQDEBUGLEVEL3 (KWQ_LOG_LOADING, "dataSource = 0x%08x, result = %d, URL = %s\n", m_dataSource, result, job->url().url().latin1());
 
     [m_dataSource _removeURLHandle: job->handle()];
 
@@ -1020,7 +1033,7 @@ void DocLoader::removeCachedObject( CachedObject* o ) const
     loadProgress->totalToLoad = [sender contentLength];
     loadProgress->bytesSoFar = [[sender availableResourceData] length];
 
-    [controller receivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: m_dataSource];
+    [controller _receivedError: error forResource: QSTRING_TO_NSSTRING(job->url().url()) partialProgress: loadProgress fromDataSource: m_dataSource];
 
     [sender autorelease];
 }
diff --git a/WebCore/src/kwq/external.h b/WebCore/src/kwq/external.h
index 7bb118d..b873542 100644
--- a/WebCore/src/kwq/external.h
+++ b/WebCore/src/kwq/external.h
@@ -34,13 +34,12 @@
 @class IFWebFrame;
 @class IFError;
 @class IFURLHandle;
-
+ at class IFLoadProgress;
 
 @protocol IFWebController
 - (IFWebFrame *)createFrameNamed: (NSString *)name for: (IFWebDataSource *)dataSource inParent: (IFWebDataSource *)dataSource;
-- (BOOL)locationWillChangeTo: (NSURL *)url forFrame: (IFWebFrame *)frame;
-- (void)locationChangeStartedForFrame: (IFWebFrame *)frame;
-- (void)locationChangeDone: (IFError *)error forFrame: (IFWebFrame *)frame;
+- (void)_receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource;
+- (void)_receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource;
 @end
 
 @protocol IFLocationChangeHandler
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 8d2d523..78e8e6f 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,44 @@
+2002-03-16  Richard Williamson  <rjw at apple.com>
+
+        Fixed error handling.  Fixed most frame loading problems.
+        Cleaned up frame state machine.
+        Moved IFMainURLHandleClient from WebCore.
+        
+	* Misc.subproj/IFError.m: (-[IFError description]):
+	* WebKit.pbproj/project.pbxproj:
+	* WebView.subproj/IFBaseWebController.mm: (-[IFBaseWebController
+	receivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	receivedError:forResource:partialProgress:fromDataSource:]),
+	(-[IFBaseWebController locationChangeDone:forFrame:]):
+	* WebView.subproj/IFBaseWebControllerPrivate.h:
+	* WebView.subproj/IFBaseWebControllerPrivate.mm: (-[IFBaseWebController
+	_receivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	_mainReceivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	_receivedError:forResource:partialProgress:fromDataSource:]),
+	(-[IFBaseWebController
+	_mainReceivedError:forResource:partialProgress:fromDataSource:]):
+	* WebView.subproj/IFWebDataSource.mm: (-[IFWebDataSource startLoading:]),
+	(-[IFWebDataSource isLoading]):
+	* WebView.subproj/IFWebDataSourcePrivate.h:
+	* WebView.subproj/IFWebDataSourcePrivate.mm: (-[IFWebDataSourcePrivate init]),
+	(-[IFWebDataSourcePrivate dealloc]), (-[IFWebDataSource
+	_setPrimaryLoadComplete:]), (-[IFWebDataSource _startLoading:]),
+	(-[IFWebDataSource _stopLoading]):
+	* WebView.subproj/IFWebFrame.h:
+	* WebView.subproj/IFWebFrame.mm: (-[IFWebFrame setProvisionalDataSource:]),
+	(-[IFWebFrame startLoading]), (-[IFWebFrame reload:]), (-[IFWebFrame errors]),
+	(-[IFWebFrame mainDocumentError]):
+	* WebView.subproj/IFWebFramePrivate.h:
+	* WebView.subproj/IFWebFramePrivate.mm: (-[IFWebFramePrivate dealloc]),
+	(-[IFWebFrame _transitionProvisionalToCommitted]), (-[IFWebFrame _setState:]),
+	(-[IFWebFrame _addError:forResource:]), (-[IFWebFrame _isLoadComplete]),
+	(+[IFWebFrame _recursiveCheckCompleteFromFrame:]), (-[IFWebFrame
+	_checkLoadCompleteResource:error:isMainDocument:]), (-[IFWebFrame
+	_setMainDocumentError:]), (-[IFWebFrame _clearErrors]):
+	* WebView.subproj/IFWebView.mm:
+	* WebView.subproj/IFMainURLHandleClient.h: added
+	* WebView.subproj/IFMainURLHandleClient.mm: added
+
 2002-03-15  John Sullivan  <sullivan at apple.com>
 
 	Impose default-based limit (1000 by default) on number of history items
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 8d2d523..78e8e6f 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,44 @@
+2002-03-16  Richard Williamson  <rjw at apple.com>
+
+        Fixed error handling.  Fixed most frame loading problems.
+        Cleaned up frame state machine.
+        Moved IFMainURLHandleClient from WebCore.
+        
+	* Misc.subproj/IFError.m: (-[IFError description]):
+	* WebKit.pbproj/project.pbxproj:
+	* WebView.subproj/IFBaseWebController.mm: (-[IFBaseWebController
+	receivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	receivedError:forResource:partialProgress:fromDataSource:]),
+	(-[IFBaseWebController locationChangeDone:forFrame:]):
+	* WebView.subproj/IFBaseWebControllerPrivate.h:
+	* WebView.subproj/IFBaseWebControllerPrivate.mm: (-[IFBaseWebController
+	_receivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	_mainReceivedProgress:forResource:fromDataSource:]), (-[IFBaseWebController
+	_receivedError:forResource:partialProgress:fromDataSource:]),
+	(-[IFBaseWebController
+	_mainReceivedError:forResource:partialProgress:fromDataSource:]):
+	* WebView.subproj/IFWebDataSource.mm: (-[IFWebDataSource startLoading:]),
+	(-[IFWebDataSource isLoading]):
+	* WebView.subproj/IFWebDataSourcePrivate.h:
+	* WebView.subproj/IFWebDataSourcePrivate.mm: (-[IFWebDataSourcePrivate init]),
+	(-[IFWebDataSourcePrivate dealloc]), (-[IFWebDataSource
+	_setPrimaryLoadComplete:]), (-[IFWebDataSource _startLoading:]),
+	(-[IFWebDataSource _stopLoading]):
+	* WebView.subproj/IFWebFrame.h:
+	* WebView.subproj/IFWebFrame.mm: (-[IFWebFrame setProvisionalDataSource:]),
+	(-[IFWebFrame startLoading]), (-[IFWebFrame reload:]), (-[IFWebFrame errors]),
+	(-[IFWebFrame mainDocumentError]):
+	* WebView.subproj/IFWebFramePrivate.h:
+	* WebView.subproj/IFWebFramePrivate.mm: (-[IFWebFramePrivate dealloc]),
+	(-[IFWebFrame _transitionProvisionalToCommitted]), (-[IFWebFrame _setState:]),
+	(-[IFWebFrame _addError:forResource:]), (-[IFWebFrame _isLoadComplete]),
+	(+[IFWebFrame _recursiveCheckCompleteFromFrame:]), (-[IFWebFrame
+	_checkLoadCompleteResource:error:isMainDocument:]), (-[IFWebFrame
+	_setMainDocumentError:]), (-[IFWebFrame _clearErrors]):
+	* WebView.subproj/IFWebView.mm:
+	* WebView.subproj/IFMainURLHandleClient.h: added
+	* WebView.subproj/IFMainURLHandleClient.mm: added
+
 2002-03-15  John Sullivan  <sullivan at apple.com>
 
 	Impose default-based limit (1000 by default) on number of history items
diff --git a/WebKit/Misc.subproj/IFError.m b/WebKit/Misc.subproj/IFError.m
index 79340a3..4986983 100644
--- a/WebKit/Misc.subproj/IFError.m
+++ b/WebKit/Misc.subproj/IFError.m
@@ -137,4 +137,9 @@ static id IFErrorMake(int code)
     return [descriptions objectForKey: [NSNumber numberWithInt: errorCode]];
 }
 
+- (NSString *)description
+{
+    return [NSString stringWithFormat: @"code %d:  %@", errorCode, [self errorDescription]];
+}
+
 @end
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 549cda3..bb86de4 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -3,7 +3,7 @@
 	archiveVersion = 1;
 	classes = {
 	};
-	objectVersion = 36;
+	objectVersion = 34;
 	objects = {
 		014CEA440018CDF011CA2923 = {
 			buildRules = (
@@ -193,6 +193,7 @@
 				9CF0E24B021361B10ECA16EA,
 				F5B92B840223191D01C1A525,
 				F5DE3CB4023575AA01A80181,
+				F5D538EA02441F2601A80181,
 			);
 			isa = PBXHeadersBuildPhase;
 		};
@@ -228,6 +229,7 @@
 				F520FB1C0221DEFD01C1A525,
 				F5B92B850223191D01C1A525,
 				F5DE3CB5023575AA01A80181,
+				F5D538ED02441FDD01A80181,
 			);
 			isa = PBXSourcesBuildPhase;
 		};
@@ -952,6 +954,8 @@
 				9CF0E249021361B00ECA16EA,
 				9CF0E24A021361B00ECA16EA,
 				F5143A370221DCCE01A80181,
+				F5D538E802441F2601A80181,
+				F5D538EC02441FDD01A80181,
 			);
 			isa = PBXGroup;
 			name = WebView;
@@ -1083,6 +1087,30 @@
 			settings = {
 			};
 		};
+		F5D538E802441F2601A80181 = {
+			isa = PBXFileReference;
+			name = IFMainURLHandleClient.h;
+			path = WebView.subproj/IFMainURLHandleClient.h;
+			refType = 2;
+		};
+		F5D538EA02441F2601A80181 = {
+			fileRef = F5D538E802441F2601A80181;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F5D538EC02441FDD01A80181 = {
+			isa = PBXFileReference;
+			name = IFMainURLHandleClient.mm;
+			path = WebView.subproj/IFMainURLHandleClient.mm;
+			refType = 2;
+		};
+		F5D538ED02441FDD01A80181 = {
+			fileRef = F5D538EC02441FDD01A80181;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		F5DE3CB2023575AA01A80181 = {
 			isa = PBXFileReference;
 			name = IFError.h;
diff --git a/WebKit/WebView.subproj/IFBaseWebController.mm b/WebKit/WebView.subproj/IFBaseWebController.mm
index 691af0e..7605ea0 100644
--- a/WebKit/WebView.subproj/IFBaseWebController.mm
+++ b/WebKit/WebView.subproj/IFBaseWebController.mm
@@ -179,33 +179,14 @@ static id IFLoadProgressMake()
 // ---------------------------------------------------------------------
 - (void)receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource
 {
-    IFWebFrame *frame = [dataSource frame];
-    
-    WEBKIT_ASSERT (dataSource != nil);
-
-    WEBKIT_ASSERT (frame != nil);
-
-    // Check to see if this is the first load for a data source, if so
-    // we need to transition the data source from provisional to committed.
-    if (progress->bytesSoFar == progress->totalToLoad && [frame provisionalDataSource] == dataSource){
-        WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "resource = %s\n", [resourceDescription cString]);
-        [frame _transitionProvisionalToCommitted];
-    }
-    
-    // This resouce has completed, so check if the load is complete for all frames.
-    if (progress->bytesSoFar == progress->totalToLoad)
-        [[self mainFrame] _checkLoadComplete: nil];
+    // Do nothing.  Subclasses typically override this method.
 }
 
-
 - (void)receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource
 {
-    WEBKIT_ASSERT ([self mainFrame] != nil);
-
-    [[self mainFrame] _checkLoadComplete: error];
+    // Do nothing.  Subclasses typically override this method.
 }
 
-
 // ---------------------------------------------------------------------
 // IFLocationChangeHandler
 // ---------------------------------------------------------------------
@@ -229,8 +210,9 @@ static id IFLoadProgressMake()
 
 - (void)locationChangeDone: (IFError *)error forFrame: (IFWebFrame *)frame
 {    
-    //[[frame view] setNeedsLayout: YES];
-    //[[frame view] setNeedsDisplay: YES];
+    if ([frame errors]){
+        NSLog (@"received the following errors loading frame %@:\n%@\n", [frame name], [frame errors]);
+    }
 }
 
 - (void)receivedPageTitle: (NSString *)title forDataSource: (IFWebDataSource *)dataSource
diff --git a/WebKit/WebView.subproj/IFBaseWebControllerPrivate.h b/WebKit/WebView.subproj/IFBaseWebControllerPrivate.h
index 46fb27c..2f46a12 100644
--- a/WebKit/WebView.subproj/IFBaseWebControllerPrivate.h
+++ b/WebKit/WebView.subproj/IFBaseWebControllerPrivate.h
@@ -15,4 +15,8 @@
 
 
 @interface IFBaseWebController (IFPrivate);
+- (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;
 @end
diff --git a/WebKit/WebView.subproj/IFBaseWebControllerPrivate.mm b/WebKit/WebView.subproj/IFBaseWebControllerPrivate.mm
index 621227f..200dbaf 100644
--- a/WebKit/WebView.subproj/IFBaseWebControllerPrivate.mm
+++ b/WebKit/WebView.subproj/IFBaseWebControllerPrivate.mm
@@ -10,6 +10,8 @@
 #include <KWQKHTMLPart.h>
 #include <rendering/render_frames.h>
 
+#import <WebKit/WebKitDebug.h>
+
 
 @implementation IFBaseWebControllerPrivate
 
@@ -31,4 +33,79 @@
 
 @implementation IFBaseWebController (IFPrivate)
 
+- (void)_receivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource
+{
+    IFWebFrame *frame = [dataSource frame];
+    
+    WEBKIT_ASSERT (dataSource != nil);
+    WEBKIT_ASSERT (frame != nil);
+
+    [self receivedProgress: progress forResource: resourceDescription fromDataSource: dataSource];
+
+    // This resouce has completed, so check if the load is complete for all frames.
+    if (progress->bytesSoFar == progress->totalToLoad){
+        [frame _checkLoadCompleteResource: resourceDescription error: nil isMainDocument: NO];
+    }
+}
+
+- (void)_mainReceivedProgress: (IFLoadProgress *)progress forResource: (NSString *)resourceDescription fromDataSource: (IFWebDataSource *)dataSource
+{
+    IFWebFrame *frame = [dataSource frame];
+    
+    WEBKIT_ASSERT (dataSource != nil);
+    WEBKIT_ASSERT (frame != nil);
+
+    [self receivedProgress: progress forResource: resourceDescription fromDataSource: dataSource];
+
+    if (progress->bytesSoFar == -1 && progress->totalToLoad == -1){
+	WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "cancelled resource = %s\n", [[[dataSource inputURL] absoluteString] cString]);
+    }
+    
+    // Check to see if this is the first complete load of a resource associated with a data source, if so
+    // we need to transition the data source from provisional to committed.
+    if (progress->bytesSoFar == progress->totalToLoad){
+    
+        [dataSource _setPrimaryLoadComplete: YES];
+        
+        if([frame provisionalDataSource] == dataSource){
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "committing resource = %s\n", [[[dataSource inputURL] absoluteString] cString]);
+            [frame _transitionProvisionalToCommitted];
+        }
+    }
+    
+    // This resouce has completed, so check if the load is complete for all frames.
+    if (progress->bytesSoFar == progress->totalToLoad){
+        [frame _checkLoadCompleteResource: resourceDescription error: nil  isMainDocument: YES];
+    }
+}
+
+
+
+- (void)_receivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource
+{
+    IFWebFrame *frame = [dataSource frame];
+
+    WEBKIT_ASSERT (frame != nil);
+
+    [self receivedError: error forResource: resourceDescription partialProgress: progress fromDataSource: dataSource];
+    
+    [frame _checkLoadCompleteResource: resourceDescription error: error isMainDocument: NO];
+}
+
+
+- (void)_mainReceivedError: (IFError *)error forResource: (NSString *)resourceDescription partialProgress: (IFLoadProgress *)progress fromDataSource: (IFWebDataSource *)dataSource
+{
+    IFWebFrame *frame = [dataSource frame];
+
+    WEBKIT_ASSERT (frame != nil);
+
+    [self receivedError: error forResource: resourceDescription partialProgress: progress fromDataSource: dataSource];
+    
+    [dataSource _setPrimaryLoadComplete: YES];
+
+    [frame _checkLoadCompleteResource: resourceDescription error: error isMainDocument: YES];
+}
+
+
+
 @end
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.h b/WebKit/WebView.subproj/IFMainURLHandleClient.h
new file mode 100644
index 0000000..51afb79
--- /dev/null
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.h
@@ -0,0 +1,22 @@
+/*	
+    IFMainURLHandleClient.h
+
+    Private header.
+    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+#import <WebFoundation/WebFoundation.h>
+
+#import <WebKit/IFWebDataSourcePrivate.h>
+
+ at interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
+{
+    id dataSource;
+    KHTMLPart *part;
+}
+- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
+ at end
+
diff --git a/WebKit/WebView.subproj/IFMainURLHandleClient.mm b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
new file mode 100644
index 0000000..ff59bd4
--- /dev/null
+++ b/WebKit/WebView.subproj/IFMainURLHandleClient.mm
@@ -0,0 +1,89 @@
+/*	
+    IFMainURLHandleClient.mm
+	    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+#import <WebKit/IFError.h>
+#import <WebKit/IFBaseWebControllerPrivate.h>
+#import <WebKit/IFMainURLHandleClient.h>
+
+#import <WebKit/WebKitDebug.h>
+
+#include <khtmlview.h>
+
+ at implementation IFMainURLHandleClient
+
+- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+{
+    if ((self = [super init])) {
+        dataSource = ds;	// Non-retained.
+        part = p;
+        return self;
+    }
+
+    return nil;
+}
+
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+}
+
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [data length];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+{
+    WEBKITDEBUGLEVEL3 (WEBKIT_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+    part->slotData(sender, (const char *)[data bytes], [data length]);
+    
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
+{
+    WEBKITDEBUGLEVEL2 (WEBKIT_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [[sender availableResourceData] length];
+
+    IFError *error = [[IFError alloc] initWithErrorCode: result];
+    [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
+    [error release];
+    
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+{
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/IFWebDataSource.mm b/WebKit/WebView.subproj/IFWebDataSource.mm
index 7419132..0f8d6fc 100644
--- a/WebKit/WebView.subproj/IFWebDataSource.mm
+++ b/WebKit/WebView.subproj/IFWebDataSource.mm
@@ -217,7 +217,7 @@ static id IFWebDataSourceMake(void *url)
 // If forceRefresh is YES the document will load from the net, not the cache.
 - (void)startLoading: (BOOL)forceRefresh
 {
-    [self _startLoading: forceRefresh initiatedByUserEvent: NO];
+    [self _startLoading: forceRefresh];
 }
 
 
@@ -234,9 +234,13 @@ static id IFWebDataSourceMake(void *url)
 // Returns YES if there are any pending loads.
 - (BOOL)isLoading
 {
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
     int i, count;
     
-    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    WEBKITDEBUGLEVEL4 (WEBKIT_LOG_LOADING, "frame %s: primaryLoadComplete %d, [data->urlHandles count] = %d, URL = %s\n", [[[self frame] name] cString], (int)data->primaryLoadComplete, [data->urlHandles count], [[[self inputURL] absoluteString] cString]);
+    if (data->primaryLoadComplete == NO)
+        return YES;
+        
     if ([data->urlHandles count])
         return YES;
     
@@ -247,6 +251,8 @@ static id IFWebDataSourceMake(void *url)
         childFrame = [[self children] objectAtIndex: i];
         if ([[childFrame dataSource] isLoading])
             return YES;
+        if ([[childFrame provisionalDataSource] isLoading])
+            return YES;
     }
     return NO;
 }
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
index 1b13065..e8695cd 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
@@ -7,26 +7,39 @@
 */
 #import <Cocoa/Cocoa.h>
 
-#import <WebFoundation/IFURLHandle.h>
+#import <WebFoundation/WebFoundation.h>
 
 #import <WebKit/IFWebDataSource.h>
 
 // includes from kde
 #include <khtmlview.h>
 
+ at class IFMainURLHandleClient;
+
 @interface IFWebDataSourcePrivate : NSObject
 {
     IFWebDataSource *parent;
     NSMutableArray *children;
+    
     id <IFWebController>controller;
+    
+    // The original URL as requested during initialization.
     NSURL *inputURL;
+    
     KHTMLPart *part;
     
     // Child frames of this frame.
     NSMutableDictionary *frames;
     
-    // Active IFURLHandles.
+    // The handle client for the main document associated with the
+    // datasource.
+    IFMainURLHandleClient *mainURLHandleClient;
+    
+    // Active IFURLHandles for resources associated with the
+    // datasource.
     NSMutableArray *urlHandles;
+    
+    bool primaryLoadComplete;
 }
 
 - init;
@@ -38,10 +51,11 @@
 - (void)_setController: (id <IFWebController>)controller;
 - (KHTMLPart *)_part;
 - (void)_setParent: (IFWebDataSource *)p;
-- (void)_startLoading: (BOOL)forceRefresh initiatedByUserEvent: (BOOL)flag;
+- (void)_startLoading: (BOOL)forceRefresh;
 
 - (void)_stopLoading;
 - (void)_recursiveStopLoading;
 - (void)_addURLHandle: (IFURLHandle *)handle;
 - (void)_removeURLHandle: (IFURLHandle *)handle;
+- (void)_setPrimaryLoadComplete: (BOOL)flag;
 @end
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index eae3a63..5120416 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -6,6 +6,8 @@
         NSWebPageDataSource.
 */
 #import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFMainURLHandleClient.h>
+#import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFException.h>
 #import <WebKit/WebKitDebug.h>
 
@@ -23,17 +25,21 @@
 
     part = new KHTMLPart();
     
+    primaryLoadComplete = NO;
+    
     return self;
 }
 
 - (void)dealloc
 {
     // controller is not retained!  IFWebControllers maintain
-    // a reference to their view and main data source.
+    // a reference to the main frame, which in turn refers to it's
+    // view and data source.
     [parent release];
     [frames release];
     [inputURL release];
     [urlHandles release];
+    [mainURLHandleClient release];
     
     delete part;
 
@@ -64,12 +70,44 @@
     ((IFWebDataSourcePrivate *)_dataSourcePrivate)->parent = [p retain];
 }
 
-- (void)_startLoading: (BOOL)forceRefresh initiatedByUserEvent: (BOOL)byUserEvent
+- (void)_setPrimaryLoadComplete: (BOOL)flag
+{
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    
+    data->primaryLoadComplete = flag;
+}
+
+- (void)_startLoading: (BOOL)forceRefresh
 {
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    NSString *urlString = [[self inputURL] absoluteString];
+    NSURL *theURL;
     KURL url = [[[self inputURL] absoluteString] cString];
+    IFURLHandle *handle;
 
+    [self _setPrimaryLoadComplete: NO];
+    
     WEBKIT_ASSERT ([self frame] != nil);
     
+    [[self frame] _clearErrors];
+    
+    // FIXME [mjs]: temporary hack to make file: URLs work right
+    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
+        urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
+    }
+    if ([urlString hasSuffix:@"/"]) {
+        urlString = [urlString substringToIndex:([urlString length] - 1)];
+    }
+    theURL = [NSURL URLWithString:urlString];
+
+    data->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self part: [self _part]];
+    
+    // The handle will be released by the client upon receipt of a 
+    // terminal callback.
+    handle = [[IFURLHandle alloc] initWithURL:theURL];
+    [handle addClient: data->mainURLHandleClient];
+    [handle loadInBackground];
+
     [self _part]->openURL (url);
     
     [[self controller] locationChangeStartedForFrame: [self frame]];
@@ -102,7 +140,7 @@
     count = [data->urlHandles count];
     for (i = 0; i < count; i++) {
         handle = [data->urlHandles objectAtIndex: i];
-        WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "canceling %s\n", [[[handle url] absoluteString] cString] );
+        WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "cancelling %s\n", [[[handle url] absoluteString] cString] );
         [[data->urlHandles objectAtIndex: i] cancelLoadInBackground];
     }
 
diff --git a/WebKit/WebView.subproj/IFWebFrame.h b/WebKit/WebView.subproj/IFWebFrame.h
index 8cee633..8f10444 100644
--- a/WebKit/WebView.subproj/IFWebFrame.h
+++ b/WebKit/WebView.subproj/IFWebFrame.h
@@ -75,7 +75,11 @@
 
 /*
 */
-- (IFError *)lastError;
+- (NSDictionary *)errors;
+
+/*
+*/
+- (IFError *)mainDocumentError;
 
 /*
     This method removes references the underlying resources.
diff --git a/WebKit/WebView.subproj/IFWebFrame.mm b/WebKit/WebView.subproj/IFWebFrame.mm
index 5bd3c7d..63ae1a2 100644
--- a/WebKit/WebView.subproj/IFWebFrame.mm
+++ b/WebKit/WebView.subproj/IFWebFrame.mm
@@ -139,11 +139,13 @@
     
     [[self view] provisionalDataSourceChanged: newDataSource];
 
+#ifdef OLD_WAY
     // This introduces a nasty dependency on the view.
     khtml::RenderPart *renderPartFrame = [self _renderFramePart];
     id view = [self view];
     if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")])
         renderPartFrame->setWidget ([view _provisionalWidget]);
+#endif
 
     [self _setState: IFWEBFRAMESTATE_PROVISIONAL];
     
@@ -154,8 +156,6 @@
 - (void)startLoading
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
-
-    [self _setLastError: nil];
     
     // Force refresh is irrelevant, as this will always be the first load.
     // The controller will transition the provisional data source to the
@@ -177,7 +177,7 @@
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
 
-    [self _setLastError: nil];
+    [self _clearErrors];
 
     [data->dataSource startLoading: forceRefresh];
 }
@@ -191,10 +191,17 @@
     [data setView: nil];
 }
 
-- (IFError *)lastError
+- (NSDictionary *)errors
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    return data->errors;
+}
+
+- (IFError *)mainDocumentError
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
-    return data->lastError;
+    return data->mainDocumentError;
 }
 
+
 @end
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.h b/WebKit/WebView.subproj/IFWebFramePrivate.h
index d8bc222..78ad6d8 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.h
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.h
@@ -26,7 +26,8 @@ typedef enum {
     void *renderFramePart;
     id <IFWebController>controller;
     IFWebFrameState state;
-    IFError *lastError;
+    NSMutableDictionary *errors;
+    IFError *mainDocumentError;
 }
 
 - (void)setName: (NSString *)n;
@@ -51,6 +52,9 @@ typedef enum {
 - (void)_transitionProvisionalToCommitted;
 - (IFWebFrameState)_state;
 - (void)_setState: (IFWebFrameState)newState;
-- (BOOL)_checkLoadComplete: (IFError *)error;
-- (void)_setLastError: (IFError *)error;
++ (void)_recursiveCheckCompleteFromFrame: (IFWebFrame *)fromFrame;
+- (void)_isLoadComplete;
+- (void)_checkLoadCompleteResource: (NSString *)resourceDescription error: (IFError *)error isMainDocument: (BOOL)flag;
+- (void)_clearErrors;
+- (void)_setMainDocumentError: (IFError *)error;
 @end
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index 1c62048..464642c 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -1,7 +1,7 @@
 /*	
-        IFWebFramePrivate.mm
+    IFWebFramePrivate.mm
 	    
-	    Copyright 2001, Apple, Inc. All rights reserved.
+    Copyright 2001, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
@@ -13,15 +13,17 @@
 
 // includes from kde
 #include <khtmlview.h>
+#include <rendering/render_frames.h>
 
 @implementation IFWebFramePrivate
 
 - (void)dealloc
 {
-    [lastError autorelease];
     [name autorelease];
     [view autorelease];
     [dataSource autorelease];
+    [errors release];
+    [mainDocumentError release];
     [super dealloc];
 }
 
@@ -104,26 +106,54 @@
 
     WEBKIT_ASSERT ([self controller] != nil);
 
-    WEBKIT_ASSERT ([self _state] == IFWEBFRAMESTATE_PROVISIONAL);
-
-    [[self view] _stopPlugins];
-    
-    [[self view] _removeSubviews];
-    
-    // Set the committed data source on the frame.
-    [self _setDataSource: data->provisionalDataSource];
-    
-    // dataSourceChanged: will reset the view and begin trying to
-    // display the new new datasource.
-    [[self view] dataSourceChanged: data->provisionalDataSource];
-
-    
-    // Now that the provisional data source is committed, release it.
-    [data setProvisionalDataSource: nil];
-
-    [self _setState: IFWEBFRAMESTATE_COMMITTED];
-
-    [[self controller] locationChangeCommittedForFrame: self];
+    switch ([self _state]){
+    	case IFWEBFRAMESTATE_PROVISIONAL:
+        {
+            id view = [self view];
+
+            WEBKIT_ASSERT (view != nil);
+
+            // Make sure any plugsin are shut down cleanly.
+            [view _stopPlugins];
+            
+            // Remove any widgets.
+            [view _removeSubviews];
+            
+            // Set the committed data source on the frame.
+            [self _setDataSource: data->provisionalDataSource];
+            
+            // If we're a frame (not the main frame) hookup the kde internals.  This introduces a nasty dependency 
+            // in kde on the view.
+            khtml::RenderPart *renderPartFrame = [self _renderFramePart];
+            if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")]){
+                // Setting the widget will delete the previous KHTMLView associated with the frame.
+                renderPartFrame->setWidget ([view _provisionalWidget]);
+            }
+        
+            // dataSourceChanged: will reset the view and begin trying to
+            // display the new new datasource.
+            [view dataSourceChanged: data->provisionalDataSource];
+        
+            
+            // Now that the provisional data source is committed, release it.
+            [data setProvisionalDataSource: nil];
+        
+            [self _setState: IFWEBFRAMESTATE_COMMITTED];
+        
+            [[self controller] locationChangeCommittedForFrame: self];
+            
+            break;
+        }
+        
+        case IFWEBFRAMESTATE_UNINITIALIZED:
+        case IFWEBFRAMESTATE_COMMITTED:
+        case IFWEBFRAMESTATE_COMPLETE:
+        default:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state attempting to transition to IFWEBFRAMESTATE_COMMITTED" userInfo: nil] raise];
+            return;
+        }
+    }
 }
 
 - (IFWebFrameState)_state
@@ -133,61 +163,151 @@
     return data->state;
 }
 
+char *stateNames[5] = {
+    "zero state",
+    "IFWEBFRAMESTATE_UNINITIALIZED",
+    "IFWEBFRAMESTATE_PROVISIONAL",
+    "IFWEBFRAMESTATE_COMMITTED",
+    "IFWEBFRAMESTATE_COMPLETE" };
+
 - (void)_setState: (IFWebFrameState)newState
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
 
+    WEBKITDEBUGLEVEL3 (WEBKIT_LOG_LOADING, "%s:  transition from %s to %s\n", [[self name] cString], stateNames[data->state], stateNames[newState]);
+    
     data->state = newState;
 }
 
-- (BOOL)_checkLoadComplete: (IFError *)error
+- (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription
 {
-    int i, count;
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    if (data->errors == 0)
+        data->errors = [[NSMutableDictionary alloc] init];
+        
+    [data->errors setObject: error forKey: resourceDescription];
+}
+
+- (void)_isLoadComplete
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
     
     WEBKIT_ASSERT ([self controller] != nil);
 
-    if ([self _state] == IFWEBFRAMESTATE_COMPLETE)
-        return YES;
-
-    if ([self _state] == IFWEBFRAMESTATE_PROVISIONAL && error == nil)
-        return NO;
-
-    // Check all children first.
-    count = [[[self dataSource] children] count];
-    for (i = 0; i < count; i++){
-        IFWebFrame *childFrame;
+    switch ([self _state]){
+        // Shouldn't ever be in this state.
+        case IFWEBFRAMESTATE_UNINITIALIZED:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state IFWEBFRAMESTATE_UNINITIALIZED during completion check with error" userInfo: nil] raise];
+            return;
+        }
         
-        childFrame = [[[self dataSource] children] objectAtIndex: i];
-        if ([childFrame _checkLoadComplete: nil] == NO)
-            return NO;
-    }
-
-    if (![[self dataSource] isLoading]){
-        if (error) {
-            [self _setLastError: error];
+        case IFWEBFRAMESTATE_PROVISIONAL:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete in IFWEBFRAMESTATE_PROVISIONAL\n", [[self name] cString]);
+            // If we've received any errors we may be stuck in the provisional state and actually
+            // complete.
+            if ([[self errors] count] != 0){
+                // Check all children first.
+                WEBKITDEBUGLEVEL2 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_PROVISIONAL, %d errors\n", [[self name] cString], [[self errors] count]);
+                if (![[self provisionalDataSource] isLoading]){
+                    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete in IFWEBFRAMESTATE_PROVISIONAL, load done\n", [[self name] cString]);
+                    // We now the provisional data source didn't cut the mustard, release it.
+                    [data setProvisionalDataSource: nil];
+                    
+                    [self _setState: IFWEBFRAMESTATE_COMPLETE];
+                    [[self controller] locationChangeDone: [self mainDocumentError] forFrame: self];
+                    return;
+                }
+            }
+            return;
         }
         
-        [self _setState: IFWEBFRAMESTATE_COMPLETE];
+        case IFWEBFRAMESTATE_COMMITTED:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_COMMITTED\n", [[self name] cString]);
+            if (![[self dataSource] isLoading]){
+               [self _setState: IFWEBFRAMESTATE_COMPLETE];
+                
+                WEBKIT_ASSERT ([self dataSource] != nil);
+                
+                [[self dataSource] _part]->end();
+                
+                //if ([[self controller] mainFrame] == self){
+                    [[self view] setNeedsLayout: YES];
+                    [[self view] layout];
+                    [[self view] display];
+                //}
+                [[self controller] locationChangeDone: [self mainDocumentError] forFrame: self];
+                
+                return;
+            }
+            return;
+        }
         
-        [[self dataSource] _part]->end();
+        case IFWEBFRAMESTATE_COMPLETE:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_COMPLETE\n", [[self name] cString]);
+            return;
+        }
         
-        if ([[self controller] mainFrame] == self){
-            [[self view] setNeedsLayout: YES];
-            [[self view] layout];
-            [[self view] display];
+        // Yikes!  Serious horkage.
+        default:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state during completion check with error" userInfo: nil] raise];
+            break;
         }
-        [[self controller] locationChangeDone: nil forFrame: self];
-        return YES;
     }
-    return NO;
 }
 
-- (void)_setLastError: (IFError *)error
++ (void)_recursiveCheckCompleteFromFrame: (IFWebFrame *)fromFrame
 {
-    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    int i, count;
+    NSArray *childFrames;
     
-    [data->lastError release];
-    data->lastError = [error retain];
+    childFrames = [[fromFrame dataSource] children];
+    count = [childFrames count];
+    for (i = 0; i < count; i++){
+        IFWebFrame *childFrame;
+        
+        childFrame = [childFrames objectAtIndex: i];
+        [IFWebFrame _recursiveCheckCompleteFromFrame: childFrame];
+        [childFrame _isLoadComplete];
+    }
+    [fromFrame _isLoadComplete];
+}
+
+// Called every time a resource is completely loaded, or an error is received.
+- (void)_checkLoadCompleteResource: (NSString *)resourceDescription error: (IFError *)error isMainDocument: (BOOL)mainDocument
+{
+
+    WEBKIT_ASSERT ([self controller] != nil);
+
+    if (error) {
+        if (mainDocument)
+            [self _setMainDocumentError: error];
+        [self _addError: error forResource: resourceDescription];
+    }
+
+    // Now walk the frame tree to see if any frame that may have initiated a load is done.
+    [IFWebFrame _recursiveCheckCompleteFromFrame: [[self controller] mainFrame]];
+}
+
+
+- (void)_setMainDocumentError: (IFError *)error
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    data->mainDocumentError = [error retain];
+}
+
+- (void)_clearErrors
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+
+    [data->errors release];
+    data->errors = nil;
+    [data->mainDocumentError release];
+    data->mainDocumentError = nil;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/IFWebView.mm b/WebKit/WebView.subproj/IFWebView.mm
index fe52cc0..0968cf0 100644
--- a/WebKit/WebView.subproj/IFWebView.mm
+++ b/WebKit/WebView.subproj/IFWebView.mm
@@ -379,13 +379,6 @@
 
 
 
-// Override superclass implementation.  We want to relayout when the frame size is changed.
-- (void)setFrame:(NSRect)rect
-{
-    WEBKITDEBUGLEVEL4 (WEBKIT_LOG_VIEW, "(%f,%f) width = %f, height = %f\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-    [super setFrame:rect];
-}
-
 - (void)windowResized: (NSNotification *)notification
 {
     if ([notification object] == [self window])
diff --git a/WebKit/WebView.subproj/WebDataSource.m b/WebKit/WebView.subproj/WebDataSource.m
index 7419132..0f8d6fc 100644
--- a/WebKit/WebView.subproj/WebDataSource.m
+++ b/WebKit/WebView.subproj/WebDataSource.m
@@ -217,7 +217,7 @@ static id IFWebDataSourceMake(void *url)
 // If forceRefresh is YES the document will load from the net, not the cache.
 - (void)startLoading: (BOOL)forceRefresh
 {
-    [self _startLoading: forceRefresh initiatedByUserEvent: NO];
+    [self _startLoading: forceRefresh];
 }
 
 
@@ -234,9 +234,13 @@ static id IFWebDataSourceMake(void *url)
 // Returns YES if there are any pending loads.
 - (BOOL)isLoading
 {
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
     int i, count;
     
-    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    WEBKITDEBUGLEVEL4 (WEBKIT_LOG_LOADING, "frame %s: primaryLoadComplete %d, [data->urlHandles count] = %d, URL = %s\n", [[[self frame] name] cString], (int)data->primaryLoadComplete, [data->urlHandles count], [[[self inputURL] absoluteString] cString]);
+    if (data->primaryLoadComplete == NO)
+        return YES;
+        
     if ([data->urlHandles count])
         return YES;
     
@@ -247,6 +251,8 @@ static id IFWebDataSourceMake(void *url)
         childFrame = [[self children] objectAtIndex: i];
         if ([[childFrame dataSource] isLoading])
             return YES;
+        if ([[childFrame provisionalDataSource] isLoading])
+            return YES;
     }
     return NO;
 }
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 1b13065..e8695cd 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -7,26 +7,39 @@
 */
 #import <Cocoa/Cocoa.h>
 
-#import <WebFoundation/IFURLHandle.h>
+#import <WebFoundation/WebFoundation.h>
 
 #import <WebKit/IFWebDataSource.h>
 
 // includes from kde
 #include <khtmlview.h>
 
+ at class IFMainURLHandleClient;
+
 @interface IFWebDataSourcePrivate : NSObject
 {
     IFWebDataSource *parent;
     NSMutableArray *children;
+    
     id <IFWebController>controller;
+    
+    // The original URL as requested during initialization.
     NSURL *inputURL;
+    
     KHTMLPart *part;
     
     // Child frames of this frame.
     NSMutableDictionary *frames;
     
-    // Active IFURLHandles.
+    // The handle client for the main document associated with the
+    // datasource.
+    IFMainURLHandleClient *mainURLHandleClient;
+    
+    // Active IFURLHandles for resources associated with the
+    // datasource.
     NSMutableArray *urlHandles;
+    
+    bool primaryLoadComplete;
 }
 
 - init;
@@ -38,10 +51,11 @@
 - (void)_setController: (id <IFWebController>)controller;
 - (KHTMLPart *)_part;
 - (void)_setParent: (IFWebDataSource *)p;
-- (void)_startLoading: (BOOL)forceRefresh initiatedByUserEvent: (BOOL)flag;
+- (void)_startLoading: (BOOL)forceRefresh;
 
 - (void)_stopLoading;
 - (void)_recursiveStopLoading;
 - (void)_addURLHandle: (IFURLHandle *)handle;
 - (void)_removeURLHandle: (IFURLHandle *)handle;
+- (void)_setPrimaryLoadComplete: (BOOL)flag;
 @end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index eae3a63..5120416 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -6,6 +6,8 @@
         NSWebPageDataSource.
 */
 #import <WebKit/IFWebDataSourcePrivate.h>
+#import <WebKit/IFMainURLHandleClient.h>
+#import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFException.h>
 #import <WebKit/WebKitDebug.h>
 
@@ -23,17 +25,21 @@
 
     part = new KHTMLPart();
     
+    primaryLoadComplete = NO;
+    
     return self;
 }
 
 - (void)dealloc
 {
     // controller is not retained!  IFWebControllers maintain
-    // a reference to their view and main data source.
+    // a reference to the main frame, which in turn refers to it's
+    // view and data source.
     [parent release];
     [frames release];
     [inputURL release];
     [urlHandles release];
+    [mainURLHandleClient release];
     
     delete part;
 
@@ -64,12 +70,44 @@
     ((IFWebDataSourcePrivate *)_dataSourcePrivate)->parent = [p retain];
 }
 
-- (void)_startLoading: (BOOL)forceRefresh initiatedByUserEvent: (BOOL)byUserEvent
+- (void)_setPrimaryLoadComplete: (BOOL)flag
+{
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    
+    data->primaryLoadComplete = flag;
+}
+
+- (void)_startLoading: (BOOL)forceRefresh
 {
+    IFWebDataSourcePrivate *data = (IFWebDataSourcePrivate *)_dataSourcePrivate;
+    NSString *urlString = [[self inputURL] absoluteString];
+    NSURL *theURL;
     KURL url = [[[self inputURL] absoluteString] cString];
+    IFURLHandle *handle;
 
+    [self _setPrimaryLoadComplete: NO];
+    
     WEBKIT_ASSERT ([self frame] != nil);
     
+    [[self frame] _clearErrors];
+    
+    // FIXME [mjs]: temporary hack to make file: URLs work right
+    if ([urlString hasPrefix:@"file:/"] && [urlString characterAtIndex:6] != '/') {
+        urlString = [@"file:///" stringByAppendingString:[urlString substringFromIndex:6]];
+    }
+    if ([urlString hasSuffix:@"/"]) {
+        urlString = [urlString substringToIndex:([urlString length] - 1)];
+    }
+    theURL = [NSURL URLWithString:urlString];
+
+    data->mainURLHandleClient = [[IFMainURLHandleClient alloc] initWithDataSource: self part: [self _part]];
+    
+    // The handle will be released by the client upon receipt of a 
+    // terminal callback.
+    handle = [[IFURLHandle alloc] initWithURL:theURL];
+    [handle addClient: data->mainURLHandleClient];
+    [handle loadInBackground];
+
     [self _part]->openURL (url);
     
     [[self controller] locationChangeStartedForFrame: [self frame]];
@@ -102,7 +140,7 @@
     count = [data->urlHandles count];
     for (i = 0; i < count; i++) {
         handle = [data->urlHandles objectAtIndex: i];
-        WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "canceling %s\n", [[[handle url] absoluteString] cString] );
+        WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "cancelling %s\n", [[[handle url] absoluteString] cString] );
         [[data->urlHandles objectAtIndex: i] cancelLoadInBackground];
     }
 
diff --git a/WebKit/WebView.subproj/WebFrame.h b/WebKit/WebView.subproj/WebFrame.h
index 8cee633..8f10444 100644
--- a/WebKit/WebView.subproj/WebFrame.h
+++ b/WebKit/WebView.subproj/WebFrame.h
@@ -75,7 +75,11 @@
 
 /*
 */
-- (IFError *)lastError;
+- (NSDictionary *)errors;
+
+/*
+*/
+- (IFError *)mainDocumentError;
 
 /*
     This method removes references the underlying resources.
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index 5bd3c7d..63ae1a2 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -139,11 +139,13 @@
     
     [[self view] provisionalDataSourceChanged: newDataSource];
 
+#ifdef OLD_WAY
     // This introduces a nasty dependency on the view.
     khtml::RenderPart *renderPartFrame = [self _renderFramePart];
     id view = [self view];
     if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")])
         renderPartFrame->setWidget ([view _provisionalWidget]);
+#endif
 
     [self _setState: IFWEBFRAMESTATE_PROVISIONAL];
     
@@ -154,8 +156,6 @@
 - (void)startLoading
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
-
-    [self _setLastError: nil];
     
     // Force refresh is irrelevant, as this will always be the first load.
     // The controller will transition the provisional data source to the
@@ -177,7 +177,7 @@
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
 
-    [self _setLastError: nil];
+    [self _clearErrors];
 
     [data->dataSource startLoading: forceRefresh];
 }
@@ -191,10 +191,17 @@
     [data setView: nil];
 }
 
-- (IFError *)lastError
+- (NSDictionary *)errors
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    return data->errors;
+}
+
+- (IFError *)mainDocumentError
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
-    return data->lastError;
+    return data->mainDocumentError;
 }
 
+
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index d8bc222..78ad6d8 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -26,7 +26,8 @@ typedef enum {
     void *renderFramePart;
     id <IFWebController>controller;
     IFWebFrameState state;
-    IFError *lastError;
+    NSMutableDictionary *errors;
+    IFError *mainDocumentError;
 }
 
 - (void)setName: (NSString *)n;
@@ -51,6 +52,9 @@ typedef enum {
 - (void)_transitionProvisionalToCommitted;
 - (IFWebFrameState)_state;
 - (void)_setState: (IFWebFrameState)newState;
-- (BOOL)_checkLoadComplete: (IFError *)error;
-- (void)_setLastError: (IFError *)error;
++ (void)_recursiveCheckCompleteFromFrame: (IFWebFrame *)fromFrame;
+- (void)_isLoadComplete;
+- (void)_checkLoadCompleteResource: (NSString *)resourceDescription error: (IFError *)error isMainDocument: (BOOL)flag;
+- (void)_clearErrors;
+- (void)_setMainDocumentError: (IFError *)error;
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 1c62048..464642c 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -1,7 +1,7 @@
 /*	
-        IFWebFramePrivate.mm
+    IFWebFramePrivate.mm
 	    
-	    Copyright 2001, Apple, Inc. All rights reserved.
+    Copyright 2001, Apple, Inc. All rights reserved.
 */
 #import <WebKit/IFWebDataSource.h>
 #import <WebKit/IFWebDataSourcePrivate.h>
@@ -13,15 +13,17 @@
 
 // includes from kde
 #include <khtmlview.h>
+#include <rendering/render_frames.h>
 
 @implementation IFWebFramePrivate
 
 - (void)dealloc
 {
-    [lastError autorelease];
     [name autorelease];
     [view autorelease];
     [dataSource autorelease];
+    [errors release];
+    [mainDocumentError release];
     [super dealloc];
 }
 
@@ -104,26 +106,54 @@
 
     WEBKIT_ASSERT ([self controller] != nil);
 
-    WEBKIT_ASSERT ([self _state] == IFWEBFRAMESTATE_PROVISIONAL);
-
-    [[self view] _stopPlugins];
-    
-    [[self view] _removeSubviews];
-    
-    // Set the committed data source on the frame.
-    [self _setDataSource: data->provisionalDataSource];
-    
-    // dataSourceChanged: will reset the view and begin trying to
-    // display the new new datasource.
-    [[self view] dataSourceChanged: data->provisionalDataSource];
-
-    
-    // Now that the provisional data source is committed, release it.
-    [data setProvisionalDataSource: nil];
-
-    [self _setState: IFWEBFRAMESTATE_COMMITTED];
-
-    [[self controller] locationChangeCommittedForFrame: self];
+    switch ([self _state]){
+    	case IFWEBFRAMESTATE_PROVISIONAL:
+        {
+            id view = [self view];
+
+            WEBKIT_ASSERT (view != nil);
+
+            // Make sure any plugsin are shut down cleanly.
+            [view _stopPlugins];
+            
+            // Remove any widgets.
+            [view _removeSubviews];
+            
+            // Set the committed data source on the frame.
+            [self _setDataSource: data->provisionalDataSource];
+            
+            // If we're a frame (not the main frame) hookup the kde internals.  This introduces a nasty dependency 
+            // in kde on the view.
+            khtml::RenderPart *renderPartFrame = [self _renderFramePart];
+            if (renderPartFrame && [view isKindOfClass: NSClassFromString(@"IFWebView")]){
+                // Setting the widget will delete the previous KHTMLView associated with the frame.
+                renderPartFrame->setWidget ([view _provisionalWidget]);
+            }
+        
+            // dataSourceChanged: will reset the view and begin trying to
+            // display the new new datasource.
+            [view dataSourceChanged: data->provisionalDataSource];
+        
+            
+            // Now that the provisional data source is committed, release it.
+            [data setProvisionalDataSource: nil];
+        
+            [self _setState: IFWEBFRAMESTATE_COMMITTED];
+        
+            [[self controller] locationChangeCommittedForFrame: self];
+            
+            break;
+        }
+        
+        case IFWEBFRAMESTATE_UNINITIALIZED:
+        case IFWEBFRAMESTATE_COMMITTED:
+        case IFWEBFRAMESTATE_COMPLETE:
+        default:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state attempting to transition to IFWEBFRAMESTATE_COMMITTED" userInfo: nil] raise];
+            return;
+        }
+    }
 }
 
 - (IFWebFrameState)_state
@@ -133,61 +163,151 @@
     return data->state;
 }
 
+char *stateNames[5] = {
+    "zero state",
+    "IFWEBFRAMESTATE_UNINITIALIZED",
+    "IFWEBFRAMESTATE_PROVISIONAL",
+    "IFWEBFRAMESTATE_COMMITTED",
+    "IFWEBFRAMESTATE_COMPLETE" };
+
 - (void)_setState: (IFWebFrameState)newState
 {
     IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
 
+    WEBKITDEBUGLEVEL3 (WEBKIT_LOG_LOADING, "%s:  transition from %s to %s\n", [[self name] cString], stateNames[data->state], stateNames[newState]);
+    
     data->state = newState;
 }
 
-- (BOOL)_checkLoadComplete: (IFError *)error
+- (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription
 {
-    int i, count;
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    if (data->errors == 0)
+        data->errors = [[NSMutableDictionary alloc] init];
+        
+    [data->errors setObject: error forKey: resourceDescription];
+}
+
+- (void)_isLoadComplete
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
     
     WEBKIT_ASSERT ([self controller] != nil);
 
-    if ([self _state] == IFWEBFRAMESTATE_COMPLETE)
-        return YES;
-
-    if ([self _state] == IFWEBFRAMESTATE_PROVISIONAL && error == nil)
-        return NO;
-
-    // Check all children first.
-    count = [[[self dataSource] children] count];
-    for (i = 0; i < count; i++){
-        IFWebFrame *childFrame;
+    switch ([self _state]){
+        // Shouldn't ever be in this state.
+        case IFWEBFRAMESTATE_UNINITIALIZED:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state IFWEBFRAMESTATE_UNINITIALIZED during completion check with error" userInfo: nil] raise];
+            return;
+        }
         
-        childFrame = [[[self dataSource] children] objectAtIndex: i];
-        if ([childFrame _checkLoadComplete: nil] == NO)
-            return NO;
-    }
-
-    if (![[self dataSource] isLoading]){
-        if (error) {
-            [self _setLastError: error];
+        case IFWEBFRAMESTATE_PROVISIONAL:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete in IFWEBFRAMESTATE_PROVISIONAL\n", [[self name] cString]);
+            // If we've received any errors we may be stuck in the provisional state and actually
+            // complete.
+            if ([[self errors] count] != 0){
+                // Check all children first.
+                WEBKITDEBUGLEVEL2 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_PROVISIONAL, %d errors\n", [[self name] cString], [[self errors] count]);
+                if (![[self provisionalDataSource] isLoading]){
+                    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete in IFWEBFRAMESTATE_PROVISIONAL, load done\n", [[self name] cString]);
+                    // We now the provisional data source didn't cut the mustard, release it.
+                    [data setProvisionalDataSource: nil];
+                    
+                    [self _setState: IFWEBFRAMESTATE_COMPLETE];
+                    [[self controller] locationChangeDone: [self mainDocumentError] forFrame: self];
+                    return;
+                }
+            }
+            return;
         }
         
-        [self _setState: IFWEBFRAMESTATE_COMPLETE];
+        case IFWEBFRAMESTATE_COMMITTED:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_COMMITTED\n", [[self name] cString]);
+            if (![[self dataSource] isLoading]){
+               [self _setState: IFWEBFRAMESTATE_COMPLETE];
+                
+                WEBKIT_ASSERT ([self dataSource] != nil);
+                
+                [[self dataSource] _part]->end();
+                
+                //if ([[self controller] mainFrame] == self){
+                    [[self view] setNeedsLayout: YES];
+                    [[self view] layout];
+                    [[self view] display];
+                //}
+                [[self controller] locationChangeDone: [self mainDocumentError] forFrame: self];
+                
+                return;
+            }
+            return;
+        }
         
-        [[self dataSource] _part]->end();
+        case IFWEBFRAMESTATE_COMPLETE:
+        {
+            WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "%s:  checking complete, current state IFWEBFRAMESTATE_COMPLETE\n", [[self name] cString]);
+            return;
+        }
         
-        if ([[self controller] mainFrame] == self){
-            [[self view] setNeedsLayout: YES];
-            [[self view] layout];
-            [[self view] display];
+        // Yikes!  Serious horkage.
+        default:
+        {
+            [[NSException exceptionWithName:NSGenericException reason:@"invalid state during completion check with error" userInfo: nil] raise];
+            break;
         }
-        [[self controller] locationChangeDone: nil forFrame: self];
-        return YES;
     }
-    return NO;
 }
 
-- (void)_setLastError: (IFError *)error
++ (void)_recursiveCheckCompleteFromFrame: (IFWebFrame *)fromFrame
 {
-    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    int i, count;
+    NSArray *childFrames;
     
-    [data->lastError release];
-    data->lastError = [error retain];
+    childFrames = [[fromFrame dataSource] children];
+    count = [childFrames count];
+    for (i = 0; i < count; i++){
+        IFWebFrame *childFrame;
+        
+        childFrame = [childFrames objectAtIndex: i];
+        [IFWebFrame _recursiveCheckCompleteFromFrame: childFrame];
+        [childFrame _isLoadComplete];
+    }
+    [fromFrame _isLoadComplete];
+}
+
+// Called every time a resource is completely loaded, or an error is received.
+- (void)_checkLoadCompleteResource: (NSString *)resourceDescription error: (IFError *)error isMainDocument: (BOOL)mainDocument
+{
+
+    WEBKIT_ASSERT ([self controller] != nil);
+
+    if (error) {
+        if (mainDocument)
+            [self _setMainDocumentError: error];
+        [self _addError: error forResource: resourceDescription];
+    }
+
+    // Now walk the frame tree to see if any frame that may have initiated a load is done.
+    [IFWebFrame _recursiveCheckCompleteFromFrame: [[self controller] mainFrame]];
+}
+
+
+- (void)_setMainDocumentError: (IFError *)error
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+    data->mainDocumentError = [error retain];
+}
+
+- (void)_clearErrors
+{
+    IFWebFramePrivate *data = (IFWebFramePrivate *)_framePrivate;
+
+    [data->errors release];
+    data->errors = nil;
+    [data->mainDocumentError release];
+    data->mainDocumentError = nil;
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebFrameView.m b/WebKit/WebView.subproj/WebFrameView.m
index fe52cc0..0968cf0 100644
--- a/WebKit/WebView.subproj/WebFrameView.m
+++ b/WebKit/WebView.subproj/WebFrameView.m
@@ -379,13 +379,6 @@
 
 
 
-// Override superclass implementation.  We want to relayout when the frame size is changed.
-- (void)setFrame:(NSRect)rect
-{
-    WEBKITDEBUGLEVEL4 (WEBKIT_LOG_VIEW, "(%f,%f) width = %f, height = %f\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-    [super setFrame:rect];
-}
-
 - (void)windowResized: (NSNotification *)notification
 {
     if ([notification object] == [self window])
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.h b/WebKit/WebView.subproj/WebMainResourceClient.h
new file mode 100644
index 0000000..51afb79
--- /dev/null
+++ b/WebKit/WebView.subproj/WebMainResourceClient.h
@@ -0,0 +1,22 @@
+/*	
+    IFMainURLHandleClient.h
+
+    Private header.
+    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+#import <WebFoundation/WebFoundation.h>
+
+#import <WebKit/IFWebDataSourcePrivate.h>
+
+ at interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
+{
+    id dataSource;
+    KHTMLPart *part;
+}
+- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
+ at end
+
diff --git a/WebKit/WebView.subproj/WebMainResourceClient.m b/WebKit/WebView.subproj/WebMainResourceClient.m
new file mode 100644
index 0000000..ff59bd4
--- /dev/null
+++ b/WebKit/WebView.subproj/WebMainResourceClient.m
@@ -0,0 +1,89 @@
+/*	
+    IFMainURLHandleClient.mm
+	    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+#import <WebKit/IFError.h>
+#import <WebKit/IFBaseWebControllerPrivate.h>
+#import <WebKit/IFMainURLHandleClient.h>
+
+#import <WebKit/WebKitDebug.h>
+
+#include <khtmlview.h>
+
+ at implementation IFMainURLHandleClient
+
+- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+{
+    if ((self = [super init])) {
+        dataSource = ds;	// Non-retained.
+        part = p;
+        return self;
+    }
+
+    return nil;
+}
+
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+}
+
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [data length];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+{
+    WEBKITDEBUGLEVEL3 (WEBKIT_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+    part->slotData(sender, (const char *)[data bytes], [data length]);
+    
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
+{
+    WEBKITDEBUGLEVEL2 (WEBKIT_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [[sender availableResourceData] length];
+
+    IFError *error = [[IFError alloc] initWithErrorCode: result];
+    [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
+    [error release];
+    
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+{
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.h b/WebKit/WebView.subproj/WebMainResourceLoader.h
new file mode 100644
index 0000000..51afb79
--- /dev/null
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.h
@@ -0,0 +1,22 @@
+/*	
+    IFMainURLHandleClient.h
+
+    Private header.
+    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+
+#import <Cocoa/Cocoa.h>
+
+#import <WebFoundation/WebFoundation.h>
+
+#import <WebKit/IFWebDataSourcePrivate.h>
+
+ at interface IFMainURLHandleClient : NSObject <IFURLHandleClient>
+{
+    id dataSource;
+    KHTMLPart *part;
+}
+- initWithDataSource: (IFWebDataSource *)ds part: (KHTMLPart *)p;
+ at end
+
diff --git a/WebKit/WebView.subproj/WebMainResourceLoader.m b/WebKit/WebView.subproj/WebMainResourceLoader.m
new file mode 100644
index 0000000..ff59bd4
--- /dev/null
+++ b/WebKit/WebView.subproj/WebMainResourceLoader.m
@@ -0,0 +1,89 @@
+/*	
+    IFMainURLHandleClient.mm
+	    
+    Copyright 2001, Apple, Inc. All rights reserved.
+*/
+#import <WebKit/IFError.h>
+#import <WebKit/IFBaseWebControllerPrivate.h>
+#import <WebKit/IFMainURLHandleClient.h>
+
+#import <WebKit/WebKitDebug.h>
+
+#include <khtmlview.h>
+
+ at implementation IFMainURLHandleClient
+
+- initWithDataSource: (IFWebDataSource *)ds part:(KHTMLPart *)p
+{
+    if ((self = [super init])) {
+        dataSource = ds;	// Non-retained.
+        part = p;
+        return self;
+    }
+
+    return nil;
+}
+
+- (void)IFURLHandleResourceDidBeginLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+}
+
+- (void)IFURLHandleResourceDidCancelLoading:(IFURLHandle *)sender
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = -1;
+    loadProgress->bytesSoFar = -1;
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandleResourceDidFinishLoading:(IFURLHandle *)sender data: (NSData *)data
+{
+    WEBKITDEBUGLEVEL1 (WEBKIT_LOG_LOADING, "url = %s\n", [[[sender url] absoluteString] cString]);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [data length];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)data
+{
+    WEBKITDEBUGLEVEL3 (WEBKIT_LOG_LOADING, "url = %s, data = 0x%08x, length %d\n", [[[sender url] absoluteString] cString], data, [data length]);
+    part->slotData(sender, (const char *)[data bytes], [data length]);
+    
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [data length];
+    [[dataSource controller] _mainReceivedProgress: (IFLoadProgress *)loadProgress forResource: [[sender url] absoluteString] fromDataSource: dataSource];
+    [loadProgress release];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender resourceDidFailLoadingWithResult:(int)result
+{
+    WEBKITDEBUGLEVEL2 (WEBKIT_LOG_LOADING, "url = %s, result = %d\n", [[[sender url] absoluteString] cString], result);
+
+    IFLoadProgress *loadProgress = [[IFLoadProgress alloc] init];
+    loadProgress->totalToLoad = [sender contentLength];
+    loadProgress->bytesSoFar = [[sender availableResourceData] length];
+
+    IFError *error = [[IFError alloc] initWithErrorCode: result];
+    [[dataSource controller] _mainReceivedError: error forResource: [[sender url] absoluteString] partialProgress: loadProgress fromDataSource: dataSource];
+    [error release];
+    
+    [sender autorelease];
+}
+
+- (void)IFURLHandle:(IFURLHandle *)sender didRedirectToURL:(NSURL *)url
+{
+}
+
+ at end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list