#include "PageTransitionEvent.h"
#include "PlatformStrategies.h"
#include "PluginData.h"
-#include "PluginDatabase.h"
#include "PluginDocument.h"
#include "PolicyChecker.h"
#include "ProgressTracker.h"
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
-#if ENABLE(SHARED_WORKERS)
-#include "SharedWorkerRepository.h"
-#endif
-
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
#include "Archive.h"
#endif
// time into freed memory.
RefPtr<DocumentLoader> documentLoader = m_provisionalDocumentLoader;
m_pageDismissalEventBeingDispatched = UnloadDismissal;
- if (documentLoader && !documentLoader->timing()->unloadEventStart() && !documentLoader->timing()->unloadEventEnd()) {
- DocumentLoadTiming* timing = documentLoader->timing();
- ASSERT(timing->navigationStart());
- timing->markUnloadEventStart();
+ if (documentLoader && !documentLoader->timing().unloadEventStart() && !documentLoader->timing().unloadEventEnd()) {
+ DocumentLoadTiming& timing = documentLoader->timing();
+ ASSERT(timing.navigationStart());
+ timing.markUnloadEventStart();
m_frame.document()->domWindow()->dispatchEvent(unloadEvent, m_frame.document());
- timing->markUnloadEventEnd();
+ timing.markUnloadEventEnd();
} else
m_frame.document()->domWindow()->dispatchEvent(unloadEvent, m_frame.document());
}
// http://www.w3.org/Bugs/Public/show_bug.cgi?id=10537
doc->setReadyState(Document::Complete);
-#if ENABLE(SQL_DATABASE)
// FIXME: Should the DatabaseManager watch for something like ActiveDOMObject::stop() rather than being special-cased here?
DatabaseManager::manager().stopDatabases(doc, 0);
-#endif
}
// FIXME: This will cancel redirection timer, which really needs to be restarted when restoring the frame from b/f cache.
if (m_frame.editor().hasComposition()) {
// The text was already present in DOM, so it's better to confirm than to cancel the composition.
m_frame.editor().confirmComposition();
- if (EditorClient* editorClient = m_frame.editor().client())
+ if (EditorClient* editorClient = m_frame.editor().client()) {
editorClient->respondToChangedSelection(&m_frame);
+ editorClient->discardedComposition(&m_frame);
+ }
}
}
bool FrameLoader::closeURL()
{
history().saveDocumentState();
-
- // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.
+
Document* currentDocument = m_frame.document();
- stopLoading(currentDocument && !currentDocument->inPageCache() ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly);
+ UnloadEventPolicy unloadEventPolicy;
+ if (m_frame.page() && m_frame.page()->chrome().client().isSVGImageChromeClient()) {
+ // If this is the SVGDocument of an SVGImage, no need to dispatch events or recalcStyle.
+ unloadEventPolicy = UnloadEventPolicyNone;
+ } else {
+ // Should only send the pagehide event here if the current document exists and has not been placed in the page cache.
+ unloadEventPolicy = currentDocument && !currentDocument->inPageCache() ? UnloadEventPolicyUnloadAndPageHide : UnloadEventPolicyUnloadOnly;
+ }
+
+ stopLoading(unloadEventPolicy);
m_frame.editor().clearUndoRedoOperations();
return true;
m_frame.document()->initContentSecurityPolicy();
const Settings& settings = m_frame.settings();
- m_frame.document()->cachedResourceLoader()->setImagesEnabled(settings.areImagesEnabled());
- m_frame.document()->cachedResourceLoader()->setAutoLoadImages(settings.loadsImagesAutomatically());
+ m_frame.document()->cachedResourceLoader().setImagesEnabled(settings.areImagesEnabled());
+ m_frame.document()->cachedResourceLoader().setAutoLoadImages(settings.loadsImagesAutomatically());
if (m_documentLoader) {
String dnsPrefetchControl = m_documentLoader->response().httpHeaderField(HTTPHeaderName::XDNSPrefetchControl);
return;
// Still waiting for images/scripts?
- if (m_frame.document()->cachedResourceLoader()->requestCount())
+ if (m_frame.document()->cachedResourceLoader().requestCount())
return;
// Still waiting for elements that don't go through a FrameLoader?
}
#endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
-ObjectContentType FrameLoader::defaultObjectContentType(const URL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages)
-{
- String mimeType = mimeTypeIn;
-
- if (mimeType.isEmpty())
- mimeType = mimeTypeFromURL(url);
-
-#if !PLATFORM(COCOA) && !PLATFORM(EFL) // Mac has no PluginDatabase, nor does EFL
- if (mimeType.isEmpty()) {
- String decodedPath = decodeURLEscapeSequences(url.path());
- mimeType = PluginDatabase::installedPlugins()->MIMETypeForExtension(decodedPath.substring(decodedPath.reverseFind('.') + 1));
- }
-#endif
-
- if (mimeType.isEmpty())
- return ObjectContentFrame; // Go ahead and hope that we can display the content.
-
-#if !PLATFORM(COCOA) && !PLATFORM(EFL) // Mac has no PluginDatabase, nor does EFL
- bool plugInSupportsMIMEType = PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType);
-#else
- bool plugInSupportsMIMEType = false;
-#endif
-
- if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
- return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? WebCore::ObjectContentNetscapePlugin : WebCore::ObjectContentImage;
-
- if (plugInSupportsMIMEType)
- return WebCore::ObjectContentNetscapePlugin;
-
- if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
- return WebCore::ObjectContentFrame;
-
- return WebCore::ObjectContentNone;
-}
-
String FrameLoader::outgoingReferrer() const
{
// See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources
parent->loader().checkCompleted();
if (m_frame.view())
- m_frame.view()->maintainScrollPositionAtAnchor(0);
+ m_frame.view()->maintainScrollPositionAtAnchor(nullptr);
m_activityAssertion = nullptr;
}
loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes);
}
+static void logNavigation(MainFrame& frame, FrameLoadType type)
+{
+ String navigationDescription;
+ switch (type) {
+ case FrameLoadType::Standard:
+ navigationDescription = ASCIILiteral("standard");
+ break;
+ case FrameLoadType::Back:
+ navigationDescription = ASCIILiteral("back");
+ break;
+ case FrameLoadType::Forward:
+ navigationDescription = ASCIILiteral("forward");
+ break;
+ case FrameLoadType::IndexedBackForward:
+ navigationDescription = ASCIILiteral("indexedBackForward");
+ break;
+ case FrameLoadType::Reload:
+ navigationDescription = ASCIILiteral("reload");
+ break;
+ case FrameLoadType::Same:
+ navigationDescription = ASCIILiteral("same");
+ break;
+ case FrameLoadType::ReloadFromOrigin:
+ navigationDescription = ASCIILiteral("reloadFromOrigin");
+ break;
+ case FrameLoadType::Replace:
+ case FrameLoadType::RedirectWithLockedBackForwardList:
+ // Not logging those for now.
+ return;
+ }
+ frame.diagnosticLoggingClient().logDiagnosticMessage(DiagnosticLoggingKeys::navigationKey(), navigationDescription);
+}
+
void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> prpFormState, AllowNavigationToInvalidURL allowNavigationToInvalidURL)
{
// Retain because dispatchBeforeLoadEvent may release the last reference to it.
if (m_frame.document())
m_previousURL = m_frame.document()->url();
+ // Log main frame navigation types.
+ if (m_frame.isMainFrame())
+ logNavigation(static_cast<MainFrame&>(m_frame), type);
+
policyChecker().setLoadType(type);
RefPtr<FormState> formState = prpFormState;
bool isFormSubmission = formState;
std::unique_ptr<CachedPage> cachedPage;
if (m_loadingFromCachedPage)
- cachedPage = pageCache()->take(history().provisionalItem());
+ cachedPage = PageCache::shared().take(history().provisionalItem(), m_frame.page());
LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame.tree().uniqueName().string().utf8().data(),
m_frame.document() ? m_frame.document()->url().stringCenterEllipsizedToLength().utf8().data() : "",
LOG(MemoryPressure, "Pruning page cache because under memory pressure at: %s", __PRETTY_FUNCTION__);
LOG(PageCache, "Pruning page cache to 0 due to memory pressure");
// Don't cache any page if we are under memory pressure.
- pageCache()->pruneToCapacityNow(0);
+ PageCache::shared().pruneToCapacityNow(0, PruningReason::MemoryPressure);
} else if (systemMemoryLevel() <= memoryLevelThresholdToPrunePageCache) {
LOG(MemoryPressure, "Pruning page cache because system memory level is %d at: %s", systemMemoryLevel(), __PRETTY_FUNCTION__);
- LOG(PageCache, "Pruning page cache to %d due to low memory (level %d less or equal to %d threshold)", pageCache()->capacity() / 2, systemMemoryLevel(), memoryLevelThresholdToPrunePageCache);
- pageCache()->pruneToCapacityNow(pageCache()->capacity() / 2);
+ LOG(PageCache, "Pruning page cache to %d due to low memory (level %d less or equal to %d threshold)", PageCache::shared().capacity() / 2, systemMemoryLevel(), memoryLevelThresholdToPrunePageCache);
+ PageCache::shared().pruneToCapacityNow(PageCache::shared().capacity() / 2, PruningReason::MemoryPressure);
}
}
#endif
// Check to see if we need to cache the page we are navigating away from into the back/forward cache.
// We are doing this here because we know for sure that a new page is about to be loaded.
HistoryItem* item = history().currentItem();
- if (!m_frame.tree().parent() && pageCache()->canCache(m_frame.page()) && !item->isInPageCache())
- pageCache()->add(item, *m_frame.page());
+ if (!m_frame.tree().parent() && PageCache::shared().canCache(m_frame.page()) && !item->isInPageCache())
+ PageCache::shared().add(item, *m_frame.page());
if (m_loadType != FrameLoadType::Replace)
closeOldDataSources();
if (pdl && m_documentLoader) {
// Check if the destination page is allowed to access the previous page's timing information.
- RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->request().url());
- m_documentLoader->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canRequest(m_previousURL));
+ Ref<SecurityOrigin> securityOrigin(SecurityOrigin::create(pdl->request().url()));
+ m_documentLoader->timing().setHasSameOriginAsPreviousDocument(securityOrigin.get().canRequest(m_previousURL));
}
// Call clientRedirectCancelledOrFinished() here so that the frame load delegate is notified that the redirect's
if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache())
cache->frameLoadingEventNotification(&m_frame, loadingEvent);
- if (!page || !page->settings().diagnosticLoggingEnabled())
- return;
-
- DiagnosticLoggingClient* diagnosticLoggingClient = page->mainFrame().diagnosticLoggingClient();
- if (!diagnosticLoggingClient)
- return;
-
- diagnosticLoggingClient->logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingClient::Pass : DiagnosticLoggingClient::Fail);
+ if (page)
+ page->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageLoadedKey(), emptyString(), error.isNull() ? DiagnosticLoggingResultPass : DiagnosticLoggingResultFail);
return;
}
int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
{
if (!recurse)
- return m_frame.document()->cachedResourceLoader()->requestCount();
+ return m_frame.document()->cachedResourceLoader().requestCount();
int count = 0;
for (Frame* frame = &m_frame; frame; frame = frame->tree().traverseNext(&m_frame))
- count += frame->document()->cachedResourceLoader()->requestCount();
+ count += frame->document()->cachedResourceLoader().requestCount();
return count;
}
// handlers might start a new subresource load in this frame.
stopAllLoaders();
- InspectorInstrumentation::frameDetachedFromParent(&m_frame);
+ InspectorInstrumentation::frameDetachedFromParent(m_frame);
detachViewsAndDocumentLoader();
return true;
RefPtr<Document> document = m_frame.document();
- if (!document->body())
+ if (!document->bodyOrFrameset())
return true;
RefPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create();
if (!m_frame.page())
return;
-#if ENABLE(INSPECTOR)
if (Page* page = m_frame.page()) {
if (m_frame.isMainFrame())
page->inspectorController().resume();
}
-#endif
setProvisionalDocumentLoader(m_policyDocumentLoader.get());
m_loadType = type;
return;
if (!page->areMemoryCacheClientCallsEnabled()) {
- InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
+ InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), resource);
m_documentLoader->recordMemoryCacheLoadForFutureClientNotification(resource->resourceRequest());
m_documentLoader->didTellClientAboutLoad(resource->url());
return;
}
if (m_client.dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), newRequest, resource->response(), resource->encodedSize())) {
- InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
+ InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), resource);
m_documentLoader->didTellClientAboutLoad(resource->url());
return;
}
unsigned long identifier;
ResourceError error;
requestFromDelegate(newRequest, identifier, error);
- InspectorInstrumentation::markResourceAsCached(page, identifier);
+ InspectorInstrumentation::markResourceAsCached(*page, identifier);
notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, newRequest, resource->response(), 0, resource->encodedSize(), 0, error);
}
m_loadingFromCachedPage = true;
// Should have timing data from previous time(s) the page was shown.
- ASSERT(provisionalLoader->timing()->navigationStart());
+ ASSERT(provisionalLoader->timing().navigationStart());
provisionalLoader->resetTiming();
- provisionalLoader->timing()->markNavigationStart();
+ provisionalLoader->timing().markNavigationStart();
provisionalLoader->setCommitted(true);
commitProvisionalLoad();
// Remember this item so we can traverse any child items as child frames load
history().setProvisionalItem(item);
- if (CachedPage* cachedPage = pageCache()->get(item)) {
+ if (CachedPage* cachedPage = PageCache::shared().get(item, m_frame.page())) {
auto documentLoader = cachedPage->documentLoader();
documentLoader->setTriggeringAction(NavigationAction(documentLoader->request(), loadType, false));
documentLoader->setLastCheckedRequest(ResourceRequest());
m_client.dispatchDidClearWindowObjectInWorld(world);
-#if ENABLE(INSPECTOR)
if (Page* page = m_frame.page())
- page->inspectorController().didClearWindowObjectInWorld(&m_frame, world);
-#endif
+ page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
- InspectorInstrumentation::didClearWindowObjectInWorld(&m_frame, world);
+ InspectorInstrumentation::didClearWindowObjectInWorld(m_frame, world);
}
void FrameLoader::dispatchGlobalObjectAvailableInAllWorlds()
m_frame.page()->resetSeenMediaEngines();
}
- InspectorInstrumentation::didCommitLoad(&m_frame, m_documentLoader.get());
+ InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get());
#if ENABLE(REMOTE_INSPECTOR)
if (m_frame.isMainFrame())