+2006-10-27 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Maciej.
+
+ Moved some WebCoreFrameBridge functions into FrameLoader.
+
+ I had to make FrameLoader.h capable of compiling in C++-only source files
+ by adding some forward declarations and __OBJC__ #ifdefs.
+
+ * WebCore.exp:
+ * bridge/mac/FrameMac.h:
+ * bridge/mac/FrameMac.mm:
+ (WebCore::FrameMac::createEmptyDocument):
+ (WebCore::FrameMac::tokenizerProcessedData):
+ * bridge/mac/WebCoreFrameBridge.h:
+ * bridge/mac/WebCoreFrameBridge.mm:
+ * dom/Document.cpp:
+ (WebCore::Document::processHttpEquiv):
+ (WebCore::Document::referrer):
+ * loader/LoaderFunctions.h:
+ * loader/mac/FrameLoader.h:
+ * loader/mac/FrameLoader.mm:
+ (WebCore::numRequests):
+ (WebCore::FrameLoader::numPendingOrLoadingRequests):
+ (WebCore::FrameLoader::isReloading):
+ (WebCore::FrameLoader::referrer):
+ (WebCore::FrameLoader::loadEmptyDocumentSynchronously):
+ (WebCore::FrameLoader::startLoadingResource):
+ * loader/mac/LoaderFunctionsMac.mm:
+ (WebCore::CheckIfReloading):
+ * page/Frame.h:
+ * page/FrameTree.cpp:
+ (WebCore::FrameTree::isDescendantOf):
+ (WebCore::FrameTree::traverseNext):
+ * page/FrameTree.h:
+ * platform/network/mac/ResourceLoaderMac.mm:
+ (WebCore::ResourceLoader::start):
+
2006-10-27 Timothy Hatcher <timothy@apple.com>
Reviewed by Darin.
__ZNK7WebCore8FrameMac31fontAttributesForSelectionStartEv
__ZNK7WebCore9FloatRectcv6CGRectEv
__ZNK7WebCore9FloatRectcv7_NSRectEv
-__ZNK7WebCore9FrameTree12traverseNextEPNS_5FrameE
-__ZNK7WebCore9FrameTree14isDescendantOfEPNS_5FrameE
__ZNK7WebCore9FrameTree20traverseNextWithWrapEb
__ZNK7WebCore9FrameTree24traversePreviousWithWrapEb
__ZNK7WebCore9FrameTree4findERKNS_12AtomicStringE
_wkSignalCFReadStreamError
_wkSignalCFReadStreamHasBytes
_wkSupportsMultipartXMixedReplace
+__ZNK7WebCore11FrameLoader27numPendingOrLoadingRequestsEb
+__ZNK7WebCore9FrameTree12traverseNextEPKNS_5FrameE
+__ZNK7WebCore9FrameTree14isDescendantOfEPKNS_5FrameE
+
static WebCoreFrameBridge* bridgeForWidget(const Widget*);
- virtual String incomingReferrer() const;
virtual String userAgent() const;
virtual String mimeTypeForFileName(const String&) const;
END_BLOCK_OBJC_EXCEPTIONS;
}
-String FrameMac::incomingReferrer() const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [_bridge incomingReferrer];
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return String();
-}
-
void FrameMac::runJavaScriptAlert(const String& message)
{
String text = message;
// it does nothing if we already have a document, and just creates an
// empty one if we have no document at all.
if (!d->m_doc) {
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [_bridge loadEmptyDocumentSynchronously];
- END_BLOCK_OBJC_EXCEPTIONS;
-
+ loader()->loadEmptyDocumentSynchronously();
updateBaseURLForEmptyDocument();
}
}
{
if (d->m_doc)
checkCompleted();
- [_bridge tokenizerProcessedData];
+ loader()->checkLoadComplete();
}
void FrameMac::setBridge(WebCoreFrameBridge *bridge)
- (void)setShouldCreateRenderers:(BOOL)f;
- (BOOL)shouldCreateRenderers;
-- (int)numPendingOrLoadingRequests;
- (BOOL)doneProcessingData;
- (void)setBaseBackgroundColor:(NSColor *)backgroundColor;
- (NSURL*)originalRequestURL;
- (void)frameDetached;
-- (void)tokenizerProcessedData;
- (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
-- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders;
-- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders postData:(NSArray *)data;
- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response:(NSURLResponse *)response data:(NSData *)data;
- (NSData *)syncLoadResourceWithMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)requestHeaders postData:(NSArray *)postData finalURL:(NSURL **)finalNSURL responseHeaders:(NSDictionary **)responseHeaderDict statusCode:(int *)statusCode;
-- (BOOL)isReloading;
-- (NSString *)incomingReferrer;
-- (void)loadEmptyDocumentSynchronously;
@end
return _shouldCreateRenderers;
}
-- (int)numPendingOrLoadingRequests
-{
- Document *doc = m_frame->document();
- if (doc)
- return NumberOfPendingOrLoadingRequests(doc->docLoader());
- return 0;
-}
-
- (BOOL)doneProcessingData
{
Document *doc = m_frame->document();
m_frame->loader()->detachFromParent();
}
-- (void)tokenizerProcessedData
-{
- m_frame->loader()->checkLoadComplete();
-}
-
- (void)receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName
{
// Set the encoding. This only needs to be done once, but it's harmless to do it again later.
[self addData:data];
}
-- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)resourceLoader withMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders
-{
- // If we are no longer attached to a page, this must be an attempted load from an
- // onunload handler, so let's just block it.
- if (!m_frame->page())
- return nil;
-
- // Since this is a subresource, we can load any URL (we ignore the return value).
- // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
- String referrer = m_frame->referrer();
- bool hideReferrer;
- m_frame->loader()->canLoad(URL, referrer, hideReferrer);
- if (hideReferrer)
- referrer = String();
-
- return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, referrer);
-}
-
- (void)objectLoadedFromCacheWithURL:(NSURL *)URL response:(NSURLResponse *)response data:(NSData *)data
{
if (!m_frame)
[request release];
}
-- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)resourceLoader withMethod:(NSString *)method URL:(NSURL *)URL
- customHeaders:(NSDictionary *)customHeaders postData:(NSArray *)postData
-{
- // If we are no longer attached to a Page, this must be an attempted load from an
- // onunload handler, so let's just block it.
- if (!m_frame->page())
- return nil;
-
- // Since this is a subresource, we can load any URL (we ignore the return value).
- // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
- String referrer = m_frame->referrer();
- bool hideReferrer;
- m_frame->loader()->canLoad(URL, referrer, hideReferrer);
- if (hideReferrer)
- referrer = String();
-
- return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, postData, referrer);
-}
-
- (NSData *)syncLoadResourceWithMethod:(NSString *)method URL:(NSURL *)URL customHeaders:(NSDictionary *)requestHeaders postData:(NSArray *)postData finalURL:(NSURL **)finalURL responseHeaders:(NSDictionary **)responseHeaderDict statusCode:(int *)statusCode
{
// Since this is a subresource, we can load any URL (we ignore the return value).
// -------------------
-- (NSString *)incomingReferrer
-{
- return [m_frame->loader()->documentLoader()->request() valueForHTTPHeaderField:@"Referer"];
-}
-
-- (BOOL)isReloading
-{
- return [m_frame->loader()->documentLoader()->request() cachePolicy] == NSURLRequestReloadIgnoringCacheData;
-}
-
-- (void)loadEmptyDocumentSynchronously
-{
- if (!m_frame)
- return;
-
- NSURL *url = [[NSURL alloc] initWithString:@""];
- NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
- m_frame->loader()->load(request);
- [request release];
- [url release];
-}
-
- (FrameMac*)_frame
{
return m_frame;
#include "EventNames.h"
#include "ExceptionCode.h"
#include "Frame.h"
+#include "FrameLoader.h"
#include "FrameTree.h"
#include "HTMLBodyElement.h"
#include "HTMLDocument.h"
} else if (equalIgnoringCase(equiv, "expires")) {
String str = content.stripWhiteSpace();
time_t expire_date = str.toInt();
- if (m_docLoader)
- m_docLoader->setExpireDate(expire_date);
+ m_docLoader->setExpireDate(expire_date);
} else if ((equalIgnoringCase(equiv, "pragma") || equalIgnoringCase(equiv, "cache-control")) && frame) {
DeprecatedString str = content.deprecatedString().lower().stripWhiteSpace();
KURL url = frame->url();
String Document::referrer() const
{
if (frame())
- return frame()->incomingReferrer();
+ return frame()->loader()->referrer();
return String();
}
DeprecatedString ResponseURL(PlatformResponse);
DeprecatedString ResponseMIMEType(PlatformResponse);
bool ResponseIsMultipart(PlatformResponse);
-int NumberOfPendingOrLoadingRequests(DocLoader*);
time_t CacheObjectExpiresTime(DocLoader*, PlatformResponse);
NSString* HeaderStringFromDictionary(NSDictionary* headers, int statusCode);
#if PLATFORM(MAC)
#import "RetainPtr.h"
+#import <objc/objc.h>
+#ifdef __OBJC__
@class WebCoreFrameBridge;
@class WebCoreFrameLoaderAsDelegate;
@class WebPolicyDecider;
-#endif
+@class NSArray;
+@class NSDate;
+@class NSURL;
+@class NSURLConnection;
+@class NSURLRequest;
+@class NSURLResponse;
+@class NSDictionary;
+@class NSEvent;
+@class NSError;
+@class NSData;
+@class NSMutableURLRequest;
+@class NSURLAuthenticationChallenge;
+
+@protocol WebCoreResourceLoader;
+@protocol WebCoreResourceHandle;
+
+#else
+
+class WebCoreFrameBridge;
+class WebCoreFrameLoaderAsDelegate;
+class WebPolicyDecider;
+
+class NSArray;
+class NSDate;
+class NSURL;
+class NSURLConnection;
+class NSURLRequest;
+class NSURLResponse;
+class NSDictionary;
+class NSEvent;
+class NSError;
+class NSData;
+class NSMutableURLRequest;
+class NSURLAuthenticationChallenge;
+#endif // __OBJC__
+
+#endif // PLATFORM(MAC)
namespace WebCore {
class FrameLoaderClient;
class MainResourceLoader;
class String;
+ class SubresourceLoader;
class WebResourceLoader;
bool isBackForwardLoadType(FrameLoadType);
NSData *mainResourceData() const;
void releaseMainResourceLoader();
+ int numPendingOrLoadingRequests(bool recurse) const;
+ bool isReloading() const;
+ String referrer() const;
+ void loadEmptyDocumentSynchronously();
+
+#ifdef __OBJC__
+ id <WebCoreResourceHandle> startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders);
+ id <WebCoreResourceHandle> startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders, NSArray *postData);
+#endif
+
DocumentLoader* activeDocumentLoader() const;
DocumentLoader* documentLoader() const;
DocumentLoader* provisionalDocumentLoader();
#import "config.h"
#import "FrameLoader.h"
+#import "Cache.h"
+#import "Document.h"
#import "DOMElementInternal.h"
#import "Element.h"
#import "FrameLoadRequest.h"
#import "WebFrameLoaderClient.h"
#import "WebMainResourceLoader.h"
#import "WebPolicyDecider.h"
+#import "WebSubresourceLoader.h"
#import <objc/objc-runtime.h>
#import <wtf/Assertions.h>
return false;
}
+static int numRequests(Document* document)
+{
+ if (document)
+ return cache()->loader()->numRequests(document->docLoader());
+ return 0;
+}
+
FrameLoader::FrameLoader(Frame* frame)
: m_frame(frame)
, m_client(nil)
frame->loader()->checkLoadCompleteForThisFrame();
}
+int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
+{
+ int count = 0;
+ const Frame* frame = m_frame;
+
+ count += numRequests(frame->document());
+
+ if (recurse)
+ while ((frame = frame->tree()->traverseNext(frame)))
+ count += numRequests(frame->document());
+
+ return count;
+}
+
+bool FrameLoader::isReloading() const
+{
+ return [documentLoader()->request() cachePolicy] == NSURLRequestReloadIgnoringCacheData;
+}
+
+String FrameLoader::referrer() const
+{
+ return [documentLoader()->request() valueForHTTPHeaderField:@"Referer"];
+}
+
+void FrameLoader::loadEmptyDocumentSynchronously()
+{
+ NSURL *url = [[NSURL alloc] initWithString:@""];
+ NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
+ m_frame->loader()->load(request);
+ [request release];
+ [url release];
+}
+
+id <WebCoreResourceHandle> FrameLoader::startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders)
+{
+ // If we are no longer attached to a page, this must be an attempted load from an
+ // onunload handler, so let's just block it.
+ if (!m_frame->page())
+ return nil;
+
+ // Since this is a subresource, we can load any URL (we ignore the return value).
+ // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
+ String referrer = m_frame->referrer();
+ bool hideReferrer;
+ canLoad(URL, referrer, hideReferrer);
+ if (hideReferrer)
+ referrer = String();
+
+ return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, referrer);
+}
+
+id <WebCoreResourceHandle> FrameLoader::startLoadingResource(id <WebCoreResourceLoader> resourceLoader, const String& method, NSURL *URL, NSDictionary *customHeaders, NSArray *postData)
+{
+ // If we are no longer attached to a Page, this must be an attempted load from an
+ // onunload handler, so let's just block it.
+ if (!m_frame->page())
+ return nil;
+
+ // Since this is a subresource, we can load any URL (we ignore the return value).
+ // But we still want to know whether we should hide the referrer or not, so we call the canLoadURL method.
+ String referrer = m_frame->referrer();
+ bool hideReferrer;
+ canLoad(URL, referrer, hideReferrer);
+ if (hideReferrer)
+ referrer = String();
+
+ return SubresourceLoader::create(m_frame, resourceLoader, method, URL, customHeaders, postData, referrer);
+}
+
void FrameLoader::setClient(FrameLoaderClient* client)
{
ASSERT(client);
#import "CachedImage.h"
#import "DocLoader.h"
#import "FoundationExtras.h"
+#import "FrameLoader.h"
#import "FrameMac.h"
#import "FormData.h"
#import "FormDataMac.h"
return Vector<char>();
}
-int NumberOfPendingOrLoadingRequests(DocLoader *dl)
-{
- return cache()->loader()->numRequests(dl);
-}
-
bool CheckIfReloading(DocLoader *loader)
{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (FrameMac *frame = static_cast<FrameMac *>(loader->frame()))
- return [frame->bridge() isReloading];
- END_BLOCK_OBJC_EXCEPTIONS;
-
+ if (Frame* frame = loader->frame())
+ return frame->loader()->isReloading();
return false;
}
virtual void setTitle(const String&) = 0;
virtual void handledOnloadEvents() = 0;
virtual String userAgent() const = 0;
- virtual String incomingReferrer() const = 0;
virtual String mimeTypeForFileName(const String&) const = 0;
virtual KJS::Bindings::Instance* getEmbedInstanceForWidget(Widget*) = 0;
virtual KJS::Bindings::Instance* getObjectInstanceForWidget(Widget*) = 0;
return 0;
}
-bool FrameTree::isDescendantOf(Frame* ancestor) const
+bool FrameTree::isDescendantOf(const Frame* ancestor) const
{
for (Frame* frame = m_thisFrame; frame; frame = frame->tree()->parent())
if (frame == ancestor)
return false;
}
-Frame* FrameTree::traverseNext(Frame* stayWithin) const
+Frame* FrameTree::traverseNext(const Frame* stayWithin) const
{
Frame* child = firstChild();
if (child) {
Frame* lastChild() const { return m_lastChild; }
unsigned childCount() const { return m_childCount; }
- bool isDescendantOf(Frame* ancestor) const;
- Frame* traverseNext(Frame* stayWithin = 0) const;
+ bool isDescendantOf(const Frame* ancestor) const;
+ Frame* traverseNext(const Frame* stayWithin = 0) const;
Frame* traverseNextWithWrap(bool) const;
Frame* traversePreviousWithWrap(bool) const;
#import "BlockExceptions.h"
#import "DocLoader.h"
#import "FoundationExtras.h"
+#import "FrameLoader.h"
#import "FrameMac.h"
#import "KURL.h"
#import "FormDataMac.h"
return false;
}
- WebCoreFrameBridge* bridge = frame->bridge();
-
frame->didTellBridgeAboutLoad(url().url());
BEGIN_BLOCK_OBJC_EXCEPTIONS;
headerDict = [NSDictionary _webcore_dictionaryWithHeaderMap:d->m_request.httpHeaderFields()];
if (!postData().elements().isEmpty())
- handle = [bridge startLoadingResource:resourceLoader withMethod:method() URL:url().getNSURL() customHeaders:headerDict postData:arrayFromFormData(postData())];
+ handle = frame->loader()->startLoadingResource(resourceLoader, method(), url().getNSURL(), headerDict, arrayFromFormData(postData()));
else
- handle = [bridge startLoadingResource:resourceLoader withMethod:method() URL:url().getNSURL() customHeaders:headerDict];
+ handle = frame->loader()->startLoadingResource(resourceLoader, method(), url().getNSURL(), headerDict);
[resourceLoader setHandle:handle];
[resourceLoader release];
+2006-10-27 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Maciej.
+
+ Moved some WebCoreFrameBridge functions into FrameLoader.
+
+ * WebView/WebFrame.mm:
+ (-[WebFrame _numPendingOrLoadingRequests:]):
+
2006-10-27 Timothy Hatcher <timothy@apple.com>
Reviewed by Beth.
- (int)_numPendingOrLoadingRequests:(BOOL)recurse
{
- if (!recurse)
- return [_private->bridge numPendingOrLoadingRequests];
-
- int num = 0;
- Frame* coreFrame = core(self);
- for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
- num += [Mac(frame)->bridge() numPendingOrLoadingRequests];
-
- return num;
+ return core(self)->loader()->numPendingOrLoadingRequests(recurse);
}
- (void)_reloadForPluginChanges