diff options
Diffstat (limited to 'WebCore/loader')
29 files changed, 149 insertions, 107 deletions
diff --git a/WebCore/loader/Cache.cpp b/WebCore/loader/Cache.cpp index 7acbd56..dbcec00 100644 --- a/WebCore/loader/Cache.cpp +++ b/WebCore/loader/Cache.cpp @@ -99,17 +99,16 @@ CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoade // Would it be better to just go on with the cache code and let it fail later? if (url.isEmpty()) return 0; - + // Look up the resource in our map. CachedResource* resource = resourceForURL(url.string()); - + if (resource && requestIsPreload && !resource->isPreloaded()) return 0; - - if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canDisplay(url, String(), cachedResourceLoader->doc())) { - Document* doc = cachedResourceLoader->doc(); - if (doc && !requestIsPreload) - FrameLoader::reportLocalLoadFailed(doc->frame(), url.string()); + + if (!cachedResourceLoader->doc()->securityOrigin()->canDisplay(url)) { + if (!requestIsPreload) + FrameLoader::reportLocalLoadFailed(cachedResourceLoader->doc()->frame(), url.string()); return 0; } diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp index 1bb2f87..b0c0e0a 100644 --- a/WebCore/loader/DocumentLoader.cpp +++ b/WebCore/loader/DocumentLoader.cpp @@ -43,6 +43,7 @@ #include "Event.h" #include "Frame.h" #include "FrameLoader.h" +#include "FrameLoaderClient.h" #include "FrameTree.h" #include "HistoryItem.h" #include "Logging.h" @@ -53,6 +54,7 @@ #include "SharedBuffer.h" #include <wtf/Assertions.h> +#include <wtf/text/CString.h> #include <wtf/unicode/Unicode.h> namespace WebCore { @@ -281,8 +283,27 @@ void DocumentLoader::commitLoad(const char* data, int length) RefPtr<DocumentLoader> protect(this); commitIfReady(); - if (FrameLoader* frameLoader = DocumentLoader::frameLoader()) - frameLoader->committedLoad(this, data, length); + FrameLoader* frameLoader = DocumentLoader::frameLoader(); + if (!frameLoader) + return; + if (ArchiveFactory::isArchiveMimeType(response().mimeType())) + return; + frameLoader->client()->committedLoad(this, data, length); +} + +void DocumentLoader::commitData(const char* bytes, int length) +{ + // Set the text encoding. This is safe to call multiple times. + bool userChosen = true; + String encoding = overrideEncoding(); + if (encoding.isNull()) { + userChosen = false; + encoding = response().textEncodingName(); + } + // FIXME: DocumentWriter should be owned by DocumentLoader. + m_frame->loader()->writer()->setEncoding(encoding, userChosen); + ASSERT(m_frame->document()->parsing()); + m_frame->loader()->writer()->addData(bytes, length); } bool DocumentLoader::doesProgressiveLoad(const String& MIMEType) const @@ -547,7 +568,7 @@ void DocumentLoader::substituteResourceDeliveryTimerFired(Timer<DocumentLoader>* loader->didReceiveResponse(resource->response()); loader->didReceiveData(data->data(), data->size(), data->size(), true); - loader->didFinishLoading(); + loader->didFinishLoading(0); } else { // A null resource means that we should fail the load. // FIXME: Maybe we should use another error here - something like "not in cache". diff --git a/WebCore/loader/DocumentLoader.h b/WebCore/loader/DocumentLoader.h index bc81350..ebb6525 100644 --- a/WebCore/loader/DocumentLoader.h +++ b/WebCore/loader/DocumentLoader.h @@ -215,6 +215,10 @@ namespace WebCore { DocumentLoadTiming* timing() { return &m_documentLoadTiming; } void resetTiming() { m_documentLoadTiming = DocumentLoadTiming(); } + // The WebKit layer calls this function when it's ready for the data to + // actually be added to the document. + void commitData(const char* bytes, int length); + #if ENABLE(OFFLINE_WEB_APPLICATIONS) ApplicationCacheHost* applicationCacheHost() const { return m_applicationCacheHost.get(); } #endif diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h index e012b64..f295663 100644 --- a/WebCore/loader/EmptyClients.h +++ b/WebCore/loader/EmptyClients.h @@ -309,6 +309,7 @@ public: virtual bool canHandleRequest(const ResourceRequest&) const { return false; } virtual bool canShowMIMEType(const String&) const { return false; } + virtual bool canShowMIMETypeAsHTML(const String&) const { return false; } virtual bool representationExistsForURLScheme(const String&) const { return false; } virtual String generatedMIMETypeForURLScheme(const String&) const { return ""; } @@ -442,6 +443,8 @@ public: virtual void markedTextAbandoned(Frame*) { } virtual NSString* userVisibleString(NSURL*) { return 0; } + virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector<RefPtr<ArchiveResource> >&) { return 0; }; + virtual void setInsertionPasteboard(NSPasteboard*) { }; #ifdef BUILDING_ON_TIGER virtual NSArray* pasteboardTypesForSelection(Frame*) { return 0; } #endif @@ -475,6 +478,7 @@ public: #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) virtual void showCorrectionPanel(const FloatRect&, const String&, const String&, Editor*) { } virtual void dismissCorrectionPanel(bool) { } + virtual bool isShowingCorrectionPanel() { return false; } #endif virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { } virtual void updateSpellingUIWithMisspelledWord(const String&) { } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 17db3fa..35909ea 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -1107,14 +1107,6 @@ void FrameLoader::willSetEncoding() receivedFirstData(); } -void FrameLoader::addData(const char* bytes, int length) -{ - ASSERT(m_workingURL.isEmpty()); - ASSERT(m_frame->document()); - ASSERT(m_frame->document()->parsing()); - writer()->addData(bytes, length); -} - #if ENABLE(WML) static inline bool frameContainsWMLContent(Frame* frame) { @@ -1283,9 +1275,10 @@ void FrameLoader::loadFrameRequest(const FrameLoadRequest& request, bool lockHis referrer = m_outgoingReferrer; ASSERT(frame()->document()); - if (SchemeRegistry::shouldTreatURLAsLocal(url.string()) && !isFeedWithNestedProtocolInHTTPFamily(url)) { - if (!SecurityOrigin::canDisplay(url, String(), frame()->document()) && !SecurityOrigin::canDisplay(url, referrer, 0)) { - FrameLoader::reportLocalLoadFailed(m_frame, url.string()); + // FIXME: Should we move the isFeedWithNestedProtocolInHTTPFamily logic inside SecurityOrigin::canDisplay? + if (!isFeedWithNestedProtocolInHTTPFamily(url)) { + if (!frame()->document()->securityOrigin()->canDisplay(url) && !SecurityOrigin::deprecatedCanDisplay(referrer, url)) { + reportLocalLoadFailed(m_frame, url.string()); return; } } @@ -1519,11 +1512,6 @@ const ResourceRequest& FrameLoader::initialRequest() const return activeDocumentLoader()->originalRequest(); } -void FrameLoader::receivedData(const char* data, int length) -{ - activeDocumentLoader()->receivedData(data, length); -} - bool FrameLoader::willLoadMediaElementURL(KURL& url) { ResourceRequest request(url); @@ -1880,6 +1868,14 @@ void FrameLoader::commitProvisionalLoad() if (cachedPage && cachedPage->document()) { prepareForCachedPageRestore(); cachedPage->restore(m_frame->page()); + + dispatchDidCommitLoad(); + + // If we have a title let the WebView know about it. + String title = m_documentLoader->title(); + if (!title.isNull()) + m_client->dispatchDidReceiveTitle(title); + checkCompleted(); } else { KURL url = pdl->substituteData().responseURL(); @@ -1960,7 +1956,6 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage) // Handle adding the URL to the back/forward list. DocumentLoader* dl = m_documentLoader.get(); - String ptitle = dl->title(); switch (m_loadType) { case FrameLoadTypeForward: @@ -2037,14 +2032,6 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage) if (!m_client->hasHTMLView()) receivedFirstData(); - else if (cachedPage) { - // For non-cached HTML pages, these methods are called in receivedFirstData(). - dispatchDidCommitLoad(); - - // If we have a title let the WebView know about it. - if (!ptitle.isNull()) - m_client->dispatchDidReceiveTitle(ptitle); - } } void FrameLoader::clientRedirectCancelledOrFinished(bool cancelWithLoadInProgress) @@ -2260,8 +2247,10 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader) if (!archive) return; - loader->addAllArchiveResources(archive.get()); + // FIXME: The remainder of this function should be in DocumentLoader. + loader->addAllArchiveResources(archive.get()); + ArchiveResource* mainResource = archive->mainResource(); loader->setParsedArchiveData(mainResource->data()); @@ -2270,9 +2259,11 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader) closeURL(); didOpenURL(mainResource->url()); + ASSERT(m_frame->document()); String userChosenEncoding = documentLoader()->overrideEncoding(); bool encodingIsUserChosen = !userChosenEncoding.isNull(); writer()->setEncoding(encodingIsUserChosen ? userChosenEncoding : mainResource->textEncoding(), encodingIsUserChosen); +<<<<<<< HEAD ASSERT(m_frame->document()); @@ -2280,6 +2271,9 @@ void FrameLoader::finishedLoadingDocument(DocumentLoader* loader) #else m_client->finishedLoading(loader); #endif // ARCHIVE +======= + writer()->addData(mainResource->data()->data(), mainResource->data()->size()); +>>>>>>> webkit.org at r67908 } bool FrameLoader::isReplacing() const @@ -2738,6 +2732,7 @@ void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, String origin) request.setHTTPOrigin(origin); } +<<<<<<< HEAD void FrameLoader::committedLoad(DocumentLoader* loader, const char* data, int length) { #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size @@ -2747,6 +2742,8 @@ void FrameLoader::committedLoad(DocumentLoader* loader, const char* data, int le m_client->committedLoad(loader, data, length); } +======= +>>>>>>> webkit.org at r67908 void FrameLoader::loadPostRequest(const ResourceRequest& inRequest, const String& referrer, const String& frameName, bool lockHistory, FrameLoadType loadType, PassRefPtr<Event> event, PassRefPtr<FormState> prpFormState) { RefPtr<FormState> formState = prpFormState; @@ -2817,7 +2814,7 @@ unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& requ #if ENABLE(OFFLINE_WEB_APPLICATIONS) if (!documentLoader()->applicationCacheHost()->maybeLoadSynchronously(newRequest, error, response, data)) { #endif - ResourceHandle::loadResourceSynchronously(newRequest, storedCredentials, error, response, data, m_frame); + ResourceHandle::loadResourceSynchronously(networkingContext(), newRequest, storedCredentials, error, response, data); #if ENABLE(OFFLINE_WEB_APPLICATIONS) documentLoader()->applicationCacheHost()->maybeLoadFallbackSynchronously(newRequest, error, response, data); } @@ -3094,6 +3091,9 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource) unsigned long identifier; ResourceError error; requestFromDelegate(request, identifier, error); +#if ENABLE(INSPECTOR) + page->inspectorController()->markResourceAsCached(identifier); +#endif notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, resource->response(), resource->encodedSize(), error); } diff --git a/WebCore/loader/FrameLoader.h b/WebCore/loader/FrameLoader.h index a887e3b..965e57f 100644 --- a/WebCore/loader/FrameLoader.h +++ b/WebCore/loader/FrameLoader.h @@ -157,7 +157,6 @@ public: const ResourceRequest& originalRequest() const; const ResourceRequest& initialRequest() const; void receivedMainResourceError(const ResourceError&, bool isComplete); - void receivedData(const char*, int); bool willLoadMediaElementURL(KURL&); @@ -183,7 +182,6 @@ public: void didReceiveServerRedirectForProvisionalLoadForFrame(); void finishedLoadingDocument(DocumentLoader*); - void committedLoad(DocumentLoader*, const char*, int); bool isReplacing() const; void setReplacing(); void revertToProvisional(DocumentLoader*); @@ -266,8 +264,6 @@ public: void resetMultipleFormSubmissionProtection(); - void addData(const char* bytes, int length); - void checkCallImplicitClose(); void frameDetached(); @@ -337,7 +333,7 @@ public: bool pageDismissalEventBeingDispatched() const { return m_pageDismissalEventBeingDispatched; } - inline NetworkingContext* networkingContext() const; + NetworkingContext* networkingContext() const; private: bool canCachePageContainingThisFrame(); diff --git a/WebCore/loader/FrameLoaderClient.h b/WebCore/loader/FrameLoaderClient.h index 7c28c51..427b81e 100644 --- a/WebCore/loader/FrameLoaderClient.h +++ b/WebCore/loader/FrameLoaderClient.h @@ -204,6 +204,7 @@ namespace WebCore { virtual bool canHandleRequest(const ResourceRequest&) const = 0; virtual bool canShowMIMEType(const String& MIMEType) const = 0; + virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const = 0; virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0; virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0; diff --git a/WebCore/loader/MainResourceLoader.cpp b/WebCore/loader/MainResourceLoader.cpp index a7a5968..d976841 100644 --- a/WebCore/loader/MainResourceLoader.cpp +++ b/WebCore/loader/MainResourceLoader.cpp @@ -146,7 +146,7 @@ bool MainResourceLoader::isPostOrRedirectAfterPost(const ResourceRequest& newReq void MainResourceLoader::addData(const char* data, int length, bool allAtOnce) { ResourceLoader::addData(data, length, allAtOnce); - frameLoader()->receivedData(data, length); + documentLoader()->receivedData(data, length); } void MainResourceLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse) @@ -275,9 +275,9 @@ void MainResourceLoader::continueAfterContentPolicy(PolicyAction contentPolicy, if (m_substituteData.content()->size()) didReceiveData(m_substituteData.content()->data(), m_substituteData.content()->size(), m_substituteData.content()->size(), true); if (frameLoader() && !frameLoader()->isStopping()) - didFinishLoading(); + didFinishLoading(0); } else if (shouldLoadAsEmptyDocument(url) || frameLoader()->representationExistsForURLScheme(url.protocol())) - didFinishLoading(); + didFinishLoading(0); } } @@ -420,7 +420,7 @@ void MainResourceLoader::didReceiveData(const char* data, int length, long long ResourceLoader::didReceiveData(data, length, lengthReceived, allAtOnce); } -void MainResourceLoader::didFinishLoading() +void MainResourceLoader::didFinishLoading(double finishTime) { // There is a bug in CFNetwork where callbacks can be dispatched even when loads are deferred. // See <rdar://problem/6304600> for more details. @@ -439,7 +439,7 @@ void MainResourceLoader::didFinishLoading() ASSERT(!documentLoader()->timing()->responseEnd); documentLoader()->timing()->responseEnd = m_timeOfLastDataReceived; frameLoader()->finishedLoading(); - ResourceLoader::didFinishLoading(); + ResourceLoader::didFinishLoading(finishTime); #if ENABLE(OFFLINE_WEB_APPLICATIONS) dl->applicationCacheHost()->finishedLoadingMainResource(); @@ -538,7 +538,7 @@ bool MainResourceLoader::loadNow(ResourceRequest& r) else if (shouldLoadEmpty || frameLoader()->representationExistsForURLScheme(url.protocol())) handleEmptyLoad(url, !shouldLoadEmpty); else - m_handle = ResourceHandle::create(r, this, m_frame.get(), false, true); + m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), r, this, false, true); return false; } diff --git a/WebCore/loader/MainResourceLoader.h b/WebCore/loader/MainResourceLoader.h index e2d075c..35eab2f 100644 --- a/WebCore/loader/MainResourceLoader.h +++ b/WebCore/loader/MainResourceLoader.h @@ -58,7 +58,7 @@ namespace WebCore { virtual void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse); virtual void didReceiveResponse(const ResourceResponse&); virtual void didReceiveData(const char*, int, long long lengthReceived, bool allAtOnce); - virtual void didFinishLoading(); + virtual void didFinishLoading(double finishTime); virtual void didFail(const ResourceError&); #if HAVE(RUNLOOP_TIMER) diff --git a/WebCore/loader/NetscapePlugInStreamLoader.cpp b/WebCore/loader/NetscapePlugInStreamLoader.cpp index 9d0e81b..1225652 100644 --- a/WebCore/loader/NetscapePlugInStreamLoader.cpp +++ b/WebCore/loader/NetscapePlugInStreamLoader.cpp @@ -95,13 +95,13 @@ void NetscapePlugInStreamLoader::didReceiveData(const char* data, int length, lo ResourceLoader::didReceiveData(data, length, lengthReceived, allAtOnce); } -void NetscapePlugInStreamLoader::didFinishLoading() +void NetscapePlugInStreamLoader::didFinishLoading(double finishTime) { RefPtr<NetscapePlugInStreamLoader> protect(this); m_documentLoader->removePlugInStreamLoader(this); m_client->didFinishLoading(this); - ResourceLoader::didFinishLoading(); + ResourceLoader::didFinishLoading(finishTime); } void NetscapePlugInStreamLoader::didFail(const ResourceError& error) diff --git a/WebCore/loader/NetscapePlugInStreamLoader.h b/WebCore/loader/NetscapePlugInStreamLoader.h index 092c6fc..c8c4cb6 100644 --- a/WebCore/loader/NetscapePlugInStreamLoader.h +++ b/WebCore/loader/NetscapePlugInStreamLoader.h @@ -55,7 +55,7 @@ namespace WebCore { private: virtual void didReceiveResponse(const ResourceResponse&); virtual void didReceiveData(const char*, int, long long lengthReceived, bool allAtOnce); - virtual void didFinishLoading(); + virtual void didFinishLoading(double finishTime); virtual void didFail(const ResourceError&); virtual void releaseResources(); diff --git a/WebCore/loader/PingLoader.cpp b/WebCore/loader/PingLoader.cpp index 268e007..2a628ce 100644 --- a/WebCore/loader/PingLoader.cpp +++ b/WebCore/loader/PingLoader.cpp @@ -42,7 +42,7 @@ namespace WebCore { void PingLoader::loadImage(Frame* frame, const KURL& url) { - if (SecurityOrigin::restrictAccessToLocal() && !SecurityOrigin::canDisplay(url, String(), frame->document())) { + if (!frame->document()->securityOrigin()->canDisplay(url)) { FrameLoader::reportLocalLoadFailed(frame, url); return; } @@ -62,7 +62,7 @@ void PingLoader::loadImage(Frame* frame, const KURL& url) PingLoader::PingLoader(Frame* frame, const ResourceRequest& request) { - m_handle = ResourceHandle::create(request, this, frame, false, false); + m_handle = ResourceHandle::create(frame->loader()->networkingContext(), request, this, false, false); } PingLoader::~PingLoader() diff --git a/WebCore/loader/PingLoader.h b/WebCore/loader/PingLoader.h index 1d8a2d8..e26a9c9 100644 --- a/WebCore/loader/PingLoader.h +++ b/WebCore/loader/PingLoader.h @@ -60,7 +60,7 @@ private: void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { delete this; } void didReceiveData(ResourceHandle*, const char*, int) { delete this; } - void didFinishLoading(ResourceHandle*) { delete this; } + void didFinishLoading(ResourceHandle*, double) { delete this; } void didFail(ResourceHandle*, const ResourceError&) { delete this; } RefPtr<ResourceHandle> m_handle; diff --git a/WebCore/loader/RedirectScheduler.cpp b/WebCore/loader/RedirectScheduler.cpp index 7cb6090..ce0e3f8 100644 --- a/WebCore/loader/RedirectScheduler.cpp +++ b/WebCore/loader/RedirectScheduler.cpp @@ -33,6 +33,7 @@ #include "RedirectScheduler.h" #include "BackForwardList.h" +#include "DOMWindow.h" #include "DocumentLoader.h" #include "Event.h" #include "FormState.h" @@ -41,9 +42,9 @@ #include "FrameLoadRequest.h" #include "FrameLoader.h" #include "FrameLoaderStateMachine.h" -#include "HistoryItem.h" #include "HTMLFormElement.h" #include "HTMLFrameOwnerElement.h" +#include "HistoryItem.h" #include "Page.h" #include "UserGestureIndicator.h" #include <wtf/CurrentTime.h> @@ -52,12 +53,13 @@ namespace WebCore { class ScheduledNavigation : public Noncopyable { public: - ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange) + ScheduledNavigation(double delay, bool lockHistory, bool lockBackForwardList, bool wasDuringLoad, bool isLocationChange, bool wasUserGesture) : m_delay(delay) , m_lockHistory(lockHistory) , m_lockBackForwardList(lockBackForwardList) , m_wasDuringLoad(wasDuringLoad) , m_isLocationChange(isLocationChange) + , m_wasUserGesture(wasUserGesture) { } virtual ~ScheduledNavigation() { } @@ -73,6 +75,7 @@ public: bool lockBackForwardList() const { return m_lockBackForwardList; } bool wasDuringLoad() const { return m_wasDuringLoad; } bool isLocationChange() const { return m_isLocationChange; } + bool wasUserGesture() const { return m_wasUserGesture; } private: double m_delay; @@ -80,22 +83,22 @@ private: bool m_lockBackForwardList; bool m_wasDuringLoad; bool m_isLocationChange; + bool m_wasUserGesture; }; class ScheduledURLNavigation : public ScheduledNavigation { public: ScheduledURLNavigation(double delay, const String& url, const String& referrer, bool lockHistory, bool lockBackForwardList, bool wasUserGesture, bool duringLoad, bool isLocationChange) - : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange) + : ScheduledNavigation(delay, lockHistory, lockBackForwardList, duringLoad, isLocationChange, wasUserGesture) , m_url(url) , m_referrer(referrer) - , m_wasUserGesture(wasUserGesture) , m_haveToldClient(false) { } virtual void fire(Frame* frame) { - frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), m_wasUserGesture, false); + frame->loader()->changeLocation(KURL(ParsedURLString, m_url), m_referrer, lockHistory(), lockBackForwardList(), wasUserGesture(), false); } virtual void didStartTimer(Frame* frame, Timer<RedirectScheduler>* timer) @@ -115,12 +118,10 @@ public: String url() const { return m_url; } String referrer() const { return m_referrer; } - bool wasUserGesture() const { return m_wasUserGesture; } private: String m_url; String m_referrer; - bool m_wasUserGesture; bool m_haveToldClient; }; @@ -151,14 +152,17 @@ public: class ScheduledHistoryNavigation : public ScheduledNavigation { public: - explicit ScheduledHistoryNavigation(int historySteps) : ScheduledNavigation(0, false, false, false, true), m_historySteps(historySteps) { } + explicit ScheduledHistoryNavigation(int historySteps, bool wasUserGesture) : ScheduledNavigation(0, false, false, false, true, wasUserGesture), m_historySteps(historySteps) { } virtual void fire(Frame* frame) { + UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture); + FrameLoader* loader = frame->loader(); if (!m_historySteps) { // Special case for go(0) from a frame -> reload only the frame - loader->urlSelected(loader->url(), "", 0, lockHistory(), lockBackForwardList(), false, SendReferrer); + // To follow Firefox and IE's behavior, history reload can only navigate the self frame. + loader->urlSelected(loader->url(), "_self", 0, lockHistory(), lockBackForwardList(), wasUserGesture(), SendReferrer); return; } // go(i!=0) from a frame navigates into the history of the frame only, @@ -173,17 +177,16 @@ private: class ScheduledFormSubmission : public ScheduledNavigation { public: ScheduledFormSubmission(PassRefPtr<FormSubmission> submission, bool lockBackForwardList, bool duringLoad, bool wasUserGesture) - : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true) + : ScheduledNavigation(0, submission->lockHistory(), lockBackForwardList, duringLoad, true, wasUserGesture) , m_submission(submission) , m_haveToldClient(false) - , m_wasUserGesture(wasUserGesture) { ASSERT(m_submission->state()); } virtual void fire(Frame* frame) { - UserGestureIndicator gestureIndicator(m_wasUserGesture ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture); + UserGestureIndicator gestureIndicator(wasUserGesture() ? DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture); // The submitForm function will find a target frame before using the redirection timer. // Now that the timer has fired, we need to repeat the security check which normally is done when @@ -214,7 +217,6 @@ public: private: RefPtr<FormSubmission> m_submission; bool m_haveToldClient; - bool m_wasUserGesture; }; RedirectScheduler::RedirectScheduler(Frame* frame) @@ -344,9 +346,9 @@ void RedirectScheduler::scheduleHistoryNavigation(int steps) cancel(); return; } - + // In all other cases, schedule the history traversal to occur asynchronously. - schedule(adoptPtr(new ScheduledHistoryNavigation(steps))); + schedule(adoptPtr(new ScheduledHistoryNavigation(steps, m_frame->loader()->isProcessingUserGesture()))); } void RedirectScheduler::timerFired(Timer<RedirectScheduler>*) diff --git a/WebCore/loader/ResourceLoadNotifier.cpp b/WebCore/loader/ResourceLoadNotifier.cpp index d225cb8..c43a1da 100644 --- a/WebCore/loader/ResourceLoadNotifier.cpp +++ b/WebCore/loader/ResourceLoadNotifier.cpp @@ -82,11 +82,11 @@ void ResourceLoadNotifier::didReceiveData(ResourceLoader* loader, const char* da dispatchDidReceiveContentLength(loader->documentLoader(), loader->identifier(), lengthReceived); } -void ResourceLoadNotifier::didFinishLoad(ResourceLoader* loader) +void ResourceLoadNotifier::didFinishLoad(ResourceLoader* loader, double finishTime) { if (Page* page = m_frame->page()) page->progress()->completeProgress(loader->identifier()); - dispatchDidFinishLoading(loader->documentLoader(), loader->identifier()); + dispatchDidFinishLoading(loader->documentLoader(), loader->identifier(), finishTime); } void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceError& error) @@ -150,13 +150,13 @@ void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loade #endif } -void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier) +void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier, double finishTime) { m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier); #if ENABLE(INSPECTOR) if (Page* page = m_frame->page()) - page->inspectorController()->didFinishLoading(identifier); + page->inspectorController()->didFinishLoading(identifier, finishTime); #endif } @@ -169,7 +169,7 @@ void ResourceLoadNotifier::sendRemainingDelegateMessages(DocumentLoader* loader, dispatchDidReceiveContentLength(loader, identifier, length); if (error.isNull()) - dispatchDidFinishLoading(loader, identifier); + dispatchDidFinishLoading(loader, identifier, 0); else m_frame->loader()->client()->dispatchDidFailLoading(loader, identifier, error); } diff --git a/WebCore/loader/ResourceLoadNotifier.h b/WebCore/loader/ResourceLoadNotifier.h index b0a5cbf..758e414 100644 --- a/WebCore/loader/ResourceLoadNotifier.h +++ b/WebCore/loader/ResourceLoadNotifier.h @@ -53,14 +53,14 @@ public: void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse); void didReceiveResponse(ResourceLoader*, const ResourceResponse&); void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived); - void didFinishLoad(ResourceLoader*); + void didFinishLoad(ResourceLoader*, double finishTime); void didFailToLoad(ResourceLoader*, const ResourceError&); void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse); void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&); void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length); - void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier); + void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier, double finishTime); void sendRemainingDelegateMessages(DocumentLoader*, unsigned long identifier, const ResourceResponse&, int length, const ResourceError&); diff --git a/WebCore/loader/ResourceLoader.cpp b/WebCore/loader/ResourceLoader.cpp index f66aa67..3bc1119 100644 --- a/WebCore/loader/ResourceLoader.cpp +++ b/WebCore/loader/ResourceLoader.cpp @@ -35,6 +35,8 @@ #include "FileStreamProxy.h" #include "Frame.h" #include "FrameLoader.h" +#include "FrameLoaderClient.h" +#include "InspectorController.h" #include "InspectorTimelineAgent.h" #include "Page.h" #include "ProgressTracker.h" @@ -145,7 +147,7 @@ bool ResourceLoader::load(const ResourceRequest& r) return true; } - m_handle = ResourceHandle::create(clientRequest, this, m_frame.get(), m_defersLoading, m_shouldContentSniff); + m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), clientRequest, this, m_defersLoading, m_shouldContentSniff); return true; } @@ -286,7 +288,7 @@ void ResourceLoader::willStopBufferingData(const char* data, int length) m_resourceData = SharedBuffer::create(data, length); } -void ResourceLoader::didFinishLoading() +void ResourceLoader::didFinishLoading(double finishTime) { // If load has been cancelled after finishing (which could happen with a // JavaScript that changes the window location), do nothing. @@ -294,11 +296,11 @@ void ResourceLoader::didFinishLoading() return; ASSERT(!m_reachedTerminalState); - didFinishLoadingOnePart(); + didFinishLoadingOnePart(finishTime); releaseResources(); } -void ResourceLoader::didFinishLoadingOnePart() +void ResourceLoader::didFinishLoadingOnePart(double finishTime) { if (m_cancelled) return; @@ -308,7 +310,7 @@ void ResourceLoader::didFinishLoadingOnePart() return; m_calledDidFinishLoad = true; if (m_sendResourceLoadCallbacks) - frameLoader()->notifier()->didFinishLoad(this); + frameLoader()->notifier()->didFinishLoad(this, finishTime); } void ResourceLoader::didFail(const ResourceError& error) @@ -450,9 +452,9 @@ void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int lengt #endif } -void ResourceLoader::didFinishLoading(ResourceHandle*) +void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime) { - didFinishLoading(); + didFinishLoading(finishTime); } void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error) diff --git a/WebCore/loader/ResourceLoader.h b/WebCore/loader/ResourceLoader.h index f2a3161..29afbc1 100644 --- a/WebCore/loader/ResourceLoader.h +++ b/WebCore/loader/ResourceLoader.h @@ -86,7 +86,7 @@ namespace WebCore { virtual void didReceiveData(const char*, int, long long lengthReceived, bool allAtOnce); virtual void didReceiveCachedMetadata(const char*, int) { } void willStopBufferingData(const char*, int); - virtual void didFinishLoading(); + virtual void didFinishLoading(double finishTime); virtual void didFail(const ResourceError&); virtual bool shouldUseCredentialStorage(); @@ -103,7 +103,7 @@ namespace WebCore { virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived); virtual void didReceiveCachedMetadata(ResourceHandle*, const char* data, int length) { didReceiveCachedMetadata(data, length); } - virtual void didFinishLoading(ResourceHandle*); + virtual void didFinishLoading(ResourceHandle*, double finishTime); virtual void didFail(ResourceHandle*, const ResourceError&); virtual void wasBlocked(ResourceHandle*); virtual void cannotShowURL(ResourceHandle*); @@ -139,7 +139,7 @@ namespace WebCore { #endif virtual void didCancel(const ResourceError&); - void didFinishLoadingOnePart(); + void didFinishLoadingOnePart(double finishTime); const ResourceRequest& request() const { return m_request; } bool reachedTerminalState() const { return m_reachedTerminalState; } diff --git a/WebCore/loader/SubframeLoader.cpp b/WebCore/loader/SubframeLoader.cpp index c25b37e..e247e5b 100644 --- a/WebCore/loader/SubframeLoader.cpp +++ b/WebCore/loader/SubframeLoader.cpp @@ -87,6 +87,15 @@ bool SubframeLoader::requestFrame(HTMLFrameOwnerElement* ownerElement, const Str return true; } + +bool SubframeLoader::resourceWillUsePlugin(const String& url, const String& mimeType) +{ + KURL completedURL; + if (!url.isEmpty()) + completedURL = completeURL(url); + bool useFallback; + return shouldUsePlugin(completedURL, mimeType, false, useFallback); +} bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) @@ -147,7 +156,7 @@ PassRefPtr<Widget> SubframeLoader::loadMediaPlayerProxyPlugin(Node* node, const if (!url.isEmpty()) completedURL = completeURL(url); - if (!SecurityOrigin::canDisplay(completedURL, String(), m_frame->document())) { + if (!m_frame->document()->securityOrigin()->canDisplay(completedURL)) { FrameLoader::reportLocalLoadFailed(m_frame, completedURL.string()); return 0; } @@ -205,7 +214,7 @@ PassRefPtr<Widget> SubframeLoader::createJavaAppletWidget(const IntSize& size, H if (!codeBaseURLString.isEmpty()) { KURL codeBaseURL = completeURL(codeBaseURLString); - if (!SecurityOrigin::canDisplay(codeBaseURL, String(), element->document())) { + if (!element->document()->securityOrigin()->canDisplay(codeBaseURL)) { FrameLoader::reportLocalLoadFailed(m_frame, codeBaseURL.string()); return 0; } @@ -247,7 +256,7 @@ Frame* SubframeLoader::loadSubframe(HTMLFrameOwnerElement* ownerElement, const K marginHeight = o->getMarginHeight(); } - if (!SecurityOrigin::canDisplay(url, String(), ownerElement->document())) { + if (!ownerElement->document()->securityOrigin()->canDisplay(url)) { FrameLoader::reportLocalLoadFailed(m_frame, url.string()); return 0; } @@ -336,7 +345,7 @@ bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const KUR if (!renderer || useFallback) return false; - if (!SecurityOrigin::canDisplay(url, String(), document())) { + if (!document()->securityOrigin()->canDisplay(url)) { FrameLoader::reportLocalLoadFailed(m_frame, url.string()); return false; } diff --git a/WebCore/loader/SubframeLoader.h b/WebCore/loader/SubframeLoader.h index 6c3baf8..a573045 100644 --- a/WebCore/loader/SubframeLoader.h +++ b/WebCore/loader/SubframeLoader.h @@ -75,6 +75,8 @@ public: bool allowPlugins(ReasonForCallingAllowPlugins); bool containsPlugins() const { return m_containsPlugins; } + + bool resourceWillUsePlugin(const String& url, const String& mimeType); private: Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement*, const KURL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList); diff --git a/WebCore/loader/SubresourceLoader.cpp b/WebCore/loader/SubresourceLoader.cpp index a389082..5377382 100644 --- a/WebCore/loader/SubresourceLoader.cpp +++ b/WebCore/loader/SubresourceLoader.cpp @@ -71,9 +71,7 @@ PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, Subresourc ResourceRequest newRequest = request; - if (securityCheck == DoSecurityCheck - && SecurityOrigin::restrictAccessToLocal() - && !SecurityOrigin::canDisplay(request.url(), String(), frame->document())) { + if (securityCheck == DoSecurityCheck && !frame->document()->securityOrigin()->canDisplay(request.url())) { FrameLoader::reportLocalLoadFailed(frame, request.url().string()); return 0; } @@ -142,7 +140,7 @@ void SubresourceLoader::didReceiveResponse(const ResourceResponse& r) // After the first multipart section is complete, signal to delegates that this load is "finished" m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this); - didFinishLoadingOnePart(); + didFinishLoadingOnePart(0); } } @@ -170,7 +168,7 @@ void SubresourceLoader::didReceiveCachedMetadata(const char* data, int length) m_client->didReceiveCachedMetadata(this, data, length); } -void SubresourceLoader::didFinishLoading() +void SubresourceLoader::didFinishLoading(double finishTime) { if (cancelled()) return; @@ -187,7 +185,7 @@ void SubresourceLoader::didFinishLoading() if (cancelled()) return; m_documentLoader->removeSubresourceLoader(this); - ResourceLoader::didFinishLoading(); + ResourceLoader::didFinishLoading(finishTime); } void SubresourceLoader::didFail(const ResourceError& error) diff --git a/WebCore/loader/SubresourceLoader.h b/WebCore/loader/SubresourceLoader.h index 4a58345..cb7ed81 100644 --- a/WebCore/loader/SubresourceLoader.h +++ b/WebCore/loader/SubresourceLoader.h @@ -52,7 +52,7 @@ namespace WebCore { virtual void didReceiveResponse(const ResourceResponse&); virtual void didReceiveData(const char*, int, long long lengthReceived, bool allAtOnce); virtual void didReceiveCachedMetadata(const char*, int); - virtual void didFinishLoading(); + virtual void didFinishLoading(double finishTime); virtual void didFail(const ResourceError&); virtual bool shouldUseCredentialStorage(); virtual void didReceiveAuthenticationChallenge(const AuthenticationChallenge&); diff --git a/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/WebCore/loader/appcache/ApplicationCacheGroup.cpp index 3ae8d9f..d89f819 100644 --- a/WebCore/loader/appcache/ApplicationCacheGroup.cpp +++ b/WebCore/loader/appcache/ApplicationCacheGroup.cpp @@ -39,6 +39,7 @@ #include "DOMWindow.h" #include "Frame.h" #include "FrameLoader.h" +#include "FrameLoaderClient.h" #include "MainResourceLoader.h" #include "ManifestParser.h" #include "Page.h" @@ -479,7 +480,7 @@ PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KUR } } - RefPtr<ResourceHandle> handle = ResourceHandle::create(request, this, m_frame, false, true); + RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader()->networkingContext(), request, this, false, true); #if ENABLE(INSPECTOR) // Because willSendRequest only gets called during redirects, we initialize // the identifier and the first willSendRequest here. @@ -601,11 +602,11 @@ void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d m_loadedSize += length; } -void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle) +void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double finishTime) { #if ENABLE(INSPECTOR) if (Page* page = m_frame->page()) - page->inspectorController()->didFinishLoading(m_currentResourceIdentifier); + page->inspectorController()->didFinishLoading(m_currentResourceIdentifier, finishTime); #endif if (handle == m_manifestHandle) { diff --git a/WebCore/loader/appcache/ApplicationCacheGroup.h b/WebCore/loader/appcache/ApplicationCacheGroup.h index b5cdf7b..99ab71a 100644 --- a/WebCore/loader/appcache/ApplicationCacheGroup.h +++ b/WebCore/loader/appcache/ApplicationCacheGroup.h @@ -113,7 +113,7 @@ private: #endif virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); virtual void didReceiveData(ResourceHandle*, const char*, int length, int lengthReceived); - virtual void didFinishLoading(ResourceHandle*); + virtual void didFinishLoading(ResourceHandle*, double finishTime); virtual void didFail(ResourceHandle*, const ResourceError&); void didReceiveManifestResponse(const ResourceResponse&); diff --git a/WebCore/loader/icon/IconDatabase.cpp b/WebCore/loader/icon/IconDatabase.cpp index 130b442..6040037 100644 --- a/WebCore/loader/icon/IconDatabase.cpp +++ b/WebCore/loader/icon/IconDatabase.cpp @@ -43,6 +43,7 @@ #include <wtf/CurrentTime.h> #include <wtf/MainThread.h> #include <wtf/StdLibExtras.h> +#include <wtf/text/CString.h> // For methods that are meant to support API from the main thread - should not be called internally #define ASSERT_NOT_SYNC_THREAD() ASSERT(!m_syncThreadRunning || !IS_ICON_SYNC_THREAD()) diff --git a/WebCore/loader/icon/IconFetcher.cpp b/WebCore/loader/icon/IconFetcher.cpp index 1107d7b..f6b80fa 100644 --- a/WebCore/loader/icon/IconFetcher.cpp +++ b/WebCore/loader/icon/IconFetcher.cpp @@ -27,6 +27,7 @@ #include "IconFetcher.h" #include "Frame.h" +#include "FrameLoaderClient.h" #include "HTMLHeadElement.h" #include "HTMLLinkElement.h" #include "HTMLNames.h" @@ -173,7 +174,7 @@ void IconFetcher::loadEntry() ASSERT(m_currentEntry < m_entries.size()); ASSERT(!m_handle); - m_handle = ResourceHandle::create(m_entries[m_currentEntry].url(), this, m_frame, false, false); + m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), m_entries[m_currentEntry].url(), this, false, false); } void IconFetcher::loadFailed() @@ -201,7 +202,7 @@ void IconFetcher::didReceiveData(ResourceHandle* handle, const char* data, int l m_entries[m_currentEntry].buffer()->append(data, length); } -void IconFetcher::didFinishLoading(ResourceHandle* handle) +void IconFetcher::didFinishLoading(ResourceHandle* handle, double) { ASSERT_UNUSED(handle, m_handle == handle); diff --git a/WebCore/loader/icon/IconFetcher.h b/WebCore/loader/icon/IconFetcher.h index 5327693..387e1c3 100644 --- a/WebCore/loader/icon/IconFetcher.h +++ b/WebCore/loader/icon/IconFetcher.h @@ -62,12 +62,12 @@ private: virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&); virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived); - virtual void didFinishLoading(ResourceHandle*); + virtual void didFinishLoading(ResourceHandle*, double /*finishTime*/); virtual void didFail(ResourceHandle*, const ResourceError&); - + Frame* m_frame; IconFetcherClient* m_client; - + unsigned m_currentEntry; RefPtr<ResourceHandle> m_handle; Vector<IconLinkEntry> m_entries; diff --git a/WebCore/loader/icon/IconLoader.cpp b/WebCore/loader/icon/IconLoader.cpp index 877c80e..adfa04b 100644 --- a/WebCore/loader/icon/IconLoader.cpp +++ b/WebCore/loader/icon/IconLoader.cpp @@ -38,6 +38,7 @@ #include "SharedBuffer.h" #include "SubresourceLoader.h" #include <wtf/UnusedParam.h> +#include <wtf/text/CString.h> using namespace std; diff --git a/WebCore/loader/icon/wince/IconDatabaseWince.cpp b/WebCore/loader/icon/wince/IconDatabaseWinCE.cpp index 54a36e5..54a36e5 100644 --- a/WebCore/loader/icon/wince/IconDatabaseWince.cpp +++ b/WebCore/loader/icon/wince/IconDatabaseWinCE.cpp |