2006-10-20 Nikolas Zimmermann <zimmermann@kde.org>
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 19:14:00 +0000 (19:14 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Oct 2006 19:14:00 +0000 (19:14 +0000)
        Reviewed and landed by Anders.

        Offer a way for WebKitPart to be able to detect when
        the webpage has been completly loaded (including subresources).

        Also fix Qt/Linux build by removing PopupMenu.cpp from CMakeLists.txt
        and removing some functions from PopupMenuQt.cpp, and alter FrameQt.cpp.

        * CMakeLists.txt:
        * platform/qt/FrameQt.cpp:
        (WebCore::FrameQt::submitForm):
        (WebCore::FrameQt::client):
        * platform/qt/FrameQt.h:
        * platform/qt/FrameQtClient.cpp:
        (WebCore::FrameQtClientDefault::setFrame):
        (WebCore::FrameQtClientDefault::openURL):
        (WebCore::FrameQtClientDefault::submitForm):
        (WebCore::FrameQtClientDefault::checkLoaded):
        (WebCore::FrameQtClientDefault::traverseNextFrameStayWithin):
        (WebCore::FrameQtClientDefault::numPendingOrLoadingRequests):
        (WebCore::FrameQtClientDefault::receivedAllData):
        * platform/qt/FrameQtClient.h:
        * platform/qt/LoaderFunctionsQt.cpp:
        (WebCore::CheckCacheObjectStatus):
        * platform/qt/PopupMenuQt.cpp:
        * platform/qt/ResourceLoaderManager.cpp:
        (WebCore::ResourceLoaderManager::ResourceLoaderManager):
        (WebCore::ResourceLoaderManager::slotResult):
        (WebCore::ResourceLoaderManager::add):
        * platform/qt/ResourceLoaderManager.h:
        * platform/qt/ResourceLoaderQt.cpp:
        (WebCore::ResourceLoader::start):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17165 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/platform/qt/FrameQt.cpp
WebCore/platform/qt/FrameQt.h
WebCore/platform/qt/FrameQtClient.cpp
WebCore/platform/qt/FrameQtClient.h
WebCore/platform/qt/LoaderFunctionsQt.cpp
WebCore/platform/qt/PopupMenuQt.cpp
WebCore/platform/qt/ResourceLoaderManager.cpp
WebCore/platform/qt/ResourceLoaderManager.h
WebCore/platform/qt/ResourceLoaderQt.cpp

index eb3530e168ada0b4f392da9f16a4ed2350c494bd..d413834277a56c55b5857b2995a6fd14ac8beb10 100644 (file)
@@ -1076,7 +1076,6 @@ set(WebCore_SRCS
     platform/GlyphMap.cpp
     platform/Font.cpp
     platform/FontData.cpp
-    platform/PopupMenu.cpp
     rendering/RenderCounter.cpp
     rendering/CounterNode.cpp
     rendering/CounterResetNode.cpp
index 8440144211b5927e576eba33f341ec29713535d8..72ae620f490c3a04d796bcf7c8f2765e991e239b 100644 (file)
@@ -1,3 +1,38 @@
+2006-10-20  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed and landed by Anders.
+
+        Offer a way for WebKitPart to be able to detect when
+        the webpage has been completly loaded (including subresources).
+
+        Also fix Qt/Linux build by removing PopupMenu.cpp from CMakeLists.txt
+        and removing some functions from PopupMenuQt.cpp, and alter FrameQt.cpp.
+
+        * CMakeLists.txt:
+        * platform/qt/FrameQt.cpp:
+        (WebCore::FrameQt::submitForm):
+        (WebCore::FrameQt::client):
+        * platform/qt/FrameQt.h:
+        * platform/qt/FrameQtClient.cpp:
+        (WebCore::FrameQtClientDefault::setFrame):
+        (WebCore::FrameQtClientDefault::openURL):
+        (WebCore::FrameQtClientDefault::submitForm):
+        (WebCore::FrameQtClientDefault::checkLoaded):
+        (WebCore::FrameQtClientDefault::traverseNextFrameStayWithin):
+        (WebCore::FrameQtClientDefault::numPendingOrLoadingRequests):
+        (WebCore::FrameQtClientDefault::receivedAllData):
+        * platform/qt/FrameQtClient.h:
+        * platform/qt/LoaderFunctionsQt.cpp:
+        (WebCore::CheckCacheObjectStatus):
+        * platform/qt/PopupMenuQt.cpp:
+        * platform/qt/ResourceLoaderManager.cpp:
+        (WebCore::ResourceLoaderManager::ResourceLoaderManager):
+        (WebCore::ResourceLoaderManager::slotResult):
+        (WebCore::ResourceLoaderManager::add):
+        * platform/qt/ResourceLoaderManager.h:
+        * platform/qt/ResourceLoaderQt.cpp:
+        (WebCore::ResourceLoader::start):
+
 2006-10-20  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Geoff.
index 016a437b925321dbb2073e0e3fd4fa74944a0c33..8d603f8de092e017df8bc6412b0b961c3817be16 100644 (file)
@@ -143,12 +143,12 @@ void FrameQt::submitForm(const FrameLoadRequest& frameLoadRequest)
     d->m_submittedFormURL = request.url();
 
     if (m_client)
-        m_client->submitForm(request.doPost() ? "POST" : "GET", request.url(), &request.postData);
+        m_client->submitForm(request.httpMethod(), request.url(), &request.httpBody());
 
     clearRecordedFormValues();
 }
 
-void FrameQt::urlSelected(const FrameLoadRequest& frameLoadRequest)
+void FrameQt::urlSelected(const FrameLoadRequest& frameLoadRequest, const Event*)
 {
     ResourceRequest request = frameLoadRequest.m_request;
 
@@ -305,7 +305,7 @@ void FrameQt::restoreDocumentState()
 
 void FrameQt::openURLRequest(const FrameLoadRequest& request)
 {
-    urlSelected(request);
+    urlSelected(request, 0);
 }
 
 void FrameQt::scheduleClose()
@@ -564,6 +564,11 @@ void FrameQt::tokenizerProcessedData()
         checkCompleted();
 }
 
+FrameQtClient* FrameQt::client() const
+{
+    return m_client;
+}
+
 }
 
 // vim: ts=4 sw=4 et
index cd8950aa7cb681c7590d09504664b1005988ceb2..6518a9ce90ea8101d7ad27a327953ad16a9a0d5b 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual bool openURL(const KURL&);
     virtual void openURLRequest(const FrameLoadRequest&);
     virtual void submitForm(const FrameLoadRequest&);
-    virtual void urlSelected(const FrameLoadRequest&);
+    virtual void urlSelected(const FrameLoadRequest&, const Event*);
 
     virtual void setTitle(const String&);
 
@@ -134,6 +134,8 @@ public:
 
     virtual void tokenizerProcessedData();
 
+    FrameQtClient* client() const;
+
 private:
     void init();
 
index f56844f3ecf19a2fa99b4dbce1153ec40beecae0..27687b25e94056200cffc6520f7796928b6e72d3 100644 (file)
 #include "FrameQtClient.h"
 
 #include "FrameQt.h"
+#include "Document.h"
+#include "FrameTree.h"
 #include "ResourceLoader.h"
+#include "LoaderFunctions.h"
 #include "ResourceLoaderInternal.h"
 
 #include <kstdguiitem.h>
@@ -52,7 +55,7 @@ FrameQtClientDefault::~FrameQtClientDefault()
 
 void FrameQtClientDefault::setFrame(const FrameQt* frame)
 {
-    ASSERT(frame != 0);
+    ASSERT(frame);
     m_frame = const_cast<FrameQt*>(frame);
 }
 
@@ -64,15 +67,27 @@ void FrameQtClientDefault::openURL(const KURL& url)
     m_assignedMimetype = false;
 
     RefPtr<ResourceLoader> loader = ResourceLoader::create(this, "GET", url);
-    loader->start(0);
+    loader->start(m_frame->document() ? m_frame->document()->docLoader() : 0);
 }
 
 void FrameQtClientDefault::submitForm(const String& method, const KURL& url, const FormData* postData)
 {
+    ASSERT(m_frame);
+
     m_assignedMimetype = false;
 
     RefPtr<ResourceLoader> loader = ResourceLoader::create(this, method, url, *postData);
-    loader->start(0);
+    loader->start(m_frame->document() ? m_frame->document()->docLoader() : 0);
+}
+
+void FrameQtClientDefault::checkLoaded()
+{
+    ASSERT(m_frame && m_frame->document() && m_frame->document()->docLoader());
+
+    // Recursively check the frame tree for open requests...
+    int num = numPendingOrLoadingRequests(true);
+    if (!num)
+        loadFinished();
 }
 
 void FrameQtClientDefault::runJavaScriptAlert(String const& message)
@@ -150,12 +165,29 @@ void FrameQtClientDefault::receivedData(ResourceLoader* job, const char* data, i
     m_frame->write(data, length);
 }
 
+FrameQt* FrameQtClientDefault::traverseNextFrameStayWithin(FrameQt* frame) const
+{
+    return QtFrame(m_frame->tree()->traverseNext(frame));
+}
+
+int FrameQtClientDefault::numPendingOrLoadingRequests(bool recurse) const
+{
+    if (!recurse)
+        return NumberOfPendingOrLoadingRequests(m_frame->document()->docLoader());
+
+    int num = 0;
+    for (FrameQt* frame = m_frame; frame != 0; frame = traverseNextFrameStayWithin(frame))
+        num += NumberOfPendingOrLoadingRequests(frame->document()->docLoader());
+
+    return num;
+}
+
 void FrameQtClientDefault::receivedAllData(ResourceLoader* job, PlatformData data)
 {
+    ASSERT(m_frame);
+  
     m_frame->end();
     m_assignedMimetype = false;
-
-    loadFinished();
 }
 
 }
index 10550b7a15bcca421351ef5729d02ffed4deb77c..b648fd968d9a444fc75bf2a46a327f0b8a959ed2 100644 (file)
@@ -45,6 +45,10 @@ public:
     virtual void openURL(const KURL&) = 0;
     virtual void submitForm(const String& method, const KURL&, const FormData*) = 0;
 
+    // This is invoked after any ResourceLoader is done,
+    // to check wheter all items to be loaded are finished.
+    virtual void checkLoaded() = 0;
+
     // WebKitPart / DumpRenderTree want to handle this differently.
     virtual bool menubarVisible() const = 0;
     virtual bool toolbarVisible() const = 0;
@@ -72,6 +76,8 @@ public:
     virtual void openURL(const KURL&);
     virtual void submitForm(const String& method, const KURL&, const FormData*);
 
+    virtual void checkLoaded();
+
     virtual void runJavaScriptAlert(String const& message);
     virtual bool runJavaScriptConfirm(const String& message);
     virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result);
@@ -90,6 +96,10 @@ public:
     virtual void receivedAllData(ResourceLoader*, PlatformData);
 
 private:
+    // Internal helpers
+    FrameQt* traverseNextFrameStayWithin(FrameQt*) const;
+    int numPendingOrLoadingRequests(bool recurse) const;
+
     FrameQt* m_frame;
     bool m_assignedMimetype : 1;
 };
index ff6eb9754be0b5955bfcf4d56760059c39bb692d..4fd91c123b0982a36b2b248c33e662e7eeffba8c 100644 (file)
@@ -98,7 +98,7 @@ void CheckCacheObjectStatus(DocLoader* docLoader, CachedResource* cachedObject)
             return;
     }
 
-    ASSERT(cachedObject->response());
+    // FIXME: Doesn't work at the moment! ASSERT(cachedObject->response());
 
     // FIXME: Notify the caller that we "loaded".
 }
index 33b179d8dbb4bfee03011d19e8d980a498055477..a509d3d8db1b9804ed70347821b7f78fed6f01cf 100644 (file)
@@ -39,16 +39,6 @@ PopupMenu::~PopupMenu()
 {
 }
 
-void PopupMenu::clear()
-{
-    notImplemented();
-}
-
-void PopupMenu::populate()
-{
-    notImplemented();
-}
-
 void PopupMenu::show(const IntRect&, FrameView*, int)
 {
     notImplemented();
@@ -59,21 +49,6 @@ void PopupMenu::hide()
     notImplemented();
 }
 
-void PopupMenu::addSeparator()
-{
-    notImplemented();
-}
-
-void PopupMenu::addGroupLabel(HTMLOptGroupElement*)
-{
-    notImplemented();
-}
-
-void PopupMenu::addOption(HTMLOptionElement*)
-{
-    notImplemented();
-}
-
 }
 
 // vim: ts=4 sw=4 et
index 3a9722bfe121e184adf2c62fb52135c8ef002918..f4bef87fcf36c8e0f1eaa58eff0b1943a79967d1 100644 (file)
@@ -40,6 +40,7 @@ static ResourceLoaderManager* s_self = 0;
 ResourceLoaderManager::ResourceLoaderManager()
     : m_jobToKioMap()
     , m_kioToJobMap()
+    , m_frameClient(0)
 {
 }
 
@@ -111,6 +112,9 @@ void ResourceLoaderManager::slotResult(KJob* kjob)
 
     job->setError(kjob->error());
     remove(job);
+
+    ASSERT(m_frameClient);
+    m_frameClient->checkLoaded();
 }
 
 void ResourceLoaderManager::remove(ResourceLoader* job)
@@ -150,7 +154,7 @@ void ResourceLoaderManager::remove(ResourceLoader* job)
     m_kioToJobMap.remove(kioJob);
 }
 
-void ResourceLoaderManager::add(ResourceLoader* job)
+void ResourceLoaderManager::add(ResourceLoader* job, FrameQtClient* frameClient)
 {
     ResourceLoaderInternal* d = job->getInternal();
     DeprecatedString url = d->URL.url();
@@ -176,6 +180,11 @@ void ResourceLoaderManager::add(ResourceLoader* job)
 
     m_jobToKioMap.insert(job, kioJob);
     m_kioToJobMap.insert(kioJob, job);
+
+    if (!m_frameClient)
+        m_frameClient = frameClient;
+    else
+        ASSERT(m_frameClient == frameClient);
 }
 
 void ResourceLoaderManager::cancel(ResourceLoader* job)
index e3b1d812ced7126a5bb0aeefb8ab63593c0952f1..5b383b44b65455b3d5aa186ade58e954541f1e8e 100644 (file)
 #include <QMap>
 #include <QObject>
 
-#include "Frame.h"
-#include "Timer.h"
 #include "ResourceLoader.h"
 
 namespace WebCore {
 
+class FrameQtClient;
+
 class ResourceLoaderManager : public QObject {
 Q_OBJECT
 public:
     static ResourceLoaderManager* self();
 
-    void add(ResourceLoader*);
+    void add(ResourceLoader*, FrameQtClient*);
     void cancel(ResourceLoader*);
 
 public Q_SLOTS:
@@ -59,6 +59,8 @@ private:
     // KIO Job <-> WebKit Job mapping
     QMap<ResourceLoader*, KIO::Job*> m_jobToKioMap;
     QMap<KIO::Job*, ResourceLoader*> m_kioToJobMap;
+
+    FrameQtClient* m_frameClient;
 };
 
 }
index 104170629ccc4f9e467fd24445e4405f8334a014..3d1734200c7a206836a63c17206e736dd07a3d7a 100644 (file)
@@ -53,15 +53,13 @@ bool ResourceLoader::start(DocLoader* docLoader)
     ref();
     d->m_loading = true;
 
+    FrameQt* frame = 0;
     if (docLoader) {
-        FrameQt* frame = QtFrame(docLoader->frame());
-        if (!frame ) {
-            kill();
-            return false;
-        }
+        frame = QtFrame(docLoader->frame());
+        ASSERT(frame);
     }
 
-    ResourceLoaderManager::self()->add(this);
+    ResourceLoaderManager::self()->add(this, frame ? frame->client() : 0);
     return true;
 }