+2006-11-03 Zack Rusin <zack@kde.org>
+
+ Reviewed by Hyatt. Landed by Maciej.
+
+ Adding setPlatformPen/setPlatformFont/setPlatformFillColor
+ to graphics context to be able to set consistant state
+ on the platform specific painter without having to change
+ fill/stroke/font on every operation. This fixes color/stroke/fill
+ and font handling in the Qt port.
+
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::setFont):
+ (WebCore::GraphicsContext::setPen):
+ (WebCore::GraphicsContext::setFillColor):
+ (WebCore::GraphicsContext::setPlatformPen):
+ (WebCore::GraphicsContext::setPlatformFillColor):
+ (WebCore::GraphicsContext::setPlatformFont):
+ * platform/graphics/GraphicsContext.h:
+ * platform/qt/GraphicsContextQt.cpp:
+ (WebCore::toQtCompositionMode):
+ (WebCore::toQtLineCap):
+ (WebCore::toQtLineJoin):
+ (WebCore::toQPenStyle):
+ (WebCore::penToQPen):
+ (WebCore::TransparencyLayer::TransparencyLayer):
+ (WebCore::GraphicsContext::addRoundedRectClip):
+ (WebCore::GraphicsContext::setPlatformFont):
+ (WebCore::GraphicsContext::setPlatformPen):
+ (WebCore::GraphicsContext::setPlatformFillColor):
+ * platform/qt/ScrollViewCanvasQt.cpp:
+ (WebCore::ScrollViewCanvasQt::ScrollViewCanvasQt):
+ (WebCore::ScrollViewCanvasQt::paintEvent):
+ (WebCore::ScrollViewCanvasQt::handleKeyEvent):
+ * platform/qt/ScrollViewCanvasQt.h:
+
2006-11-02 Adele Peterson <adele@apple.com>
Reviewed by Anders.
51F11E150A48C2920034A24E /* SQLTransaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51F11E140A48C2920034A24E /* SQLTransaction.cpp */; };
550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
550A0BCA085F6039007353D6 /* QualifiedName.h in Headers */ = {isa = PBXBuildFile; fileRef = 550A0BC8085F6039007353D6 /* QualifiedName.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 650E3F690AF6C168001FA3AD /* ResourceRequestMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 650E3F670AF6C168001FA3AD /* ResourceRequestMac.h */; };
+ 650E3F6A0AF6C168001FA3AD /* ResourceRequestMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 650E3F680AF6C168001FA3AD /* ResourceRequestMac.mm */; };
650F53DC09D15DDA00C9B0C8 /* CSSGrammar.h in Headers */ = {isa = PBXBuildFile; fileRef = 650F53DB09D15DDA00C9B0C8 /* CSSGrammar.h */; };
650F53DD09D15DDF00C9B0C8 /* CSSGrammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6565814409D13043000E61D7 /* CSSGrammar.cpp */; };
651B4D8509AC83370029F1EF /* DeprecatedStringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 651B4D8309AC83370029F1EF /* DeprecatedStringList.cpp */; };
6550B6A6099DF0270090D781 /* Text.h in Headers */ = {isa = PBXBuildFile; fileRef = 6550B69C099DF0270090D781 /* Text.h */; settings = {ATTRIBUTES = (Private, ); }; };
6552E7AA096AA11B0006F248 /* WebCoreFrameNamespaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 6552E7A8096AA11B0006F248 /* WebCoreFrameNamespaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
6552E7AB096AA11B0006F248 /* WebCoreFrameNamespaces.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6552E7A9096AA11B0006F248 /* WebCoreFrameNamespaces.mm */; };
- 655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 655A81BD0AEF67E6000975F0 /* HTTPHeaderMap.h */; };
+ 655A81BE0AEF67E6000975F0 /* HTTPHeaderMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 655A81BD0AEF67E6000975F0 /* HTTPHeaderMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
6563A9A70ADF4094000ED2CD /* LoaderNSURLRequestExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 6563A9A50ADF4094000ED2CD /* LoaderNSURLRequestExtras.h */; };
6563A9A80ADF4094000ED2CD /* LoaderNSURLRequestExtras.m in Sources */ = {isa = PBXBuildFile; fileRef = 6563A9A60ADF4094000ED2CD /* LoaderNSURLRequestExtras.m */; };
656580F409D12B20000E61D7 /* CSSPropertyNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 656580EF09D12B20000E61D7 /* CSSPropertyNames.h */; };
6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */; };
6582A17809999EA000BEEB6D /* DeprecatedStringMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */; };
658436860AE01B7400E53753 /* FrameLoadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 658436850AE01B7400E53753 /* FrameLoadRequest.h */; };
- 658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821650AF4CDF700F01D1F /* ResourceResponse.h */; };
+ 658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821650AF4CDF700F01D1F /* ResourceResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 658821680AF4CE1200F01D1F /* ResourceResponseMac.h */; };
6588216C0AF4CE1200F01D1F /* ResourceResponseMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */; };
65901A4409FC6039005BD752 /* WebCoreStringTruncator.h in Headers */ = {isa = PBXBuildFile; fileRef = 65901A4209FC6039005BD752 /* WebCoreStringTruncator.h */; settings = {ATTRIBUTES = (Private, ); }; };
55998A5B052B59CC0017A6C1 /* WebCoreAXObject.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreAXObject.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
55998A5C052B59CC0017A6C1 /* AXObjectCache.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AXObjectCache.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
55998A5D052B59CC0017A6C1 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+ 650E3F670AF6C168001FA3AD /* ResourceRequestMac.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceRequestMac.h; sourceTree = "<group>"; };
+ 650E3F680AF6C168001FA3AD /* ResourceRequestMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceRequestMac.mm; sourceTree = "<group>"; };
650F53DB09D15DDA00C9B0C8 /* CSSGrammar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSGrammar.h; sourceTree = "<group>"; };
651B4D8309AC83370029F1EF /* DeprecatedStringList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedStringList.cpp; sourceTree = "<group>"; };
651B4D8409AC83370029F1EF /* DeprecatedStringList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DeprecatedStringList.h; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
656B84EA0AEA1DDA00A095B4 /* ResourceHandleMac.mm */,
+ 650E3F670AF6C168001FA3AD /* ResourceRequestMac.h */,
+ 650E3F680AF6C168001FA3AD /* ResourceRequestMac.mm */,
658821680AF4CE1200F01D1F /* ResourceResponseMac.h */,
658821690AF4CE1200F01D1F /* ResourceResponseMac.mm */,
);
93E22A730AF5E94C00D48324 /* PageState.h in Headers */,
658821660AF4CDF700F01D1F /* ResourceResponse.h in Headers */,
6588216B0AF4CE1200F01D1F /* ResourceResponseMac.h in Headers */,
+ 650E3F690AF6C168001FA3AD /* ResourceRequestMac.h in Headers */,
93CCF0270AF6C52900018E89 /* NavigationAction.h in Headers */,
B2A015A90AF6CD53006BCE0E /* GraphicsContext.h in Headers */,
B2A015AB0AF6CD53006BCE0E /* GraphicsTypes.h in Headers */,
93E227E30AF589AD00D48324 /* ResourceLoader.cpp in Sources */,
93E227E40AF589AD00D48324 /* SubresourceLoader.cpp in Sources */,
93E22A6F0AF5E94100D48324 /* PageState.cpp in Sources */,
+ 650E3F6A0AF6C168001FA3AD /* ResourceRequestMac.mm in Sources */,
93CCF0580AF6C9FE00018E89 /* NavigationActionMac.mm in Sources */,
93CCF0600AF6CA7600018E89 /* NavigationAction.cpp in Sources */,
B2A015A80AF6CD53006BCE0E /* GraphicsContext.cpp in Sources */,
return NO;
*data = resource->allData();
- *response = resource->response();
+ *response = resource->platformResponse();
return YES;
}
HashMap<String, CachedResource*>::const_iterator end = allResources.end();
for (HashMap<String, CachedResource*>::const_iterator it = allResources.begin(); it != end; ++it) {
[d addObject:it->second->allData()];
- [r addObject:it->second->response()];
+ [r addObject:it->second->platformResponse()];
}
*datas = [d autorelease];
return;
CachedResourceClientWalker w(m_clients);
- while (CachedResourceClient *c = w.next()) {
- if (m_response && !IsResponseURLEqualToURL(m_response, m_url))
- c->setCSSStyleSheet(ResponseURL(m_response), m_decoder->encoding().name(), m_sheet);
- else
- c->setCSSStyleSheet(m_url, m_decoder->encoding().name(), m_sheet);
- }
+ while (CachedResourceClient *c = w.next())
+ c->setCSSStyleSheet(m_response.url().url(), m_decoder->encoding().name(), m_sheet);
}
void CachedCSSStyleSheet::error()
{
// Create the image if it doesn't yet exist.
if (!m_image)
- m_image = new Image(this, ResponseMIMEType(m_response) == "application/pdf");
+ m_image = new Image(this, m_response.mimeType() == "application/pdf");
}
Vector<char>& CachedImage::bufferData(const char* bytes, int addedSize, Request* request)
namespace WebCore {
-CachedResource::CachedResource(const String& URL, Type type, CachePolicy cachePolicy, time_t expireDate, unsigned size)
+CachedResource::CachedResource(const String& URL, Type type, CachePolicy cachePolicy, unsigned size)
{
m_url = URL;
m_type = type;
m_inCache = false;
m_cachePolicy = cachePolicy;
m_request = 0;
- m_response = 0;
+ m_platformResponse = 0;
m_allData = 0;
- m_expireDate = expireDate;
m_expireDateChanged = false;
m_accessCount = 0;
m_nextInLRUList = 0;
#ifndef NDEBUG
m_deleted = true;
#endif
- setResponse(0);
+ setPlatformResponse(0);
setAllData(0);
}
m_expireDateChanged = false;
}
-void CachedResource::setExpireDate(time_t expireDate, bool changeHttpCache)
-{
- if (expireDate == m_expireDate)
- return;
-
- if (m_status == Cached)
- finish();
-
- m_expireDate = expireDate;
- if (changeHttpCache && m_expireDate)
- m_expireDateChanged = true;
-}
-
bool CachedResource::isExpired() const
{
- if (!m_expireDate)
+ if (!m_response.expirationDate())
return false;
time_t now = time(0);
- return (difftime(now, m_expireDate) >= 0);
+ return (difftime(now, m_response.expirationDate()) >= 0);
}
void CachedResource::setRequest(Request* request)
#include "CachePolicy.h"
#include "PlatformString.h"
#include "ResourceHandleClient.h" // defines PlatformResponse and PlatformData
+#include "ResourceResponse.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
#include <time.h>
Cached // regular case
};
- CachedResource(const String& URL, Type type, CachePolicy cachePolicy, time_t expireDate, unsigned size = 0);
+ CachedResource(const String& URL, Type type, CachePolicy cachePolicy, unsigned size = 0);
virtual ~CachedResource();
virtual void setEncoding(const String&) { }
void setRequest(Request*);
- PlatformResponse response() const { return m_response; }
- void setResponse(PlatformResponse);
+ PlatformResponse platformResponse() const { return m_platformResponse; }
+ void setPlatformResponse(PlatformResponse);
PlatformData allData() const { return m_allData; }
void setAllData(PlatformData);
- bool canDelete() const { return !referenced() && !m_request; }
+ void setResponse(const ResourceResponse& response) { m_response = response; }
- void setExpireDate(time_t expireDate, bool changeHttpCache);
+ bool canDelete() const { return !referenced() && !m_request; }
bool isExpired() const;
RetainPtr<NSURLRequest> m_nsURLRequest;
#endif
- PlatformResponse m_response;
+ ResourceResponse m_response;
+ PlatformResponse m_platformResponse;
PlatformData m_allData;
Type m_type;
unsigned m_accessCount;
protected:
- time_t m_expireDate;
CachePolicy m_cachePolicy;
bool m_inCache;
bool m_loading;
void CheckCacheObjectStatus(DocLoader*, CachedResource*);
bool CheckIfReloading(DocLoader*);
-bool IsResponseURLEqualToURL(PlatformResponse , const String& URL);
-DeprecatedString ResponseURL(PlatformResponse);
-DeprecatedString ResponseMIMEType(PlatformResponse);
-bool ResponseIsMultipart(PlatformResponse);
-NSString* HeaderStringFromDictionary(NSDictionary* headers, int statusCode);
}
// FIXME: the win32 platform does not have PlatformResponse yet.
ASSERT(response);
#endif
- req->cachedResource()->setResponse(response);
+ req->cachedResource()->setPlatformResponse(response);
}
-void Loader::didReceivedResponse(ResourceHandle* handle, const ResourceResponse& response)
+void Loader::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response)
{
Request* req = m_requestsLoading.get(handle);
ASSERT(req);
- req->cachedResource()->setExpireDate(response.expirationDate(), false);
+ req->cachedResource()->setResponse(response);
String encoding = response.textEncodingName();
if (!encoding.isNull())
private:
virtual void receivedResponse(ResourceHandle*, PlatformResponse);
- virtual void didReceivedResponse(ResourceHandle* handle, const ResourceResponse& response);
+ virtual void didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response);
virtual void didReceiveData(ResourceHandle*, const char*, int);
virtual void receivedAllData(ResourceHandle*, PlatformData);
namespace WebCore {
class FormData;
void setHTTPBody(NSMutableURLRequest *, const FormData&);
+ const FormData* httpBodyFromStream(NSInputStream* stream);
}
#import <sys/stat.h>
#import <sys/types.h>
#import <wtf/Assertions.h>
+#import <wtf/HashMap.h>
namespace WebCore {
+static HashMap<CFReadStreamRef, const FormData*>* streamFormDatas = 0;
+
+static HashMap<CFReadStreamRef, const FormData*>* getStreamFormDatas()
+{
+ if (!streamFormDatas)
+ streamFormDatas = new HashMap<CFReadStreamRef, const FormData*>();
+ return streamFormDatas;
+}
+
static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context);
struct FormStreamFields {
for (size_t i = 0; i < size; ++i)
newInfo->remainingElements.append(formData->elements()[size - i - 1]);
+ getStreamFormDatas()->set(stream, new FormData(*formData));
+
return newInfo;
}
{
FormStreamFields* form = static_cast<FormStreamFields*>(context);
+ delete getStreamFormDatas()->get(stream);
+ getStreamFormDatas()->remove(stream);
+
closeCurrentStream(form);
CFRelease(form->scheduledRunLoopPairs);
delete form;
CFRelease(stream);
}
+
+const FormData* httpBodyFromStream(NSInputStream* stream)
+{
+ return getStreamFormDatas()->get((CFReadStreamRef)stream);
+}
+
}
Frame* frame = document->frame();
NSURLResponse *response = frame->loader()->documentLoader()->response();
- image->setResponse(response);
+ image->setPlatformResponse(response);
IntSize size = image->imageSize();
if (size.width())
return;
}
- ASSERT(cachedResource->response());
+ ASSERT(cachedResource->platformResponse());
// Notify the caller that we "loaded".
FrameMac *frame = static_cast<FrameMac *>(loader->frame());
return;
NSURLRequest *request = cachedResource->getNSURLRequest();
- NSURLResponse *response = cachedResource->response();
+ NSURLResponse *response = cachedResource->platformResponse();
NSData *data = cachedResource->allData();
// FIXME: If the WebKit client changes or cancels the request, WebCore does not respect this and continues the load.
return false;
}
-void CachedResource::setResponse(PlatformResponse response)
+void CachedResource::setPlatformResponse(PlatformResponse response)
{
HardRetain(response);
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- HardRelease(m_response);
+ HardRelease(m_platformResponse);
END_BLOCK_OBJC_EXCEPTIONS;
- m_response = response;
+ m_platformResponse = response;
}
void CachedResource::setAllData(PlatformData allData)
NSURL *oldURL = [request() URL];
NSURLRequest *clientRequest = ResourceLoader::willSendRequest(newRequest, redirectResponse);
if (clientRequest && oldURL != [clientRequest URL] && ![oldURL isEqual:[clientRequest URL]])
- m_handle->redirectedToURL([clientRequest URL]);
+ clientRequest = m_handle->willSendRequest(clientRequest, redirectResponse);
return clientRequest;
}
void GraphicsContext::setFont(const Font& aFont)
{
m_common->state.font = aFont;
+ setPlatformFont(aFont);
}
const Pen& GraphicsContext::pen() const
void GraphicsContext::setPen(const Pen& pen)
{
m_common->state.pen = pen;
+ setPlatformPen(pen);
}
void GraphicsContext::setPen(Pen::PenStyle style)
m_common->state.pen.setStyle(style);
m_common->state.pen.setColor(Color::black);
m_common->state.pen.setWidth(0);
+ setPlatformPen(m_common->state.pen);
}
void GraphicsContext::setPen(RGBA32 rgb)
m_common->state.pen.setStyle(Pen::SolidLine);
m_common->state.pen.setColor(rgb);
m_common->state.pen.setWidth(0);
+ setPlatformPen(m_common->state.pen);
}
void GraphicsContext::setFillColor(const Color& color)
{
m_common->state.fillColor = color;
+ setPlatformFillColor(color);
}
Color GraphicsContext::fillColor() const
image->drawTiled(this, dest, srcRect, hRule, vRule, op);
}
+#if !PLATFORM(QT)
+void GraphicsContext::setPlatformPen(const Pen&)
+{
+}
+
+void GraphicsContext::setPlatformFillColor(const Color&)
+{
+}
+
+void GraphicsContext::setPlatformFont(const Font&)
+{
+}
+#endif
+
}
private:
void savePlatformState();
void restorePlatformState();
+ void setPlatformPen(const Pen& pen);
+ void setPlatformFillColor(const Color& fill);
+ void setPlatformFont(const Font& font);
int focusRingWidth() const;
int focusRingOffset() const;
#if PLATFORM(MAC)
#ifdef __OBJC__
@class WebCoreResourceLoaderImp;
+@class NSURLRequest;
+@class NSURLResponse;
#else
class WebCoreResourceLoaderImp;
+class NSURLRequest;
+class NSURLResponse;
#endif
#endif
void kill();
#if PLATFORM(MAC)
- void redirectedToURL(NSURL *url);
+ NSURLRequest *willSendRequest(NSURLRequest *, NSURLResponse *);
void addData(NSData *data);
void finishJobAndHandle(NSData *data);
void reportError();
class KURL;
class ResourceHandle;
+ class ResourceRequest;
class ResourceResponse;
class ResourceHandleClient {
virtual ~ResourceHandleClient() { }
// request may be modified
- // void willSendRequest(ResourceHandle*, Request&, const ResourceResonse& redirectResponse) { }
+ virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse) { }
// void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
// void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
// void willCacheResponse(ResourceHandle*, CachedResourceResponse&) { }
// old-style methods
- virtual void receivedRedirect(ResourceHandle*, const KURL&) { }
virtual void receivedResponse(ResourceHandle*, PlatformResponse) { }
virtual void receivedAllData(ResourceHandle*, PlatformData) { }
};
FormData& httpBody() { return m_httpBody; }
void setHTTPBody(const FormData& httpBody) { m_httpBody = httpBody; }
- bool allowHTTPCookies() const;
- void setAllowHTTPCookies(bool);
+ bool allowHTTPCookies() const { return m_allowHTTPCookies; }
+ void setAllowHTTPCookies(bool allowHTTPCookies) { m_allowHTTPCookies = allowHTTPCookies; }
private:
static const int defaultTimeoutInterval = 60;
class ResourceResponse {
public:
- ResourceResponse() : m_expectedContentLength(0), m_httpStatusCode(0) {}
+ ResourceResponse()
+ : m_expectedContentLength(0)
+ , m_httpStatusCode(0)
+ , m_expirationDate(0)
+ {
+ }
ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
: m_url(url)
, m_textEncodingName(textEncodingName)
, m_suggestedFilename(filename)
, m_httpStatusCode(0)
+ , m_expirationDate(0)
{
}
const HTTPHeaderMap& httpHeaderFields() const { return m_httpHeaderFields; }
HTTPHeaderMap& httpHeaderFields() { return m_httpHeaderFields; }
- // possibly add calculated expiration info
- // lastModifiedDate (date)
-
bool isMultipart() const { return m_mimeType == "multipart/x-mixed-replace"; }
void setExpirationDate(time_t expirationDate) { m_expirationDate = expirationDate; }
/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#import "KURL.h"
#import "LoaderFunctions.h"
#import "Logging.h"
+#import "ResourceRequestMac.h"
#import "ResourceResponse.h"
#import "ResourceResponseMac.h"
#import "WebCoreFrameBridge.h"
d->m_subresourceLoader->cancel();
}
-void ResourceHandle::redirectedToURL(NSURL *url)
+NSURLRequest *ResourceHandle::willSendRequest(NSURLRequest *nsRequest, NSURLResponse* nsRedirectResponse)
{
- ASSERT(url);
- if (ResourceHandleClient* c = client())
- c->receivedRedirect(this, KURL(url));
+ ASSERT(nsRequest);
+ if (ResourceHandleClient* c = client()) {
+ ResourceRequest request;
+ getResourceRequest(request, nsRequest);
+ ResourceResponse redirectResponse;
+ getResourceResponse(redirectResponse, nsRedirectResponse);
+ c->willSendRequest(this, request, redirectResponse);
+ return nsURLRequest(request);
+ }
+
+ return nsRequest;
}
void ResourceHandle::addData(NSData *data)
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ResourceRequestMac_h_
+#define ResourceRequestMac_h_
+
+@class NSURLRequest;
+
+namespace WebCore {
+
+ class ResourceRequest;
+
+ void getResourceRequest(ResourceRequest&, NSURLRequest *);
+ NSURLRequest *nsURLRequest(const ResourceRequest&);
+
+}
+
+#endif // ResourceRequestMac_h_
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ResourceRequestMac.h"
+
+#import "FormDataStream.h"
+#import "ResourceRequest.h"
+
+#import <Foundation/Foundation.h>
+
+namespace WebCore {
+
+ void getResourceRequest(ResourceRequest& request, NSURLRequest* nsRequest)
+ {
+ request = ResourceRequest([nsRequest URL]);
+
+ request.setCachePolicy((ResourceRequestCachePolicy)[nsRequest cachePolicy]);
+ request.setTimeoutInterval([nsRequest timeoutInterval]);
+ request.setMainDocumentURL(KURL([nsRequest mainDocumentURL]));
+ if (NSString* method = [nsRequest HTTPMethod])
+ request.setHTTPMethod(method);
+ request.setAllowHTTPCookies([nsRequest HTTPShouldHandleCookies]);
+
+ NSDictionary *headers = [nsRequest allHTTPHeaderFields];
+ NSEnumerator *e = [headers keyEnumerator];
+ NSString *name;
+ while ((name = [e nextObject]))
+ request.setHTTPHeaderField(name, [headers objectForKey:name]);
+
+ if (NSData* bodyData = [nsRequest HTTPBody])
+ request.setHTTPBody(FormData([bodyData bytes], [bodyData length]));
+ else if (NSInputStream* bodyStream = [nsRequest HTTPBodyStream])
+ if (const FormData* formData = httpBodyFromStream(bodyStream))
+ request.setHTTPBody(*formData);
+ // FIXME: what to do about arbitrary body streams?
+ }
+
+ NSURLRequest* nsURLRequest(const ResourceRequest& request)
+ {
+ NSMutableURLRequest* nsRequest = [[NSMutableURLRequest alloc] initWithURL:request.url().getNSURL()];
+
+ [nsRequest setCachePolicy:(NSURLRequestCachePolicy)request.cachePolicy()];
+ [nsRequest setTimeoutInterval:request.timeoutInterval()];
+ [nsRequest setMainDocumentURL:request.mainDocumentURL().getNSURL()];
+ if (!request.httpMethod().isEmpty())
+ [nsRequest setHTTPMethod:request.httpMethod()];
+ [nsRequest setHTTPShouldHandleCookies:request.allowHTTPCookies()];
+
+ HTTPHeaderMap::const_iterator end = request.httpHeaderFields().end();
+ for (HTTPHeaderMap::const_iterator it = request.httpHeaderFields().begin(); it != end; ++it)
+ [nsRequest setValue:it->second forHTTPHeaderField:it->first];
+
+ if (!request.httpBody().isEmpty())
+ setHTTPBody(nsRequest, request.httpBody());
+
+ return [nsRequest autorelease];
+ }
+
+}
#include "Path.h"
#include "Color.h"
#include "GraphicsContext.h"
+#include "Font.h"
+#include "Pen.h"
#include <QStack>
#include <QPainter>
namespace WebCore {
-static QPainter::CompositionMode toQtCompositionMode(CompositeOperator op)
+static inline QPainter::CompositionMode toQtCompositionMode(CompositeOperator op)
{
switch (op) {
case CompositeClear:
return QPainter::CompositionMode_SourceOver;
}
-static Qt::PenCapStyle toQtLineCap(LineCap lc)
+static inline Qt::PenCapStyle toQtLineCap(LineCap lc)
{
switch (lc) {
case ButtCap:
return Qt::FlatCap;
}
-static Qt::PenJoinStyle toQtLineJoin(LineJoin lj)
+static inline Qt::PenJoinStyle toQtLineJoin(LineJoin lj)
{
switch (lj) {
case MiterJoin:
return Qt::MiterJoin;
}
+static Qt::PenStyle toQPenStyle(Pen::PenStyle style)
+{
+ switch (style) {
+ case Pen::NoPen:
+ return Qt::NoPen;
+ break;
+ case Pen::SolidLine:
+ return Qt::SolidLine;
+ break;
+ case Pen::DotLine:
+ return Qt::DotLine;
+ break;
+ case Pen::DashLine:
+ return Qt::DashLine;
+ break;
+ }
+ qWarning("couldn't recognize the pen style");
+ return Qt::NoPen;
+}
+
+static inline QPen penToQPen(const Pen& pen)
+{
+ return QPen(QColor(pen.color()), pen.width(), toQPenStyle(pen.style()));
+}
+
struct TransparencyLayer
{
TransparencyLayer(const QPainter& p, int width, int height)
painter->setPen(p.pen());
painter->setBrush(p.brush());
painter->setMatrix(p.matrix());
+ painter->setOpacity(p.opacity());
+ painter->setFont(p.font());
+ painter->setCompositionMode(p.compositionMode());
+ painter->setClipPath(p.clipPath());
}
TransparencyLayer()
return IntPoint(qRound(m_data->p().matrix().dx()),
qRound(m_data->p().matrix().dy()));
}
-
+
void GraphicsContext::rotate(float radians)
{
if (paintingDisabled())
int topLeftRightHeightMax = qMax(topLeft.height(), topRight.height());
int bottomLeftRightHeightMax = qMax(bottomLeft.height(), bottomRight.height());
-
- int topBottomLeftWidthMax = qMax(topLeft.width(), bottomLeft.width());
+
+ int topBottomLeftWidthMax = qMax(topLeft.width(), bottomLeft.width());
int topBottomRightWidthMax = qMax(topRight.width(), bottomRight.width());
-
+
// Now add five rects (one for each edge rect in between the rounded corners and one for the interior).
path.addRect(QRectF(rect.x() + topLeft.width(),
rect.y(),
rect.y() + topLeft.height(),
topBottomLeftWidthMax,
rect.height() - topLeft.height() - bottomLeft.height()));
-
+
path.addRect(QRectF(rect.right() - topBottomRightWidthMax,
rect.y() + topRight.height(),
topBottomRightWidthMax,
rect.height() - topRight.height() - bottomRight.height()));
-
+
path.addRect(QRectF(rect.x() + topBottomLeftWidthMax,
rect.y() + topLeftRightHeightMax,
rect.width() - topBottomLeftWidthMax - topBottomRightWidthMax,
notImplemented();
}
+void GraphicsContext::setPlatformFont(const Font& aFont)
+{
+ m_data->p().setFont(aFont);
+}
+
+void GraphicsContext::setPlatformPen(const Pen& pen)
+{
+ m_data->p().setPen(penToQPen(pen));
+}
+
+void GraphicsContext::setPlatformFillColor(const Color& color)
+{
+ m_data->p().setBrush(QBrush(color));
+}
+
#ifdef SVG_SUPPORT
KRenderingDeviceContext* GraphicsContext::createRenderingDeviceContext()
{
#include <QPaintEvent>
#include <QMouseEvent>
+
namespace WebCore {
ScrollViewCanvasQt::ScrollViewCanvasQt(ScrollView* frameView, QWidget* parent)
- : QWidget(parent)
- , m_frameView(frameView)
+ : QWidget(parent),
+ m_frameView(frameView)
{
setMouseTracking(true);
setFocusPolicy(Qt::StrongFocus);
handled = true;
}
-
+
// FIXME: doScroll stuff()!
}
}
class ScrollView;
-class ScrollViewCanvasQt : public QWidget {
-Q_OBJECT
+class ScrollViewCanvasQt : public QWidget
+{
+ Q_OBJECT
public:
ScrollViewCanvasQt(ScrollView*, QWidget* parent = 0);
}
}
-void XMLHttpRequest::receivedRedirect(ResourceHandle*, const KURL& m_url)
+void XMLHttpRequest::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
- if (!urlMatchesDocumentDomain(m_url))
+ if (!urlMatchesDocumentDomain(request.url()))
abort();
}
private:
bool urlMatchesDocumentDomain(const KURL&) const;
- virtual void receivedRedirect(ResourceHandle*, const KURL&);
+ virtual void willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char* data, int size);
virtual void didFinishLoading(ResourceHandle*);