Start using the loader in the Qt port.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@18765 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b8f60dc..3ced23d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2007-01-11  Lars Knoll <lars@trolltech.com>
+
+        Reviewed by Darin.
+
+        Start using the loader in the Qt port.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::clear):
+        (WebCore::FrameLoader::URL):
+        (WebCore::FrameLoader::createEmptyDocument):
+        * loader/qt/FrameLoaderQt.cpp:
+        (WebCore::FrameLoader::setTitle):
+        (WebCore::FrameLoader::originalRequestURL):
+        (WebCore::FrameLoader::referrer):
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        * page/qt/FrameQtClient.cpp:
+        (WebCore::FrameQtClient::openURL):
+
 2007-01-11  Darin Adler  <darin@apple.com>
 
         Reviewed by Hyatt.
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index e65d99b..9a07e23 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -718,11 +718,11 @@
         return;
     m_needsClear = false;
 
-#if !PLATFORM(MAC)
+#if !PLATFORM(MAC) && !PLATFORM(QT)
     // FIXME: Remove this after making other platforms do loading more like Mac.
     detachChildren();
 #endif
-
+    
     if (m_frame->document()) {
         m_frame->document()->cancelParsing();
         m_frame->document()->willRemove();
@@ -2514,10 +2514,6 @@
 
 KURL FrameLoader::URL() const
 {
-#if PLATFORM(QT)
-    if (!activeDocumentLoader())
-        return KURL();
-#endif
     return activeDocumentLoader()->URL();
 }
 
@@ -2693,7 +2689,7 @@
     return m_client;
 }
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(QT)
 void FrameLoader::submitForm(const FrameLoadRequest& request, Event* event)
 {
 #ifdef MULTIPLE_FORM_SUBMISSION_PROTECTION
@@ -2731,7 +2727,7 @@
     load(copy, true, event, 0, HashMap<String, String>());
 }
 #endif
-
+    
 String FrameLoader::userAgent() const
 {
     return m_client->userAgent();
@@ -2742,16 +2738,11 @@
     // Although it's not completely clear from the name of this function,
     // it does nothing if we already have a document, and just creates an
     // empty one if we have no document at all.
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(QT)
     if (!m_frame->document()) {
         loadEmptyDocumentSynchronously();
         updateBaseURLForEmptyDocument();
     }
-#elif PLATFORM(QT)
-    if (!m_frame->document()) {
-        begin();
-        end();
-    }
 #endif
 }
 
diff --git a/WebCore/loader/qt/FrameLoaderQt.cpp b/WebCore/loader/qt/FrameLoaderQt.cpp
index 79c454c..b335446 100644
--- a/WebCore/loader/qt/FrameLoaderQt.cpp
+++ b/WebCore/loader/qt/FrameLoaderQt.cpp
@@ -52,6 +52,7 @@
 #include "HTMLDocument.h"
 #include "HTMLElement.h"
 #include "HTMLFormElement.h"
+#include "HistoryItem.h"
 #include "JSLock.h"
 #include "MouseEventWithHitTestResults.h"
 #include "Page.h"
@@ -78,49 +79,10 @@
 
 namespace WebCore {
 
-void FrameLoader::submitForm(const FrameLoadRequest& frameLoadRequest, Event*)
-{
-#ifdef MULTIPLE_FORM_SUBMISSION_PROTECTION
-    // FIXME: We'd like to remove this altogether and fix the multiple form submission issue another way.
-    // We do not want to submit more than one form from the same page,
-    // nor do we want to submit a single form more than once.
-    // This flag prevents these from happening; not sure how other browsers prevent this.
-    // The flag is reset in each time we start handle a new mouse or key down event, and
-    // also in setView since this part may get reused for a page from the back/forward cache.
-    // The form multi-submit logic here is only needed when we are submitting a form that affects this frame.
-    // FIXME: Frame targeting is only one of the ways the submission could end up doing something other
-    // than replacing this frame's content, so this check is flawed. On the other hand, the check is hardly
-    // needed any more now that we reset m_submittedFormURL on each mouse or key down event.
-    Frame* target = m_frame->tree()->find(frameLoadRequest.frameName());
-    if (m_frame->tree()->isDescendantOf(target)) {
-        if (m_submittedFormURL == frameLoadRequest.resourceRequest().url())
-            return;
-        m_submittedFormURL = frameLoadRequest.resourceRequest().url();
-    }
-#endif
-
-    RefPtr<FormData> formData = frameLoadRequest.resourceRequest().httpBody();
-    if (formData && !formData->isEmpty() && QtFrame(m_frame)->client())
-        QtFrame(m_frame)->client()->submitForm(frameLoadRequest.resourceRequest().httpMethod(),
-                                               frameLoadRequest.resourceRequest().url(),
-                                               formData);
-
-    clearRecordedFormValues();
-}
-
-void FrameLoader::urlSelected(const FrameLoadRequest& frameLoadRequest, Event*)
-{
-    const ResourceRequest& request = frameLoadRequest.resourceRequest();
-
-    if (!QtFrame(m_frame)->client())
-        return;
-
-    QtFrame(m_frame)->client()->openURL(request.url());
-}
 
 void FrameLoader::setTitle(const String& title)
 {
-    client()->setTitle(title, URL());
+    documentLoader()->setTitle(title);
 }
 
 Frame* FrameLoader::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer)
@@ -149,8 +111,7 @@
 
 KURL FrameLoader::originalRequestURL() const
 {
-    notImplemented();
-    return KURL();
+    return activeDocumentLoader()->initialRequest().url();
 }
 
 String FrameLoader::overrideMediaType() const
@@ -161,8 +122,7 @@
 
 String FrameLoader::referrer() const
 {
-    notImplemented();
-    return String();
+    return documentLoader()->request().httpReferrer();
 }
 
 
@@ -170,46 +130,90 @@
 void FrameLoader::checkLoadCompleteForThisFrame()
 {
     ASSERT(m_client->hasWebView());
-    //notImplemented();
 
     switch (m_state) {
-    case FrameStateProvisional: {
-    }
+        case FrameStateProvisional: {
+            if (m_delegateIsHandlingProvisionalLoadError)
+                return;
 
-    case FrameStateCommittedPage: {
-        DocumentLoader* dl = m_documentLoader.get();
-        if (!dl || dl->isLoadingInAPISense())
+            RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
+            if (!pdl)
+                return;
+                
+            // If we've received any errors we may be stuck in the provisional state and actually complete.
+            const ResourceError& error = pdl->mainDocumentError();
+            if (error.isNull())
+                return;
+
+            // Check all children first.
+            RefPtr<HistoryItem> item;
+            if (isBackForwardLoadType(loadType()) && m_frame == m_frame->page()->mainFrame())
+                item = m_currentHistoryItem;
+                
+            bool shouldReset = true;
+            if (!pdl->isLoadingInAPISense()) {
+                m_delegateIsHandlingProvisionalLoadError = true;
+                m_client->dispatchDidFailProvisionalLoad(error);
+                m_delegateIsHandlingProvisionalLoadError = false;
+
+                // FIXME: can stopping loading here possibly have any effect, if isLoading is false,
+                // which it must be to be in this branch of the if? And is it OK to just do a full-on
+                // stopAllLoaders instead of stopLoadingSubframes?
+                stopLoadingSubframes();
+                pdl->stopLoading();
+
+                // Finish resetting the load state, but only if another load hasn't been started by the
+                // delegate callback.
+                if (pdl == m_provisionalDocumentLoader)
+                    clearProvisionalLoad();
+                else if (m_documentLoader) {
+                    KURL unreachableURL = m_documentLoader->unreachableURL();
+                    if (!unreachableURL.isEmpty() && unreachableURL == pdl->request().url())
+                        shouldReset = false;
+                }
+            }
+            if (shouldReset && item && m_frame->page())
+                 m_frame->page()->backForwardList()->goToItem(item.get());
+
             return;
-
-        markLoadComplete();
-
-        // FIXME: Is this subsequent work important if we already navigated away?
-        // Maybe there are bugs because of that, or extra work we can skip because
-        // the new page is ready.
-
-        m_client->forceLayoutForNonHTML();
-             
-        // If the user had a scroll point, scroll to it, overriding the anchor point if any.
-//         if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload)
-//             && m_client->hasBackForwardList())
-//             m_client->restoreScrollPositionAndViewState();
-
-//         if (error)
-//             m_client->dispatchDidFailLoad(error);
-//         else
-            m_client->dispatchDidFinishLoad();
-            
-        m_client->progressCompleted();
-        return;
-    }
+        }
         
-    case FrameStateComplete:
-        // Even if already complete, we might have set a previous item on a frame that
-        // didn't do any data loading on the past transaction. Make sure to clear these out.
-        m_client->frameLoadCompleted();
-        return;
+        case FrameStateCommittedPage: {
+            DocumentLoader* dl = m_documentLoader.get();            
+            if (dl->isLoadingInAPISense())
+                return;
+
+            markLoadComplete();
+
+            // FIXME: Is this subsequent work important if we already navigated away?
+            // Maybe there are bugs because of that, or extra work we can skip because
+            // the new page is ready.
+
+            m_client->forceLayoutForNonHTML();
+             
+            // If the user had a scroll point, scroll to it, overriding the anchor point if any.
+            if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload)
+                    && m_frame->page() && m_frame->page()->backForwardList())
+                restoreScrollPositionAndViewState();
+
+            const ResourceError& error = dl->mainDocumentError();
+            if (!error.isNull())
+                m_client->dispatchDidFailLoad(error);
+            else
+                m_client->dispatchDidFinishLoad();
+
+            m_client->progressCompleted();
+            return;
+        }
+        
+        case FrameStateComplete:
+            // Even if already complete, we might have set a previous item on a frame that
+            // didn't do any data loading on the past transaction. Make sure to clear these out.
+            m_client->frameLoadCompleted();
+            return;
     }
 
+    ASSERT_NOT_REACHED();
 }
 
 void FrameLoader::partClearedInBegin()
diff --git a/WebCore/page/qt/FrameQtClient.cpp b/WebCore/page/qt/FrameQtClient.cpp
index b038ea8..306a4fc 100644
--- a/WebCore/page/qt/FrameQtClient.cpp
+++ b/WebCore/page/qt/FrameQtClient.cpp
@@ -72,20 +72,7 @@
 {
     ASSERT(m_frame);
 
-//     m_frame->loader()->load(url);
-    m_frame->loader()->didOpenURL(url);
-
-    if (!m_frame->document()) {
-        m_frame->loader()->createEmptyDocument();
-        m_frame->loader()->didOpenURL(url);
-    }
-
-
-    ASSERT(m_frame->document());
-
-    ResourceRequest request(url);
-    RefPtr<ResourceHandle> loader = ResourceHandle::create(request, this, m_frame, false);
-    loader.get()->ref();
+    m_frame->loader()->load(url);
 }
 
 void FrameQtClient::submitForm(const String& method, const KURL& url, PassRefPtr<FormData> postData)
diff --git a/WebKitQt/ChangeLog b/WebKitQt/ChangeLog
index 3a3cf60..c06e8d3 100644
--- a/WebKitQt/ChangeLog
+++ b/WebKitQt/ChangeLog
@@ -1,3 +1,50 @@
+2007-01-11  Lars Knoll <lars@trolltech.com>
+
+        Reviewed by Darin
+
+        Start using the loader in the Qt port.
+
+        * QtLauncher/main.cpp:
+        (main):
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::FrameLoaderClientQt):
+        (WebCore::FrameLoaderClientQt::~FrameLoaderClientQt):
+        (WebCore::FrameLoaderClientQt::setFrame):
+        (WebCore::FrameLoaderClientQt::detachFrameLoader):
+        (WebCore::FrameLoaderClientQt::makeDocumentView):
+        (WebCore::FrameLoaderClientQt::makeRepresentation):
+        (WebCore::FrameLoaderClientQt::setCopiesOnScroll):
+        (WebCore::FrameLoaderClientQt::dispatchDidStartProvisionalLoad):
+        (WebCore::FrameLoaderClientQt::cancelPolicyCheck):
+        (WebCore::FrameLoaderClientQt::dispatchWillSubmitForm):
+        (WebCore::FrameLoaderClientQt::progressStarted):
+        (WebCore::FrameLoaderClientQt::progressCompleted):
+        (WebCore::FrameLoaderClientQt::setMainFrameDocumentReady):
+        (WebCore::FrameLoaderClientQt::clearArchivedResources):
+        (WebCore::FrameLoaderClientQt::canShowMIMEType):
+        (WebCore::FrameLoaderClientQt::representationExistsForURLScheme):
+        (WebCore::FrameLoaderClientQt::provisionalLoadStarted):
+        (WebCore::FrameLoaderClientQt::prepareForDataSourceReplacement):
+        (WebCore::FrameLoaderClientQt::frameLoaderDestroyed):
+        (WebCore::FrameLoaderClientQt::canHandleRequest):
+        (WebCore::FrameLoaderClientQt::shouldGoToHistoryItem):
+        (WebCore::FrameLoaderClientQt::canCachePage):
+        (WebCore::FrameLoaderClientQt::committedLoad):
+        (WebCore::FrameLoaderClientQt::cancelledError):
+        (WebCore::FrameLoaderClientQt::cannotShowURLError):
+        (WebCore::FrameLoaderClientQt::interruptForPolicyChangeError):
+        (WebCore::FrameLoaderClientQt::cannotShowMIMETypeError):
+        (WebCore::FrameLoaderClientQt::fileDoesNotExistError):
+        (WebCore::FrameLoaderClientQt::shouldFallBack):
+        (WebCore::FrameLoaderClientQt::createDocumentLoader):
+        (WebCore::FrameLoaderClientQt::dispatchWillSendRequest):
+        (WebCore::FrameLoaderClientQt::dispatchDidReceiveResponse):
+        (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForMIMEType):
+        (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction):
+        (WebCore::FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction):
+        (WebCore::FrameLoaderClientQt::willUseArchive):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+
 2007-01-11  George Staikos  <staikos@kde.org>
 
         Fix Qt Build.
diff --git a/WebKitQt/QtLauncher/main.cpp b/WebKitQt/QtLauncher/main.cpp
index 0148e38..6fbc3e9 100644
--- a/WebKitQt/QtLauncher/main.cpp
+++ b/WebKitQt/QtLauncher/main.cpp
@@ -88,7 +88,9 @@
     // Initialize WebCore in Qt platform mode...
     Page* page = new Page(new ChromeClientQt(), new ContextMenuClientQt(),
                           new EditorClientQt());
-    Frame* frame = new FrameQt(page, 0, new FrameQtClient(), new FrameLoaderClientQt());
+    FrameLoaderClientQt *frameLoaderClient = new FrameLoaderClientQt();
+    FrameQt* frame = new FrameQt(page, 0, new FrameQtClient(), frameLoaderClient);
+    frameLoaderClient->setFrame(frame);
 
     FrameView* frameView = new FrameView(frame);
     frame->setView(frameView);
diff --git a/WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp
index caa014f..fecca8d 100644
--- a/WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -29,27 +29,33 @@
 #include "config.h"
 #include "FrameLoaderClientQt.h"
 #include "DocumentLoader.h"
+#include "ResourceResponse.h"
+#include "qdebug.h"
 
 #define notImplemented() do { fprintf(stderr, "FIXME: UNIMPLEMENTED: %s:%d (%s)\n", __FILE__, __LINE__, __FUNCTION__); } while(0)
 
+
 namespace WebCore
 {
 
 FrameLoaderClientQt::FrameLoaderClientQt()
+    : m_frame(0)
 {
-    notImplemented();
 }
 
 
 FrameLoaderClientQt::~FrameLoaderClientQt()
 {
-    notImplemented();
 }
 
+void FrameLoaderClientQt::setFrame(FrameQt *frame)
+{
+    m_frame = frame;
+}
 
 void FrameLoaderClientQt::detachFrameLoader()
 {
-    notImplemented();
+    m_frame = 0;
 }
 
 void FrameLoaderClientQt::ref()
@@ -118,13 +124,16 @@
 
 void FrameLoaderClientQt::makeDocumentView()
 {
-    notImplemented();
+    qDebug() << "FrameLoaderClientQt::makeDocumentView" << m_frame->document();
+    
+//     if (!m_frame->document()) 
+//         m_frame->loader()->createEmptyDocument();
 }
 
 
 void FrameLoaderClientQt::makeRepresentation(DocumentLoader*)
 {
-    notImplemented();
+    // don't need this for now I think.
 }
 
 
@@ -178,7 +187,7 @@
 
 void FrameLoaderClientQt::setCopiesOnScroll()
 {
-    notImplemented();
+    // apparently mac specific 
 }
 
 
@@ -277,7 +286,7 @@
 
 void FrameLoaderClientQt::dispatchDidStartProvisionalLoad()
 {
-    notImplemented();
+    // we're not interested in this neither I think
 }
 
 
@@ -313,14 +322,17 @@
 
 void FrameLoaderClientQt::cancelPolicyCheck()
 {
-    notImplemented();
+    // don't need to do anything here as long as we don't start doing asyncronous policy checks
 }
 
 
-void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction,
+void FrameLoaderClientQt::dispatchWillSubmitForm(FramePolicyFunction function,
                                                  PassRefPtr<FormState>)
 {
-    notImplemented();
+    // FIXME: This is surely too simple
+    if (!m_frame)
+        return;
+    (m_frame->loader()->*function)(PolicyUse);
 }
 
 
@@ -357,19 +369,19 @@
 
 void FrameLoaderClientQt::progressStarted()
 {
-    notImplemented();
+    // no progress notification for now
 }
 
 
 void FrameLoaderClientQt::progressCompleted()
 {
-    notImplemented();
+    // no progress notification for now
 }
 
 
-void FrameLoaderClientQt::setMainFrameDocumentReady(bool)
+void FrameLoaderClientQt::setMainFrameDocumentReady(bool b)
 {
-    notImplemented();
+    // this is only interesting once we provide an external API for the DOM
 }
 
 
@@ -418,21 +430,22 @@
 
 void FrameLoaderClientQt::clearArchivedResources()
 {
-    notImplemented();
+    // don't think we need to do anything here currently
 }
 
 
 bool FrameLoaderClientQt::canShowMIMEType(const String& MIMEType) const
 {
-    notImplemented();
-    return false;
+    // FIXME: This is not good enough in the general case
+    qDebug() << "FrameLoaderClientQt::canShowMIMEType" << MIMEType;
+    return true;
 }
 
 
-bool FrameLoaderClientQt::representationExistsForURLScheme(
-    const String& URLScheme) const
+bool FrameLoaderClientQt::representationExistsForURLScheme(const String& URLScheme) const
 {
     notImplemented();
+    qDebug() << "    scheme is" << URLScheme;
     return false;
 }
 
@@ -458,7 +471,7 @@
 
 void FrameLoaderClientQt::provisionalLoadStarted()
 {
-    notImplemented();
+    // don't need to do anything here
 }
 
 
@@ -483,7 +496,7 @@
 
 void FrameLoaderClientQt::prepareForDataSourceReplacement()
 {
-    notImplemented();
+    m_frame->loader()->detachChildren();
 }
 
 
@@ -505,12 +518,13 @@
 
 void FrameLoaderClientQt::frameLoaderDestroyed()
 {
-    notImplemented();
+    m_frame = 0;
+    delete this;
 }
 
 bool FrameLoaderClientQt::canHandleRequest(const WebCore::ResourceRequest&) const
 {
-    notImplemented();
+    return true;
 }
 
 void FrameLoaderClientQt::partClearedInBegin()
@@ -536,6 +550,7 @@
 bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem*) const
 {
     notImplemented();
+    return false;
 }
 
 void FrameLoaderClientQt::saveScrollPositionAndViewStateToItem(WebCore::HistoryItem*)
@@ -550,7 +565,8 @@
 
 bool FrameLoaderClientQt::canCachePage() const
 {
-    notImplemented();
+    // don't do any caching for now
+    return false;
 }
 
 void FrameLoaderClientQt::setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&)
@@ -558,44 +574,56 @@
     notImplemented();
 }
 
-void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader*, const char*, int)
+void FrameLoaderClientQt::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
 {
-    notImplemented();
+    qDebug() << "FrameLoaderClientQt::committedLoad" << length;
+    if (!m_frame)
+        return;
+    FrameLoader *fl = loader->frameLoader();
+    fl->setEncoding(m_response.textEncodingName(), false);
+    fl->addData(data, length);
 }
 
 WebCore::ResourceError FrameLoaderClientQt::cancelledError(const WebCore::ResourceRequest&)
 {
     notImplemented();
+    return ResourceError();
 }
 
 WebCore::ResourceError FrameLoaderClientQt::cannotShowURLError(const WebCore::ResourceRequest&)
 {
     notImplemented();
+    return ResourceError();
 }
 
 WebCore::ResourceError FrameLoaderClientQt::interruptForPolicyChangeError(const WebCore::ResourceRequest&)
 {
     notImplemented();
+    return ResourceError();
 }
 
 WebCore::ResourceError FrameLoaderClientQt::cannotShowMIMETypeError(const WebCore::ResourceResponse&)
 {
     notImplemented();
+    return ResourceError();
 }
 
 WebCore::ResourceError FrameLoaderClientQt::fileDoesNotExistError(const WebCore::ResourceResponse&)
 {
     notImplemented();
+    return ResourceError();
 }
 
 bool FrameLoaderClientQt::shouldFallBack(const WebCore::ResourceError&)
 {
     notImplemented();
+    return false;
 }
 
-WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoader(const WebCore::ResourceRequest&)
+WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClientQt::createDocumentLoader(const WebCore::ResourceRequest& request)
 {
-    notImplemented();
+    RefPtr<DocumentLoader> loader = new DocumentLoader(request);
+    return loader.release();
 }
 
 void FrameLoaderClientQt::download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
@@ -603,14 +631,18 @@
     notImplemented();
 }
 
-void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, void*, WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
+void FrameLoaderClientQt::dispatchWillSendRequest(WebCore::DocumentLoader*, void*, WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response)
 {
-    notImplemented();
+    // seems like the Mac code doesn't do anything here by default neither
+    qDebug() << "FrameLoaderClientQt::dispatchWillSendRequest" << request.isNull() << request.url().url();
 }
 
-void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, void*, const WebCore::ResourceResponse&)
+void FrameLoaderClientQt::dispatchDidReceiveResponse(WebCore::DocumentLoader*, void*, const WebCore::ResourceResponse& response)
 {
-    notImplemented();
+
+    m_response = response;
+    m_firstData = true;
+    qDebug() << "    got response from" << response.url().url();
 }
 
 void FrameLoaderClientQt::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, void*, int)
@@ -648,19 +680,28 @@
     notImplemented();
 }
 
-void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::String&, const WebCore::ResourceRequest&)
+void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String&, const WebCore::ResourceRequest&)
 {
-    notImplemented();
+    if (!m_frame)
+        return;
+    // FIXME: This is maybe too simple
+    (m_frame->loader()->*function)(PolicyUse);
 }
 
-void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&)
+void FrameLoaderClientQt::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&)
 {
-    notImplemented();
+    if (!m_frame)
+        return;
+    // FIXME: This is maybe too simple
+    (m_frame->loader()->*function)(PolicyIgnore);
 }
 
-void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::NavigationAction&, const WebCore::ResourceRequest&)
+void FrameLoaderClientQt::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&)
 {
-    notImplemented();
+    if (!m_frame)
+        return;
+    // FIXME: This is maybe too simple
+    (m_frame->loader()->*function)(PolicyUse);
 }
 
 void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::ResourceError&)
@@ -691,6 +732,7 @@
 bool FrameLoaderClientQt::willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL&) const
 {
     notImplemented();
+    return false;
 }
 
 
diff --git a/WebKitQt/WebCoreSupport/FrameLoaderClientQt.h b/WebKitQt/WebCoreSupport/FrameLoaderClientQt.h
index 1030831..224f1c3 100644
--- a/WebKitQt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKitQt/WebCoreSupport/FrameLoaderClientQt.h
@@ -33,6 +33,7 @@
 #include "FrameQt.h"
 #include "FrameLoader.h"
 #include "Shared.h"
+#include "ResourceResponse.h"
 
 namespace WebCore {
 
@@ -49,6 +50,7 @@
     public:
         FrameLoaderClientQt();
         ~FrameLoaderClientQt();
+        void setFrame(FrameQt *frame);
         virtual void detachFrameLoader();
 
         virtual void ref();
@@ -178,9 +180,9 @@
         virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
         virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
         virtual WebCore::Frame* dispatchCreatePage();
-        virtual void dispatchDecidePolicyForMIMEType(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::String&, const WebCore::ResourceRequest&);
-        virtual void dispatchDecidePolicyForNewWindowAction(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&);
-        virtual void dispatchDecidePolicyForNavigationAction(void (WebCore::FrameLoader::*)(WebCore::PolicyAction), const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
+        virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String&, const WebCore::ResourceRequest&);
+        virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String&);
+        virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
         virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
         virtual void incrementProgress(void*, const WebCore::ResourceResponse&);
         virtual void incrementProgress(void*, const char*, int);
@@ -190,7 +192,12 @@
 
         // FIXME: This should probably not be here, but it's needed for the tests currently
         virtual void partClearedInBegin();
-        
+
+
+    private:
+        Frame *m_frame;
+        ResourceResponse m_response;
+        bool m_firstData;
     };
 
 }
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 79a3d33..70f759d 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,12 @@
+2007-01-11  Lars Knoll <lars@trolltech.com>
+
+        Reviewed by Darin.
+
+        Adjust to loader changes.
+
+        * DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp:
+        (WebCore::DumpRenderTree::DumpRenderTree):
+
 2007-01-06  George Staikos  <staikos@kde.org>
 
         This doesn't build on all unix platforms!
diff --git a/WebKitTools/DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp
index ab49fcd..3a182b0 100644
--- a/WebKitTools/DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp
+++ b/WebKitTools/DumpRenderTree/DumpRenderTree.qtproj/DumpRenderTree.cpp
@@ -78,6 +78,7 @@
     // Initialize WebCore in Qt platform mode...
     Page* page = new Page(new ChromeClientQt(), new ContextMenuClientQt(), new EditorClientQt());
     m_frame = new FrameQt(page, 0, new FrameQtClient(), m_client);
+    m_client->setFrame(m_frame);
 
     FrameView* view = new FrameView(m_frame);
     view->setScrollbarsMode(ScrollbarAlwaysOff);