Reviewed and landed by ap.
Changed PlatformResponse handling for Qt. Don't just store
a QString object containing the data but a new PlatformResponseQt struct
containing data and url, and store it as pointer. This is compatible
to the OS X handling and removes the Qt plaform specific hacks from
CachedCSSStyleSheet, CachedResource & loader.
Add new file LoaderFunctionsQt, similar to LoaderFunctionsMac, and move
all methods from TemporaryLinkStubs related to loading in there, and implement
some like ServeSynchronousRequest (yay for xslt handling!).
* CMakeLists.txt:
* loader/CachedCSSStyleSheet.cpp:
(WebCore::CachedCSSStyleSheet::checkNotify):
* loader/CachedResource.h:
(WebCore::CachedResource::CachedResource):
* loader/loader.cpp:
(WebCore::Loader::receivedResponse):
* platform/ResourceLoaderClient.h:
* platform/ResourceLoaderInternal.h:
* platform/qt/FrameQt.cpp:
(WebCore::FrameQt::~FrameQt):
(WebCore::FrameQt::createEmptyDocument):
* platform/qt/FrameQt.h:
(WebCore::QtFrame):
* platform/qt/FrameQtClient.cpp:
(WebCore::FrameQtClientDefault::setFrame):
(WebCore::FrameQtClientDefault::openURL):
(WebCore::FrameQtClientDefault::loadFinished):
(WebCore::FrameQtClientDefault::receivedAllData):
* platform/qt/FrameQtClient.h:
* platform/qt/LoaderFunctionsQt.cpp: Added.
(WebCore::ServeSynchronousRequest):
(WebCore::NumberOfPendingOrLoadingRequests):
(WebCore::CheckIfReloading):
(WebCore::CheckCacheObjectStatus):
(WebCore::IsResponseURLEqualToURL):
(WebCore::ResponseURL):
(WebCore::ResponseMIMEType):
(WebCore::ResponseIsMultipart):
(WebCore::CacheObjectExpiresTime):
(WebCore::CachedResource::setResponse):
(WebCore::CachedResource::setAllData):
* platform/qt/ResourceLoaderManager.cpp:
(WebCore::ResourceLoaderManager::remove):
* platform/qt/ResourceLoaderQt.cpp:
(WebCore::ResourceLoader::~ResourceLoader):
(WebCore::ResourceLoader::start):
(WebCore::ResourceLoader::assembleResponseHeaders):
(WebCore::ResourceLoader::receivedResponse):
* platform/qt/TemporaryLinkStubs.cpp:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@17063
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
platform/FloatRect.cpp
platform/ResourceLoader.cpp
platform/Path.cpp
+ platform/qt/LoaderFunctionsQt.cpp
platform/qt/FileChooserQt.cpp
platform/qt/IconQt.cpp
platform/qt/AffineTransformQt.cpp
+2006-10-15 Nikolas Zimmermann <zimmermann@kde.org>
+
+ Reviewed and landed by ap.
+
+ Changed PlatformResponse handling for Qt. Don't just store
+ a QString object containing the data but a new PlatformResponseQt struct
+ containing data and url, and store it as pointer. This is compatible
+ to the OS X handling and removes the Qt plaform specific hacks from
+ CachedCSSStyleSheet, CachedResource & loader.
+
+ Add new file LoaderFunctionsQt, similar to LoaderFunctionsMac, and move
+ all methods from TemporaryLinkStubs related to loading in there, and implement
+ some like ServeSynchronousRequest (yay for xslt handling!).
+
+ * CMakeLists.txt:
+ * loader/CachedCSSStyleSheet.cpp:
+ (WebCore::CachedCSSStyleSheet::checkNotify):
+ * loader/CachedResource.h:
+ (WebCore::CachedResource::CachedResource):
+ * loader/loader.cpp:
+ (WebCore::Loader::receivedResponse):
+ * platform/ResourceLoaderClient.h:
+ * platform/ResourceLoaderInternal.h:
+ * platform/qt/FrameQt.cpp:
+ (WebCore::FrameQt::~FrameQt):
+ (WebCore::FrameQt::createEmptyDocument):
+ * platform/qt/FrameQt.h:
+ (WebCore::QtFrame):
+ * platform/qt/FrameQtClient.cpp:
+ (WebCore::FrameQtClientDefault::setFrame):
+ (WebCore::FrameQtClientDefault::openURL):
+ (WebCore::FrameQtClientDefault::loadFinished):
+ (WebCore::FrameQtClientDefault::receivedAllData):
+ * platform/qt/FrameQtClient.h:
+ * platform/qt/LoaderFunctionsQt.cpp: Added.
+ (WebCore::ServeSynchronousRequest):
+ (WebCore::NumberOfPendingOrLoadingRequests):
+ (WebCore::CheckIfReloading):
+ (WebCore::CheckCacheObjectStatus):
+ (WebCore::IsResponseURLEqualToURL):
+ (WebCore::ResponseURL):
+ (WebCore::ResponseMIMEType):
+ (WebCore::ResponseIsMultipart):
+ (WebCore::CacheObjectExpiresTime):
+ (WebCore::CachedResource::setResponse):
+ (WebCore::CachedResource::setAllData):
+ * platform/qt/ResourceLoaderManager.cpp:
+ (WebCore::ResourceLoaderManager::remove):
+ * platform/qt/ResourceLoaderQt.cpp:
+ (WebCore::ResourceLoader::~ResourceLoader):
+ (WebCore::ResourceLoader::start):
+ (WebCore::ResourceLoader::assembleResponseHeaders):
+ (WebCore::ResourceLoader::receivedResponse):
+ * platform/qt/TemporaryLinkStubs.cpp:
+
2006-10-14 Rob Buis <buis@kde.org>
Reviewed by Mitz.
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next()) {
-#if !PLATFORM(QT)
if (m_response && !IsResponseURLEqualToURL(m_response, m_url))
-#else
- if (!m_response.isEmpty() && !IsResponseURLEqualToURL(m_response, m_url))
-#endif
c->setCSSStyleSheet(ResponseURL(m_response), m_decoder->encoding().name(), m_sheet);
else
c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);
m_free = false;
m_cachePolicy = cachePolicy;
m_request = 0;
-#if !PLATFORM(QT)
m_response = 0;
-#endif
m_allData = 0;
m_expireDate = expireDate;
m_deleted = false;
{
Request* req = m_requestsLoading.get(job);
ASSERT(req);
-#if !PLATFORM(QT)
ASSERT(response);
-#else
- ASSERT(!response.isEmpty());
-#endif
req->cachedObject()->setResponse(response);
req->cachedObject()->setExpireDate(CacheObjectExpiresTime(req->docLoader(), response), false);
#if PLATFORM(QT)
#include <QString>
+#include <wtf/RefPtr.h>
+
+#include "Shared.h"
#endif
namespace WebCore {
typedef NSData* PlatformData;
typedef NSURLResponse* PlatformResponse;
#elif PLATFORM(QT)
+ class PlatformResponseQt : public Shared<PlatformResponseQt> {
+ public:
+ QString data;
+ QString url;
+ };
+
typedef void* PlatformData;
- typedef QString PlatformResponse;
+ typedef RefPtr<PlatformResponseQt> PlatformResponse;
#else
// Not sure what the strategy for this will be on other platforms.
typedef struct PlatformDataStruct* PlatformData;
#if PLATFORM(QT)
QString m_charset;
QString m_mimetype;
- QString m_response;
+ PlatformResponse m_response;
#endif
};
FrameQt::~FrameQt()
{
- closeURL();
-
setView(0);
clearRecordedFormValues();
+
+ cancelAndClear();
}
bool FrameQt::openURL(const KURL& url)
void FrameQt::createEmptyDocument()
{
- // FIXME: Implement like described in this comment from FrameMac:
- //
// 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.
+
+ // Force creation.
+ if (!d->m_doc) {
+ begin();
+ end();
+ }
}
Range* FrameQt::markedTextRange() const
};
+inline FrameQt* QtFrame(Frame* frame) { return static_cast<FrameQt*>(frame); }
+inline const FrameQt* QtFrame(const Frame* frame) { return static_cast<const FrameQt*>(frame); }
+
}
#endif
void FrameQtClientDefault::setFrame(const FrameQt* frame)
{
- Q_ASSERT(frame != 0);
+ ASSERT(frame != 0);
m_frame = const_cast<FrameQt*>(frame);
}
void FrameQtClientDefault::openURL(const KURL& url)
{
+ ASSERT(m_frame);
+
m_frame->didOpenURL(url);
m_assignedMimetype = false;
return false;
}
+void FrameQtClientDefault::loadFinished() const
+{
+ // no-op
+}
+
void FrameQtClientDefault::receivedResponse(ResourceLoader*, PlatformResponse)
{
// no-op
{
m_frame->end();
m_assignedMimetype = false;
+
+ loadFinished();
}
}
virtual bool personalbarVisible() const = 0;
virtual bool locationbarVisible() const = 0;
+ virtual void loadFinished() const = 0;
+
virtual void runJavaScriptAlert(String const& message) = 0;
virtual bool runJavaScriptConfirm(const String& message) = 0;
virtual bool runJavaScriptPrompt(const String& message, const String& defaultValue, String& result) = 0;
virtual bool personalbarVisible() const;
virtual bool locationbarVisible() const;
+ virtual void loadFinished() const;
+
// ResourceLoaderClient
virtual void receivedResponse(ResourceLoader*, PlatformResponse);
virtual void receivedData(ResourceLoader*, const char*, int);
--- /dev/null
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <wtf/Vector.h>
+#include <kio/netaccess.h>
+
+#include <QFile>
+
+#include "Cache.h"
+#include "loader.h"
+#include "FrameQt.h"
+#include "DocLoader.h"
+#include "CachedResource.h"
+#include "DeprecatedString.h"
+
+namespace WebCore {
+
+Vector<char> ServeSynchronousRequest(Loader*, DocLoader* docLoader, ResourceLoader*, KURL& url, DeprecatedString&)
+{
+ // FIXME: Handle last paremeter: "responseHeaders"
+ FrameQt* frame = QtFrame(docLoader->frame());
+
+ if (!frame)
+ return Vector<char>();
+
+ // FIXME: We shouldn't use temporary files for sync jobs!
+ QString tempFile;
+ if (!KIO::NetAccess::download(KUrl(url.url()), tempFile, 0))
+ return Vector<char>();
+
+ QFile file(tempFile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ KIO::NetAccess::removeTempFile(tempFile);
+ return Vector<char>();
+ }
+
+ ASSERT(!file.atEnd());
+
+ QByteArray content = file.readAll();
+ KIO::NetAccess::removeTempFile(tempFile);
+
+ Vector<char> resultBuffer;
+ resultBuffer.append(content.data(), content.size());
+
+ return resultBuffer;
+}
+
+int NumberOfPendingOrLoadingRequests(DocLoader* docLoader)
+{
+ return Cache::loader()->numRequests(docLoader);
+}
+
+bool CheckIfReloading(WebCore::DocLoader* docLoader)
+{
+ // FIXME: Needs a real implementation!
+ return false;
+}
+
+void CheckCacheObjectStatus(DocLoader* docLoader, CachedResource* cachedObject)
+{
+ // Return from the function for objects that we didn't load from the cache.
+ if (!cachedObject)
+ return;
+
+ switch (cachedObject->status()) {
+ case CachedResource::Persistent:
+ case CachedResource::Cached:
+ case CachedResource::Uncacheable:
+ break;
+ case CachedResource::NotCached:
+ case CachedResource::Unknown:
+ case CachedResource::New:
+ case CachedResource::Pending:
+ return;
+ }
+
+ ASSERT(cachedObject->response());
+
+ // FIXME: Notify the caller that we "loaded".
+}
+
+bool IsResponseURLEqualToURL(PlatformResponse response, const String& url)
+{
+ if (!response)
+ return false;
+
+ return response->url == QString(url);
+}
+
+DeprecatedString ResponseURL(PlatformResponse response)
+{
+ if (!response)
+ return DeprecatedString();
+
+ return response->url;
+}
+
+DeprecatedString ResponseMIMEType(PlatformResponse)
+{
+ // FIXME: Store the response mime type in QtPlatformResponse!
+ return DeprecatedString();
+}
+
+bool ResponseIsMultipart(PlatformResponse response)
+{
+ return ResponseMIMEType(response) == "multipart/x-mixed-replace";
+}
+
+time_t CacheObjectExpiresTime(DocLoader*, PlatformResponse)
+{
+ // FIXME: Implement me!
+ return 0;
+}
+
+void CachedResource::setResponse(PlatformResponse response)
+{
+ m_response = response;
+}
+
+void CachedResource::setAllData(PlatformData allData)
+{
+ m_allData = allData;
+}
+
+} // namespace WebCore
// Will take care of informing our client...
// This must be called before receivedAllData(),
// otherwhise assembleResponseHeaders() is called too early...
- job->receivedResponse(headers);
+ RefPtr<PlatformResponseQt> response(new PlatformResponseQt());
+ response->data = headers;
+ response->url = job->url().url();
+
+ job->receivedResponse(response);
}
d->client->receivedAllData(job, 0);
#include <kio/job.h>
+#include "FrameQt.h"
#include "DocLoader.h"
#include "ResourceLoader.h"
#include "DeprecatedString.h"
ResourceLoader::~ResourceLoader()
{
cancel();
+ delete d;
}
-bool ResourceLoader::start(DocLoader*)
+bool ResourceLoader::start(DocLoader* docLoader)
{
ref();
+ d->m_loading = true;
+
+ if (docLoader) {
+ FrameQt* frame = QtFrame(docLoader->frame());
+ if (!frame ) {
+ kill();
+ return false;
+ }
+ }
+
ResourceLoaderManager::self()->add(this);
return true;
}
void ResourceLoader::assembleResponseHeaders() const
{
if (!d->assembledResponseHeaders) {
- d->responseHeaders = d->m_response;
+ ASSERT(d->m_response);
+
+ d->responseHeaders = d->m_response->data;
d->assembledResponseHeaders = true;
- d->m_response = QString(); // Reset
}
}
}
}
-void ResourceLoader::receivedResponse(QString response)
+void ResourceLoader::receivedResponse(PlatformResponse response)
{
Q_ASSERT(method() == "POST");
IconDatabase* IconDatabase::sharedIconDatabase() { return 0; }
bool IconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL) { return false; }
-void CheckCacheObjectStatus(DocLoader*, CachedResource*) { }
-bool CheckIfReloading(WebCore::DocLoader*) { return false; }
-Vector<char> ServeSynchronousRequest(Loader*, DocLoader*, ResourceLoader*, KURL&, DeprecatedString&) { notImplemented(); return Vector<char>(); }
-time_t CacheObjectExpiresTime(DocLoader*, PlatformResponse) { return 0; }
-bool ResponseIsMultipart(PlatformResponse) { return false; }
-DeprecatedString ResponseMIMEType(PlatformResponse) { return DeprecatedString(); }
-bool IsResponseURLEqualToURL(PlatformResponse , const String& URL) { return false; }
-DeprecatedString ResponseURL(PlatformResponse) { return DeprecatedString(); }
-void CachedResource::setResponse(PlatformResponse) { }
-void CachedResource::setAllData(PlatformData) { }
}
bool WebCore::historyContains(DeprecatedString const&) { return false; }